Project

General

Profile

Edit Copy Actions

Bug #11773

open

Ensure Unconditional Immediate Database Invoice Balance Sync on Quotation Update

Added by Yalavarthi Thriveni 5 days ago.

Status:
New
Priority:
Normal
Target version:
-
Start date:
10/28/2026
Due date:
% Done:

0%

Estimated time:
2:00 h
Tested Date:
10/28/2026
Raised by Tester:
Page/ Module (POS):
Quotes

Description

In

syncInvoiceDepositFromQuotation
, database synchronization of invoice.remainingBalance is guarded by shouldSyncDeposit:
javascript
const shouldSyncDeposit =
Object.prototype.hasOwnProperty.call(updates, "actualTotal") ||
Object.prototype.hasOwnProperty.call(updates, "actualSubTotal");
If an update modifies financial totals (e.g. updating costBreakdowns or discountAmount) without passing top-level actualTotal, the Invoice document in MongoDB preserves its old remainingBalance until a user views the invoice (at which point getInvoiceDetailsByQuotationNumber calculates it dynamically at runtime).
If an automated script reads the raw Invoice model from MongoDB without calling getInvoiceDetailsByQuotationNumber, it reads the un-synchronized balance.
2. Acceptance Criteria
AC 5.1 (Direct Balance Recalculation): Given an active quotation with an existing linked invoice, When updateQuotation modifies any field affecting the final cost (costBreakdowns, discount, discountAmount, taxAmount, excludeTax), Then syncInvoiceDepositFromQuotation MUST re-evaluate newTotalAmount and immediately persist the updated remainingBalance to the MongoDB Invoice collection.
AC 5.2 (Paid Installment Preservation): The updated remainingBalance in the database MUST strictly equal Math.max(0, newTotalAmount - sumOfPaidInstallments).
AC 5.3 (Audit Trail): When remainingBalance changes in the invoice document due to a quote update, log an entry into the invoice's actionHistory indicating automatic sync from quote revision.


Add

Subtasks


Add

Related issues

No data to display

Edit Copy Actions

Also available in: Atom PDF