@voyantjs/finance 0.6.9 → 0.8.0

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 (47) hide show
  1. package/dist/index.d.ts +9 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +6 -1
  4. package/dist/routes-bookings-quick-create.d.ts +3 -0
  5. package/dist/routes-bookings-quick-create.d.ts.map +1 -0
  6. package/dist/routes-bookings-quick-create.js +103 -0
  7. package/dist/routes-public.d.ts +22 -22
  8. package/dist/routes.d.ts +279 -18
  9. package/dist/routes.d.ts.map +1 -1
  10. package/dist/routes.js +57 -1
  11. package/dist/schema.d.ts +451 -0
  12. package/dist/schema.d.ts.map +1 -1
  13. package/dist/schema.js +79 -0
  14. package/dist/service-aggregates.d.ts +47 -0
  15. package/dist/service-aggregates.d.ts.map +1 -0
  16. package/dist/service-aggregates.js +106 -0
  17. package/dist/service-bookings-dual-create.d.ts +185 -0
  18. package/dist/service-bookings-dual-create.d.ts.map +1 -0
  19. package/dist/service-bookings-dual-create.js +131 -0
  20. package/dist/service-bookings-quick-create.d.ts +168 -0
  21. package/dist/service-bookings-quick-create.d.ts.map +1 -0
  22. package/dist/service-bookings-quick-create.js +312 -0
  23. package/dist/service-public.d.ts +11 -11
  24. package/dist/service-public.d.ts.map +1 -1
  25. package/dist/service-public.js +79 -36
  26. package/dist/service-vouchers-migration.d.ts +44 -0
  27. package/dist/service-vouchers-migration.d.ts.map +1 -0
  28. package/dist/service-vouchers-migration.js +147 -0
  29. package/dist/service-vouchers.d.ts +157 -0
  30. package/dist/service-vouchers.d.ts.map +1 -0
  31. package/dist/service-vouchers.js +191 -0
  32. package/dist/service.d.ts +180 -17
  33. package/dist/service.d.ts.map +1 -1
  34. package/dist/service.js +4 -0
  35. package/dist/validation-public.d.ts +2 -2
  36. package/dist/validation-public.d.ts.map +1 -1
  37. package/dist/validation-public.js +4 -1
  38. package/dist/validation-shared.d.ts +17 -0
  39. package/dist/validation-shared.d.ts.map +1 -1
  40. package/dist/validation-shared.js +12 -0
  41. package/dist/validation-vouchers.d.ts +62 -0
  42. package/dist/validation-vouchers.d.ts.map +1 -0
  43. package/dist/validation-vouchers.js +46 -0
  44. package/dist/validation.d.ts +1 -0
  45. package/dist/validation.d.ts.map +1 -1
  46. package/dist/validation.js +1 -0
  47. package/package.json +9 -8
package/dist/routes.d.ts CHANGED
@@ -1,6 +1,42 @@
1
1
  import type { publicFinanceRoutes } from "./routes-public.js";
2
2
  import type { Env } from "./routes-shared.js";
3
3
  export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
