@voyantjs/finance 0.52.2 → 0.52.3
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/dist/action-ledger-drift.d.ts +29 -0
- package/dist/action-ledger-drift.d.ts.map +1 -0
- package/dist/action-ledger-drift.js +163 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/routes-action-ledger.d.ts +181 -0
- package/dist/routes-action-ledger.d.ts.map +1 -0
- package/dist/routes-action-ledger.js +142 -0
- package/dist/routes-documents.d.ts +8 -8
- package/dist/routes-public.d.ts +48 -48
- package/dist/routes-settlement.d.ts +1 -1
- package/dist/routes-shared.d.ts +12 -0
- package/dist/routes-shared.d.ts.map +1 -1
- package/dist/routes.d.ts +224 -224
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +252 -46
- package/dist/schema.d.ts +22 -22
- package/dist/service-action-ledger-accounting.d.ts +77 -0
- package/dist/service-action-ledger-accounting.d.ts.map +1 -0
- package/dist/service-action-ledger-accounting.js +307 -0
- package/dist/service-action-ledger-booking-payments.d.ts +48 -0
- package/dist/service-action-ledger-booking-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-booking-payments.js +178 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts +48 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-authorizations.js +209 -0
- package/dist/service-action-ledger-payment-sessions.d.ts +83 -0
- package/dist/service-action-ledger-payment-sessions.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-sessions.js +294 -0
- package/dist/service-action-ledger-supplier-payments.d.ts +21 -0
- package/dist/service-action-ledger-supplier-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-payments.js +70 -0
- package/dist/service-action-ledger.d.ts +6 -0
- package/dist/service-action-ledger.d.ts.map +1 -0
- package/dist/service-action-ledger.js +5 -0
- package/dist/service-booking-create.d.ts +12 -12
- package/dist/service-bookings-dual-create.d.ts +12 -12
- package/dist/service-issue.d.ts +15 -12
- package/dist/service-issue.d.ts.map +1 -1
- package/dist/service-issue.js +24 -3
- package/dist/service-public.d.ts +13 -13
- package/dist/service-vouchers.d.ts +10 -10
- package/dist/service.d.ts +291 -279
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +731 -234
- package/dist/validation-billing.d.ts +37 -37
- package/dist/validation-payments.d.ts +102 -102
- package/dist/validation-public.d.ts +45 -45
- package/dist/validation-shared.d.ts +32 -32
- package/dist/validation-vouchers.d.ts +2 -2
- package/package.json +13 -7
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { buildIdempotencyFingerprint, } from "@voyantjs/action-ledger";
|
|
2
|
+
export function buildPaymentInstrumentCreateActionLedgerInput(context, input, options = {}) {
|
|
3
|
+
const target = getPaymentInstrumentLedgerTarget(input.instrument);
|
|
4
|
+
const ownerRef = getPaymentInstrumentOwnerRef(input.instrument);
|
|
5
|
+
return {
|
|
6
|
+
context,
|
|
7
|
+
actionName: "finance.payment_instrument.create",
|
|
8
|
+
actionVersion: "v1",
|
|
9
|
+
actionKind: "create",
|
|
10
|
+
status: "succeeded",
|
|
11
|
+
evaluatedRisk: "high",
|
|
12
|
+
targetType: target.type,
|
|
13
|
+
targetId: target.id,
|
|
14
|
+
routeOrToolName: "finance.payment_instrument.create",
|
|
15
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_instrument.route",
|
|
16
|
+
idempotencyScope: null,
|
|
17
|
+
idempotencyKey: null,
|
|
18
|
+
idempotencyFingerprint: null,
|
|
19
|
+
mutationDetail: {
|
|
20
|
+
commandInputRef: `${ownerRef}:payment_instrument`,
|
|
21
|
+
commandResultRef: `payment_instrument:${input.instrument.id}`,
|
|
22
|
+
summary: `Payment instrument ${input.instrument.id} created for ${ownerRef}`,
|
|
23
|
+
reversalKind: "none",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function buildPaymentInstrumentUpdateActionLedgerInput(context, input, options = {}) {
|
|
28
|
+
const target = getPaymentInstrumentLedgerTarget(input.instrument);
|
|
29
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
30
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
31
|
+
return {
|
|
32
|
+
context,
|
|
33
|
+
actionName: "finance.payment_instrument.update",
|
|
34
|
+
actionVersion: "v1",
|
|
35
|
+
actionKind: "update",
|
|
36
|
+
status: "succeeded",
|
|
37
|
+
evaluatedRisk: "high",
|
|
38
|
+
targetType: target.type,
|
|
39
|
+
targetId: target.id,
|
|
40
|
+
routeOrToolName: "finance.payment_instrument.update",
|
|
41
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_instrument.route",
|
|
42
|
+
idempotencyScope: null,
|
|
43
|
+
idempotencyKey: null,
|
|
44
|
+
idempotencyFingerprint: null,
|
|
45
|
+
mutationDetail: {
|
|
46
|
+
commandInputRef: `payment_instrument:${input.instrument.id}:update`,
|
|
47
|
+
commandResultRef: `payment_instrument:${input.instrument.id}`,
|
|
48
|
+
summary: `Payment instrument ${input.instrument.id} updated (${changeSummary})`,
|
|
49
|
+
reversalKind: "none",
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function buildPaymentInstrumentDeleteActionLedgerInput(context, input, options = {}) {
|
|
54
|
+
const target = getPaymentInstrumentLedgerTarget(input.instrument);
|
|
55
|
+
return {
|
|
56
|
+
context,
|
|
57
|
+
actionName: "finance.payment_instrument.delete",
|
|
58
|
+
actionVersion: "v1",
|
|
59
|
+
actionKind: "delete",
|
|
60
|
+
status: "succeeded",
|
|
61
|
+
evaluatedRisk: "high",
|
|
62
|
+
targetType: target.type,
|
|
63
|
+
targetId: target.id,
|
|
64
|
+
routeOrToolName: "finance.payment_instrument.delete",
|
|
65
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_instrument.route",
|
|
66
|
+
idempotencyScope: null,
|
|
67
|
+
idempotencyKey: null,
|
|
68
|
+
idempotencyFingerprint: null,
|
|
69
|
+
mutationDetail: {
|
|
70
|
+
commandInputRef: `payment_instrument:${input.instrument.id}:delete`,
|
|
71
|
+
commandResultRef: null,
|
|
72
|
+
summary: `Payment instrument ${input.instrument.id} deleted`,
|
|
73
|
+
reversalKind: "none",
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function getPaymentInstrumentLedgerTarget(instrument) {
|
|
78
|
+
if (instrument.personId)
|
|
79
|
+
return { type: "person", id: instrument.personId };
|
|
80
|
+
if (instrument.organizationId)
|
|
81
|
+
return { type: "organization", id: instrument.organizationId };
|
|
82
|
+
if (instrument.supplierId)
|
|
83
|
+
return { type: "supplier", id: instrument.supplierId };
|
|
84
|
+
if (instrument.channelId)
|
|
85
|
+
return { type: "channel", id: instrument.channelId };
|
|
86
|
+
return { type: "payment_instrument", id: instrument.id };
|
|
87
|
+
}
|
|
88
|
+
function getPaymentInstrumentOwnerRef(instrument) {
|
|
89
|
+
const target = getPaymentInstrumentLedgerTarget(instrument);
|
|
90
|
+
return `${target.type}:${target.id}`;
|
|
91
|
+
}
|
|
92
|
+
export async function buildPaymentSessionCreateActionLedgerInput(context, input, options = {}) {
|
|
93
|
+
const target = getPaymentSessionLedgerTarget(input.session);
|
|
94
|
+
const idempotencyKey = input.session.idempotencyKey;
|
|
95
|
+
return {
|
|
96
|
+
context,
|
|
97
|
+
actionName: "finance.payment_session.create",
|
|
98
|
+
actionVersion: "v1",
|
|
99
|
+
actionKind: "create",
|
|
100
|
+
status: "succeeded",
|
|
101
|
+
evaluatedRisk: "high",
|
|
102
|
+
targetType: target.type,
|
|
103
|
+
targetId: target.id,
|
|
104
|
+
routeOrToolName: "finance.payment_session.create",
|
|
105
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_session.route",
|
|
106
|
+
idempotencyScope: idempotencyKey && target.id
|
|
107
|
+
? `finance.payment_session:${target.type}:${target.id}:create`
|
|
108
|
+
: null,
|
|
109
|
+
idempotencyKey,
|
|
110
|
+
idempotencyFingerprint: idempotencyKey && target.id
|
|
111
|
+
? await buildIdempotencyFingerprint({
|
|
112
|
+
actionName: "finance.payment_session.create",
|
|
113
|
+
actionVersion: "v1",
|
|
114
|
+
targetType: target.type,
|
|
115
|
+
targetId: target.id,
|
|
116
|
+
commandInput: {
|
|
117
|
+
paymentSessionId: input.session.id,
|
|
118
|
+
targetType: input.session.targetType,
|
|
119
|
+
targetId: input.session.targetId,
|
|
120
|
+
amountCents: input.session.amountCents,
|
|
121
|
+
currency: input.session.currency,
|
|
122
|
+
provider: input.session.provider,
|
|
123
|
+
idempotencyKey: input.session.idempotencyKey,
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
: null,
|
|
127
|
+
mutationDetail: {
|
|
128
|
+
commandInputRef: target.id
|
|
129
|
+
? `${target.type}:${target.id}:payment_session`
|
|
130
|
+
: "payment_session:create",
|
|
131
|
+
commandResultRef: `payment_session:${input.session.id}`,
|
|
132
|
+
summary: `Payment session ${input.session.id} created for ${target.type} ${target.id ?? "unknown"}`,
|
|
133
|
+
reversalKind: "none",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export async function buildPaymentSessionCompletionActionLedgerInput(context, input, options = {}) {
|
|
138
|
+
const target = getPaymentSessionCompletionLedgerTarget(input.session);
|
|
139
|
+
const idempotencyKey = input.session.providerPaymentId ??
|
|
140
|
+
input.session.externalReference ??
|
|
141
|
+
input.session.idempotencyKey ??
|
|
142
|
+
null;
|
|
143
|
+
const idempotencyFingerprint = idempotencyKey
|
|
144
|
+
? await buildIdempotencyFingerprint({
|
|
145
|
+
actionName: "finance.payment_session.complete",
|
|
146
|
+
actionVersion: "v1",
|
|
147
|
+
targetType: target.type,
|
|
148
|
+
targetId: target.id,
|
|
149
|
+
commandInput: {
|
|
150
|
+
paymentSessionId: input.session.id,
|
|
151
|
+
status: input.status,
|
|
152
|
+
providerPaymentId: input.session.providerPaymentId,
|
|
153
|
+
externalReference: input.session.externalReference,
|
|
154
|
+
paymentId: input.paymentId,
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
: null;
|
|
158
|
+
return {
|
|
159
|
+
context,
|
|
160
|
+
actionName: "finance.payment_session.complete",
|
|
161
|
+
actionVersion: "v1",
|
|
162
|
+
actionKind: "execute",
|
|
163
|
+
status: "succeeded",
|
|
164
|
+
evaluatedRisk: "high",
|
|
165
|
+
targetType: target.type,
|
|
166
|
+
targetId: target.id,
|
|
167
|
+
routeOrToolName: "finance.payment_session.complete",
|
|
168
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_session.route",
|
|
169
|
+
idempotencyScope: idempotencyKey
|
|
170
|
+
? `finance.payment_session:${input.session.id}:complete`
|
|
171
|
+
: null,
|
|
172
|
+
idempotencyKey,
|
|
173
|
+
idempotencyFingerprint,
|
|
174
|
+
mutationDetail: {
|
|
175
|
+
commandInputRef: `payment_session:${input.session.id}:complete`,
|
|
176
|
+
commandResultRef: input.paymentId ? `payment:${input.paymentId}` : null,
|
|
177
|
+
summary: `Payment session ${input.session.id} completed as ${input.status}`,
|
|
178
|
+
reversalKind: "none",
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function getPaymentSessionCompletionLedgerTarget(session) {
|
|
183
|
+
return getPaymentSessionLedgerTarget(session);
|
|
184
|
+
}
|
|
185
|
+
function getPaymentSessionLedgerTarget(session) {
|
|
186
|
+
if (session.bookingId)
|
|
187
|
+
return { type: "booking", id: session.bookingId };
|
|
188
|
+
if (session.invoiceId)
|
|
189
|
+
return { type: "invoice", id: session.invoiceId };
|
|
190
|
+
if (session.orderId)
|
|
191
|
+
return { type: "order", id: session.orderId };
|
|
192
|
+
if (session.targetId && session.targetType !== "other") {
|
|
193
|
+
return { type: session.targetType, id: session.targetId };
|
|
194
|
+
}
|
|
195
|
+
return { type: "payment_session", id: session.id };
|
|
196
|
+
}
|
|
197
|
+
export function buildPaymentSessionUpdateActionLedgerInput(context, input, options = {}) {
|
|
198
|
+
const target = getPaymentSessionLedgerTarget(input.session);
|
|
199
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
200
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
201
|
+
return {
|
|
202
|
+
context,
|
|
203
|
+
actionName: "finance.payment_session.update",
|
|
204
|
+
actionVersion: "v1",
|
|
205
|
+
actionKind: "update",
|
|
206
|
+
status: "succeeded",
|
|
207
|
+
evaluatedRisk: "high",
|
|
208
|
+
targetType: target.type,
|
|
209
|
+
targetId: target.id,
|
|
210
|
+
routeOrToolName: "finance.payment_session.update",
|
|
211
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_session.route",
|
|
212
|
+
idempotencyScope: null,
|
|
213
|
+
idempotencyKey: null,
|
|
214
|
+
idempotencyFingerprint: null,
|
|
215
|
+
mutationDetail: {
|
|
216
|
+
commandInputRef: `payment_session:${input.session.id}:update`,
|
|
217
|
+
commandResultRef: `payment_session:${input.session.id}`,
|
|
218
|
+
summary: `Payment session ${input.session.id} updated (${changeSummary})`,
|
|
219
|
+
reversalKind: "none",
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export function buildPaymentSessionRequiresRedirectActionLedgerInput(context, input, options = {}) {
|
|
224
|
+
return buildPaymentSessionStatusActionLedgerInput(context, {
|
|
225
|
+
session: input.session,
|
|
226
|
+
actionName: "finance.payment_session.requires_redirect",
|
|
227
|
+
actionKind: "update",
|
|
228
|
+
routeOrToolName: "finance.payment_session.requires_redirect",
|
|
229
|
+
commandInputRef: `payment_session:${input.session.id}:requires_redirect`,
|
|
230
|
+
commandResultRef: `payment_session:${input.session.id}`,
|
|
231
|
+
summary: `Payment session ${input.session.id} marked as requiring redirect`,
|
|
232
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_session.route",
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
export function buildPaymentSessionFailedActionLedgerInput(context, input, options = {}) {
|
|
236
|
+
return buildPaymentSessionStatusActionLedgerInput(context, {
|
|
237
|
+
session: input.session,
|
|
238
|
+
actionName: "finance.payment_session.fail",
|
|
239
|
+
actionKind: "update",
|
|
240
|
+
routeOrToolName: "finance.payment_session.fail",
|
|
241
|
+
commandInputRef: `payment_session:${input.session.id}:fail`,
|
|
242
|
+
commandResultRef: `payment_session:${input.session.id}`,
|
|
243
|
+
summary: `Payment session ${input.session.id} marked as failed`,
|
|
244
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_session.route",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
export function buildPaymentSessionCancelledActionLedgerInput(context, input, options = {}) {
|
|
248
|
+
return buildPaymentSessionStatusActionLedgerInput(context, {
|
|
249
|
+
session: input.session,
|
|
250
|
+
actionName: "finance.payment_session.cancel",
|
|
251
|
+
actionKind: "update",
|
|
252
|
+
routeOrToolName: "finance.payment_session.cancel",
|
|
253
|
+
commandInputRef: `payment_session:${input.session.id}:cancel`,
|
|
254
|
+
commandResultRef: `payment_session:${input.session.id}`,
|
|
255
|
+
summary: `Payment session ${input.session.id} marked as cancelled`,
|
|
256
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_session.route",
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
export function buildPaymentSessionExpiredActionLedgerInput(context, input, options = {}) {
|
|
260
|
+
return buildPaymentSessionStatusActionLedgerInput(context, {
|
|
261
|
+
session: input.session,
|
|
262
|
+
actionName: "finance.payment_session.expire",
|
|
263
|
+
actionKind: "update",
|
|
264
|
+
routeOrToolName: "finance.payment_session.expire",
|
|
265
|
+
commandInputRef: `payment_session:${input.session.id}:expire`,
|
|
266
|
+
commandResultRef: `payment_session:${input.session.id}`,
|
|
267
|
+
summary: `Payment session ${input.session.id} marked as expired`,
|
|
268
|
+
authorizationSource: options.authorizationSource ?? "finance.payment_session.route",
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function buildPaymentSessionStatusActionLedgerInput(context, input) {
|
|
272
|
+
const target = getPaymentSessionLedgerTarget(input.session);
|
|
273
|
+
return {
|
|
274
|
+
context,
|
|
275
|
+
actionName: input.actionName,
|
|
276
|
+
actionVersion: "v1",
|
|
277
|
+
actionKind: input.actionKind,
|
|
278
|
+
status: "succeeded",
|
|
279
|
+
evaluatedRisk: "high",
|
|
280
|
+
targetType: target.type,
|
|
281
|
+
targetId: target.id,
|
|
282
|
+
routeOrToolName: input.routeOrToolName,
|
|
283
|
+
authorizationSource: input.authorizationSource,
|
|
284
|
+
idempotencyScope: null,
|
|
285
|
+
idempotencyKey: null,
|
|
286
|
+
idempotencyFingerprint: null,
|
|
287
|
+
mutationDetail: {
|
|
288
|
+
commandInputRef: input.commandInputRef,
|
|
289
|
+
commandResultRef: input.commandResultRef,
|
|
290
|
+
summary: input.summary,
|
|
291
|
+
reversalKind: "none",
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ActionLedgerRequestContextValues, type BuildActionLedgerMutationInput } from "@voyantjs/action-ledger";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { supplierPayments } from "./schema.js";
|
|
4
|
+
import type { updateSupplierPaymentSchema } from "./validation.js";
|
|
5
|
+
type UpdateSupplierPaymentInput = z.infer<typeof updateSupplierPaymentSchema>;
|
|
6
|
+
type SupplierPaymentRecord = typeof supplierPayments.$inferSelect;
|
|
7
|
+
type SupplierPaymentCreateLedgerInput = {
|
|
8
|
+
payment: SupplierPaymentRecord;
|
|
9
|
+
};
|
|
10
|
+
type SupplierPaymentUpdateLedgerInput = {
|
|
11
|
+
payment: SupplierPaymentRecord;
|
|
12
|
+
changes: UpdateSupplierPaymentInput;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildSupplierPaymentCreateActionLedgerInput(context: ActionLedgerRequestContextValues, input: SupplierPaymentCreateLedgerInput, options?: {
|
|
15
|
+
authorizationSource?: string | null;
|
|
16
|
+
}): Promise<BuildActionLedgerMutationInput>;
|
|
17
|
+
export declare function buildSupplierPaymentUpdateActionLedgerInput(context: ActionLedgerRequestContextValues, input: SupplierPaymentUpdateLedgerInput, options?: {
|
|
18
|
+
authorizationSource?: string | null;
|
|
19
|
+
}): BuildActionLedgerMutationInput;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=service-action-ledger-supplier-payments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-action-ledger-supplier-payments.d.ts","sourceRoot":"","sources":["../src/service-action-ledger-supplier-payments.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EAEpC,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAElE,KAAK,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAC7E,KAAK,qBAAqB,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AAEjE,KAAK,gCAAgC,GAAG;IACtC,OAAO,EAAE,qBAAqB,CAAA;CAC/B,CAAA;AACD,KAAK,gCAAgC,GAAG;IACtC,OAAO,EAAE,qBAAqB,CAAA;IAC9B,OAAO,EAAE,0BAA0B,CAAA;CACpC,CAAA;AAED,wBAAsB,2CAA2C,CAC/D,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,gCAAgC,EACvC,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,OAAO,CAAC,8BAA8B,CAAC,CA4CzC;AAED,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,gCAAgC,EACvC,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,8BAA8B,CAyBhC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { buildIdempotencyFingerprint, } from "@voyantjs/action-ledger";
|
|
2
|
+
export async function buildSupplierPaymentCreateActionLedgerInput(context, input, options = {}) {
|
|
3
|
+
const idempotencyKey = input.payment.referenceNumber;
|
|
4
|
+
return {
|
|
5
|
+
context,
|
|
6
|
+
actionName: "finance.supplier_payment.create",
|
|
7
|
+
actionVersion: "v1",
|
|
8
|
+
actionKind: "create",
|
|
9
|
+
status: "succeeded",
|
|
10
|
+
evaluatedRisk: "high",
|
|
11
|
+
targetType: "booking",
|
|
12
|
+
targetId: input.payment.bookingId,
|
|
13
|
+
routeOrToolName: "finance.supplier_payment.create",
|
|
14
|
+
authorizationSource: options.authorizationSource ?? "finance.supplier_payment.route",
|
|
15
|
+
idempotencyScope: idempotencyKey
|
|
16
|
+
? `finance.booking:${input.payment.bookingId}:supplier_payment`
|
|
17
|
+
: null,
|
|
18
|
+
idempotencyKey,
|
|
19
|
+
idempotencyFingerprint: idempotencyKey
|
|
20
|
+
? await buildIdempotencyFingerprint({
|
|
21
|
+
actionName: "finance.supplier_payment.create",
|
|
22
|
+
actionVersion: "v1",
|
|
23
|
+
targetType: "booking",
|
|
24
|
+
targetId: input.payment.bookingId,
|
|
25
|
+
commandInput: {
|
|
26
|
+
supplierPaymentId: input.payment.id,
|
|
27
|
+
bookingId: input.payment.bookingId,
|
|
28
|
+
supplierId: input.payment.supplierId,
|
|
29
|
+
amountCents: input.payment.amountCents,
|
|
30
|
+
currency: input.payment.currency,
|
|
31
|
+
paymentMethod: input.payment.paymentMethod,
|
|
32
|
+
paymentDate: input.payment.paymentDate,
|
|
33
|
+
referenceNumber: input.payment.referenceNumber,
|
|
34
|
+
status: input.payment.status,
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
: null,
|
|
38
|
+
mutationDetail: {
|
|
39
|
+
commandInputRef: `booking:${input.payment.bookingId}:supplier_payment`,
|
|
40
|
+
commandResultRef: `supplier_payment:${input.payment.id}`,
|
|
41
|
+
summary: `Supplier payment ${input.payment.id} recorded for booking ${input.payment.bookingId}`,
|
|
42
|
+
reversalKind: "none",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function buildSupplierPaymentUpdateActionLedgerInput(context, input, options = {}) {
|
|
47
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
48
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
49
|
+
return {
|
|
50
|
+
context,
|
|
51
|
+
actionName: "finance.supplier_payment.update",
|
|
52
|
+
actionVersion: "v1",
|
|
53
|
+
actionKind: "update",
|
|
54
|
+
status: "succeeded",
|
|
55
|
+
evaluatedRisk: "high",
|
|
56
|
+
targetType: "booking",
|
|
57
|
+
targetId: input.payment.bookingId,
|
|
58
|
+
routeOrToolName: "finance.supplier_payment.update",
|
|
59
|
+
authorizationSource: options.authorizationSource ?? "finance.supplier_payment.route",
|
|
60
|
+
idempotencyScope: null,
|
|
61
|
+
idempotencyKey: null,
|
|
62
|
+
idempotencyFingerprint: null,
|
|
63
|
+
mutationDetail: {
|
|
64
|
+
commandInputRef: `supplier_payment:${input.payment.id}:update`,
|
|
65
|
+
commandResultRef: `supplier_payment:${input.payment.id}`,
|
|
66
|
+
summary: `Supplier payment ${input.payment.id} updated (${changeSummary})`,
|
|
67
|
+
reversalKind: "none",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./service-action-ledger-accounting.js";
|
|
2
|
+
export * from "./service-action-ledger-booking-payments.js";
|
|
3
|
+
export * from "./service-action-ledger-payment-authorizations.js";
|
|
4
|
+
export * from "./service-action-ledger-payment-sessions.js";
|
|
5
|
+
export * from "./service-action-ledger-supplier-payments.js";
|
|
6
|
+
//# sourceMappingURL=service-action-ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-action-ledger.d.ts","sourceRoot":"","sources":["../src/service-action-ledger.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA;AACrD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,mDAAmD,CAAA;AACjE,cAAc,6CAA6C,CAAA;AAC3D,cAAc,8CAA8C,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "./service-action-ledger-accounting.js";
|
|
2
|
+
export * from "./service-action-ledger-booking-payments.js";
|
|
3
|
+
export * from "./service-action-ledger-payment-authorizations.js";
|
|
4
|
+
export * from "./service-action-ledger-payment-sessions.js";
|
|
5
|
+
export * from "./service-action-ledger-supplier-payments.js";
|
|
@@ -16,8 +16,8 @@ declare const travelerInputSchema: z.ZodObject<{
|
|
|
16
16
|
occupant: "occupant";
|
|
17
17
|
}>>;
|
|
18
18
|
travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
19
|
-
child: "child";
|
|
20
19
|
other: "other";
|
|
20
|
+
child: "child";
|
|
21
21
|
adult: "adult";
|
|
22
22
|
infant: "infant";
|
|
23
23
|
senior: "senior";
|
|
@@ -41,14 +41,14 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
41
41
|
confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
42
42
|
priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
43
43
|
initialStatus: z.ZodOptional<z.ZodEnum<{
|
|
44
|
-
|
|
44
|
+
expired: "expired";
|
|
45
45
|
cancelled: "cancelled";
|
|
46
|
+
completed: "completed";
|
|
46
47
|
draft: "draft";
|
|
47
48
|
on_hold: "on_hold";
|
|
48
49
|
awaiting_payment: "awaiting_payment";
|
|
49
50
|
confirmed: "confirmed";
|
|
50
51
|
in_progress: "in_progress";
|
|
51
|
-
expired: "expired";
|
|
52
52
|
}>>;
|
|
53
53
|
suppressNotifications: z.ZodOptional<z.ZodBoolean>;
|
|
54
54
|
contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -73,8 +73,8 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
73
73
|
occupant: "occupant";
|
|
74
74
|
}>>;
|
|
75
75
|
travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
76
|
-
child: "child";
|
|
77
76
|
other: "other";
|
|
77
|
+
child: "child";
|
|
78
78
|
adult: "adult";
|
|
79
79
|
infant: "infant";
|
|
80
80
|
senior: "senior";
|
|
@@ -102,9 +102,9 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
102
102
|
hold: "hold";
|
|
103
103
|
}>>;
|
|
104
104
|
status: z.ZodDefault<z.ZodEnum<{
|
|
105
|
-
pending: "pending";
|
|
106
|
-
cancelled: "cancelled";
|
|
107
105
|
expired: "expired";
|
|
106
|
+
cancelled: "cancelled";
|
|
107
|
+
pending: "pending";
|
|
108
108
|
paid: "paid";
|
|
109
109
|
due: "due";
|
|
110
110
|
waived: "waived";
|
|
@@ -142,8 +142,8 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
142
142
|
}, z.core.$strip>;
|
|
143
143
|
export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
144
144
|
organizationId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
145
|
-
bookingNumber: z.ZodString;
|
|
146
145
|
personId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
146
|
+
bookingNumber: z.ZodString;
|
|
147
147
|
contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
148
148
|
contactLastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
149
149
|
contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -169,8 +169,8 @@ export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
|
169
169
|
occupant: "occupant";
|
|
170
170
|
}>>;
|
|
171
171
|
travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
172
|
-
child: "child";
|
|
173
172
|
other: "other";
|
|
173
|
+
child: "child";
|
|
174
174
|
adult: "adult";
|
|
175
175
|
infant: "infant";
|
|
176
176
|
senior: "senior";
|
|
@@ -187,14 +187,14 @@ export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
|
187
187
|
confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
188
188
|
priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
189
189
|
initialStatus: z.ZodOptional<z.ZodEnum<{
|
|
190
|
-
|
|
190
|
+
expired: "expired";
|
|
191
191
|
cancelled: "cancelled";
|
|
192
|
+
completed: "completed";
|
|
192
193
|
draft: "draft";
|
|
193
194
|
on_hold: "on_hold";
|
|
194
195
|
awaiting_payment: "awaiting_payment";
|
|
195
196
|
confirmed: "confirmed";
|
|
196
197
|
in_progress: "in_progress";
|
|
197
|
-
expired: "expired";
|
|
198
198
|
}>>;
|
|
199
199
|
itemLines: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
200
200
|
optionUnitId: z.ZodString;
|
|
@@ -214,9 +214,9 @@ export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
|
214
214
|
hold: "hold";
|
|
215
215
|
}>>;
|
|
216
216
|
status: z.ZodDefault<z.ZodEnum<{
|
|
217
|
-
pending: "pending";
|
|
218
|
-
cancelled: "cancelled";
|
|
219
217
|
expired: "expired";
|
|
218
|
+
cancelled: "cancelled";
|
|
219
|
+
pending: "pending";
|
|
220
220
|
paid: "paid";
|
|
221
221
|
due: "due";
|
|
222
222
|
waived: "waived";
|
|
@@ -6,8 +6,8 @@ import { type BookingCreateOutcome, type BookingCreateResult } from "./service-b
|
|
|
6
6
|
export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
7
7
|
primary: z.ZodObject<{
|
|
8
8
|
organizationId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
-
bookingNumber: z.ZodString;
|
|
10
9
|
personId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
10
|
+
bookingNumber: z.ZodString;
|
|
11
11
|
contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
12
12
|
contactLastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
13
13
|
contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -33,8 +33,8 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
|
33
33
|
occupant: "occupant";
|
|
34
34
|
}>>;
|
|
35
35
|
travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
36
|
-
child: "child";
|
|
37
36
|
other: "other";
|
|
37
|
+
child: "child";
|
|
38
38
|
adult: "adult";
|
|
39
39
|
infant: "infant";
|
|
40
40
|
senior: "senior";
|
|
@@ -51,14 +51,14 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
|
51
51
|
confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
52
52
|
priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
53
53
|
initialStatus: z.ZodOptional<z.ZodEnum<{
|
|
54
|
-
|
|
54
|
+
expired: "expired";
|
|
55
55
|
cancelled: "cancelled";
|
|
56
|
+
completed: "completed";
|
|
56
57
|
draft: "draft";
|
|
57
58
|
on_hold: "on_hold";
|
|
58
59
|
awaiting_payment: "awaiting_payment";
|
|
59
60
|
confirmed: "confirmed";
|
|
60
61
|
in_progress: "in_progress";
|
|
61
|
-
expired: "expired";
|
|
62
62
|
}>>;
|
|
63
63
|
itemLines: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
64
64
|
optionUnitId: z.ZodString;
|
|
@@ -78,9 +78,9 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
|
78
78
|
hold: "hold";
|
|
79
79
|
}>>;
|
|
80
80
|
status: z.ZodDefault<z.ZodEnum<{
|
|
81
|
-
pending: "pending";
|
|
82
|
-
cancelled: "cancelled";
|
|
83
81
|
expired: "expired";
|
|
82
|
+
cancelled: "cancelled";
|
|
83
|
+
pending: "pending";
|
|
84
84
|
paid: "paid";
|
|
85
85
|
due: "due";
|
|
86
86
|
waived: "waived";
|
|
@@ -101,8 +101,8 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
|
101
101
|
}, z.core.$strip>;
|
|
102
102
|
secondary: z.ZodObject<{
|
|
103
103
|
organizationId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
104
|
-
bookingNumber: z.ZodString;
|
|
105
104
|
personId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
105
|
+
bookingNumber: z.ZodString;
|
|
106
106
|
contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
107
107
|
contactLastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
108
108
|
contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -128,8 +128,8 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
|
128
128
|
occupant: "occupant";
|
|
129
129
|
}>>;
|
|
130
130
|
travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
131
|
-
child: "child";
|
|
132
131
|
other: "other";
|
|
132
|
+
child: "child";
|
|
133
133
|
adult: "adult";
|
|
134
134
|
infant: "infant";
|
|
135
135
|
senior: "senior";
|
|
@@ -146,14 +146,14 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
|
146
146
|
confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
147
147
|
priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
148
148
|
initialStatus: z.ZodOptional<z.ZodEnum<{
|
|
149
|
-
|
|
149
|
+
expired: "expired";
|
|
150
150
|
cancelled: "cancelled";
|
|
151
|
+
completed: "completed";
|
|
151
152
|
draft: "draft";
|
|
152
153
|
on_hold: "on_hold";
|
|
153
154
|
awaiting_payment: "awaiting_payment";
|
|
154
155
|
confirmed: "confirmed";
|
|
155
156
|
in_progress: "in_progress";
|
|
156
|
-
expired: "expired";
|
|
157
157
|
}>>;
|
|
158
158
|
itemLines: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
159
159
|
optionUnitId: z.ZodString;
|
|
@@ -173,9 +173,9 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
|
|
|
173
173
|
hold: "hold";
|
|
174
174
|
}>>;
|
|
175
175
|
status: z.ZodDefault<z.ZodEnum<{
|
|
176
|
-
pending: "pending";
|
|
177
|
-
cancelled: "cancelled";
|
|
178
176
|
expired: "expired";
|
|
177
|
+
cancelled: "cancelled";
|
|
178
|
+
pending: "pending";
|
|
179
179
|
paid: "paid";
|
|
180
180
|
due: "due";
|
|
181
181
|
waived: "waived";
|