Update invoice schema to support dynamic references for 'from' and 'to' fields by introducing 'fromType' and 'toType' fields, enhancing flexibility in vendor and client associations.
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good

This commit is contained in:
Tom Butcher 2026-07-04 15:18:25 +01:00
parent 6d4ed27996
commit cf979a6db0

View File

@ -33,8 +33,10 @@ const invoiceSchema = new Schema(
shippingAmountWithTax: { type: Number, required: true, default: 0 }, shippingAmountWithTax: { type: Number, required: true, default: 0 },
grandTotalAmount: { type: Number, required: true, default: 0 }, grandTotalAmount: { type: Number, required: true, default: 0 },
totalTaxAmount: { type: Number, required: true, default: 0 }, totalTaxAmount: { type: Number, required: true, default: 0 },
from: { type: Schema.Types.ObjectId, ref: 'vendor', required: false }, from: { type: Schema.Types.ObjectId, refPath: 'fromType', required: false },
to: { type: Schema.Types.ObjectId, ref: 'client', required: false }, fromType: { type: String, required: false },
to: { type: Schema.Types.ObjectId, refPath: 'toType', required: false },
toType: { type: String, required: false },
state: { state: {
type: { type: String, required: true, default: 'draft' }, type: { type: String, required: true, default: 'draft' },
}, },