From 4f9ed6039b7efba7235cd560e4f0908984dcc5cb Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 21 Jun 2026 22:32:59 +0100 Subject: [PATCH] Add fields for payment authorisation and decline tracking in payment schema - Introduced 'authorisedAt' and 'declinedAt' fields to the payment schema to track payment status changes. - Added new rollup configurations for counting and summing authorised and declined payments. --- src/database/schemas/finance/payment.schema.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/database/schemas/finance/payment.schema.js b/src/database/schemas/finance/payment.schema.js index 437583d..4c35a28 100644 --- a/src/database/schemas/finance/payment.schema.js +++ b/src/database/schemas/finance/payment.schema.js @@ -15,6 +15,8 @@ const paymentSchema = new Schema( }, paymentDate: { type: Date, required: false }, postedAt: { type: Date, required: false }, + authorisedAt: { type: Date, required: false }, + declinedAt: { type: Date, required: false }, cancelledAt: { type: Date, required: false }, paymentMethod: { type: String, required: false }, notes: { type: String, required: false }, @@ -39,6 +41,22 @@ const rollupConfigs = [ { name: 'postedAmount', property: 'amount', operation: 'sum' }, ], }, + { + name: 'authorised', + filter: { 'state.type': 'authorised' }, + rollups: [ + { name: 'authorisedCount', property: 'state.type', operation: 'count' }, + { name: 'authorisedAmount', property: 'amount', operation: 'sum' }, + ], + }, + { + name: 'declined', + filter: { 'state.type': 'declined' }, + rollups: [ + { name: 'declinedCount', property: 'state.type', operation: 'count' }, + { name: 'declinedAmount', property: 'amount', operation: 'sum' }, + ], + }, { name: 'cancelled', filter: { 'state.type': 'cancelled' },