πŸ”§ [Help Needed] – Draft Invoice System in Kodular | Product List Sometimes Missing When Loading Draft

Hi everyone!

I’ve been building a fairly advanced Draft Manager system in Kodular that helps users create and manage invoice drafts. The idea is: users can add products , set quantities and discounts, and save the whole invoice locally as a draft, then resume it later to complete and submit the final bill.

Let me break down everything I’ve implemented so far – all features, how the data is saved, updated, retrieved – and finally the problem I’m facing:

:package: Features of My Draft Manager System
:white_check_mark: 1. What I Store Per Draft Invoice

Each draft includes:

Invoice ID

Staff Name

Customer Name

Invoice Date

Total Amount

Total Discount

Remarks

List of Products Added (stored as a list of JSON objects)

:shopping_cart: 2. Product Details Stored for Each Item in the Cart

For each product in the draft, I store all of the following:
Field Description
Image URL Product image (from server or assets)
Product Name Name/title of the product
Box Quantity Quantity entered in boxes
Chain Quantity Quantity entered in chains
Box Price (User Input) Box price set by user manually (via TextBox)
Chain Price (User Input) Chain price set by user manually (via TextBox)
Box Price (From Server) Default box price fetched from Google Sheet
Chain Price (From Server) Default chain price fetched from Google Sheet
Max Discount Allowed Maximum discount value allowed for that product

All of this is packed into a JSON object per product and stored as a list under a TinyDB tag like:
CART_
So the final cart structure is a list of JSON objects, one per product.
:floppy_disk: 3. Where and How I Save Drafts

When user clicks β€œSave Draft”:

I store draft metadata (Invoice ID, customer, staff, discount, etc.) under one TinyDB tag, like:

DRAFT_META_

I store the product list as a JSON string (list of objects) under:

DRAFT_PRODUCTS_<invoiceID>

I also maintain a master list of all draft invoice IDs under:

DRAFT_INDEX

:repeat_button: 4. How I Load Drafts Back

When user selects a draft:

I get DRAFT_META_<invoiceID> β†’ fill all textbox fields

I get DRAFT_PRODUCTS_<invoiceID> β†’ decode JSON list β†’ populate ColinTreeListView

I also calculate total, discount, etc., again based on loaded products

:pencil: 5. Edit, Update, and Delete Products

On edit: product is reloaded into the custom notifier with all existing fields pre-filled

On update: it replaces the product in the list at its index

On delete: I remove it from the product list and update TinyDB

:money_with_wings: 6. Discount Logic

Each product has a Max Discount value.

Before saving or submitting, I check:

    If applied discount for the product exceeds its max allowed discount

    If total discount for invoice exceeds a fixed threshold

If invalid β†’ I show an error and block saving

:red_exclamation_mark: PROBLEM I’M FACING

Sometimes, when I load a saved draft:

πŸ›‘ The product list shows up as empty!
βœ… The metadata (staff, customer, discount, date) is loaded correctly.
❌ But DRAFT_PRODUCTS_<invoiceID> returns an empty list or null β€” so no products are shown.

This does not happen always, only rarely and randomly.

This results in an empty ColinTreeListView when the draft is opened. Due to which the Final Cart value , total Quantity , discount are not getting loaded 

:magnifying_glass_tilted_right: Notes:

I’m using TinyDB2 for all draft-related data.

All product list data is encoded as a JSON string (using dictionary > JSON > string).

I'm using ColinTreeListView for displaying the cart items.

:puzzle_piece: I Have Shared My Blocks and If Needed any more then please do let me know













Thanks to everyone in advance :folded_hands:
Looking forward to your ideas and suggestions.

1 Like

Please Anyone help me , and if you need any other blocks you can ask me

help me to solve my problem!!

I Request to my dear kodular community to help me to get a solution