Project

General

Profile

Edit Copy Actions

Support #12263

open

Support #12257: Vendor Management flow Issues

Vendor Outstanding Balance Never Resets to 0 (Stale Accounting Debt)

Added by Yalavarthi Thriveni 8 days ago. Updated 5 days ago.

Status:
Resolved
Priority:
Normal
Target version:
-
Start date:
11/20/2026
Due date:
11/24/2026 (4 days late)
% Done:

100%

Estimated time:

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;
}


Add

Subtasks


Add

Related issues

Actions #1

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
Actions #2

Updated by Divya Inapakurthi 5 days ago

  • % Done changed from 0 to 100
Edit Copy Actions

Also available in: Atom PDF