@voyantjs/finance 0.3.0 → 0.3.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AA+DjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAMD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CA0/BtB,CAAA;AAEJ,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAA;AAChD,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA"}
package/dist/routes.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Hono } from "hono";
2
2
  import { financeService } from "./service.js";
3
- import { agingReportQuerySchema, applyDefaultBookingPaymentPlanSchema, cancelPaymentSessionSchema, completePaymentSessionSchema, createPaymentSessionFromGuaranteeSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, expirePaymentSessionSchema, failPaymentSessionSchema, insertBookingGuaranteeSchema, insertBookingItemCommissionSchema, insertBookingItemTaxLineSchema, insertBookingPaymentScheduleSchema, insertCreditNoteLineItemSchema, insertCreditNoteSchema, insertFinanceNoteSchema, insertInvoiceExternalRefSchema, insertInvoiceLineItemSchema, insertInvoiceNumberSeriesSchema, insertInvoiceSchema, insertInvoiceTemplateSchema, insertPaymentAuthorizationSchema, insertPaymentCaptureSchema, insertPaymentInstrumentSchema, insertPaymentSchema, insertPaymentSessionSchema, insertSupplierPaymentSchema, insertTaxRegimeSchema, invoiceListQuerySchema, invoiceNumberSeriesListQuerySchema, invoiceTemplateListQuerySchema, markPaymentSessionRequiresRedirectSchema, paymentAuthorizationListQuerySchema, paymentCaptureListQuerySchema, paymentInstrumentListQuerySchema, paymentSessionListQuerySchema, profitabilityQuerySchema, renderInvoiceInputSchema, revenueReportQuerySchema, supplierPaymentListQuerySchema, taxRegimeListQuerySchema, updateBookingGuaranteeSchema, updateBookingItemCommissionSchema, updateBookingItemTaxLineSchema, updateBookingPaymentScheduleSchema, updateCreditNoteSchema, updateInvoiceLineItemSchema, updateInvoiceNumberSeriesSchema, updateInvoiceSchema, updateInvoiceTemplateSchema, updatePaymentAuthorizationSchema, updatePaymentCaptureSchema, updatePaymentInstrumentSchema, updatePaymentSessionSchema, updateSupplierPaymentSchema, updateTaxRegimeSchema, } from "./validation.js";
3
+ import { agingReportQuerySchema, applyDefaultBookingPaymentPlanSchema, cancelPaymentSessionSchema, completePaymentSessionSchema, createPaymentSessionFromGuaranteeSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, expirePaymentSessionSchema, failPaymentSessionSchema, insertBookingGuaranteeSchema, insertBookingItemCommissionSchema, insertBookingItemTaxLineSchema, insertBookingPaymentScheduleSchema, insertCreditNoteLineItemSchema, insertCreditNoteSchema, insertFinanceNoteSchema, insertInvoiceExternalRefSchema, insertInvoiceLineItemSchema, insertInvoiceNumberSeriesSchema, insertInvoiceSchema, insertInvoiceTemplateSchema, insertPaymentAuthorizationSchema, insertPaymentCaptureSchema, insertPaymentInstrumentSchema, insertPaymentSchema, insertPaymentSessionSchema, insertSupplierPaymentSchema, insertTaxRegimeSchema, invoiceFromBookingSchema, invoiceListQuerySchema, invoiceNumberSeriesListQuerySchema, invoiceTemplateListQuerySchema, markPaymentSessionRequiresRedirectSchema, paymentAuthorizationListQuerySchema, paymentCaptureListQuerySchema, paymentInstrumentListQuerySchema, paymentSessionListQuerySchema, profitabilityQuerySchema, renderInvoiceInputSchema, revenueReportQuerySchema, supplierPaymentListQuerySchema, taxRegimeListQuerySchema, updateBookingGuaranteeSchema, updateBookingItemCommissionSchema, updateBookingItemTaxLineSchema, updateBookingPaymentScheduleSchema, updateCreditNoteSchema, updateInvoiceLineItemSchema, updateInvoiceNumberSeriesSchema, updateInvoiceSchema, updateInvoiceTemplateSchema, updatePaymentAuthorizationSchema, updatePaymentCaptureSchema, updatePaymentInstrumentSchema, updatePaymentSessionSchema, updateSupplierPaymentSchema, updateTaxRegimeSchema, } from "./validation.js";
4
4
  // ==========================================================================
