/
Invoice Number Logic

Invoice Number Logic

In the account_warehouse_mapping table:

Add new columns:

  1. invoicePrefix: varchar(10) eg: RAY, CLA , This is fixed for any account_id and warehouse_id mapping.

  2. invoiceSeriesLatestNumber: bigint default value=0 , It will increment for every invoice number generation.

 

Invoice generation logic:

Run the following query to update the invoiceSeriesLatestNumber in db.

Query: UPDATE account_warehouse_mapping SET invoiceSeriesLatestNumber = (invoiceSeriesLatestNumber +1) WHERE account_id=? AND warehouse_id = ?

We must get an updated record from the above query having updated invoiceSeriesLatestNumber which we will use in our invoice.

Invoice Number = InvoicePrefix + invoiceSeriesLatestNumber

 

Tax type logic:

Pick the states from shippingAddress state and facility state.

  1. If within state(same state) - CGST/SGST

  2. If different state - IGST

  3. If sold and purchased within Andaman and Nicobar Islands, Lakshadweep, Dadra & Nagar Haveli and Daman & Diu, Ladakh and Chandigarh. - UTGST

 

For stateCode, Add new column "stateCode" in facility table.

Related content