4
+ "/aggregates": {
5
+ $get: {
6
+ input: {};
7
+ output: {
8
+ data: {
9
+ total: number;
10
+ countsByStatus: {
11
+ status: "void" | "draft" | "sent" | "partially_paid" | "paid" | "overdue";
12
+ count: number;
13
+ }[];
14
+ monthlyRevenue: {
15
+ yearMonth: string;
16
+ currency: string;
17
+ totalCents: number;
18
+ }[];
19
+ monthlyInvoiceCounts: {
20
+ yearMonth: string;
21
+ count: number;
22
+ }[];
23
+ outstanding: {
24
+ currency: string;
25
+ balanceDueCents: number;
26
+ count: number;
27
+ }[];
28
+ overdue: {
29
+ currency: string;
30
+ balanceDueCents: number;
31
+ count: number;
32
+ }[];
33
+ };
34
+ };
35
+ outputFormat: "json";
36
+ status: import("hono/utils/http-status").ContentfulStatusCode;
37
+ };
38
+ };
39
+ } & {
4
40
  "/payment-sessions": {
5
41
  $get: {
6
42
  input: {};
@@ -81,19 +117,19 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
81
117
  cancelledAt: string | null;
82
118
  completedAt: string | null;
83
119
  bookingId: string | null;
120
+ paymentId: string | null;
121
+ amountCents: number;
84
122
  provider: string | null;
85
123
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
86
124
  targetId: string | null;
87
125
  orderId: string | null;
88
126
  invoiceId: string | null;
89
- amountCents: number;
90
127
  bookingPaymentScheduleId: string | null;
91
128
  paymentInstrumentId: string | null;
92
129
  bookingGuaranteeId: string | null;
93
130
  paymentAuthorizationId: string | null;
94
131
  paymentCaptureId: string | null;
95
132
  paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
96
- paymentId: string | null;
97
133
  providerSessionId: string | null;
98
134
  providerPaymentId: string | null;
99
135
  externalReference: string | null;
@@ -881,10 +917,10 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
881
917
  currency: string;
882
918
  notes: string | null;
883
919
  bookingId: string | null;
920
+ amountCents: number;
884
921
  provider: string | null;
885
922
  orderId: string | null;
886
923
  invoiceId: string | null;
887
- amountCents: number;
888
924
  paymentInstrumentId: string | null;
889
925
  bookingGuaranteeId: string | null;
890
926
  captureMode: "manual" | "automatic";
@@ -1056,9 +1092,9 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
1056
1092
  status: "pending" | "completed" | "failed" | "refunded" | "voided";
1057
1093
  currency: string;
1058
1094
  notes: string | null;
1095
+ amountCents: number;
1059
1096
  provider: string | null;
1060
1097
  invoiceId: string | null;
1061
- amountCents: number;
1062
1098
  paymentAuthorizationId: string | null;
1063
1099
  externalCaptureId: string | null;
1064
1100
  capturedAt: string | null;
@@ -1278,9 +1314,9 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
1278
1314
  notes: string | null;
1279
1315
  bookingId: string;
1280
1316
  bookingItemId: string | null;
1317
+ amountCents: number;
1281
1318
  dueDate: string;
1282
1319
  scheduleType: "other" | "deposit" | "installment" | "balance" | "hold";
1283
- amountCents: number;
1284
1320
  };
1285
1321
  };
1286
1322
  outputFormat: "json";
@@ -1316,9 +1352,9 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
1316
1352
  notes: string | null;
1317
1353
  bookingId: string;
1318
1354
  bookingItemId: string | null;
1355
+ amountCents: number;
1319
1356
  dueDate: string;
1320
1357
  scheduleType: "other" | "deposit" | "installment" | "balance" | "hold";
1321
- amountCents: number;
1322
1358
  }[];
1323
1359
  };
1324
1360
  outputFormat: "json";
@@ -1406,19 +1442,19 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
1406
1442
  cancelledAt: string | null;
1407
1443
  completedAt: string | null;
1408
1444
  bookingId: string | null;
1445
+ paymentId: string | null;
1446
+ amountCents: number;
1409
1447
  provider: string | null;
1410
1448
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
1411
1449
  targetId: string | null;
1412
1450
  orderId: string | null;
1413
1451
  invoiceId: string | null;
1414
- amountCents: number;
1415
1452
  bookingPaymentScheduleId: string | null;
1416
1453
  paymentInstrumentId: string | null;
1417
1454
  bookingGuaranteeId: string | null;
1418
1455
  paymentAuthorizationId: string | null;
1419
1456
  paymentCaptureId: string | null;
1420
1457
  paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
1421
- paymentId: string | null;
1422
1458
  providerSessionId: string | null;
1423
1459
  providerPaymentId: string | null;
1424
1460
  externalReference: string | null;
@@ -1552,8 +1588,8 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
1552
1588
  bookingId: string;
1553
1589
  bookingItemId: string | null;
1554
1590
  releasedAt: string | null;
1555
- provider: string | null;
1556
1591
  amountCents: number | null;
1592
+ provider: string | null;
1557
1593
  bookingPaymentScheduleId: string | null;
1558
1594
  guaranteeType: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
1559
1595
  paymentInstrumentId: string | null;
@@ -1605,19 +1641,19 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
1605
1641
  cancelledAt: string | null;
1606
1642
  completedAt: string | null;
1607
1643
  bookingId: string | null;
1644
+ paymentId: string | null;
1645
+ amountCents: number;
1608
1646
  provider: string | null;
