Forum Academy Marketplace Showcase Pricing Features

Unique Invoice Number that resets based on month

I am setting up an invoice system. I have spent several hours looking for a solution but I cannot find what I am trying to do.

My invoice number will be in format RP220101 where “RP” is the user initials, “2201” is the current date formatted as “yymm”. The last two digits “01” is a count of invoices for that month. I have set up initially with an input box:

image

In my workflow, I then create an invoice number like so:

image

image

I am trying to solve two issues:

  1. When a new month rolls over, I want the last two digits to reset, so if the last number in the month of Jan is for example, RP220135, then the next number in the new month should be RP220201. How can I solve for this?

  2. Is there a way to get the last two digits without the use of the input box? I can probably hide this on my page but that is not an ideal solution.

2 Likes

Hello @mmay14 !

  • Add a hidden popup to the page that you will never open (why? … popups and all their info is always loaded to the page no matter what by Bubble … and you can run searches in the background to have the info ready for later use. The idea is that you model your database objects as light as possible so that these searches can happen fast and not add strain to the page because … the objects are light)
  • Add a group of type “number” and perform the search for invoices count +1. Just add two constraints to restrict the invoices to be only for those invoices created on the current month (greater than beg of month and less than end of the month). Call it “var - user current month invoices count”.
  • Add a group of type text and extract the user’s name and lastname initials. Call it “var user initials”
  • Add another group of type text and add the date 4 digits using the expression shown on your post. Call it “var date 4 digits”
  • Add a third group of type text. Add the following expression: “varuserinitials vardate4digits varusercurrentmonthinvoicescount”. Call it “var invoice number”

You now have a dynamic invoice number for the user that you can find when building expressions (var invoice number) :smiley:

@cmarchan - many thanks!

A couple of questions on this (sorry if they are basic as I am still new to Bubble):

  1. What info do I put in the hidden popup? Is it the first group where I am searching for invoices count +1?
  2. Can you please help me with how to add these constraints? So far I started with “created date” but I am not sure how to progress with it?:

image

image

  1. How can I extract the user’s name and last name initials?

@mmay14

image

user’s first truncated to 1
user’s last truncated to 1

Best of luck with your project :smiley:

This topic was automatically closed after 70 days. New replies are no longer allowed.