@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.
Files changed (54) hide show
  1. package/dist/action-ledger-drift.d.ts +29 -0
  2. package/dist/action-ledger-drift.d.ts.map +1 -0
  3. package/dist/action-ledger-drift.js +163 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2 -0
  6. package/dist/routes-action-ledger.d.ts +181 -0
  7. package/dist/routes-action-ledger.d.ts.map +1 -0
  8. package/dist/routes-action-ledger.js +142 -0
  9. package/dist/routes-documents.d.ts +8 -8
  10. package/dist/routes-public.d.ts +48 -48
  11. package/dist/routes-settlement.d.ts +1 -1
  12. package/dist/routes-shared.d.ts +12 -0
  13. package/dist/routes-shared.d.ts.map +1 -1
  14. package/dist/routes.d.ts +288 -217
  15. package/dist/routes.d.ts.map +1 -1
  16. package/dist/routes.js +280 -46
  17. package/dist/schema.d.ts +22 -22
  18. package/dist/service-action-ledger-accounting.d.ts +77 -0
  19. package/dist/service-action-ledger-accounting.d.ts.map +1 -0
  20. package/dist/service-action-ledger-accounting.js +307 -0
  21. package/dist/service-action-ledger-booking-payments.d.ts +48 -0
  22. package/dist/service-action-ledger-booking-payments.d.ts.map +1 -0
  23. package/dist/service-action-ledger-booking-payments.js +178 -0
  24. package/dist/service-action-ledger-payment-authorizations.d.ts +48 -0
  25. package/dist/service-action-ledger-payment-authorizations.d.ts.map +1 -0
  26. package/dist/service-action-ledger-payment-authorizations.js +209 -0
  27. package/dist/service-action-ledger-payment-sessions.d.ts +83 -0
  28. package/dist/service-action-ledger-payment-sessions.d.ts.map +1 -0
  29. package/dist/service-action-ledger-payment-sessions.js +294 -0
  30. package/dist/service-action-ledger-supplier-payments.d.ts +21 -0
  31. package/dist/service-action-ledger-supplier-payments.d.ts.map +1 -0
  32. package/dist/service-action-ledger-supplier-payments.js +70 -0
  33. package/dist/service-action-ledger.d.ts +6 -0
  34. package/dist/service-action-ledger.d.ts.map +1 -0
  35. package/dist/service-action-ledger.js +5 -0
  36. package/dist/service-booking-create.d.ts +50 -8
  37. package/dist/service-booking-create.d.ts.map +1 -1
  38. package/dist/service-booking-create.js +58 -1
  39. package/dist/service-bookings-dual-create.d.ts +50 -8
  40. package/dist/service-bookings-dual-create.d.ts.map +1 -1
  41. package/dist/service-issue.d.ts +42 -12
  42. package/dist/service-issue.d.ts.map +1 -1
  43. package/dist/service-issue.js +141 -4
  44. package/dist/service-public.d.ts +13 -13
  45. package/dist/service-vouchers.d.ts +10 -10
  46. package/dist/service.d.ts +291 -279
  47. package/dist/service.d.ts.map +1 -1
  48. package/dist/service.js +753 -238
  49. package/dist/validation-billing.d.ts +37 -37
  50. package/dist/validation-payments.d.ts +102 -102
  51. package/dist/validation-public.d.ts +45 -45
  52. package/dist/validation-shared.d.ts +32 -32
  53. package/dist/validation-vouchers.d.ts +2 -2
  54. package/package.json +13 -7
@@ -6,8 +6,18 @@ 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
+ contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
+ contactLastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
+ contactPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
15
+ contactPreferredLanguage: z.ZodNullable<z.ZodOptional<z.ZodString>>;
16
+ contactCountry: z.ZodNullable<z.ZodOptional<z.ZodString>>;
17
+ contactRegion: z.ZodNullable<z.ZodOptional<z.ZodString>>;
18
+ contactCity: z.ZodNullable<z.ZodOptional<z.ZodString>>;
19
+ contactAddressLine1: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ contactPostalCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
11
21
  internalNotes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
22
  productId: z.ZodString;
13
23
  optionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -23,8 +33,8 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
23
33
  occupant: "occupant";
24
34
  }>>;
25
35
  travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
26
- child: "child";
27
36
  other: "other";
37
+ child: "child";
28
38
  adult: "adult";
29
39
  infant: "infant";
30
40
  senior: "senior";