1609
1647
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
1610
1648
  targetId: string | null;
1611
1649
  orderId: string | null;
1612
1650
  invoiceId: string | null;
1613
- amountCents: number;
1614
1651
  bookingPaymentScheduleId: string | null;
1615
1652
  paymentInstrumentId: string | null;
1616
1653
  bookingGuaranteeId: string | null;
1617
1654
  paymentAuthorizationId: string | null;
1618
1655
  paymentCaptureId: string | null;
1619
1656
  paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
1620
- paymentId: string | null;
1621
1657
  providerSessionId: string | null;
1622
1658
  providerPaymentId: string | null;
1623
1659
  externalReference: string | null;
@@ -1939,8 +1975,8 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
1939
1975
  currency: string | null;
1940
1976
  notes: string | null;
1941
1977
  bookingItemId: string;
1942
- channelId: string | null;
1943
1978
  amountCents: number | null;
1979
+ channelId: string | null;
1944
1980
  rateBasisPoints: number | null;
1945
1981
  recipientType: "internal" | "supplier" | "other" | "affiliate" | "channel" | "agency" | "agent";
1946
1982
  commissionModel: "fixed" | "percentage" | "markup" | "net";
@@ -2073,9 +2109,9 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
2073
2109
  notes: string | null;
2074
2110
  baseCurrency: string | null;
2075
2111
  bookingId: string;
2112
+ amountCents: number;
2076
2113
  supplierId: string | null;
2077
2114
  fxRateSetId: string | null;
2078
- amountCents: number;
2079
2115
  paymentInstrumentId: string | null;
2080
2116
  referenceNumber: string | null;
2081
2117
  baseAmountCents: number | null;
@@ -2464,19 +2500,19 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
2464
2500
  cancelledAt: string | null;
2465
2501
  completedAt: string | null;
2466
2502
  bookingId: string | null;
2503
+ paymentId: string | null;
2504
+ amountCents: number;
2467
2505
  provider: string | null;
2468
2506
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
2469
2507
  targetId: string | null;
2470
2508
  orderId: string | null;
2471
2509
  invoiceId: string | null;
2472
- amountCents: number;
2473
2510
  bookingPaymentScheduleId: string | null;
2474
2511
  paymentInstrumentId: string | null;
2475
2512
  bookingGuaranteeId: string | null;
2476
2513
  paymentAuthorizationId: string | null;
2477
2514
  paymentCaptureId: string | null;
2478
2515
  paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
2479
- paymentId: string | null;
2480
2516
  providerSessionId: string | null;
2481
2517
  providerPaymentId: string | null;
2482
2518
  externalReference: string | null;
@@ -2708,9 +2744,9 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
2708
2744
  currency: string;
2709
2745
  notes: string | null;
2710
2746
  baseCurrency: string | null;
2747
+ amountCents: number;
2711
2748
  fxRateSetId: string | null;
2712
2749
  invoiceId: string;
2713
- amountCents: number;
2714
2750
  paymentInstrumentId: string | null;
2715
2751
  paymentAuthorizationId: string | null;
2716
2752
  referenceNumber: string | null;
@@ -2782,9 +2818,9 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
2782
2818
  notes: string | null;
2783
2819
  baseCurrency: string | null;
2784
2820
  reason: string;
2821
+ amountCents: number;
2785
2822
  fxRateSetId: string | null;
2786
2823
  invoiceId: string;
2787
- amountCents: number;
2788
2824
  baseAmountCents: number | null;
2789
2825
  creditNoteNumber: string;
2790
2826
  };
@@ -3632,7 +3668,232 @@ export declare const financeRoutes: import("hono/hono-base").HonoBase<Env, {
3632
3668
  status: import("hono/utils/http-status").ContentfulStatusCode;
3633
3669
  };
3634
3670
  };
