payservedb 8.9.5 → 8.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/models/invoice.js +14 -0
- package/src/models/vasinvoice.js +4 -0
package/package.json
CHANGED
package/src/models/invoice.js
CHANGED
|
@@ -78,6 +78,13 @@ const invoiceSchema = new mongoose.Schema(
|
|
|
78
78
|
type: Number,
|
|
79
79
|
required: true,
|
|
80
80
|
},
|
|
81
|
+
taxes: [
|
|
82
|
+
{
|
|
83
|
+
name: { type: String, required: true }, // e.g. "VAT", "Withholding Tax"
|
|
84
|
+
percentage: { type: Number, required: true }, // e.g. 16
|
|
85
|
+
amount: { type: Number, required: true }, // e.g. 160.00 (subTotal * percentage / 100)
|
|
86
|
+
},
|
|
87
|
+
],
|
|
81
88
|
totalAmount: {
|
|
82
89
|
type: Number,
|
|
83
90
|
required: true,
|
|
@@ -462,6 +469,13 @@ invoiceSchema.statics.findFailedTaxSync = function (facilityId) {
|
|
|
462
469
|
|
|
463
470
|
// Pre-save middleware to ensure overpay and balanceBroughtForward stay in sync during transition
|
|
464
471
|
invoiceSchema.pre("save", function (next) {
|
|
472
|
+
|
|
473
|
+
if (this.taxes && this.taxes.length > 0) {
|
|
474
|
+
this.tax = Math.round(
|
|
475
|
+
this.taxes.reduce((sum, t) => sum + (t.amount || 0), 0) * 100
|
|
476
|
+
) / 100;
|
|
477
|
+
}
|
|
478
|
+
|
|
465
479
|
// If balanceBroughtForward is negative (credit), sync with overpay for backwards compatibility
|
|
466
480
|
if (this.balanceBroughtForward < 0) {
|
|
467
481
|
this.overpay = Math.abs(this.balanceBroughtForward);
|
package/src/models/vasinvoice.js
CHANGED
|
@@ -62,6 +62,10 @@ const vasInvoiceSchema = new mongoose.Schema({
|
|
|
62
62
|
type: Number,
|
|
63
63
|
required: true
|
|
64
64
|
},
|
|
65
|
+
whatFor: {
|
|
66
|
+
invoiceType: { type: String, required: true },
|
|
67
|
+
description: { type: String },
|
|
68
|
+
},
|
|
65
69
|
currency: {
|
|
66
70
|
id: {
|
|
67
71
|
type: mongoose.Schema.Types.ObjectId
|