Add fields for payment authorisation and decline tracking in payment schema
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good

- 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.
This commit is contained in:
Tom Butcher 2026-06-21 22:32:59 +01:00
parent b1245595d9
commit 4f9ed6039b

View File

@ -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' },