3635
- }, "/", "/invoices/:id/external-refs/:refId">;
3671
+ } & {
3672
+ "/vouchers": {
3673
+ $get: {
3674
+ input: {};
3675
+ output: {
3676
+ data: {
3677
+ id: string;
3678
+ code: string;
3679
+ seriesCode: string | null;
3680
+ status: "void" | "expired" | "active" | "redeemed";
3681
+ currency: string;
3682
+ initialAmountCents: number;
3683
+ remainingAmountCents: number;
3684
+ issuedToPersonId: string | null;
3685
+ issuedToOrganizationId: string | null;
3686
+ sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
3687
+ sourceBookingId: string | null;
3688
+ sourcePaymentId: string | null;
3689
+ validFrom: string | null;
3690
+ expiresAt: string | null;
3691
+ notes: string | null;
3692
+ issuedByUserId: string | null;
3693
+ createdAt: string;
3694
+ updatedAt: string;
3695
+ }[];
3696
+ total: number;
3697
+ limit: number;
3698
+ offset: number;
3699
+ };
3700
+ outputFormat: "json";
3701
+ status: import("hono/utils/http-status").ContentfulStatusCode;
3702
+ };
3703
+ };
3704
+ } & {
3705
+ "/vouchers": {
3706
+ $post: {
3707
+ input: {};
3708
+ output: {
3709
+ data: {
3710
+ id: string;
3711
+ createdAt: string;
3712
+ updatedAt: string;
3713
+ expiresAt: string | null;
3714
+ status: "void" | "expired" | "active" | "redeemed";
3715
+ currency: string;
3716
+ notes: string | null;
3717
+ code: string;
3718
+ sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
3719
+ seriesCode: string | null;
3720
+ initialAmountCents: number;
3721
+ remainingAmountCents: number;
3722
+ issuedToPersonId: string | null;
3723
+ issuedToOrganizationId: string | null;
3724
+ sourceBookingId: string | null;
3725
+ sourcePaymentId: string | null;
3726
+ validFrom: string | null;
3727
+ issuedByUserId: string | null;
3728
+ } | null;
3729
+ };
3730
+ outputFormat: "json";
3731
+ status: 201;
3732
+ } | {
3733
+ input: {};
3734
+ output: {
3735
+ error: string;
3736
+ };
3737
+ outputFormat: "json";
3738
+ status: 409;
3739
+ };
3740
+ };
3741
+ } & {
3742
+ "/vouchers/:id": {
3743
+ $get: {
3744
+ input: {
3745
+ param: {
3746
+ id: string;
3747
+ };
3748
+ };
3749
+ output: {
3750
+ error: string;
3751
+ };
3752
+ outputFormat: "json";
3753
+ status: 404;
3754
+ } | {
3755
+ input: {
3756
+ param: {
3757
+ id: string;
3758
+ };
3759
+ };
3760
+ output: {
3761
+ data: {
3762
+ redemptions: {
3763
+ id: string;
3764
+ voucherId: string;
3765
+ bookingId: string;
3766
+ paymentId: string | null;
3767
+ amountCents: number;
3768
+ createdAt: string;
3769
+ createdByUserId: string | null;
3770
+ }[];
3771
+ id: string;
3772
+ code: string;
3773
+ seriesCode: string | null;
3774
+ status: "void" | "expired" | "active" | "redeemed";
3775
+ currency: string;
3776
+ initialAmountCents: number;
3777
+ remainingAmountCents: number;
3778
+ issuedToPersonId: string | null;
3779
+ issuedToOrganizationId: string | null;
3780
+ sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
3781
+ sourceBookingId: string | null;
3782
+ sourcePaymentId: string | null;
3783
+ validFrom: string | null;
3784
+ expiresAt: string | null;
3785
+ notes: string | null;
3786
+ issuedByUserId: string | null;
3787
+ createdAt: string;
3788
+ updatedAt: string;
3789
+ };
3790
+ };
3791
+ outputFormat: "json";
3792
+ status: import("hono/utils/http-status").ContentfulStatusCode;
3793
+ };
3794
+ };
3795
+ } & {
3796
+ "/vouchers/:id": {
3797
+ $patch: {
3798
+ input: {
3799
+ param: {
3800
+ id: string;
3801
+ };
3802
+ };
3803
+ output: {
3804
+ error: string;
3805
+ };
3806
+ outputFormat: "json";
3807
+ status: 404;
3808
+ } | {
3809
+ input: {
3810
+ param: {
3811
+ id: string;
3812
+ };
3813
+ };
3814
+ output: {
3815
+ data: {
3816
+ id: string;
3817
+ code: string;
3818
+ seriesCode: string | null;
3819
+ status: "void" | "expired" | "active" | "redeemed";
3820
+ currency: string;
3821
+ initialAmountCents: number;
3822
+ remainingAmountCents: number;
3823
+ issuedToPersonId: string | null;
3824
+ issuedToOrganizationId: string | null;
3825
+ sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
3826
+ sourceBookingId: string | null;
3827
+ sourcePaymentId: string | null;
3828
+ validFrom: string | null;
3829
+ expiresAt: string | null;
3830
+ notes: string | null;
3831
+ issuedByUserId: string | null;
3832
+ createdAt: string;
3833
+ updatedAt: string;
3834
+ };
3835
+ };
3836
+ outputFormat: "json";
3837
+ status: import("hono/utils/http-status").ContentfulStatusCode;
3838
+ };
3839
+ };
3840
+ } & {
3841
+ "/vouchers/:id/redeem": {
3842
+ $post: {
3843
+ input: {
3844
+ param: {
3845
+ id: string;
3846
+ };
3847
+ };
3848
+ output: {
3849
+ data: {
3850
+ voucher: {
3851
+ id: string;
3852
+ code: string;
3853
+ seriesCode: string | null;
3854
+ status: "void" | "expired" | "active" | "redeemed";
3855
+ currency: string;
3856
+ initialAmountCents: number;
3857
+ remainingAmountCents: number;
3858
+ issuedToPersonId: string | null;
3859
+ issuedToOrganizationId: string | null;
3860
+ sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
3861
+ sourceBookingId: string | null;
3862
+ sourcePaymentId: string | null;
3863
+ validFrom: string | null;
3864
+ expiresAt: string | null;
3865
+ notes: string | null;
3866
+ issuedByUserId: string | null;
3867
+ createdAt: string;
3868
+ updatedAt: string;
3869
+ };
3870
+ redemption: {
3871
+ id: string;
3872
+ createdAt: string;
3873
+ bookingId: string;
3874
+ voucherId: string;
3875
+ paymentId: string | null;
3876
+ amountCents: number;
3877
+ createdByUserId: string | null;
3878
+ } | null;
3879
+ };
3880
+ };
3881
+ outputFormat: "json";
3882
+ status: 201;
3883
+ } | {
3884
+ input: {
3885
+ param: {
3886
+ id: string;
3887
+ };
3888
+ };
3889
+ output: {
3890
+ error: "code_in_use" | "voucher_not_found" | "voucher_inactive" | "voucher_not_started" | "voucher_expired" | "insufficient_balance";
3891
+ };
3892
+ outputFormat: "json";
3893
+ status: 404 | 409 | 422;
3894
+ };
3895
+ };
3896
+ }, "/", "/vouchers/:id/redeem">;
3636
3897
  export type FinanceRoutes = typeof financeRoutes;
