Support #12263
openSupport #12257: Vendor Management flow Issues
Vendor Outstanding Balance Never Resets to 0 (Stale Accounting Debt)
100%
Description
Code Location: vendorInvoiceController.js:L2708
What is happening in code: The system calculates a vendor's outstanding debt by summing all invoices with paymentStatus: "Unpaid" or "Partially Paid". When you pay off the final invoice, the query finds zero unpaid invoices (result.length === 0). The code then encounters an early return statement:
if (!result || result.length === 0) return; // 💥 Exits without updating the vendor!
Real-Life Example:
You owe Vendor XYZ $5,000 across two invoices ($2,500 each).
The vendor profile correctly shows: Outstanding Balance: $5,000.
You pay off both invoices via bank transfer and mark them as "Paid".
The aggregation runs, finds 0 unpaid invoices, and immediately exits.
What breaks: The vendor profile still displays Outstanding Balance: $5,000 forever!
Business Impact: Your accounts payable reports show debts that have already been paid. You risk paying a vendor twice or having arguments over settling accounts.
Sample Fix :
if (!result || result.length === 0) {
// Explicitly reset balance to zero!
await Vendor.updateOne({ vendor_id: vendorId }, { $set: { outstandingBalance: 0 } });
return;
}
Subtasks
Related issues
Updated by Divya Inapakurthi 5 days ago
- Due date set to 11/24/2026
- Status changed from New to Resolved
- Assignee set to Divya Inapakurthi