@voyantjs/finance 0.52.1 → 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 +288 -217
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +280 -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 +50 -8
- package/dist/service-booking-create.d.ts.map +1 -1
- package/dist/service-booking-create.js +58 -1
- package/dist/service-bookings-dual-create.d.ts +50 -8
- package/dist/service-bookings-dual-create.d.ts.map +1 -1
- package/dist/service-issue.d.ts +42 -12
- package/dist/service-issue.d.ts.map +1 -1
- package/dist/service-issue.js +141 -4
- 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 +753 -238
- 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";
|
|
@@ -40,6 +40,27 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
40
40
|
catalogSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
41
41
|
confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
42
42
|
priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
43
|
+
initialStatus: z.ZodOptional<z.ZodEnum<{
|
|
44
|
+
expired: "expired";
|
|
45
|
+
cancelled: "cancelled";
|
|
46
|
+
completed: "completed";
|
|
47
|
+
draft: "draft";
|
|
48
|
+
on_hold: "on_hold";
|
|
49
|
+
awaiting_payment: "awaiting_payment";
|
|
50
|
+
confirmed: "confirmed";
|
|
51
|
+
in_progress: "in_progress";
|
|
52
|
+
}>>;
|
|
53
|
+
suppressNotifications: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
55
|
+
contactLastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
56
|
+
contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
57
|
+
contactPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
58
|
+
contactPreferredLanguage: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
59
|
+
contactCountry: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
60
|
+
contactRegion: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
61
|
+
contactCity: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
62
|
+
contactAddressLine1: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
63
|
+
contactPostalCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
43
64
|
travelers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
44
65
|
firstName: z.ZodString;
|
|
45
66
|
lastName: z.ZodString;
|
|
@@ -52,8 +73,8 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
52
73
|
occupant: "occupant";
|
|
53
74
|
}>>;
|
|
54
75
|
travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
55
|
-
child: "child";
|
|
56
76
|
other: "other";
|
|
77
|
+
child: "child";
|
|
57
78
|
adult: "adult";
|
|
58
79
|
infant: "infant";
|
|
59
80
|
senior: "senior";
|
|
@@ -81,9 +102,9 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
81
102
|
hold: "hold";
|
|
82
103
|
}>>;
|
|
83
104
|
status: z.ZodDefault<z.ZodEnum<{
|
|
84
|
-
pending: "pending";
|
|
85
|
-
cancelled: "cancelled";
|
|
86
105
|
expired: "expired";
|
|
106
|
+
cancelled: "cancelled";
|
|
107
|
+
pending: "pending";
|
|
87
108
|
paid: "paid";
|
|
88
109
|
due: "due";
|
|
89
110
|
waived: "waived";
|
|
@@ -121,8 +142,18 @@ export declare const bookingCreateSchema: z.ZodObject<{
|
|
|
121
142
|
}, z.core.$strip>;
|
|
122
143
|
export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
123
144
|
organizationId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
124
|
-
bookingNumber: z.ZodString;
|
|
125
145
|
personId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
146
|
+
bookingNumber: z.ZodString;
|
|
147
|
+
contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
148
|
+
contactLastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
149
|
+
contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
150
|
+
contactPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
151
|
+
contactPreferredLanguage: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
152
|
+
contactCountry: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
153
|
+
contactRegion: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
154
|
+
contactCity: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
155
|
+
contactAddressLine1: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
156
|
+
contactPostalCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
126
157
|
internalNotes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
127
158
|
productId: z.ZodString;
|
|
128
159
|
optionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -138,8 +169,8 @@ export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
|
138
169
|
occupant: "occupant";
|
|
139
170
|
}>>;
|
|
140
171
|
travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
141
|
-
child: "child";
|
|
142
172
|
other: "other";
|
|
173
|
+
child: "child";
|
|
143
174
|
adult: "adult";
|
|
144
175
|
infant: "infant";
|
|
145
176
|
senior: "senior";
|
|
@@ -155,6 +186,16 @@ export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
|
155
186
|
catalogSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
156
187
|
confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
157
188
|
priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
189
|
+
initialStatus: z.ZodOptional<z.ZodEnum<{
|
|
190
|
+
expired: "expired";
|
|
191
|
+
cancelled: "cancelled";
|
|
192
|
+
completed: "completed";
|
|
193
|
+
draft: "draft";
|
|
194
|
+
on_hold: "on_hold";
|
|
195
|
+
awaiting_payment: "awaiting_payment";
|
|
196
|
+
confirmed: "confirmed";
|
|
197
|
+
in_progress: "in_progress";
|
|
198
|
+
}>>;
|
|
158
199
|
itemLines: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
159
200
|
optionUnitId: z.ZodString;
|
|
160
201
|
quantity: z.ZodNumber;
|
|
@@ -163,6 +204,7 @@ export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
|
163
204
|
unitSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
164
205
|
totalSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
165
206
|
}, z.core.$strip>>>;
|
|
207
|
+
suppressNotifications: z.ZodOptional<z.ZodBoolean>;
|
|
166
208
|
paymentSchedules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
167
209
|
scheduleType: z.ZodDefault<z.ZodEnum<{
|
|
168
210
|
other: "other";
|
|
@@ -172,9 +214,9 @@ export declare const bookingCreateSubSchema: z.ZodObject<{
|
|
|
172
214
|
hold: "hold";
|
|
173
215
|
}>>;
|
|
174
216
|
status: z.ZodDefault<z.ZodEnum<{
|
|
175
|
-
pending: "pending";
|
|
176
|
-
cancelled: "cancelled";
|
|
177
217
|
expired: "expired";
|
|
218
|
+
cancelled: "cancelled";
|
|
219
|
+
pending: "pending";
|
|
178
220
|
paid: "paid";
|
|
179
221
|
due: "due";
|
|
180
222
|
waived: "waived";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-booking-create.d.ts","sourceRoot":"","sources":["../src/service-booking-create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-booking-create.d.ts","sourceRoot":"","sources":["../src/service-booking-create.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { bookingGroupsService, bookingsService } from "@voyantjs/bookings";
|
|
1
|
+
import { bookingGroupsService, bookingsService, } from "@voyantjs/bookings";
|
|
2
2
|
import { bookingItems, bookingTravelers } from "@voyantjs/bookings/schema";
|
|
3
|
+
import { bookingStatusSchema } from "@voyantjs/bookings/validation";
|
|
3
4
|
import { eq } from "drizzle-orm";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
import { bookingPaymentSchedules, vouchers } from "./schema.js";
|
|
@@ -109,6 +110,38 @@ const bookingCreateBaseSchema = z.object({
|
|
|
109
110
|
catalogSellAmountCents: z.number().int().min(0).optional().nullable(),
|
|
110
111
|
confirmedSellAmountCents: z.number().int().min(0).optional().nullable(),
|
|
111
112
|
priceOverrideReason: z.string().trim().min(1).max(1000).optional().nullable(),
|
|
113
|
+
/**
|
|
114
|
+
* Initial lifecycle status to seat the booking in — defaults to `draft`.
|
|
115
|
+
* Lets the dialog commit straight to `confirmed` or `awaiting_payment`
|
|
116
|
+
* in the same transaction, avoiding the post-create `/override-status`
|
|
117
|
+
* roundtrip that previously occasionally raced the create's COMMIT.
|
|
118
|
+
*
|
|
119
|
+
* When set to `confirmed`, the orchestrator emits `booking.confirmed`
|
|
120
|
+
* post-commit so notification + document-bundle subscribers fire just
|
|
121
|
+
* like they would for an after-the-fact transition.
|
|
122
|
+
*/
|
|
123
|
+
initialStatus: bookingStatusSchema.optional(),
|
|
124
|
+
/**
|
|
125
|
+
* When true and `initialStatus === "confirmed"`, the post-commit
|
|
126
|
+
* `booking.confirmed` event carries `suppressNotifications: true` so
|
|
127
|
+
* downstream subscribers skip customer-facing email + document
|
|
128
|
+
* bundles. Operators can confirm a booking silently this way.
|
|
129
|
+
*/
|
|
130
|
+
suppressNotifications: z.boolean().optional(),
|
|
131
|
+
// Billing-contact snapshot — captured at create time. Caller (the
|
|
132
|
+
// dialog) reads the linked CRM person/org and supplies what it
|
|
133
|
+
// knows; the convertProductToBooking helper writes everything
|
|
134
|
+
// through to the booking row's contact_* columns.
|
|
135
|
+
contactFirstName: z.string().max(255).optional().nullable(),
|
|
136
|
+
contactLastName: z.string().max(255).optional().nullable(),
|
|
137
|
+
contactEmail: z.string().max(255).optional().nullable(),
|
|
138
|
+
contactPhone: z.string().max(50).optional().nullable(),
|
|
139
|
+
contactPreferredLanguage: z.string().max(35).optional().nullable(),
|
|
140
|
+
contactCountry: z.string().max(2).optional().nullable(),
|
|
141
|
+
contactRegion: z.string().max(100).optional().nullable(),
|
|
142
|
+
contactCity: z.string().max(100).optional().nullable(),
|
|
143
|
+
contactAddressLine1: z.string().max(500).optional().nullable(),
|
|
144
|
+
contactPostalCode: z.string().max(20).optional().nullable(),
|
|
112
145
|
// Orchestration fields
|
|
113
146
|
travelers: z.array(travelerInputSchema).optional(),
|
|
114
147
|
itemLines: z.array(itemLineInputSchema).optional(),
|
|
@@ -223,6 +256,17 @@ export async function createBooking(db, rawInput, options = {}) {
|
|
|
223
256
|
catalogSellAmountCents: input.catalogSellAmountCents ?? null,
|
|
224
257
|
confirmedSellAmountCents: input.confirmedSellAmountCents ?? null,
|
|
225
258
|
priceOverrideReason: input.priceOverrideReason ?? null,
|
|
259
|
+
initialStatus: input.initialStatus,
|
|
260
|
+
contactFirstName: input.contactFirstName ?? null,
|
|
261
|
+
contactLastName: input.contactLastName ?? null,
|
|
262
|
+
contactEmail: input.contactEmail ?? null,
|
|
263
|
+
contactPhone: input.contactPhone ?? null,
|
|
264
|
+
contactPreferredLanguage: input.contactPreferredLanguage ?? null,
|
|
265
|
+
contactCountry: input.contactCountry ?? null,
|
|
266
|
+
contactRegion: input.contactRegion ?? null,
|
|
267
|
+
contactCity: input.contactCity ?? null,
|
|
268
|
+
contactAddressLine1: input.contactAddressLine1 ?? null,
|
|
269
|
+
contactPostalCode: input.contactPostalCode ?? null,
|
|
226
270
|
itemLines: input.itemLines,
|
|
227
271
|
});
|
|
228
272
|
if (!booking) {
|
|
@@ -453,6 +497,19 @@ export async function createBooking(db, rawInput, options = {}) {
|
|
|
453
497
|
occurredAt: new Date(),
|
|
454
498
|
};
|
|
455
499
|
await runtime.eventBus.emit("booking.created", event);
|
|
500
|
+
// When the caller asked us to land the booking already in
|
|
501
|
+
// `confirmed`, fan out the `booking.confirmed` event the same way
|
|
502
|
+
// the verb endpoint would so notification / document-bundle
|
|
503
|
+
// subscribers fire just once at create-time.
|
|
504
|
+
if (input.initialStatus === "confirmed") {
|
|
505
|
+
const confirmedEvent = {
|
|
506
|
+
bookingId: result.booking.id,
|
|
507
|
+
bookingNumber: result.booking.bookingNumber,
|
|
508
|
+
actorId: userId ?? null,
|
|
509
|
+
suppressNotifications: input.suppressNotifications === true ? true : undefined,
|
|
510
|
+
};
|
|
511
|
+
await runtime.eventBus.emit("booking.confirmed", confirmedEvent);
|
|
512
|
+
}
|
|
456
513
|
if (documentGeneration.contractDocument) {
|
|
457
514
|
await runtime.eventBus.emit("booking.contract_document.requested", {
|
|
458
515
|
bookingId: result.booking.id,
|