3637
3898
  export type PublicFinanceRoutes = typeof publicFinanceRoutes;
3638
3899
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAGA,OAAO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BA2iCtB,CAAA;AAEJ,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAA;AAChD,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA"}
package/dist/routes.js CHANGED
@@ -1,11 +1,19 @@
1
1
  import { parseJsonBody, parseQuery, requireUserId } from "@voyantjs/hono";
2
2
  import { Hono } from "hono";
3
3
  import { financeService } from "./service.js";
4
- 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
+ import { VoucherServiceError } from "./service-vouchers.js";
5
+ import { agingReportQuerySchema, applyDefaultBookingPaymentPlanSchema, cancelPaymentSessionSchema, completePaymentSessionSchema, createPaymentSessionFromGuaranteeSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, expirePaymentSessionSchema, failPaymentSessionSchema, financeAggregatesQuerySchema, insertBookingGuaranteeSchema, insertBookingItemCommissionSchema, insertBookingItemTaxLineSchema, insertBookingPaymentScheduleSchema, insertCreditNoteLineItemSchema, insertCreditNoteSchema, insertFinanceNoteSchema, insertInvoiceExternalRefSchema, insertInvoiceLineItemSchema, insertInvoiceNumberSeriesSchema, insertInvoiceSchema, insertInvoiceTemplateSchema, insertPaymentAuthorizationSchema, insertPaymentCaptureSchema, insertPaymentInstrumentSchema, insertPaymentSchema, insertPaymentSessionSchema, insertSupplierPaymentSchema, insertTaxRegimeSchema, insertVoucherSchema, invoiceFromBookingSchema, invoiceListQuerySchema, invoiceNumberSeriesListQuerySchema, invoiceTemplateListQuerySchema, markPaymentSessionRequiresRedirectSchema, paymentAuthorizationListQuerySchema, paymentCaptureListQuerySchema, paymentInstrumentListQuerySchema, paymentSessionListQuerySchema, profitabilityQuerySchema, redeemVoucherSchema, renderInvoiceInputSchema, revenueReportQuerySchema, supplierPaymentListQuerySchema, taxRegimeListQuerySchema, updateBookingGuaranteeSchema, updateBookingItemCommissionSchema, updateBookingItemTaxLineSchema, updateBookingPaymentScheduleSchema, updateCreditNoteSchema, updateInvoiceLineItemSchema, updateInvoiceNumberSeriesSchema, updateInvoiceSchema, updateInvoiceTemplateSchema, updatePaymentAuthorizationSchema, updatePaymentCaptureSchema, updatePaymentInstrumentSchema, updatePaymentSessionSchema, updateSupplierPaymentSchema, updateTaxRegimeSchema, updateVoucherSchema, voucherListQuerySchema, } from "./validation.js";
5
6
  // ==========================================================================
