@voyantjs/finance 0.20.0 → 0.21.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.
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/payment-policy.d.ts +113 -0
- package/dist/payment-policy.d.ts.map +1 -0
- package/dist/payment-policy.js +193 -0
- package/dist/routes-documents.d.ts +2 -2
- package/dist/routes-public.d.ts +12 -12
- package/dist/routes.d.ts +530 -31
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +120 -5
- package/dist/schema.d.ts +538 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +84 -0
- package/dist/service-issue.d.ts +108 -0
- package/dist/service-issue.d.ts.map +1 -0
- package/dist/service-issue.js +57 -0
- package/dist/service-public.d.ts +5 -5
- package/dist/service.d.ts +257 -37
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +278 -20
- package/dist/validation-billing.d.ts +109 -0
- package/dist/validation-billing.d.ts.map +1 -1
- package/dist/validation-billing.js +58 -0
- package/dist/validation-payments.d.ts +16 -16
- package/dist/validation-public.d.ts +3 -3
- package/dist/validation-shared.d.ts +5 -5
- package/package.json +7 -7
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAiF7C,eAAO,MAAM,aAAa;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAmtCtB,CAAA;AAEJ,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAA;AAChD,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA"}
|
package/dist/routes.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Hono } from "hono";
|
|
|
3
3
|
import { FINANCE_ROUTE_RUNTIME_CONTAINER_KEY } from "./route-runtime.js";
|
|
4
4
|
import { financeService } from "./service.js";
|
|
5
5
|
import { VoucherServiceError } from "./service-vouchers.js";
|
|
6
|
-
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";
|
|
6
|
+
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, insertTaxClassSchema, insertTaxPolicyProfileSchema, insertTaxPolicyRuleSchema, insertTaxRegimeSchema, insertVoucherSchema, invoiceFromBookingSchema, invoiceListQuerySchema, invoiceNumberSeriesListQuerySchema, invoiceTemplateListQuerySchema, markPaymentSessionRequiresRedirectSchema, paymentAuthorizationListQuerySchema, paymentCaptureListQuerySchema, paymentInstrumentListQuerySchema, paymentSessionListQuerySchema, profitabilityQuerySchema, redeemVoucherSchema, renderInvoiceInputSchema, revenueReportQuerySchema, supplierPaymentListQuerySchema, taxClassListQuerySchema, taxPolicyProfileListQuerySchema, taxPolicyRuleListQuerySchema, taxRegimeListQuerySchema, updateBookingGuaranteeSchema, updateBookingItemCommissionSchema, updateBookingItemTaxLineSchema, updateBookingPaymentScheduleSchema, updateCreditNoteSchema, updateInvoiceLineItemSchema, updateInvoiceNumberSeriesSchema, updateInvoiceSchema, updateInvoiceTemplateSchema, updatePaymentAuthorizationSchema, updatePaymentCaptureSchema, updatePaymentInstrumentSchema, updatePaymentSessionSchema, updateSupplierPaymentSchema, updateTaxClassSchema, updateTaxPolicyProfileSchema, updateTaxPolicyRuleSchema, updateTaxRegimeSchema, updateVoucherSchema, voucherListQuerySchema, } from "./validation.js";
|
|
7
7
|
// ==========================================================================
|
|
8
8
|
// Finance Routes — method-chained for Hono RPC type inference
|
|
9
9
|
// ==========================================================================
|
|
@@ -370,13 +370,14 @@ export const financeRoutes = new Hono()
|
|
|
370
370
|
data: await financeService.createInvoice(c.get("db"), await parseJsonBody(c, insertInvoiceSchema)),
|
|
371
371
|
}, 201);
|
|
372
372
|
})
|
|
373
|
-
// POST /invoices/from-booking — Create
|
|
373
|
+
// POST /invoices/from-booking — Create + issue invoice (or proforma) from booking + booking items
|
|
374
374
|
.post("/invoices/from-booking", async (c) => {
|
|
375
375
|
const input = await parseJsonBody(c, invoiceFromBookingSchema);
|
|
376
376
|
const db = c.get("db");
|
|
377
|
-
const [{ bookingItems, bookings }, { eq }] = await Promise.all([
|
|
377
|
+
const [{ bookingItems, bookings }, { eq }, { issueInvoiceFromBooking, issueProformaFromBooking },] = await Promise.all([
|
|
378
378
|
import("@voyantjs/bookings/schema"),
|
|
379
379
|
import("drizzle-orm"),
|
|
380
|
+
import("./service-issue.js"),
|
|
380
381
|
]);
|
|
381
382
|
const [booking] = await db
|
|
382
383
|
.select()
|
|
@@ -387,7 +388,16 @@ export const financeRoutes = new Hono()
|
|
|
387
388
|
return c.json({ error: "Booking not found" }, 404);
|
|
388
389
|
}
|
|
389
390
|
const items = await db.select().from(bookingItems).where(eq(bookingItems.bookingId, booking.id));
|
|
390
|
-
const
|
|
391
|
+
const runtime = (() => {
|
|
392
|
+
try {
|
|
393
|
+
return c.var.container?.resolve(FINANCE_ROUTE_RUNTIME_CONTAINER_KEY);
|
|
394
|
+
}
|
|
395
|
+
catch {
|
|
396
|
+
return undefined;
|
|
397
|
+
}
|
|
398
|
+
})();
|
|
399
|
+
const issuer = input.invoiceType === "proforma" ? issueProformaFromBooking : issueInvoiceFromBooking;
|
|
400
|
+
const row = await issuer(db, input, {
|
|
391
401
|
booking: {
|
|
392
402
|
id: booking.id,
|
|
393
403
|
bookingNumber: booking.bookingNumber,
|
|
@@ -406,7 +416,7 @@ export const financeRoutes = new Hono()
|
|
|
406
416
|
unitSellAmountCents: item.unitSellAmountCents,
|
|
407
417
|
totalSellAmountCents: item.totalSellAmountCents,
|
|
408
418
|
})),
|
|
409
|
-
});
|
|
419
|
+
}, { eventBus: runtime?.eventBus });
|
|
410
420
|
return c.json({ data: row }, 201);
|
|
411
421
|
})
|
|
412
422
|
// GET /invoices/:id — Get single invoice
|
|
@@ -653,6 +663,93 @@ export const financeRoutes = new Hono()
|
|
|
653
663
|
if (!row)
|
|
654
664
|
return c.json({ error: "Tax regime not found" }, 404);
|
|
655
665
|
return c.json({ success: true });
|
|
666
|
+
})
|
|
667
|
+
// ========================================================================
|
|
668
|
+
// Tax Classes
|
|
669
|
+
// ========================================================================
|
|
670
|
+
.get("/tax-classes", async (c) => {
|
|
671
|
+
const query = parseQuery(c, taxClassListQuerySchema);
|
|
672
|
+
return c.json(await financeService.listTaxClasses(c.get("db"), query));
|
|
673
|
+
})
|
|
674
|
+
.post("/tax-classes", async (c) => {
|
|
675
|
+
const row = await financeService.createTaxClass(c.get("db"), await parseJsonBody(c, insertTaxClassSchema));
|
|
676
|
+
return c.json({ data: row }, 201);
|
|
677
|
+
})
|
|
678
|
+
.get("/tax-classes/:id", async (c) => {
|
|
679
|
+
const row = await financeService.getTaxClassById(c.get("db"), c.req.param("id"));
|
|
680
|
+
if (!row)
|
|
681
|
+
return c.json({ error: "Tax class not found" }, 404);
|
|
682
|
+
return c.json({ data: row });
|
|
683
|
+
})
|
|
684
|
+
.patch("/tax-classes/:id", async (c) => {
|
|
685
|
+
const row = await financeService.updateTaxClass(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateTaxClassSchema));
|
|
686
|
+
if (!row)
|
|
687
|
+
return c.json({ error: "Tax class not found" }, 404);
|
|
688
|
+
return c.json({ data: row });
|
|
689
|
+
})
|
|
690
|
+
.delete("/tax-classes/:id", async (c) => {
|
|
691
|
+
const row = await financeService.deleteTaxClass(c.get("db"), c.req.param("id"));
|
|
692
|
+
if (!row)
|
|
693
|
+
return c.json({ error: "Tax class not found" }, 404);
|
|
694
|
+
return c.json({ success: true });
|
|
695
|
+
})
|
|
696
|
+
// ========================================================================
|
|
697
|
+
// Tax Policy Profiles
|
|
698
|
+
// ========================================================================
|
|
699
|
+
.get("/tax-policy-profiles", async (c) => {
|
|
700
|
+
const query = parseQuery(c, taxPolicyProfileListQuerySchema);
|
|
701
|
+
return c.json(await financeService.listTaxPolicyProfiles(c.get("db"), query));
|
|
702
|
+
})
|
|
703
|
+
.post("/tax-policy-profiles", async (c) => {
|
|
704
|
+
const row = await financeService.createTaxPolicyProfile(c.get("db"), await parseJsonBody(c, insertTaxPolicyProfileSchema));
|
|
705
|
+
return c.json({ data: row }, 201);
|
|
706
|
+
})
|
|
707
|
+
.get("/tax-policy-profiles/:id", async (c) => {
|
|
708
|
+
const row = await financeService.getTaxPolicyProfileById(c.get("db"), c.req.param("id"));
|
|
709
|
+
if (!row)
|
|
710
|
+
return c.json({ error: "Tax policy profile not found" }, 404);
|
|
711
|
+
return c.json({ data: row });
|
|
712
|
+
})
|
|
713
|
+
.patch("/tax-policy-profiles/:id", async (c) => {
|
|
714
|
+
const row = await financeService.updateTaxPolicyProfile(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateTaxPolicyProfileSchema));
|
|
715
|
+
if (!row)
|
|
716
|
+
return c.json({ error: "Tax policy profile not found" }, 404);
|
|
717
|
+
return c.json({ data: row });
|
|
718
|
+
})
|
|
719
|
+
.delete("/tax-policy-profiles/:id", async (c) => {
|
|
720
|
+
const row = await financeService.deleteTaxPolicyProfile(c.get("db"), c.req.param("id"));
|
|
721
|
+
if (!row)
|
|
722
|
+
return c.json({ error: "Tax policy profile not found" }, 404);
|
|
723
|
+
return c.json({ success: true });
|
|
724
|
+
})
|
|
725
|
+
// ========================================================================
|
|
726
|
+
// Tax Policy Rules
|
|
727
|
+
// ========================================================================
|
|
728
|
+
.get("/tax-policy-rules", async (c) => {
|
|
729
|
+
const query = parseQuery(c, taxPolicyRuleListQuerySchema);
|
|
730
|
+
return c.json(await financeService.listTaxPolicyRules(c.get("db"), query));
|
|
731
|
+
})
|
|
732
|
+
.post("/tax-policy-rules", async (c) => {
|
|
733
|
+
const row = await financeService.createTaxPolicyRule(c.get("db"), await parseJsonBody(c, insertTaxPolicyRuleSchema));
|
|
734
|
+
return c.json({ data: row }, 201);
|
|
735
|
+
})
|
|
736
|
+
.get("/tax-policy-rules/:id", async (c) => {
|
|
737
|
+
const row = await financeService.getTaxPolicyRuleById(c.get("db"), c.req.param("id"));
|
|
738
|
+
if (!row)
|
|
739
|
+
return c.json({ error: "Tax policy rule not found" }, 404);
|
|
740
|
+
return c.json({ data: row });
|
|
741
|
+
})
|
|
742
|
+
.patch("/tax-policy-rules/:id", async (c) => {
|
|
743
|
+
const row = await financeService.updateTaxPolicyRule(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateTaxPolicyRuleSchema));
|
|
744
|
+
if (!row)
|
|
745
|
+
return c.json({ error: "Tax policy rule not found" }, 404);
|
|
746
|
+
return c.json({ data: row });
|
|
747
|
+
})
|
|
748
|
+
.delete("/tax-policy-rules/:id", async (c) => {
|
|
749
|
+
const row = await financeService.deleteTaxPolicyRule(c.get("db"), c.req.param("id"));
|
|
750
|
+
if (!row)
|
|
751
|
+
return c.json({ error: "Tax policy rule not found" }, 404);
|
|
752
|
+
return c.json({ success: true });
|
|
656
753
|
})
|
|
657
754
|
// ========================================================================
|
|
658
755
|
// Invoice Renditions & External Refs (nested under invoice)
|
|
@@ -731,4 +828,22 @@ export const financeRoutes = new Hono()
|
|
|
731
828
|
}
|
|
732
829
|
throw error;
|
|
733
830
|
}
|
|
831
|
+
})
|
|
832
|
+
// ========================================================================
|
|
833
|
+
// Booking-scoped reads (admin)
|
|
834
|
+
// ========================================================================
|
|
835
|
+
// Mirror the customer-portal's `/v1/public/finance/bookings/:bookingId/payments`
|
|
836
|
+
// endpoint on the admin surface. The admin actor guard
|
|
837
|
+
// (`requireActor("staff")`) blocks staff sessions from hitting the
|
|
838
|
+
// public path, but operators absolutely need to see the canonical
|
|
839
|
+
// `payments` rows on the booking detail page. This handler reuses
|
|
840
|
+
// the same publicFinanceService helper so the response shape is
|
|
841
|
+
// identical to the customer-portal flow.
|
|
842
|
+
.get("/bookings/:bookingId/payments", async (c) => {
|
|
843
|
+
const { publicFinanceService } = await import("./service-public.js");
|
|
844
|
+
const result = await publicFinanceService.getBookingPayments(c.get("db"), c.req.param("bookingId"));
|
|
845
|
+
if (!result) {
|
|
846
|
+
return c.json({ error: "Booking payments not found" }, 404);
|
|
847
|
+
}
|
|
848
|
+
return c.json({ data: result });
|
|
734
849
|
});
|