5
5
  // Finance Routes — method-chained for Hono RPC type inference
6
6
  // ==========================================================================
@@ -351,6 +351,45 @@ export const financeRoutes = new Hono()
351
351
  return c.json({
352
352
  data: await financeService.createInvoice(c.get("db"), insertInvoiceSchema.parse(await c.req.json())),
353
353
  }, 201);
354
+ })
355
+ // POST /invoices/from-booking — Create draft invoice from booking + booking items
356
+ .post("/invoices/from-booking", async (c) => {
357
+ const input = invoiceFromBookingSchema.parse(await c.req.json());
358
+ const db = c.get("db");
359
+ const [{ bookingItems, bookings }, { eq }] = await Promise.all([
360
+ import("@voyantjs/bookings/schema"),
361
+ import("drizzle-orm"),
362
+ ]);
363
+ const [booking] = await db
364
+ .select()
365
+ .from(bookings)
366
+ .where(eq(bookings.id, input.bookingId))
367
+ .limit(1);
368
+ if (!booking) {
369
+ return c.json({ error: "Booking not found" }, 404);
370
+ }
371
+ const items = await db.select().from(bookingItems).where(eq(bookingItems.bookingId, booking.id));
372
+ const row = await financeService.createInvoiceFromBooking(db, input, {
373
+ booking: {
374
+ id: booking.id,
375
+ bookingNumber: booking.bookingNumber,
376
+ personId: booking.personId,
377
+ organizationId: booking.organizationId,
378
+ sellCurrency: booking.sellCurrency,
379
+ baseCurrency: booking.baseCurrency,
380
+ fxRateSetId: null,
381
+ sellAmountCents: booking.sellAmountCents,
382
+ baseSellAmountCents: booking.baseSellAmountCents,
383
+ },
384
+ items: items.map((item) => ({
385
+ id: item.id,
386
+ title: item.title,
387
+ quantity: item.quantity,
388
+ unitSellAmountCents: item.unitSellAmountCents,
389
+ totalSellAmountCents: item.totalSellAmountCents,
390
+ })),
391
+ });
392
+ return c.json({ data: row }, 201);
354
393
  })
355
394
  // GET /invoices/:id — Get single invoice