6
7
  // Finance Routes — method-chained for Hono RPC type inference
7
8
  // ==========================================================================
8
9
  export const financeRoutes = new Hono()
10
+ // ========================================================================
11
+ // Dashboard aggregates
12
+ // ========================================================================
13
+ .get("/aggregates", async (c) => {
14
+ const query = parseQuery(c, financeAggregatesQuerySchema);
15
+ return c.json({ data: await financeService.getFinanceAggregates(c.get("db"), query) });
16
+ })
9
17
  // ========================================================================
10
18
  // Payment Sessions
11
19
  // ========================================================================
@@ -666,4 +674,52 @@ export const financeRoutes = new Hono()
666
674
  if (!row)
667
675
  return c.json({ error: "External ref not found" }, 404);
668
676
  return c.json({ success: true });
677
+ })
678
+ // ========================================================================
679
+ // Vouchers — issuance, lookup, redemption
680
+ // ========================================================================
681
+ .get("/vouchers", async (c) => {
682
+ const query = parseQuery(c, voucherListQuerySchema);
683
+ return c.json(await financeService.vouchers.list(c.get("db"), query));
684
+ })
685
+ .post("/vouchers", async (c) => {
686
+ try {
687
+ const row = await financeService.vouchers.create(c.get("db"), await parseJsonBody(c, insertVoucherSchema), c.get("userId"));
688
+ return c.json({ data: row }, 201);
689
+ }
690
+ catch (error) {
691
+ if (error instanceof VoucherServiceError && error.code === "code_in_use") {
692
+ return c.json({ error: "Voucher code already in use" }, 409);
693
+ }
694
+ throw error;
695
+ }
696
+ })
697
+ .get("/vouchers/:id", async (c) => {
698
+ const row = await financeService.vouchers.getById(c.get("db"), c.req.param("id"));
699
+ if (!row)
700
+ return c.json({ error: "Voucher not found" }, 404);
701
+ return c.json({ data: row });
702
+ })
703
+ .patch("/vouchers/:id", async (c) => {
704
+ const row = await financeService.vouchers.update(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateVoucherSchema));
705
+ if (!row)
706
+ return c.json({ error: "Voucher not found" }, 404);
707
+ return c.json({ data: row });
708
+ })
709
+ .post("/vouchers/:id/redeem", async (c) => {
710
+ try {
711
+ const result = await financeService.vouchers.redeem(c.get("db"), c.req.param("id"), await parseJsonBody(c, redeemVoucherSchema), c.get("userId"));
712
+ return c.json({ data: result }, 201);
713
+ }
714
+ catch (error) {
715
+ if (error instanceof VoucherServiceError) {
716
+ const status = error.code === "voucher_not_found"
717
+ ? 404
718
+ : error.code === "insufficient_balance"
719
+ ? 409
720
+ : 422;
721
+ return c.json({ error: error.code }, status);
722
+ }
723
+ throw error;
724
+ }
669
725
  });