Support #12264
openSupport #12257: Vendor Management flow Issues
Missing Accounting Fields in Vendor Schema (Mongoose Strict Mode Risk)
100%
Description
Code Location: Vendors.js
What is happening in code: The invoice and return controllers actively write and update fields like:
outstandingBalance
creditBalance
totalPurchases
lastPurchaseDate
totalReturnsValue
None of these fields are declared in the Mongoose schema Vendors.js.
Real-Life Example:
A developer or query runs Vendor.create(...) or Vendor.find().select(...) using standard Mongoose queries.
Because Mongoose operates in strict mode by default, it silently ignores or strips any field not defined in the schema.
Business Impact: Accounting balances randomly disappear, fail to show up in API responses, or are lost when a vendor profile is edited and saved from the UI.
Simple Fix: Explicitly declare these fields in Vendors.js:
outstandingBalance: { type: Number, default: 0 },
creditBalance: { type: Number, default: 0 },
totalPurchases: { type: Number, default: 0 },
lastPurchaseDate: { type: Date, default: null },
totalReturnsValue: { type: Number, default: 0 }
Subtasks
Related issues
Updated by Divya Inapakurthi 5 days ago
- Due date set to 11/23/2026
- Status changed from New to Resolved
- Assignee set to Divya Inapakurthi
- % Done changed from 0 to 100