Private
Tracker *Bug Feature Support Testing
Subject *
Description Edit Code Location: vendorInvoiceController.js:L2128-L2152 *What is happening in code:* When you edit an already-saved vendor invoice (e.g. fixing a typo in the invoice number or notes), the code tries to reverse the old stock and re-add the new stock. In doing so: It blindly executes StockBatch.deleteMany({ invoiceId }). When reversing product stock, it subtracts raw box counts (old.quantity) instead of total units (old.quantity * old.unitsPerBox). *Real-Life Example:* On Monday, you receive an invoice for 5 boxes of ceramic pots (10 pots per box = 50 pots total). On Tuesday, you sell 15 pots to customers at the POS counter. (35 pots remain in that batch). On Wednesday, the accountant edits the vendor invoice to correct the vendor's payment reference code. What breaks immediately: The system executes deleteMany({ invoiceId }) and wipes the entire batch from the database, even though 15 pots were already sold from it! When reversing stock, it subtracts 5 (the number of boxes) instead of 50 (the total pots), leaving the inventory count completely wrong. Business Impact: Your batch audit trail is destroyed, historical sales lose their batch records, and inventory numbers become permanently inaccurate. *Simple Fix:* Before deleting batches on invoice edit, check if batch.qtyRemaining < batch.qtyReceived. If any items were already sold, block the hard deletion and adjust the remaining balance instead. Always reverse stock using old.totalUnits = old.quantity * old.unitsPerBox.
Status New
Priority *Low Normal High Immediate
Assignee Ajit ABindu DandaChandra SekharDivya InapakurthiKarthik PalakondaPavan Kumar MuralaRavi Shankar PalleRavindra AtthotaSai MahanandaSai Priyatham SadineniSowjanya atthotaSravani RangannapalemTeja Sriram SanganiYalavarthi Thriveni
Target version Sprint (10/05/2026- 10/09/2026) sprint (10/12/2026 - 10/31/2026) Backlog
Parent task
Start date
Due date
Estimated time Hours
% Done0 % 10 % 20 % 30 % 40 % 50 % 60 % 70 % 80 % 90 % 100 %