356
395
  .get("/invoices/:id", async (c) => {
package/dist/schema.d.ts CHANGED
@@ -136,7 +136,7 @@ export declare const paymentInstruments: import("drizzle-orm/pg-core").PgTableWi
136
136
  tableName: "payment_instruments";
137
137
  dataType: "string";
138
138
  columnType: "PgEnumColumn";
139
- data: "credit_card" | "debit_card" | "cash" | "wallet" | "direct_bill" | "voucher" | "other" | "bank_account";
139
+ data: "other" | "voucher" | "wallet" | "credit_card" | "debit_card" | "cash" | "direct_bill" | "bank_account";
140
140
  driverParam: string;
141
141
  notNull: true;
142
142
  hasDefault: false;
@@ -153,7 +153,7 @@ export declare const paymentInstruments: import("drizzle-orm/pg-core").PgTableWi
153
153
  tableName: "payment_instruments";
154
154
  dataType: "string";
155
155
  columnType: "PgEnumColumn";
156
- data: "expired" | "active" | "inactive" | "revoked" | "failed_verification";
156
+ data: "expired" | "revoked" | "active" | "inactive" | "failed_verification";
157
157
  driverParam: string;
158
158
  notNull: true;
159
159
  hasDefault: true;
@@ -655,7 +655,7 @@ export declare const paymentSessions: import("drizzle-orm/pg-core").PgTableWithC
655
655
  tableName: "payment_sessions";
656
656
  dataType: "string";
657
657
  columnType: "PgEnumColumn";
658
- data: "paid" | "pending" | "failed" | "requires_redirect" | "processing" | "authorized" | "cancelled" | "expired";
658
+ data: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
659
659
  driverParam: string;
660
660
  notNull: true;
661
661
  hasDefault: true;
@@ -808,7 +808,7 @@ export declare const paymentSessions: import("drizzle-orm/pg-core").PgTableWithC
808
808
  tableName: "payment_sessions";
809
809
  dataType: "string";
810
810
  columnType: "PgEnumColumn";
811
- data: "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill" | "voucher" | "other";
811
+ data: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill";
812
812
  driverParam: string;
813
813
  notNull: false;
814
814
  hasDefault: false;
@@ -1280,7 +1280,7 @@ export declare const paymentAuthorizations: import("drizzle-orm/pg-core").PgTabl
1280
1280
  tableName: "payment_authorizations";
1281
1281
  dataType: "string";
1282
1282
  columnType: "PgEnumColumn";
1283
- data: "pending" | "failed" | "authorized" | "expired" | "partially_captured" | "captured" | "voided";
1283
+ data: "expired" | "pending" | "failed" | "authorized" | "partially_captured" | "captured" | "voided";
1284
1284
  driverParam: string;
1285
1285
  notNull: true;
1286
1286
  hasDefault: true;
@@ -1297,7 +1297,7 @@ export declare const paymentAuthorizations: import("drizzle-orm/pg-core").PgTabl
1297
1297
  tableName: "payment_authorizations";
1298
1298
  dataType: "string";
1299
1299
  columnType: "PgEnumColumn";
1300
- data: "automatic" | "manual";
1300
+ data: "manual" | "automatic";
1301
1301
  driverParam: string;
1302
1302
  notNull: true;
1303
1303
  hasDefault: true;
@@ -1561,7 +1561,7 @@ export declare const paymentCaptures: import("drizzle-orm/pg-core").PgTableWithC
1561
1561
  tableName: "payment_captures";
1562
1562
  dataType: "string";
1563
1563
  columnType: "PgEnumColumn";
1564
- data: "pending" | "completed" | "failed" | "refunded" | "voided";
1564
+ data: "completed" | "pending" | "failed" | "refunded" | "voided";
1565
1565
  driverParam: string;
1566
1566
  notNull: true;
1567
1567
  hasDefault: true;
@@ -1808,7 +1808,7 @@ export declare const bookingPaymentSchedules: import("drizzle-orm/pg-core").PgTa
1808
1808
  tableName: "booking_payment_schedules";
1809
1809
  dataType: "string";
1810
1810
  columnType: "PgEnumColumn";
1811
- data: "paid" | "pending" | "cancelled" | "expired" | "due" | "waived";
1811
+ data: "expired" | "cancelled" | "pending" | "paid" | "due" | "waived";
1812
1812
  driverParam: string;
1813
1813
  notNull: true;
1814
1814
  hasDefault: true;
@@ -2004,7 +2004,7 @@ export declare const bookingGuarantees: import("drizzle-orm/pg-core").PgTableWit
2004
2004
  tableName: "booking_guarantees";
2005
2005
  dataType: "string";
2006
2006
  columnType: "PgEnumColumn";
2007
- data: "bank_transfer" | "credit_card" | "voucher" | "other" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
2007
+ data: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
2008
2008
  driverParam: string;
2009
2009
  notNull: true;
2010
2010
  hasDefault: false;
@@ -2021,7 +2021,7 @@ export declare const bookingGuarantees: import("drizzle-orm/pg-core").PgTableWit
2021
2021
  tableName: "booking_guarantees";
2022
2022
  dataType: "string";
2023
2023
  columnType: "PgEnumColumn";
2024
- data: "pending" | "failed" | "cancelled" | "expired" | "active" | "released";
2024
+ data: "expired" | "cancelled" | "pending" | "released" | "failed" | "active";
2025
2025
  driverParam: string;
2026
2026
  notNull: true;
2027
2027
  hasDefault: true;
@@ -2549,7 +2549,7 @@ export declare const bookingItemCommissions: import("drizzle-orm/pg-core").PgTab
2549
2549
  tableName: "booking_item_commissions";
2550
2550
  dataType: "string";
2551
2551
  columnType: "PgEnumColumn";
2552
- data: "internal" | "supplier" | "other" | "channel" | "agency" | "affiliate" | "agent";
2552
+ data: "internal" | "supplier" | "other" | "affiliate" | "channel" | "agency" | "agent";
2553
2553
  driverParam: string;
2554
2554
  notNull: true;
2555
2555
  hasDefault: false;
@@ -2634,7 +2634,7 @@ export declare const bookingItemCommissions: import("drizzle-orm/pg-core").PgTab
2634
2634
  tableName: "booking_item_commissions";
2635
2635
  dataType: "string";
2636
2636
  columnType: "PgEnumColumn";
2637
- data: "paid" | "void" | "pending" | "accrued" | "payable";
2637
+ data: "pending" | "paid" | "void" | "accrued" | "payable";
2638
2638
  driverParam: string;
2639
2639
  notNull: true;
2640
2640
  hasDefault: true;
@@ -3596,7 +3596,7 @@ export declare const payments: import("drizzle-orm/pg-core").PgTableWithColumns<
3596
3596
  tableName: "payments";
3597
3597
  dataType: "string";
3598
3598
  columnType: "PgEnumColumn";
3599
- data: "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill" | "voucher" | "other";
3599
+ data: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill";
3600
3600
  driverParam: string;
3601
3601
  notNull: true;
3602
3602
  hasDefault: false;
@@ -3664,7 +3664,7 @@ export declare const payments: import("drizzle-orm/pg-core").PgTableWithColumns<
3664
3664
  tableName: "payments";
3665
3665
  dataType: "string";
3666
3666
  columnType: "PgEnumColumn";
3667
- data: "pending" | "completed" | "failed" | "refunded";
3667
+ data: "completed" | "pending" | "failed" | "refunded";
3668
3668
  driverParam: string;
3669
3669
  notNull: true;
3670
3670
  hasDefault: true;
@@ -4303,7 +4303,7 @@ export declare const supplierPayments: import("drizzle-orm/pg-core").PgTableWith
4303
4303
  tableName: "supplier_payments";
4304
4304
  dataType: "string";
4305
4305
  columnType: "PgEnumColumn";
4306
- data: "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill" | "voucher" | "other";
4306
+ data: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill";
4307
4307
  driverParam: string;
4308
4308
  notNull: true;
4309
4309
  hasDefault: false;
@@ -4337,7 +4337,7 @@ export declare const supplierPayments: import("drizzle-orm/pg-core").PgTableWith
4337
4337
  tableName: "supplier_payments";
4338
4338
  dataType: "string";
4339
4339
  columnType: "PgEnumColumn";
4340
- data: "pending" | "completed" | "failed" | "refunded";
4340
+ data: "completed" | "pending" | "failed" | "refunded";
4341
4341
  driverParam: string;
4342
4342
  notNull: true;
4343
4343
  hasDefault: true;
@@ -5053,7 +5053,7 @@ export declare const invoiceRenditions: import("drizzle-orm/pg-core").PgTableWit
5053
5053
  tableName: "invoice_renditions";
5054
5054
  dataType: "string";
5055
5055
  columnType: "PgEnumColumn";
5056
- data: "html" | "pdf" | "xml" | "json";
5056
+ data: "json" | "pdf" | "html" | "xml";
5057
5057
  driverParam: string;
5058
5058
  notNull: true;
5059
5059
  hasDefault: true;
@@ -0,0 +1,250 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { PublicBookingFinanceDocuments, PublicPaymentOptionsQuery, PublicStartPaymentSessionInput, PublicValidateVoucherInput } from "./validation-public.js";
3
+ export declare const publicFinanceService: {
4
+ getBookingDocuments(db: PostgresJsDatabase, bookingId: string): Promise<PublicBookingFinanceDocuments | null>;
5
+ getBookingPaymentOptions(db: PostgresJsDatabase, bookingId: string, query: PublicPaymentOptionsQuery): Promise<{
6
+ bookingId: string;
7
+ accounts: {
8
+ id: string;
9
+ label: string;
10
+ provider: string | null;
11
+ instrumentType: "other" | "voucher" | "wallet" | "credit_card" | "debit_card" | "cash" | "direct_bill" | "bank_account";
12
+ status: "expired" | "revoked" | "active" | "inactive" | "failed_verification";
13
+ brand: string | null;
14
+ last4: string | null;
15
+ expiryMonth: number | null;
16
+ expiryYear: number | null;
17
+ isDefault: boolean;
18
+ }[];
19
+ schedules: {
20
+ id: string;
21
+ scheduleType: "other" | "deposit" | "installment" | "balance" | "hold";
22
+ status: "expired" | "cancelled" | "pending" | "paid" | "due" | "waived";
23
+ dueDate: string;
24
+ currency: string;
25
+ amountCents: number;
26
+ notes: string | null;
27
+ }[];
28
+ guarantees: {
29
+ id: string;
30
+ bookingPaymentScheduleId: string | null;
31
+ guaranteeType: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
32
+ status: "expired" | "cancelled" | "pending" | "released" | "failed" | "active";
33
+ currency: string | null;
34
+ amountCents: number | null;
35
+ provider: string | null;
36
+ referenceNumber: string | null;
37
+ expiresAt: string | null;
38
+ notes: string | null;
39
+ }[];
40
+ recommendedTarget: {
41
+ targetType: "booking_payment_schedule" | "booking_guarantee";
42
+ targetId: string | null;
43
+ } | null;
44
+ } | null>;
45
+ getPaymentSession(db: PostgresJsDatabase, sessionId: string): Promise<{
46
+ id: string;
47
+ targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
48
+ targetId: string | null;
49
+ bookingId: string | null;
50
+ invoiceId: string | null;
51
+ bookingPaymentScheduleId: string | null;
52
+ bookingGuaranteeId: string | null;
53
+ status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
54
+ provider: string | null;
55
+ providerSessionId: string | null;
56
+ providerPaymentId: string | null;
57
+ externalReference: string | null;
58
+ clientReference: string | null;
59
+ currency: string;
60
+ amountCents: number;
61
+ paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
62
+ payerEmail: string | null;
63
+ payerName: string | null;
64
+ redirectUrl: string | null;
65
+ returnUrl: string | null;
66
+ cancelUrl: string | null;
67
+ expiresAt: string | null;
68
+ completedAt: string | null;
69
+ failureCode: string | null;
70
+ failureMessage: string | null;
71
+ } | null>;
72
+ startBookingSchedulePaymentSession(db: PostgresJsDatabase, bookingId: string, scheduleId: string, input: PublicStartPaymentSessionInput): Promise<{
73
+ id: string;
74
+ targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
75
+ targetId: string | null;
76
+ bookingId: string | null;
77
+ invoiceId: string | null;
78
+ bookingPaymentScheduleId: string | null;
79
+ bookingGuaranteeId: string | null;
80
+ status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
81
+ provider: string | null;
82
+ providerSessionId: string | null;
83
+ providerPaymentId: string | null;
84
+ externalReference: string | null;
85
+ clientReference: string | null;
86
+ currency: string;
87
+ amountCents: number;
88
+ paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
89
+ payerEmail: string | null;
90
+ payerName: string | null;
91
+ redirectUrl: string | null;
92
+ returnUrl: string | null;
93
+ cancelUrl: string | null;
94
+ expiresAt: string | null;
95
+ completedAt: string | null;
96
+ failureCode: string | null;
97
+ failureMessage: string | null;
98
+ } | null>;
99
+ startBookingGuaranteePaymentSession(db: PostgresJsDatabase, bookingId: string, guaranteeId: string, input: PublicStartPaymentSessionInput): Promise<{
100
+ id: string;
101
+ targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
102
+ targetId: string | null;
103
+ bookingId: string | null;
104
+ invoiceId: string | null;
105
+ bookingPaymentScheduleId: string | null;
106
+ bookingGuaranteeId: string | null;
107
+ status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
108
+ provider: string | null;
109
+ providerSessionId: string | null;
110
+ providerPaymentId: string | null;
111
+ externalReference: string | null;
112
+ clientReference: string | null;
113
+ currency: string;
114
+ amountCents: number;
115
+ paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
116
+ payerEmail: string | null;
117
+ payerName: string | null;
118
+ redirectUrl: string | null;
119
+ returnUrl: string | null;
120
+ cancelUrl: string | null;
121
+ expiresAt: string | null;
122
+ completedAt: string | null;
123
+ failureCode: string | null;
124
+ failureMessage: string | null;
125
+ } | null>;
126
+ startInvoicePaymentSession(db: PostgresJsDatabase, invoiceId: string, input: PublicStartPaymentSessionInput): Promise<{
127
+ id: string;
128
+ targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
129
+ targetId: string | null;
130
+ bookingId: string | null;
131
+ invoiceId: string | null;
132
+ bookingPaymentScheduleId: string | null;
133
+ bookingGuaranteeId: string | null;
134
+ status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
135
+ provider: string | null;
136
+ providerSessionId: string | null;
137
+ providerPaymentId: string | null;
138
+ externalReference: string | null;
139
+ clientReference: string | null;
140
+ currency: string;
141
+ amountCents: number;
142
+ paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
143
+ payerEmail: string | null;
144
+ payerName: string | null;
145
+ redirectUrl: string | null;
146
+ returnUrl: string | null;
147
+ cancelUrl: string | null;
148
+ expiresAt: string | null;
149
+ completedAt: string | null;
150
+ failureCode: string | null;
151
+ failureMessage: string | null;
152
+ } | null>;
153
+ validateVoucher(db: PostgresJsDatabase, input: PublicValidateVoucherInput): Promise<{
154
+ valid: false;
155
+ reason: "not_found";
156
+ voucher: null;
157
+ } | {
158
+ valid: false;
159
+ reason: "inactive";
160
+ voucher: {
161
+ id: string;
162
+ code: string;
163
+ label: string;
164
+ provider: string | null;
165
+ currency: string | null;
166
+ amountCents: number | null;
167
+ remainingAmountCents: number | null;
168
+ expiresAt: string | null;
169
+ };
170
+ } | {
171
+ valid: false;
172
+ reason: "not_started";
173
+ voucher: {
174
+ id: string;
175
+ code: string;
176
+ label: string;
177
+ provider: string | null;
178
+ currency: string | null;
179
+ amountCents: number | null;
180
+ remainingAmountCents: number | null;
181
+ expiresAt: string | null;
182
+ };
183
+ } | {
184
+ valid: false;
185
+ reason: "expired";
186
+ voucher: {
187
+ id: string;
188
+ code: string;
189
+ label: string;
190
+ provider: string | null;
191
+ currency: string | null;
192
+ amountCents: number | null;
193
+ remainingAmountCents: number | null;
194
+ expiresAt: string | null;
195
+ };
196
+ } | {
197
+ valid: false;
198
+ reason: "booking_mismatch";
199
+ voucher: {
200
+ id: string;
201
+ code: string;
202
+ label: string;
203
+ provider: string | null;
204
+ currency: string | null;
205
+ amountCents: number | null;
206
+ remainingAmountCents: number | null;
207
+ expiresAt: string | null;
208
+ };
209
+ } | {
210
+ valid: false;
211
+ reason: "currency_mismatch";
212
+ voucher: {
213
+ id: string;
214
+ code: string;
215
+ label: string;
216
+ provider: string | null;
217
+ currency: string | null;
218
+ amountCents: number | null;
219
+ remainingAmountCents: number | null;
220
+ expiresAt: string | null;
221
+ };
222
+ } | {
223
+ valid: false;
224
+ reason: "insufficient_balance";
225
+ voucher: {
226
+ id: string;
227
+ code: string;
228
+ label: string;
229
+ provider: string | null;
230
+ currency: string | null;
231
+ amountCents: number | null;
232
+ remainingAmountCents: number | null;
233
+ expiresAt: string | null;
234
+ };
235
+ } | {
236
+ valid: true;
237
+ reason: null;
238
+ voucher: {
239
+ id: string;
240
+ code: string;
241
+ label: string;
242
+ provider: string | null;
243
+ currency: string | null;
244
+ amountCents: number | null;
245
+ remainingAmountCents: number | null;
246
+ expiresAt: string | null;
247
+ };
248
+ }>;
249
+ };
250
+ //# sourceMappingURL=service-public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-public.d.ts","sourceRoot":"","sources":["../src/service-public.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAUjE,OAAO,KAAK,EACV,6BAA6B,EAC7B,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,wBAAwB,CAAA;AA4H/B,eAAO,MAAM,oBAAoB;4BAEzB,kBAAkB,aACX,MAAM,GAChB,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC;iCAqE1C,kBAAkB,aACX,MAAM,SACV,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAmHN,kBAAkB,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAM3D,kBAAkB,aACX,MAAM,cACL,MAAM,SACX,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;4CA4BjC,kBAAkB,aACX,MAAM,eACJ,MAAM,SACZ,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAuBjC,kBAAkB,aACX,MAAM,SACV,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAMb,kBAAkB,SAAS,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FhF,CAAA"}