@@ -40,6 +50,16 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
40
50
  catalogSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
41
51
  confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
42
52
  priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
53
+ initialStatus: z.ZodOptional<z.ZodEnum<{
54
+ expired: "expired";
55
+ cancelled: "cancelled";
56
+ completed: "completed";
57
+ draft: "draft";
58
+ on_hold: "on_hold";
59
+ awaiting_payment: "awaiting_payment";
60
+ confirmed: "confirmed";
61
+ in_progress: "in_progress";
62
+ }>>;
43
63
  itemLines: z.ZodOptional<z.ZodArray<z.ZodObject<{
44
64
  optionUnitId: z.ZodString;
45
65
  quantity: z.ZodNumber;
@@ -48,6 +68,7 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
48
68
  unitSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
49
69
  totalSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
50
70
  }, z.core.$strip>>>;
71
+ suppressNotifications: z.ZodOptional<z.ZodBoolean>;
51
72
  paymentSchedules: z.ZodOptional<z.ZodArray<z.ZodObject<{
52
73
  scheduleType: z.ZodDefault<z.ZodEnum<{
53
74
  other: "other";
@@ -57,9 +78,9 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
57
78
  hold: "hold";
58
79
  }>>;
59
80
  status: z.ZodDefault<z.ZodEnum<{
60
- pending: "pending";
61
- cancelled: "cancelled";
62
81
  expired: "expired";
82
+ cancelled: "cancelled";
83
+ pending: "pending";
63
84
  paid: "paid";
64
85
  due: "due";
65
86
  waived: "waived";
@@ -80,8 +101,18 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
80
101
  }, z.core.$strip>;
81
102
  secondary: z.ZodObject<{
82
103
  organizationId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
83
- bookingNumber: z.ZodString;
84
104
  personId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
105
+ bookingNumber: z.ZodString;
106
+ contactFirstName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
107
+ contactLastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
108
+ contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
109
+ contactPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
110
+ contactPreferredLanguage: z.ZodNullable<z.ZodOptional<z.ZodString>>;
111
+ contactCountry: z.ZodNullable<z.ZodOptional<z.ZodString>>;
112
+ contactRegion: z.ZodNullable<z.ZodOptional<z.ZodString>>;
113
+ contactCity: z.ZodNullable<z.ZodOptional<z.ZodString>>;
114
+ contactAddressLine1: z.ZodNullable<z.ZodOptional<z.ZodString>>;
115
+ contactPostalCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
85
116
  internalNotes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
86
117
  productId: z.ZodString;
87
118
  optionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -97,8 +128,8 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
97
128
  occupant: "occupant";
98
129
  }>>;
99
130
  travelerCategory: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
100
- child: "child";
101
131
  other: "other";
132
+ child: "child";
102
133
  adult: "adult";
103
134
  infant: "infant";
104
135
  senior: "senior";
@@ -114,6 +145,16 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
114
145
  catalogSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
115
146
  confirmedSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
116
147
  priceOverrideReason: z.ZodNullable<z.ZodOptional<z.ZodString>>;
148
+ initialStatus: z.ZodOptional<z.ZodEnum<{
149
+ expired: "expired";
150
+ cancelled: "cancelled";
151
+ completed: "completed";
152
+ draft: "draft";
153
+ on_hold: "on_hold";
154
+ awaiting_payment: "awaiting_payment";
155
+ confirmed: "confirmed";
156
+ in_progress: "in_progress";
157
+ }>>;
117
158
  itemLines: z.ZodOptional<z.ZodArray<z.ZodObject<{
118
159
  optionUnitId: z.ZodString;
119
160
  quantity: z.ZodNumber;
@@ -122,6 +163,7 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
122
163
  unitSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
123
164
  totalSellAmountCents: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
124
165
  }, z.core.$strip>>>;
166
+ suppressNotifications: z.ZodOptional<z.ZodBoolean>;
125
167
  paymentSchedules: z.ZodOptional<z.ZodArray<z.ZodObject<{
126
168
  scheduleType: z.ZodDefault<z.ZodEnum<{
127
169
  other: "other";
@@ -131,9 +173,9 @@ export declare const dualCreateBookingSchema: z.ZodObject<{
131
173
  hold: "hold";
132
174
  }>>;
133
175
  status: z.ZodDefault<z.ZodEnum<{
134
- pending: "pending";
135
- cancelled: "cancelled";
136
176
  expired: "expired";
177
+ cancelled: "cancelled";
178
+ pending: "pending";
137
179
  paid: "paid";
138
180
  due: "due";
139
181
  waived: "waived";
@@ -1 +1 @@
1
- {"version":3,"file":"service-bookings-dual-create.d.ts","sourceRoot":"","sources":["../src/service-bookings-dual-create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACjF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gB,EAAE,MAAM,CAAA;IACxB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,UAAU,EAAE,IAAI,CAAA;CACjB;AAID,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,SAAS,EAAE,mBAAmB,CAAA;IAC9B,KAAK,EAAE,YAAY,CAAA;IACnB,aAAa,EAAE,kBAAkB,CAAA;IACjC,eAAe,EAAE,kBAAkB,CAAA;CACpC;AAED,MAAM,MAAM,wBAAwB,GAChC;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,GACjD;IACE,MAAM,EAAE,gBAAgB,GAAG,kBAAkB,CAAA;IAC7C,MAAM,EAAE,OAAO,CAAC,oBAAoB,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,CAAC,CAAA;CACxD,CAAA;AAqBL;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,kBAAkB,EACtB,QAAQ,EAAE,sBAAsB,EAChC,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,wBAAwB,CAAA;CAC9B,GACL,OAAO,CAAC,wBAAwB,CAAC,CAkFnC"}
@@ -1,5 +1,7 @@
1
+ import { type ActionLedgerRequestContextValues } from "@voyantjs/action-ledger";
1
2
  import type { EventBus } from "@voyantjs/core";
2
3
  import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
4
+ import { invoices } from "./schema.js";
3
5
  import { type CreateInvoiceFromBookingInput, type InvoiceFromBookingData } from "./service.js";
4
6
  /**
5
7
  * Issue / proforma orchestration helpers that wrap the bare invoice
@@ -12,6 +14,8 @@ import { type CreateInvoiceFromBookingInput, type InvoiceFromBookingData } from
12
14
  */
13
15
  export interface InvoiceIssueRuntime {
14
16
  eventBus?: EventBus;
17
+ actionLedgerContext?: ActionLedgerRequestContextValues;
18
+ actionLedgerAuthorizationSource?: string | null;
15
19
  }
16
20
  export interface InvoiceIssuedEvent {
17
21
  invoiceId: string;
@@ -52,17 +56,14 @@ export interface InvoiceIssuedLineItem {
52
56
  */
53
57
  export declare function issueInvoiceFromBooking(db: PostgresJsDatabase, input: CreateInvoiceFromBookingInput, bookingData: InvoiceFromBookingData, runtime?: InvoiceIssueRuntime): Promise<{
54
58
  id: string;
55
- createdAt: Date;
56
- updatedAt: Date;
59
+ status: "draft" | "sent" | "partially_paid" | "paid" | "overdue" | "void";
57
60
  organizationId: string | null;
58
- status: "void" | "draft" | "sent" | "partially_paid" | "paid" | "overdue";
59
- issueDate: string;
61
+ createdAt: Date;
60
62
  currency: string;
61
63
  notes: string | null;
64
+ updatedAt: Date;
62
65
  bookingId: string;
63
66
  personId: string | null;
64
- baseCurrency: string | null;
65
- fxRateSetId: string | null;
66
67
  invoiceNumber: string;
67
68
  invoiceType: "invoice" | "proforma" | "credit_note";
68
69
  convertedFromInvoiceId: string | null;
@@ -71,6 +72,8 @@ export declare function issueInvoiceFromBooking(db: PostgresJsDatabase, input: C
71
72
  templateId: string | null;
72
73
  taxRegimeId: string | null;
73
74
  language: string | null;
75
+ baseCurrency: string | null;
76
+ fxRateSetId: string | null;
74
77
  subtotalCents: number;
75
78
  baseSubtotalCents: number | null;
76
79
  taxCents: number;
@@ -83,6 +86,7 @@ export declare function issueInvoiceFromBooking(db: PostgresJsDatabase, input: C
83
86
  baseBalanceDueCents: number | null;
84
87
  commissionPercent: number | null;
85
88
  commissionAmountCents: number | null;
89
+ issueDate: string;
86
90
  dueDate: string;
87
91
  } | null>;
88
92
  /**
@@ -93,17 +97,14 @@ export declare function issueInvoiceFromBooking(db: PostgresJsDatabase, input: C
93
97
  */
94
98
  export declare function issueProformaFromBooking(db: PostgresJsDatabase, input: CreateInvoiceFromBookingInput, bookingData: InvoiceFromBookingData, runtime?: InvoiceIssueRuntime): Promise<{
95
99
  id: string;
96
- createdAt: Date;
97
- updatedAt: Date;
100
+ status: "draft" | "sent" | "partially_paid" | "paid" | "overdue" | "void";
98
101
  organizationId: string | null;
99
- status: "void" | "draft" | "sent" | "partially_paid" | "paid" | "overdue";
100
- issueDate: string;
102
+ createdAt: Date;
101
103
  currency: string;
102
104
  notes: string | null;
105
+ updatedAt: Date;
103
106
  bookingId: string;
104
107
  personId: string | null;
105
- baseCurrency: string | null;
106
- fxRateSetId: string | null;
107
108
  invoiceNumber: string;
108
109
  invoiceType: "invoice" | "proforma" | "credit_note";
109
110
  convertedFromInvoiceId: string | null;
@@ -112,6 +113,8 @@ export declare function issueProformaFromBooking(db: PostgresJsDatabase, input:
112
113
  templateId: string | null;
113
114
  taxRegimeId: string | null;
114
115
  language: string | null;
116
+ baseCurrency: string | null;
117
+ fxRateSetId: string | null;
115
118
  subtotalCents: number;
116
119
  baseSubtotalCents: number | null;
117
120
  taxCents: number;
@@ -124,6 +127,33 @@ export declare function issueProformaFromBooking(db: PostgresJsDatabase, input:
124
127
  baseBalanceDueCents: number | null;
125
128
  commissionPercent: number | null;
126
129
  commissionAmountCents: number | null;
130
+ issueDate: string;
127
131
  dueDate: string;
128
132
  } | null>;
133
+ /**
134
+ * Convert an issued proforma into a final invoice. Copies the proforma's
135
+ * line items verbatim (totals + taxes already match the booking the
136
+ * customer accepted) and voids the proforma so it stops counting against
137
+ * outstanding balances. The new invoice carries `convertedFromInvoiceId`
138
+ * so the audit chain is preserved; downstream subscribers (SmartBill
139
+ * etc.) see the linkage on the emitted `invoice.issued` event.
140
+ *
141
+ * Number derivation: `PRO-` prefix → `INV-`; otherwise the original
142
+ * number is suffixed with `-INV`. Callers can override via the optional
143
+ * `invoiceNumber` argument when they want a series-derived number.
144
+ */
145
+ export declare function convertProformaToInvoice(db: PostgresJsDatabase, proformaId: string, options?: {
146
+ invoiceNumber?: string;
147
+ issueDate?: string;
148
+ dueDate?: string;
149
+ }, runtime?: InvoiceIssueRuntime): Promise<{
150
+ status: "ok";
151
+ invoice: typeof invoices.$inferSelect;
152
+ } | {
153
+ status: "not_found";
154
+ } | {
155
+ status: "not_proforma";
156
+ } | {
157
+ status: "already_converted";
158
+ }>;
129
159
  //# sourceMappingURL=service-issue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service-issue.d.ts","sourceRoot":"","sources":["../src/service-issue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EACL,KAAK,6BAA6B,EAElC,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAA;AAErB;;;;;;;;GAQG;AAEH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,SAAS,GAAG,UAAU,GAAG,aAAa,CAAA;IACnD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,qDAAqD;IACrD,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IA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CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAKD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,6BAA6B,EACpC,WAAW,EAAE,sBAAsB,EACnC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmClC;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,6BAA6B,EACpC,WAAW,EAAE,sBAAsB,EACnC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmClC;AAiDD;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;CACZ,EACN,OAAO,GAAE,mBAAwB,GAChC,OAAO,CACN;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,QAAQ,CAAC,YAAY,CAAA;CAAE,GACvD;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,cAAc,CAAA;CAAE,GAC1B;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAClC,CA0GA"}
@@ -1,7 +1,8 @@
1
+ import { appendActionLedgerMutation, } from "@voyantjs/action-ledger";
1
2
  import { bookings } from "@voyantjs/bookings/schema";
2
3
  import { asc, eq } from "drizzle-orm";
3
- import { invoiceLineItems, invoices } from "./schema.js";
4
- import { financeService, } from "./service.js";
4
+ import { invoiceLineItems, invoices, payments } from "./schema.js";
5
+ import { buildInvoiceIssuedActionLedgerInput, financeService, } from "./service.js";
5
6
  const ISSUED_EVENT = "invoice.issued";
6
7
  const PROFORMA_ISSUED_EVENT = "invoice.proforma.issued";
7
8
  /**
@@ -14,11 +15,21 @@ export async function issueInvoiceFromBooking(db, input, bookingData, runtime =
14
15
  const draft = await financeService.createInvoiceFromBooking(db, input, bookingData);
15
16
  if (!draft)
16
17
  return null;
17
- const [issued] = await db
18
+ const updateIssuedInvoice = (writer) => writer
18
19
  .update(invoices)
19
20
  .set({ status: "sent", updatedAt: new Date() })
20
21
  .where(eq(invoices.id, draft.id))
21
22
  .returning();
23
+ const actionLedgerContext = runtime.actionLedgerContext;
24
+ const issued = actionLedgerContext
25
+ ? await db.transaction(async (tx) => {
26
+ const [row] = await updateIssuedInvoice(tx);
27
+ if (row) {
28
+ await appendActionLedgerMutation(tx, await buildInvoiceIssuedActionLedgerInput(actionLedgerContext, { invoice: row }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
29
+ }
30
+ return row;
31
+ })
32
+ : (await updateIssuedInvoice(db))[0];
22
33
  const row = issued ?? draft;
23
34
  await emitIssued(db, runtime, ISSUED_EVENT, row);
24
35
  return row;
@@ -33,11 +44,21 @@ export async function issueProformaFromBooking(db, input, bookingData, runtime =
33
44
  const draft = await financeService.createInvoiceFromBooking(db, input, bookingData);
34
45
  if (!draft)
35
46
  return null;
36
- const [issued] = await db
47
+ const updateIssuedInvoice = (writer) => writer
37
48
  .update(invoices)
38
49
  .set({ invoiceType: "proforma", status: "sent", updatedAt: new Date() })
39
50
  .where(eq(invoices.id, draft.id))
40
51
  .returning();
52
+ const actionLedgerContext = runtime.actionLedgerContext;
53
+ const issued = actionLedgerContext
54
+ ? await db.transaction(async (tx) => {
55
+ const [row] = await updateIssuedInvoice(tx);
56
+ if (row) {
57
+ await appendActionLedgerMutation(tx, await buildInvoiceIssuedActionLedgerInput(actionLedgerContext, { invoice: row }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
58
+ }
59
+ return row;
60
+ })
61
+ : (await updateIssuedInvoice(db))[0];
41
62
  const row = issued ?? draft;
42
63
  await emitIssued(db, runtime, PROFORMA_ISSUED_EVENT, row);
43
64
  return row;
@@ -84,6 +105,122 @@ async function emitIssued(db, runtime, eventName, invoice) {
84
105
  };
85
106
  await runtime.eventBus.emit(eventName, payload);
86
107
  }
108
+ /**
109
+ * Convert an issued proforma into a final invoice. Copies the proforma's
110
+ * line items verbatim (totals + taxes already match the booking the
111
+ * customer accepted) and voids the proforma so it stops counting against
112
+ * outstanding balances. The new invoice carries `convertedFromInvoiceId`
113
+ * so the audit chain is preserved; downstream subscribers (SmartBill
114
+ * etc.) see the linkage on the emitted `invoice.issued` event.
115
+ *
116
+ * Number derivation: `PRO-` prefix → `INV-`; otherwise the original
117
+ * number is suffixed with `-INV`. Callers can override via the optional
118
+ * `invoiceNumber` argument when they want a series-derived number.
119
+ */
120
+ export async function convertProformaToInvoice(db, proformaId, options = {}, runtime = {}) {
121
+ const [proforma] = await db.select().from(invoices).where(eq(invoices.id, proformaId)).limit(1);
122
+ if (!proforma)
123
+ return { status: "not_found" };
124
+ if (proforma.invoiceType !== "proforma")
125
+ return { status: "not_proforma" };
126
+ if (proforma.status === "void")
127
+ return { status: "already_converted" };
128
+ const [existing] = await db
129
+ .select({ id: invoices.id })
130
+ .from(invoices)
131
+ .where(eq(invoices.convertedFromInvoiceId, proformaId))
132
+ .limit(1);
133
+ if (existing)
134
+ return { status: "already_converted" };
135
+ const lineItems = await db
136
+ .select()
137
+ .from(invoiceLineItems)
138
+ .where(eq(invoiceLineItems.invoiceId, proformaId))
139
+ .orderBy(asc(invoiceLineItems.sortOrder));
140
+ const newInvoiceNumber = options.invoiceNumber ?? deriveInvoiceNumberFromProforma(proforma.invoiceNumber);
141
+ const todayIso = new Date().toISOString().slice(0, 10);
142
+ const issueDate = options.issueDate ?? todayIso;
143
+ const dueDate = options.dueDate ?? toDateString(proforma.dueDate);
144
+ const created = await db.transaction(async (tx) => {
145
+ const [inserted] = await tx
146
+ .insert(invoices)
147
+ .values({
148
+ invoiceNumber: newInvoiceNumber,
149
+ invoiceType: "invoice",
150
+ convertedFromInvoiceId: proforma.id,
151
+ seriesId: proforma.seriesId,
152
+ templateId: proforma.templateId,
153
+ taxRegimeId: proforma.taxRegimeId,
154
+ language: proforma.language,
155
+ bookingId: proforma.bookingId,
156
+ personId: proforma.personId,
157
+ organizationId: proforma.organizationId,
158
+ status: "sent",
159
+ currency: proforma.currency,
160
+ baseCurrency: proforma.baseCurrency,
161
+ fxRateSetId: proforma.fxRateSetId,
162
+ subtotalCents: proforma.subtotalCents,
163
+ baseSubtotalCents: proforma.baseSubtotalCents,
164
+ taxCents: proforma.taxCents,
165
+ baseTaxCents: proforma.baseTaxCents,
166
+ totalCents: proforma.totalCents,
167
+ baseTotalCents: proforma.baseTotalCents,
168
+ // Carry the proforma's settled amounts forward — a partially
169
+ // (or fully) paid proforma must convert to an invoice that
170
+ // reflects those payments, otherwise the new invoice shows the
171
+ // full total as outstanding and the payment rows reassigned
172
+ // below would orphan the balance.
173
+ paidCents: proforma.paidCents,
174
+ basePaidCents: proforma.basePaidCents,
175
+ balanceDueCents: proforma.totalCents - proforma.paidCents,
176
+ baseBalanceDueCents: proforma.baseTotalCents !== null && proforma.basePaidCents !== null
177
+ ? proforma.baseTotalCents - proforma.basePaidCents
178
+ : proforma.baseTotalCents,
179
+ commissionPercent: proforma.commissionPercent,
180
+ commissionAmountCents: proforma.commissionAmountCents,
181
+ issueDate,
182
+ dueDate,
183
+ notes: proforma.notes,
184
+ })
185
+ .returning();
186
+ if (!inserted)
187
+ return null;
188
+ if (lineItems.length > 0) {
189
+ await tx.insert(invoiceLineItems).values(lineItems.map((line) => ({
190
+ invoiceId: inserted.id,
191
+ bookingItemId: line.bookingItemId,
192
+ description: line.description,
193
+ quantity: line.quantity,
194
+ unitPriceCents: line.unitPriceCents,
195
+ totalCents: line.totalCents,
196
+ taxRate: line.taxRate,
197
+ sortOrder: line.sortOrder,
198
+ })));
199
+ }
200
+ // Reassign payments off the proforma so they don't sit attached to
201
+ // a void document. The proforma's payment rows become the final
202
+ // invoice's payment history.
203
+ await tx
204
+ .update(payments)
205
+ .set({ invoiceId: inserted.id, updatedAt: new Date() })
206
+ .where(eq(payments.invoiceId, proforma.id));
207
+ await tx
208
+ .update(invoices)
209
+ .set({ status: "void", updatedAt: new Date() })
210
+ .where(eq(invoices.id, proforma.id));
211
+ return inserted;
212
+ });
213
+ if (!created)
214
+ return { status: "not_found" };
215
+ await emitIssued(db, runtime, ISSUED_EVENT, created);
216
+ return { status: "ok", invoice: created };
217
+ }
218
+ function deriveInvoiceNumberFromProforma(proformaNumber) {
219
+ if (/^PRO-/i.test(proformaNumber)) {
220
+ return proformaNumber.replace(/^PRO-/i, "INV-");
221
+ }
222
+ return `${proformaNumber}-INV`;
223
+ }
87
224
  function buildClientName(booking) {
88
225
  const name = [booking?.contactFirstName, booking?.contactLastName]
89
226
  .filter((part) => typeof part === "string" && part.length > 0)
@@ -13,8 +13,8 @@ export declare const publicFinanceService: {
13
13
  id: string;
14
14
  label: string;
15
15
  provider: string | null;
16
- instrumentType: "other" | "voucher" | "wallet" | "credit_card" | "debit_card" | "cash" | "direct_bill" | "bank_account";
17
- status: "active" | "expired" | "revoked" | "inactive" | "failed_verification";
16
+ instrumentType: "credit_card" | "debit_card" | "cash" | "wallet" | "direct_bill" | "voucher" | "other" | "bank_account";
17
+ status: "expired" | "active" | "inactive" | "revoked" | "failed_verification";
18
18
  brand: string | null;
19
19
  last4: string | null;
20
20
  expiryMonth: number | null;
@@ -24,7 +24,7 @@ export declare const publicFinanceService: {
24
24
  schedules: {
25
25
  id: string;
26
26
  scheduleType: "other" | "deposit" | "installment" | "balance" | "hold";
27
- status: "pending" | "cancelled" | "expired" | "paid" | "due" | "waived";
27
+ status: "expired" | "cancelled" | "pending" | "paid" | "due" | "waived";
28
28
  dueDate: string;
29
29
  currency: string;
30
30
  amountCents: number;
@@ -33,8 +33,8 @@ export declare const publicFinanceService: {
33
33
  guarantees: {
34
34
  id: string;
35
35
  bookingPaymentScheduleId: string | null;
36
- guaranteeType: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
37
- status: "pending" | "failed" | "cancelled" | "active" | "expired" | "released";
36
+ guaranteeType: "bank_transfer" | "credit_card" | "voucher" | "other" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
37
+ status: "failed" | "expired" | "cancelled" | "pending" | "active" | "released";
38
38
  currency: string | null;
39
39
  amountCents: number | null;
40
40
  provider: string | null;
@@ -56,7 +56,7 @@ export declare const publicFinanceService: {
56
56
  invoiceId: string | null;
57
57
  bookingPaymentScheduleId: string | null;
58
58
  bookingGuaranteeId: string | null;
59
- status: "pending" | "failed" | "cancelled" | "expired" | "paid" | "requires_redirect" | "processing" | "authorized";
59
+ status: "failed" | "expired" | "cancelled" | "pending" | "processing" | "paid" | "requires_redirect" | "authorized";
60
60
  provider: string | null;
61
61
  providerSessionId: string | null;
62
62
  providerPaymentId: string | null;
@@ -64,7 +64,7 @@ export declare const publicFinanceService: {
64
64
  clientReference: string | null;
65
65
  currency: string;
66
66
  amountCents: number;
67
- paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
67
+ paymentMethod: "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill" | "voucher" | "other" | null;
68
68
  payerEmail: string | null;
69
69
  payerName: string | null;
70
70
  redirectUrl: string | null;
@@ -85,7 +85,7 @@ export declare const publicFinanceService: {
85
85
  invoiceId: string | null;
86
86
  bookingPaymentScheduleId: string | null;
87
87
  bookingGuaranteeId: string | null;
88
- status: "pending" | "failed" | "cancelled" | "expired" | "paid" | "requires_redirect" | "processing" | "authorized";
88
+ status: "failed" | "expired" | "cancelled" | "pending" | "processing" | "paid" | "requires_redirect" | "authorized";
89
89
  provider: string | null;
90
90
  providerSessionId: string | null;
91
91
  providerPaymentId: string | null;
@@ -93,7 +93,7 @@ export declare const publicFinanceService: {
93
93
  clientReference: string | null;
94
94
  currency: string;
95
95
  amountCents: number;
96
- paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
96
+ paymentMethod: "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill" | "voucher" | "other" | null;
97
97
  payerEmail: string | null;
98
98
  payerName: string | null;
99
99
  redirectUrl: string | null;
@@ -113,7 +113,7 @@ export declare const publicFinanceService: {
113
113
  invoiceId: string | null;
114
114
  bookingPaymentScheduleId: string | null;
115
115
  bookingGuaranteeId: string | null;
116
- status: "pending" | "failed" | "cancelled" | "expired" | "paid" | "requires_redirect" | "processing" | "authorized";
116
+ status: "failed" | "expired" | "cancelled" | "pending" | "processing" | "paid" | "requires_redirect" | "authorized";
117
117
  provider: string | null;
118
118
  providerSessionId: string | null;
119
119
  providerPaymentId: string | null;
@@ -121,7 +121,7 @@ export declare const publicFinanceService: {
121
121
  clientReference: string | null;
122
122
  currency: string;
123
123
  amountCents: number;
124
- paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
124
+ paymentMethod: "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill" | "voucher" | "other" | null;
125
125
  payerEmail: string | null;
126
126
  payerName: string | null;
127
127
  redirectUrl: string | null;
@@ -141,7 +141,7 @@ export declare const publicFinanceService: {
141
141
  invoiceId: string | null;
142
142
  bookingPaymentScheduleId: string | null;
143
143
  bookingGuaranteeId: string | null;
144
- status: "pending" | "failed" | "cancelled" | "expired" | "paid" | "requires_redirect" | "processing" | "authorized";
144
+ status: "failed" | "expired" | "cancelled" | "pending" | "processing" | "paid" | "requires_redirect" | "authorized";
145
145
  provider: string | null;
146
146
  providerSessionId: string | null;
147
147
  providerPaymentId: string | null;
@@ -149,7 +149,7 @@ export declare const publicFinanceService: {
149
149
  clientReference: string | null;
150
150
  currency: string;
151
151
  amountCents: number;
152
- paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
152
+ paymentMethod: "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill" | "voucher" | "other" | null;
153
153
  payerEmail: string | null;
154
154
  payerName: string | null;
155
155
  redirectUrl: string | null;
@@ -25,7 +25,7 @@ export declare const vouchersService: {
25
25
  id: string;
26
26
  code: string;
27
27
  seriesCode: string | null;
28
- status: "void" | "active" | "expired" | "redeemed";
28
+ status: "expired" | "void" | "active" | "redeemed";
29
29
  currency: string;
30
30
  initialAmountCents: number;
31
31
  remainingAmountCents: number;
@@ -58,7 +58,7 @@ export declare const vouchersService: {
58
58
  id: string;
59
59
  code: string;
60
60
  seriesCode: string | null;
61
- status: "void" | "active" | "expired" | "redeemed";
61
+ status: "expired" | "void" | "active" | "redeemed";
62
62
  currency: string;
63
63
  initialAmountCents: number;
64
64
  remainingAmountCents: number;
@@ -76,29 +76,29 @@ export declare const vouchersService: {
76
76
  } | null>;
77
77
  create(db: PostgresJsDatabase, input: CreateVoucherInput, issuedByUserId?: string): Promise<{
78
78
  id: string;
79
+ status: "expired" | "void" | "active" | "redeemed";
79
80
  createdAt: Date;
80
- updatedAt: Date;
81
81
  expiresAt: Date | null;
82
- status: "void" | "active" | "expired" | "redeemed";
83
- currency: string;
84
- notes: string | null;
85
82
  code: string;
86
- sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
87
83
  seriesCode: string | null;
84
+ currency: string;
88
85
  initialAmountCents: number;
89
86
  remainingAmountCents: number;
90
87
  issuedToPersonId: string | null;
91
88
  issuedToOrganizationId: string | null;
89
+ sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
92
90
  sourceBookingId: string | null;
93
91
  sourcePaymentId: string | null;
94
92
  validFrom: Date | null;
93
+ notes: string | null;
95
94
  issuedByUserId: string | null;
95
+ updatedAt: Date;
96
96
  } | null>;
97
97
  update(db: PostgresJsDatabase, id: string, input: UpdateVoucherInput): Promise<{
98
98
  id: string;
99
99
  code: string;
100
100
  seriesCode: string | null;
101
- status: "void" | "active" | "expired" | "redeemed";
101
+ status: "expired" | "void" | "active" | "redeemed";
102
102
  currency: string;
103
103
  initialAmountCents: number;
104
104
  remainingAmountCents: number;
@@ -126,7 +126,7 @@ export declare const vouchersService: {
126
126
  id: string;
127
127
  code: string;
128
128
  seriesCode: string | null;
129
- status: "void" | "active" | "expired" | "redeemed";
129
+ status: "expired" | "void" | "active" | "redeemed";
130
130
  currency: string;
131
131
  initialAmountCents: number;
132
132
  remainingAmountCents: number;
@@ -145,8 +145,8 @@ export declare const vouchersService: {
145
145
  redemption: {
146
146
  id: string;
147
147
  createdAt: Date;
148
- bookingId: string;
149
148
  voucherId: string;
149
+ bookingId: string;
150
150
  paymentId: string | null;
151
151
  amountCents: number;
152
152
  createdByUserId: string | null;