Adding and displaying line items for invoice

Hi friends -

I’d like to create a dynamic invoice builder where a user can add line items. The line items will display in a repeating group, and the total amount will be calculated at the end. Then, the user will click ‘create invoice’ and one invoice will be created with all of those line items.

I’m getting a little stuck in that process.

I currently have date type Line Items with fields: line item, quantity, amount, and invoice.
I then have data type invoice with a list of line items.

Current workflow is when user clicks add to invoice, create a new line item.

Then display line items in the RG.

How do I only display the line items created in that moment in the RG? Do I need to use custom states?

Ideally if a user starts an invoice and doesn’t save it, we won’t hold on to those line items in the data base.

Any help is appreciated! Thank you!

Yes, add a custom state on the repeating group (or anywhere on the page, really) that is a list of line items. When you create a new line item, add it to the custom state list of line items. When you create the final invoice, make its list of line items the list from the custom state.

To clear out unused line items: When you create the invoice, update the list of line items with the invoice. Like, have a field within your Line Item data type that is for the Invoice. Then, periodically and preferably in a backend workflow, do a search for any line item that doesn’t have an invoice and delete it to keep your database clean.

Hey Brian! Thanks for your help.

I’m having trouble getting this to work, and maybe you can help me troubleshoot!

I’ve got the custom state list of line items to display in the repeating group, however everytime I add a new line item, the newest one is the only one that displays in the repeating group.

Workflow is set up to create a new Line Item, then to set the states of the repeating group to custom state items (type: list of Line Items); with the value being Result of Step 1 (create a new Line Item)

I recorded a video to help you!

Feel free to take a look at the editor to piece things together: Brianhenderson | Bubble Editor

The usual disclaimer applies: There are a million ways to do stuff in Bubble, I don’t pretend to have provided perfect answers here, but hopefully this will inspire you to solve what you need to solve.

5 Likes

I followed this - the one only issue is how do we actually control the line item database so after creation the only line item remaining is the one we created?

Brian, thank you so much for this! This was honestly so helpful. I think I’ve got everything working now!

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