@dainamite/billing 0.17.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/CHANGELOG.md +658 -0
- package/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/modules/billing/acl.js +20 -0
- package/dist/modules/billing/acl.js.map +7 -0
- package/dist/modules/billing/api/accounts/route.js +182 -0
- package/dist/modules/billing/api/accounts/route.js.map +7 -0
- package/dist/modules/billing/api/export/account/[id]/route.js +170 -0
- package/dist/modules/billing/api/export/account/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/[id]/route.js +85 -0
- package/dist/modules/billing/api/invoices/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/add-line/route.js +69 -0
- package/dist/modules/billing/api/invoices/add-line/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/edit-line/route.js +78 -0
- package/dist/modules/billing/api/invoices/edit-line/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/post/route.js +74 -0
- package/dist/modules/billing/api/invoices/post/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/remove-line/route.js +69 -0
- package/dist/modules/billing/api/invoices/remove-line/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/route.js +109 -0
- package/dist/modules/billing/api/invoices/route.js.map +7 -0
- package/dist/modules/billing/api/items/bulk/route.js +74 -0
- package/dist/modules/billing/api/items/bulk/route.js.map +7 -0
- package/dist/modules/billing/api/items/route.js +224 -0
- package/dist/modules/billing/api/items/route.js.map +7 -0
- package/dist/modules/billing/api/openapi.js +25 -0
- package/dist/modules/billing/api/openapi.js.map +7 -0
- package/dist/modules/billing/api/run-outcomes/route.js +122 -0
- package/dist/modules/billing/api/run-outcomes/route.js.map +7 -0
- package/dist/modules/billing/api/runs/retry-failed/route.js +70 -0
- package/dist/modules/billing/api/runs/retry-failed/route.js.map +7 -0
- package/dist/modules/billing/api/runs/route.js +143 -0
- package/dist/modules/billing/api/runs/route.js.map +7 -0
- package/dist/modules/billing/api/test-invoices/wipe/route.js +65 -0
- package/dist/modules/billing/api/test-invoices/wipe/route.js.map +7 -0
- package/dist/modules/billing/api/usage/route.js +138 -0
- package/dist/modules/billing/api/usage/route.js.map +7 -0
- package/dist/modules/billing/backend/billing/accounts/[id]/page.js +402 -0
- package/dist/modules/billing/backend/billing/accounts/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/accounts/[id]/page.meta.js +25 -0
- package/dist/modules/billing/backend/billing/accounts/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/accounts/create/page.js +82 -0
- package/dist/modules/billing/backend/billing/accounts/create/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/accounts/create/page.meta.js +25 -0
- package/dist/modules/billing/backend/billing/accounts/create/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/accounts/page.js +173 -0
- package/dist/modules/billing/backend/billing/accounts/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/accounts/page.meta.js +18 -0
- package/dist/modules/billing/backend/billing/accounts/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/invoices/[id]/page.js +500 -0
- package/dist/modules/billing/backend/billing/invoices/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/invoices/[id]/page.meta.js +25 -0
- package/dist/modules/billing/backend/billing/invoices/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/invoices/page.js +187 -0
- package/dist/modules/billing/backend/billing/invoices/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/invoices/page.meta.js +18 -0
- package/dist/modules/billing/backend/billing/invoices/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/items/[id]/page.js +265 -0
- package/dist/modules/billing/backend/billing/items/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/items/[id]/page.meta.js +25 -0
- package/dist/modules/billing/backend/billing/items/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/items/create/page.js +90 -0
- package/dist/modules/billing/backend/billing/items/create/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/items/create/page.meta.js +25 -0
- package/dist/modules/billing/backend/billing/items/create/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/items/page.js +208 -0
- package/dist/modules/billing/backend/billing/items/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/items/page.meta.js +18 -0
- package/dist/modules/billing/backend/billing/items/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/runs/[id]/page.js +293 -0
- package/dist/modules/billing/backend/billing/runs/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/runs/[id]/page.meta.js +21 -0
- package/dist/modules/billing/backend/billing/runs/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/runs/page.js +341 -0
- package/dist/modules/billing/backend/billing/runs/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/runs/page.meta.js +18 -0
- package/dist/modules/billing/backend/billing/runs/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/usage/create/page.js +100 -0
- package/dist/modules/billing/backend/billing/usage/create/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/usage/create/page.meta.js +25 -0
- package/dist/modules/billing/backend/billing/usage/create/page.meta.js.map +7 -0
- package/dist/modules/billing/ce.js +56 -0
- package/dist/modules/billing/ce.js.map +7 -0
- package/dist/modules/billing/cli.js +67 -0
- package/dist/modules/billing/cli.js.map +7 -0
- package/dist/modules/billing/commands/accounts.js +157 -0
- package/dist/modules/billing/commands/accounts.js.map +7 -0
- package/dist/modules/billing/commands/index.js +6 -0
- package/dist/modules/billing/commands/index.js.map +7 -0
- package/dist/modules/billing/commands/invoices.js +401 -0
- package/dist/modules/billing/commands/invoices.js.map +7 -0
- package/dist/modules/billing/commands/items.js +317 -0
- package/dist/modules/billing/commands/items.js.map +7 -0
- package/dist/modules/billing/commands/runs.js +123 -0
- package/dist/modules/billing/commands/runs.js.map +7 -0
- package/dist/modules/billing/commands/usage.js +88 -0
- package/dist/modules/billing/commands/usage.js.map +7 -0
- package/dist/modules/billing/components/AccountForm.js +420 -0
- package/dist/modules/billing/components/AccountForm.js.map +7 -0
- package/dist/modules/billing/components/DetailFields.js +37 -0
- package/dist/modules/billing/components/DetailFields.js.map +7 -0
- package/dist/modules/billing/components/ItemForm.js +440 -0
- package/dist/modules/billing/components/ItemForm.js.map +7 -0
- package/dist/modules/billing/components/LineFormDialog.js +195 -0
- package/dist/modules/billing/components/LineFormDialog.js.map +7 -0
- package/dist/modules/billing/components/UsageForm.js +262 -0
- package/dist/modules/billing/components/UsageForm.js.map +7 -0
- package/dist/modules/billing/data/entities.js +433 -0
- package/dist/modules/billing/data/entities.js.map +7 -0
- package/dist/modules/billing/data/entityIds.js +12 -0
- package/dist/modules/billing/data/entityIds.js.map +7 -0
- package/dist/modules/billing/data/validators.js +396 -0
- package/dist/modules/billing/data/validators.js.map +7 -0
- package/dist/modules/billing/di.js +6 -0
- package/dist/modules/billing/di.js.map +7 -0
- package/dist/modules/billing/events.js +35 -0
- package/dist/modules/billing/events.js.map +7 -0
- package/dist/modules/billing/i18n/en.json +336 -0
- package/dist/modules/billing/i18n/pl.json +336 -0
- package/dist/modules/billing/index.js +17 -0
- package/dist/modules/billing/index.js.map +7 -0
- package/dist/modules/billing/lib/billPeriod.js +101 -0
- package/dist/modules/billing/lib/billPeriod.js.map +7 -0
- package/dist/modules/billing/lib/billRunEngine.js +256 -0
- package/dist/modules/billing/lib/billRunEngine.js.map +7 -0
- package/dist/modules/billing/lib/billRunLabel.js +8 -0
- package/dist/modules/billing/lib/billRunLabel.js.map +7 -0
- package/dist/modules/billing/lib/idempotency.js +13 -0
- package/dist/modules/billing/lib/idempotency.js.map +7 -0
- package/dist/modules/billing/lib/invoiceStatus.js +38 -0
- package/dist/modules/billing/lib/invoiceStatus.js.map +7 -0
- package/dist/modules/billing/lib/invoiceWriter.js +153 -0
- package/dist/modules/billing/lib/invoiceWriter.js.map +7 -0
- package/dist/modules/billing/lib/itemSelector.js +77 -0
- package/dist/modules/billing/lib/itemSelector.js.map +7 -0
- package/dist/modules/billing/lib/seeds/demo.js +130 -0
- package/dist/modules/billing/lib/seeds/demo.js.map +7 -0
- package/dist/modules/billing/lib/tenantLock.js +32 -0
- package/dist/modules/billing/lib/tenantLock.js.map +7 -0
- package/dist/modules/billing/lib/usageRater.js +150 -0
- package/dist/modules/billing/lib/usageRater.js.map +7 -0
- package/dist/modules/billing/lib/usageRunner.js +82 -0
- package/dist/modules/billing/lib/usageRunner.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20260519000000_billing.js +144 -0
- package/dist/modules/billing/migrations/Migration20260519000000_billing.js.map +7 -0
- package/dist/modules/billing/setup.js +190 -0
- package/dist/modules/billing/setup.js.map +7 -0
- package/dist/modules/billing/subscribers/payment-captured-to-paid.js +47 -0
- package/dist/modules/billing/subscribers/payment-captured-to-paid.js.map +7 -0
- package/dist/modules/billing/translations.js +5 -0
- package/dist/modules/billing/translations.js.map +7 -0
- package/dist/modules/billing/workers/reap-stale-bill-runs.js +31 -0
- package/dist/modules/billing/workers/reap-stale-bill-runs.js.map +7 -0
- package/package.json +148 -0
- package/src/modules/billing/__integration__/TC-BILL-001.spec.ts +116 -0
- package/src/modules/billing/__integration__/TC-BILL-002.spec.ts +169 -0
- package/src/modules/billing/__integration__/TC-BILL-003.spec.ts +28 -0
- package/src/modules/billing/__integration__/meta.ts +4 -0
- package/src/modules/billing/__tests__/commands/invoices.test.ts +464 -0
- package/src/modules/billing/__tests__/commands/itemsBulk.test.ts +284 -0
- package/src/modules/billing/__tests__/lib/billPeriod.test.ts +131 -0
- package/src/modules/billing/__tests__/lib/billRunEngine.test.ts +561 -0
- package/src/modules/billing/__tests__/lib/idempotency.test.ts +81 -0
- package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +97 -0
- package/src/modules/billing/__tests__/lib/invoiceWriter.test.ts +119 -0
- package/src/modules/billing/__tests__/lib/itemSelector.test.ts +192 -0
- package/src/modules/billing/__tests__/lib/seedsDemo.test.ts +86 -0
- package/src/modules/billing/__tests__/lib/tenantLock.test.ts +126 -0
- package/src/modules/billing/__tests__/lib/usageRater.test.ts +190 -0
- package/src/modules/billing/__tests__/package-isolation.test.ts +223 -0
- package/src/modules/billing/__tests__/setup.test.ts +107 -0
- package/src/modules/billing/__tests__/validators.test.ts +594 -0
- package/src/modules/billing/acl.ts +16 -0
- package/src/modules/billing/api/accounts/route.ts +198 -0
- package/src/modules/billing/api/export/account/[id]/route.ts +233 -0
- package/src/modules/billing/api/invoices/[id]/route.ts +143 -0
- package/src/modules/billing/api/invoices/add-line/route.ts +74 -0
- package/src/modules/billing/api/invoices/edit-line/route.ts +97 -0
- package/src/modules/billing/api/invoices/post/route.ts +97 -0
- package/src/modules/billing/api/invoices/remove-line/route.ts +75 -0
- package/src/modules/billing/api/invoices/route.ts +167 -0
- package/src/modules/billing/api/items/bulk/route.ts +92 -0
- package/src/modules/billing/api/items/route.ts +255 -0
- package/src/modules/billing/api/openapi.ts +33 -0
- package/src/modules/billing/api/run-outcomes/route.ts +149 -0
- package/src/modules/billing/api/runs/retry-failed/route.ts +88 -0
- package/src/modules/billing/api/runs/route.ts +170 -0
- package/src/modules/billing/api/test-invoices/wipe/route.ts +87 -0
- package/src/modules/billing/api/usage/route.ts +148 -0
- package/src/modules/billing/backend/billing/accounts/[id]/page.meta.ts +23 -0
- package/src/modules/billing/backend/billing/accounts/[id]/page.tsx +574 -0
- package/src/modules/billing/backend/billing/accounts/create/page.meta.ts +23 -0
- package/src/modules/billing/backend/billing/accounts/create/page.tsx +101 -0
- package/src/modules/billing/backend/billing/accounts/page.meta.ts +16 -0
- package/src/modules/billing/backend/billing/accounts/page.tsx +222 -0
- package/src/modules/billing/backend/billing/invoices/[id]/page.meta.ts +23 -0
- package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +613 -0
- package/src/modules/billing/backend/billing/invoices/page.meta.ts +16 -0
- package/src/modules/billing/backend/billing/invoices/page.tsx +245 -0
- package/src/modules/billing/backend/billing/items/[id]/page.meta.ts +23 -0
- package/src/modules/billing/backend/billing/items/[id]/page.tsx +366 -0
- package/src/modules/billing/backend/billing/items/create/page.meta.ts +23 -0
- package/src/modules/billing/backend/billing/items/create/page.tsx +110 -0
- package/src/modules/billing/backend/billing/items/page.meta.ts +16 -0
- package/src/modules/billing/backend/billing/items/page.tsx +272 -0
- package/src/modules/billing/backend/billing/runs/[id]/page.meta.ts +19 -0
- package/src/modules/billing/backend/billing/runs/[id]/page.tsx +404 -0
- package/src/modules/billing/backend/billing/runs/page.meta.ts +16 -0
- package/src/modules/billing/backend/billing/runs/page.tsx +426 -0
- package/src/modules/billing/backend/billing/usage/create/page.meta.ts +23 -0
- package/src/modules/billing/backend/billing/usage/create/page.tsx +120 -0
- package/src/modules/billing/ce.ts +74 -0
- package/src/modules/billing/cli.ts +89 -0
- package/src/modules/billing/commands/accounts.ts +205 -0
- package/src/modules/billing/commands/index.ts +13 -0
- package/src/modules/billing/commands/invoices.ts +542 -0
- package/src/modules/billing/commands/items.ts +438 -0
- package/src/modules/billing/commands/runs.ts +166 -0
- package/src/modules/billing/commands/usage.ts +118 -0
- package/src/modules/billing/components/AccountForm.tsx +517 -0
- package/src/modules/billing/components/DetailFields.tsx +60 -0
- package/src/modules/billing/components/ItemForm.tsx +558 -0
- package/src/modules/billing/components/LineFormDialog.tsx +253 -0
- package/src/modules/billing/components/UsageForm.tsx +326 -0
- package/src/modules/billing/data/entities.ts +533 -0
- package/src/modules/billing/data/entityIds.ts +25 -0
- package/src/modules/billing/data/validators.ts +562 -0
- package/src/modules/billing/di.ts +14 -0
- package/src/modules/billing/events.ts +47 -0
- package/src/modules/billing/i18n/en.json +336 -0
- package/src/modules/billing/i18n/pl.json +336 -0
- package/src/modules/billing/index.ts +22 -0
- package/src/modules/billing/lib/billPeriod.ts +181 -0
- package/src/modules/billing/lib/billRunEngine.ts +416 -0
- package/src/modules/billing/lib/billRunLabel.ts +14 -0
- package/src/modules/billing/lib/idempotency.ts +46 -0
- package/src/modules/billing/lib/invoiceStatus.ts +61 -0
- package/src/modules/billing/lib/invoiceWriter.ts +260 -0
- package/src/modules/billing/lib/itemSelector.ts +154 -0
- package/src/modules/billing/lib/seeds/demo.ts +199 -0
- package/src/modules/billing/lib/tenantLock.ts +87 -0
- package/src/modules/billing/lib/usageRater.ts +250 -0
- package/src/modules/billing/lib/usageRunner.ts +189 -0
- package/src/modules/billing/migrations/Migration20260519000000_billing.ts +175 -0
- package/src/modules/billing/setup.ts +252 -0
- package/src/modules/billing/subscribers/payment-captured-to-paid.ts +89 -0
- package/src/modules/billing/translations.ts +9 -0
- package/src/modules/billing/workers/reap-stale-bill-runs.ts +57 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
5
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
6
|
+
import { Textarea } from "@open-mercato/ui/primitives/textarea";
|
|
7
|
+
import {
|
|
8
|
+
Select,
|
|
9
|
+
SelectContent,
|
|
10
|
+
SelectItem,
|
|
11
|
+
SelectTrigger,
|
|
12
|
+
SelectValue
|
|
13
|
+
} from "@open-mercato/ui/primitives/select";
|
|
14
|
+
import { Switch } from "@open-mercato/ui/primitives/switch";
|
|
15
|
+
import { Kbd, KbdShortcut } from "@open-mercato/ui/primitives/kbd";
|
|
16
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
17
|
+
const EMPTY_VALUES = {
|
|
18
|
+
billAccountId: "",
|
|
19
|
+
type: "recurring",
|
|
20
|
+
billStartDate: "",
|
|
21
|
+
billEndDate: "",
|
|
22
|
+
description: "",
|
|
23
|
+
oneTimeAmount: "",
|
|
24
|
+
recurringUnitPrice: "",
|
|
25
|
+
usageMode: "simple",
|
|
26
|
+
usageUnitPrice: "",
|
|
27
|
+
usageTieredJson: "",
|
|
28
|
+
uomCode: "",
|
|
29
|
+
subscriptionId: "",
|
|
30
|
+
subscriptionItemId: "",
|
|
31
|
+
isActive: true
|
|
32
|
+
};
|
|
33
|
+
function todayIso() {
|
|
34
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
35
|
+
}
|
|
36
|
+
function mergeInitial(initial) {
|
|
37
|
+
return {
|
|
38
|
+
...EMPTY_VALUES,
|
|
39
|
+
billStartDate: EMPTY_VALUES.billStartDate || todayIso(),
|
|
40
|
+
...initial
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function toNumber(raw) {
|
|
44
|
+
if (raw.trim() === "") return null;
|
|
45
|
+
const n = Number.parseFloat(raw);
|
|
46
|
+
return Number.isFinite(n) ? n : null;
|
|
47
|
+
}
|
|
48
|
+
function ItemForm({
|
|
49
|
+
mode,
|
|
50
|
+
accountOptions,
|
|
51
|
+
initial,
|
|
52
|
+
submitting = false,
|
|
53
|
+
onSubmit,
|
|
54
|
+
onCancel
|
|
55
|
+
}) {
|
|
56
|
+
const t = useT();
|
|
57
|
+
const [values, setValues] = React.useState(() => mergeInitial(initial));
|
|
58
|
+
const [error, setError] = React.useState(null);
|
|
59
|
+
const isEdit = mode === "edit";
|
|
60
|
+
const initialKey = React.useMemo(() => JSON.stringify(initial ?? null), [initial]);
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
setValues(mergeInitial(initial));
|
|
63
|
+
}, [initialKey, initial]);
|
|
64
|
+
const set = React.useCallback(
|
|
65
|
+
(key, value) => {
|
|
66
|
+
setValues((prev) => ({ ...prev, [key]: value }));
|
|
67
|
+
},
|
|
68
|
+
[]
|
|
69
|
+
);
|
|
70
|
+
const buildRateJson = React.useCallback(() => {
|
|
71
|
+
switch (values.type) {
|
|
72
|
+
case "one_time": {
|
|
73
|
+
const amount = toNumber(values.oneTimeAmount);
|
|
74
|
+
if (amount == null) {
|
|
75
|
+
return t("billing.items.form.error.amount_invalid", "Amount must be a number");
|
|
76
|
+
}
|
|
77
|
+
return { amount };
|
|
78
|
+
}
|
|
79
|
+
case "recurring": {
|
|
80
|
+
const unit = toNumber(values.recurringUnitPrice);
|
|
81
|
+
if (unit == null || unit < 0) {
|
|
82
|
+
return t(
|
|
83
|
+
"billing.items.form.error.unit_price_invalid",
|
|
84
|
+
"Unit price must be a non-negative number"
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return { unit_price: unit };
|
|
88
|
+
}
|
|
89
|
+
case "usage": {
|
|
90
|
+
if (values.usageMode === "simple") {
|
|
91
|
+
const unit = toNumber(values.usageUnitPrice);
|
|
92
|
+
if (unit == null || unit < 0) {
|
|
93
|
+
return t(
|
|
94
|
+
"billing.items.form.error.unit_price_invalid",
|
|
95
|
+
"Unit price must be a non-negative number"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return { unit_price: unit };
|
|
99
|
+
}
|
|
100
|
+
const raw = values.usageTieredJson.trim();
|
|
101
|
+
if (!raw) {
|
|
102
|
+
return t(
|
|
103
|
+
"billing.items.form.error.tiered_required",
|
|
104
|
+
"Tiered rate JSON is required for tiered usage"
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const parsed = JSON.parse(raw);
|
|
109
|
+
if (typeof parsed !== "object" || parsed === null || !("model" in parsed) || !("tiers" in parsed)) {
|
|
110
|
+
return t(
|
|
111
|
+
"billing.items.form.error.tiered_shape",
|
|
112
|
+
"Tiered JSON must include `model` and `tiers`"
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return parsed;
|
|
116
|
+
} catch {
|
|
117
|
+
return t(
|
|
118
|
+
"billing.items.form.error.tiered_json",
|
|
119
|
+
"Tiered rate JSON is not valid JSON"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, [
|
|
125
|
+
t,
|
|
126
|
+
values.oneTimeAmount,
|
|
127
|
+
values.recurringUnitPrice,
|
|
128
|
+
values.type,
|
|
129
|
+
values.usageMode,
|
|
130
|
+
values.usageTieredJson,
|
|
131
|
+
values.usageUnitPrice
|
|
132
|
+
]);
|
|
133
|
+
const handleSubmit = React.useCallback(async () => {
|
|
134
|
+
if (!isEdit && !values.billAccountId.trim()) {
|
|
135
|
+
setError(t("billing.items.form.error.account_required", "Billing Account is required"));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (!values.description.trim()) {
|
|
139
|
+
setError(t("billing.items.form.error.description_required", "Description is required"));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!values.billStartDate) {
|
|
143
|
+
setError(t("billing.items.form.error.start_date_required", "Bill start date is required"));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (values.type === "usage" && !values.uomCode.trim()) {
|
|
147
|
+
setError(t("billing.items.form.error.uom_required", "UoM code is required for usage items"));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const rateJsonResult = buildRateJson();
|
|
151
|
+
if (typeof rateJsonResult === "string") {
|
|
152
|
+
setError(rateJsonResult);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
setError(null);
|
|
156
|
+
const payload = {
|
|
157
|
+
billAccountId: values.billAccountId,
|
|
158
|
+
type: values.type,
|
|
159
|
+
billStartDate: values.billStartDate,
|
|
160
|
+
description: values.description.trim(),
|
|
161
|
+
rateJson: rateJsonResult
|
|
162
|
+
};
|
|
163
|
+
if (values.billEndDate) payload.billEndDate = values.billEndDate;
|
|
164
|
+
if (values.type === "usage" && values.uomCode.trim()) {
|
|
165
|
+
payload.uomCode = values.uomCode.trim();
|
|
166
|
+
}
|
|
167
|
+
if (values.subscriptionId.trim()) payload.subscriptionId = values.subscriptionId.trim();
|
|
168
|
+
if (values.subscriptionItemId.trim()) {
|
|
169
|
+
payload.subscriptionItemId = values.subscriptionItemId.trim();
|
|
170
|
+
}
|
|
171
|
+
if (isEdit) payload.isActive = values.isActive;
|
|
172
|
+
await onSubmit(payload);
|
|
173
|
+
}, [buildRateJson, isEdit, onSubmit, t, values]);
|
|
174
|
+
const handleKeyDown = React.useCallback(
|
|
175
|
+
(event) => {
|
|
176
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
void handleSubmit();
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
[handleSubmit]
|
|
182
|
+
);
|
|
183
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border bg-card p-6", onKeyDown: handleKeyDown, children: [
|
|
184
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
185
|
+
!isEdit ? /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm col-span-2", children: [
|
|
186
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
187
|
+
t("billing.items.form.account", "Billing Account"),
|
|
188
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ jsxs(
|
|
191
|
+
Select,
|
|
192
|
+
{
|
|
193
|
+
value: values.billAccountId,
|
|
194
|
+
onValueChange: (next) => set("billAccountId", next),
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t("billing.items.form.account.placeholder", "Select an account") }) }),
|
|
197
|
+
/* @__PURE__ */ jsx(SelectContent, { children: (accountOptions ?? []).map((opt) => /* @__PURE__ */ jsxs(SelectItem, { value: opt.id, children: [
|
|
198
|
+
opt.name,
|
|
199
|
+
" \xB7 ",
|
|
200
|
+
opt.customer_id,
|
|
201
|
+
" \xB7 ",
|
|
202
|
+
opt.currency_code
|
|
203
|
+
] }, opt.id)) })
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] }) : null,
|
|
208
|
+
!isEdit ? /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
209
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
210
|
+
t("billing.items.form.type", "Type"),
|
|
211
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
212
|
+
] }),
|
|
213
|
+
/* @__PURE__ */ jsxs(
|
|
214
|
+
Select,
|
|
215
|
+
{
|
|
216
|
+
value: values.type,
|
|
217
|
+
onValueChange: (next) => set("type", next),
|
|
218
|
+
children: [
|
|
219
|
+
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
220
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
221
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "one_time", children: t("billing.items.form.type.one_time", "One-time charge") }),
|
|
222
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "recurring", children: t("billing.items.form.type.recurring", "Recurring (per cycle)") }),
|
|
223
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "usage", children: t("billing.items.form.type.usage", "Usage (metered)") })
|
|
224
|
+
] })
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
] }) : null,
|
|
229
|
+
/* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
230
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
231
|
+
t("billing.items.form.start_date", "Bill start date"),
|
|
232
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
233
|
+
] }),
|
|
234
|
+
/* @__PURE__ */ jsx(
|
|
235
|
+
Input,
|
|
236
|
+
{
|
|
237
|
+
type: "date",
|
|
238
|
+
value: values.billStartDate,
|
|
239
|
+
onChange: (event) => set("billStartDate", event.currentTarget.value)
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
244
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.items.form.end_date", "Bill end date (optional)") }),
|
|
245
|
+
/* @__PURE__ */ jsx(
|
|
246
|
+
Input,
|
|
247
|
+
{
|
|
248
|
+
type: "date",
|
|
249
|
+
value: values.billEndDate,
|
|
250
|
+
onChange: (event) => set("billEndDate", event.currentTarget.value)
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
] }),
|
|
254
|
+
/* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm col-span-2", children: [
|
|
255
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
256
|
+
t("billing.items.form.description", "Description"),
|
|
257
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
258
|
+
] }),
|
|
259
|
+
/* @__PURE__ */ jsx(
|
|
260
|
+
Textarea,
|
|
261
|
+
{
|
|
262
|
+
value: values.description,
|
|
263
|
+
rows: 2,
|
|
264
|
+
onChange: (event) => set("description", event.currentTarget.value)
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t(
|
|
268
|
+
"billing.items.form.description.help",
|
|
269
|
+
"Shown verbatim on the invoice line."
|
|
270
|
+
) })
|
|
271
|
+
] })
|
|
272
|
+
] }),
|
|
273
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold mt-6 mb-2", children: t("billing.items.form.rate.title", "Rate") }),
|
|
274
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
275
|
+
values.type === "one_time" ? /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
276
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
277
|
+
t("billing.items.form.rate.amount", "Amount"),
|
|
278
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ jsx(
|
|
281
|
+
Input,
|
|
282
|
+
{
|
|
283
|
+
type: "number",
|
|
284
|
+
step: "0.0001",
|
|
285
|
+
value: values.oneTimeAmount,
|
|
286
|
+
onChange: (event) => set("oneTimeAmount", event.currentTarget.value)
|
|
287
|
+
}
|
|
288
|
+
),
|
|
289
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t(
|
|
290
|
+
"billing.items.form.rate.amount.help",
|
|
291
|
+
"Negative allowed for refunds / credits / proration credits."
|
|
292
|
+
) })
|
|
293
|
+
] }) : null,
|
|
294
|
+
values.type === "recurring" ? /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
295
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
296
|
+
t("billing.items.form.rate.unit_price_recurring", "Unit price per cycle"),
|
|
297
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
298
|
+
] }),
|
|
299
|
+
/* @__PURE__ */ jsx(
|
|
300
|
+
Input,
|
|
301
|
+
{
|
|
302
|
+
type: "number",
|
|
303
|
+
step: "0.0001",
|
|
304
|
+
value: values.recurringUnitPrice,
|
|
305
|
+
onChange: (event) => set("recurringUnitPrice", event.currentTarget.value)
|
|
306
|
+
}
|
|
307
|
+
)
|
|
308
|
+
] }) : null,
|
|
309
|
+
values.type === "usage" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
310
|
+
/* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
311
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.items.form.rate.usage_mode", "Rate model") }),
|
|
312
|
+
/* @__PURE__ */ jsxs(
|
|
313
|
+
Select,
|
|
314
|
+
{
|
|
315
|
+
value: values.usageMode,
|
|
316
|
+
onValueChange: (next) => set("usageMode", next),
|
|
317
|
+
children: [
|
|
318
|
+
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
319
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
320
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "simple", children: t("billing.items.form.rate.usage_mode.simple", "Simple flat rate") }),
|
|
321
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "tiered", children: t("billing.items.form.rate.usage_mode.tiered", "Tiered (volume / graduated / flat)") })
|
|
322
|
+
] })
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
] }),
|
|
327
|
+
values.usageMode === "simple" ? /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
328
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
329
|
+
t("billing.items.form.rate.unit_price_usage", "Unit price per unit consumed"),
|
|
330
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
331
|
+
] }),
|
|
332
|
+
/* @__PURE__ */ jsx(
|
|
333
|
+
Input,
|
|
334
|
+
{
|
|
335
|
+
type: "number",
|
|
336
|
+
step: "0.000001",
|
|
337
|
+
value: values.usageUnitPrice,
|
|
338
|
+
onChange: (event) => set("usageUnitPrice", event.currentTarget.value)
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
] }) : /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm col-span-2", children: [
|
|
342
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
343
|
+
t("billing.items.form.rate.tiered_json", "Tiered rate JSON"),
|
|
344
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
345
|
+
] }),
|
|
346
|
+
/* @__PURE__ */ jsx(
|
|
347
|
+
Textarea,
|
|
348
|
+
{
|
|
349
|
+
rows: 6,
|
|
350
|
+
value: values.usageTieredJson,
|
|
351
|
+
placeholder: '{ "model": "graduated", "tiers": [{ "up_to": 10000, "unit_price": 0 }, { "up_to": null, "unit_price": 0.001 }] }',
|
|
352
|
+
onChange: (event) => set("usageTieredJson", event.currentTarget.value)
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t(
|
|
356
|
+
"billing.items.form.rate.tiered_json.help",
|
|
357
|
+
"Models: volume / graduated / flat. Exactly one tier must have `up_to: null` (the open-ended top tier). Server-side validators reject malformed shapes."
|
|
358
|
+
) })
|
|
359
|
+
] }),
|
|
360
|
+
/* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
361
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
362
|
+
t("billing.items.form.uom_code", "UoM code"),
|
|
363
|
+
/* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
|
|
364
|
+
] }),
|
|
365
|
+
/* @__PURE__ */ jsx(
|
|
366
|
+
Input,
|
|
367
|
+
{
|
|
368
|
+
value: values.uomCode,
|
|
369
|
+
placeholder: "api_request, gb, seat, \u2026",
|
|
370
|
+
onChange: (event) => set("uomCode", event.currentTarget.value)
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t(
|
|
374
|
+
"billing.items.form.uom_code.help",
|
|
375
|
+
"Must exactly match the `uom_code` on usage records. No conversion."
|
|
376
|
+
) })
|
|
377
|
+
] })
|
|
378
|
+
] }) : null
|
|
379
|
+
] }),
|
|
380
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold mt-6 mb-2", children: t("billing.items.form.refs.title", "External references (optional)") }),
|
|
381
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
382
|
+
/* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
383
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.items.form.subscription_id", "Subscription ID") }),
|
|
384
|
+
/* @__PURE__ */ jsx(
|
|
385
|
+
Input,
|
|
386
|
+
{
|
|
387
|
+
value: values.subscriptionId,
|
|
388
|
+
onChange: (event) => set("subscriptionId", event.currentTarget.value)
|
|
389
|
+
}
|
|
390
|
+
)
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
|
|
393
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.items.form.subscription_item_id", "Subscription item ID") }),
|
|
394
|
+
/* @__PURE__ */ jsx(
|
|
395
|
+
Input,
|
|
396
|
+
{
|
|
397
|
+
value: values.subscriptionItemId,
|
|
398
|
+
onChange: (event) => set("subscriptionItemId", event.currentTarget.value)
|
|
399
|
+
}
|
|
400
|
+
)
|
|
401
|
+
] })
|
|
402
|
+
] }),
|
|
403
|
+
isEdit ? /* @__PURE__ */ jsxs("div", { className: "mt-6 flex items-center justify-between gap-3", children: [
|
|
404
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
405
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: t("billing.items.form.active", "Active") }),
|
|
406
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: t(
|
|
407
|
+
"billing.items.form.active.help",
|
|
408
|
+
"Inactive items are skipped by the Bill Run engine."
|
|
409
|
+
) })
|
|
410
|
+
] }),
|
|
411
|
+
/* @__PURE__ */ jsx(
|
|
412
|
+
Switch,
|
|
413
|
+
{
|
|
414
|
+
checked: values.isActive,
|
|
415
|
+
onCheckedChange: (next) => set("isActive", next)
|
|
416
|
+
}
|
|
417
|
+
)
|
|
418
|
+
] }) : null,
|
|
419
|
+
error ? /* @__PURE__ */ jsx("div", { className: "mt-4 text-sm text-destructive", children: error }) : null,
|
|
420
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-6 flex items-center justify-between gap-3", children: [
|
|
421
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
422
|
+
/* @__PURE__ */ jsx(KbdShortcut, { keys: ["Ctrl/\u2318", "Enter"] }),
|
|
423
|
+
" ",
|
|
424
|
+
t("billing.items.form.submit_hint", "to save,"),
|
|
425
|
+
" ",
|
|
426
|
+
/* @__PURE__ */ jsx(Kbd, { children: "Esc" }),
|
|
427
|
+
" ",
|
|
428
|
+
t("billing.items.form.cancel_hint", "to discard")
|
|
429
|
+
] }),
|
|
430
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
431
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onCancel, children: t("billing.common.cancel", "Cancel") }),
|
|
432
|
+
/* @__PURE__ */ jsx(Button, { type: "button", onClick: () => void handleSubmit(), disabled: submitting, children: submitting ? t("billing.items.form.saving", "Saving\u2026") : isEdit ? t("billing.items.form.save", "Save changes") : t("billing.items.form.create", "Create item") })
|
|
433
|
+
] })
|
|
434
|
+
] })
|
|
435
|
+
] });
|
|
436
|
+
}
|
|
437
|
+
export {
|
|
438
|
+
ItemForm
|
|
439
|
+
};
|
|
440
|
+
//# sourceMappingURL=ItemForm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/billing/components/ItemForm.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\n/**\n * Shared form for Billing Item create + edit.\n *\n * The `rate_json` field is type-discriminated per the spec's\n * \"Rate Formats\" section:\n * - `one_time`: `{ amount }` \u2014 one number.\n * - `recurring`: `{ unit_price }` \u2014 one number.\n * - `usage` (simple): `{ unit_price }` + required `uomCode`.\n * - `usage` (tiered, advanced): operator pastes raw JSON\n * `{ model, tiers: [...] }` into the textarea \u2014 for occasional\n * hand-built tiered rates. The integration flow uses CPQ \u2192\n * connector to land tiered rates without UI input.\n *\n * `type` is immutable on edit (per `billingItemUpdateSchema`); we\n * hide the `type` selector in `mode='edit'` so it can't even be\n * surfaced.\n */\n\ntype BillingItemType = 'one_time' | 'recurring' | 'usage'\ntype UsageRateMode = 'simple' | 'tiered'\n\nexport type ItemFormValues = {\n billAccountId: string\n type: BillingItemType\n billStartDate: string\n billEndDate: string\n description: string\n // Rate is type-dependent \u2014 we keep the inputs separate and assemble\n // `rate_json` on submit.\n oneTimeAmount: string\n recurringUnitPrice: string\n usageMode: UsageRateMode\n usageUnitPrice: string\n usageTieredJson: string\n uomCode: string\n subscriptionId: string\n subscriptionItemId: string\n isActive: boolean\n}\n\n// The accounts list API (`/api/billing/accounts`) returns snake_case\n// rows \u2014 mirror that here so the picker reads real values. (camelCase\n// resolved to `undefined`, rendering \"Name \u00B7 undefined \u00B7 undefined\".)\nexport type AccountOption = {\n id: string\n name: string\n customer_id: string\n currency_code: string\n}\n\nexport type ItemFormProps = {\n mode: 'create' | 'edit'\n /** For create mode: full list of accounts the operator can attach to. */\n accountOptions?: AccountOption[]\n initial?: Partial<ItemFormValues>\n submitting?: boolean\n /** Returns the assembled payload (with rate_json built). */\n onSubmit: (assembled: AssembledItemPayload) => Promise<void> | void\n onCancel: () => void\n}\n\nexport type AssembledItemPayload = {\n billAccountId: string\n type: BillingItemType\n billStartDate: string\n billEndDate?: string\n description: string\n rateJson: Record<string, unknown>\n uomCode?: string\n subscriptionId?: string\n subscriptionItemId?: string\n isActive?: boolean\n}\n\nconst EMPTY_VALUES: ItemFormValues = {\n billAccountId: '',\n type: 'recurring',\n billStartDate: '',\n billEndDate: '',\n description: '',\n oneTimeAmount: '',\n recurringUnitPrice: '',\n usageMode: 'simple',\n usageUnitPrice: '',\n usageTieredJson: '',\n uomCode: '',\n subscriptionId: '',\n subscriptionItemId: '',\n isActive: true,\n}\n\nfunction todayIso(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction mergeInitial(initial: Partial<ItemFormValues> | undefined): ItemFormValues {\n return {\n ...EMPTY_VALUES,\n billStartDate: EMPTY_VALUES.billStartDate || todayIso(),\n ...initial,\n }\n}\n\nfunction toNumber(raw: string): number | null {\n if (raw.trim() === '') return null\n const n = Number.parseFloat(raw)\n return Number.isFinite(n) ? n : null\n}\n\nexport function ItemForm({\n mode,\n accountOptions,\n initial,\n submitting = false,\n onSubmit,\n onCancel,\n}: ItemFormProps) {\n const t = useT()\n const [values, setValues] = React.useState<ItemFormValues>(() => mergeInitial(initial))\n const [error, setError] = React.useState<string | null>(null)\n const isEdit = mode === 'edit'\n\n const initialKey = React.useMemo(() => JSON.stringify(initial ?? null), [initial])\n React.useEffect(() => {\n setValues(mergeInitial(initial))\n }, [initialKey, initial])\n\n const set = React.useCallback(\n <K extends keyof ItemFormValues>(key: K, value: ItemFormValues[K]) => {\n setValues((prev) => ({ ...prev, [key]: value }))\n },\n [],\n )\n\n const buildRateJson = React.useCallback((): Record<string, unknown> | string => {\n switch (values.type) {\n case 'one_time': {\n const amount = toNumber(values.oneTimeAmount)\n if (amount == null) {\n return t('billing.items.form.error.amount_invalid', 'Amount must be a number')\n }\n return { amount }\n }\n case 'recurring': {\n const unit = toNumber(values.recurringUnitPrice)\n if (unit == null || unit < 0) {\n return t(\n 'billing.items.form.error.unit_price_invalid',\n 'Unit price must be a non-negative number',\n )\n }\n return { unit_price: unit }\n }\n case 'usage': {\n if (values.usageMode === 'simple') {\n const unit = toNumber(values.usageUnitPrice)\n if (unit == null || unit < 0) {\n return t(\n 'billing.items.form.error.unit_price_invalid',\n 'Unit price must be a non-negative number',\n )\n }\n return { unit_price: unit }\n }\n // Tiered: parse the textarea as JSON.\n const raw = values.usageTieredJson.trim()\n if (!raw) {\n return t(\n 'billing.items.form.error.tiered_required',\n 'Tiered rate JSON is required for tiered usage',\n )\n }\n try {\n const parsed = JSON.parse(raw) as Record<string, unknown>\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n !('model' in parsed) ||\n !('tiers' in parsed)\n ) {\n return t(\n 'billing.items.form.error.tiered_shape',\n 'Tiered JSON must include `model` and `tiers`',\n )\n }\n return parsed\n } catch {\n return t(\n 'billing.items.form.error.tiered_json',\n 'Tiered rate JSON is not valid JSON',\n )\n }\n }\n }\n }, [\n t,\n values.oneTimeAmount,\n values.recurringUnitPrice,\n values.type,\n values.usageMode,\n values.usageTieredJson,\n values.usageUnitPrice,\n ])\n\n const handleSubmit = React.useCallback(async () => {\n if (!isEdit && !values.billAccountId.trim()) {\n setError(t('billing.items.form.error.account_required', 'Billing Account is required'))\n return\n }\n if (!values.description.trim()) {\n setError(t('billing.items.form.error.description_required', 'Description is required'))\n return\n }\n if (!values.billStartDate) {\n setError(t('billing.items.form.error.start_date_required', 'Bill start date is required'))\n return\n }\n if (values.type === 'usage' && !values.uomCode.trim()) {\n setError(t('billing.items.form.error.uom_required', 'UoM code is required for usage items'))\n return\n }\n const rateJsonResult = buildRateJson()\n if (typeof rateJsonResult === 'string') {\n // builder returned an error message\n setError(rateJsonResult)\n return\n }\n setError(null)\n\n const payload: AssembledItemPayload = {\n billAccountId: values.billAccountId,\n type: values.type,\n billStartDate: values.billStartDate,\n description: values.description.trim(),\n rateJson: rateJsonResult,\n }\n if (values.billEndDate) payload.billEndDate = values.billEndDate\n if (values.type === 'usage' && values.uomCode.trim()) {\n payload.uomCode = values.uomCode.trim()\n }\n if (values.subscriptionId.trim()) payload.subscriptionId = values.subscriptionId.trim()\n if (values.subscriptionItemId.trim()) {\n payload.subscriptionItemId = values.subscriptionItemId.trim()\n }\n if (isEdit) payload.isActive = values.isActive\n await onSubmit(payload)\n }, [buildRateJson, isEdit, onSubmit, t, values])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void handleSubmit()\n }\n },\n [handleSubmit],\n )\n\n return (\n <div className=\"rounded-lg border border-border bg-card p-6\" onKeyDown={handleKeyDown}>\n <div className=\"grid grid-cols-2 gap-4\">\n {!isEdit ? (\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.account', 'Billing Account')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Select\n value={values.billAccountId}\n onValueChange={(next) => set('billAccountId', next)}\n >\n <SelectTrigger>\n <SelectValue placeholder={t('billing.items.form.account.placeholder', 'Select an account')} />\n </SelectTrigger>\n <SelectContent>\n {(accountOptions ?? []).map((opt) => (\n <SelectItem key={opt.id} value={opt.id}>\n {opt.name} \u00B7 {opt.customer_id} \u00B7 {opt.currency_code}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </label>\n ) : null}\n\n {!isEdit ? (\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.type', 'Type')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Select\n value={values.type}\n onValueChange={(next) => set('type', next as BillingItemType)}\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"one_time\">\n {t('billing.items.form.type.one_time', 'One-time charge')}\n </SelectItem>\n <SelectItem value=\"recurring\">\n {t('billing.items.form.type.recurring', 'Recurring (per cycle)')}\n </SelectItem>\n <SelectItem value=\"usage\">\n {t('billing.items.form.type.usage', 'Usage (metered)')}\n </SelectItem>\n </SelectContent>\n </Select>\n </label>\n ) : null}\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.start_date', 'Bill start date')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"date\"\n value={values.billStartDate}\n onChange={(event) => set('billStartDate', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.end_date', 'Bill end date (optional)')}\n </span>\n <Input\n type=\"date\"\n value={values.billEndDate}\n onChange={(event) => set('billEndDate', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.description', 'Description')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Textarea\n value={values.description}\n rows={2}\n onChange={(event) => set('description', event.currentTarget.value)}\n />\n <span className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.items.form.description.help',\n 'Shown verbatim on the invoice line.',\n )}\n </span>\n </label>\n </div>\n\n <h3 className=\"text-sm font-semibold mt-6 mb-2\">\n {t('billing.items.form.rate.title', 'Rate')}\n </h3>\n <div className=\"grid grid-cols-2 gap-4\">\n {values.type === 'one_time' ? (\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.rate.amount', 'Amount')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"number\"\n step=\"0.0001\"\n value={values.oneTimeAmount}\n onChange={(event) => set('oneTimeAmount', event.currentTarget.value)}\n />\n <span className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.items.form.rate.amount.help',\n 'Negative allowed for refunds / credits / proration credits.',\n )}\n </span>\n </label>\n ) : null}\n\n {values.type === 'recurring' ? (\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.rate.unit_price_recurring', 'Unit price per cycle')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"number\"\n step=\"0.0001\"\n value={values.recurringUnitPrice}\n onChange={(event) => set('recurringUnitPrice', event.currentTarget.value)}\n />\n </label>\n ) : null}\n\n {values.type === 'usage' ? (\n <>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.rate.usage_mode', 'Rate model')}\n </span>\n <Select\n value={values.usageMode}\n onValueChange={(next) => set('usageMode', next as UsageRateMode)}\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"simple\">\n {t('billing.items.form.rate.usage_mode.simple', 'Simple flat rate')}\n </SelectItem>\n <SelectItem value=\"tiered\">\n {t('billing.items.form.rate.usage_mode.tiered', 'Tiered (volume / graduated / flat)')}\n </SelectItem>\n </SelectContent>\n </Select>\n </label>\n\n {values.usageMode === 'simple' ? (\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.rate.unit_price_usage', 'Unit price per unit consumed')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"number\"\n step=\"0.000001\"\n value={values.usageUnitPrice}\n onChange={(event) => set('usageUnitPrice', event.currentTarget.value)}\n />\n </label>\n ) : (\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.rate.tiered_json', 'Tiered rate JSON')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Textarea\n rows={6}\n value={values.usageTieredJson}\n placeholder='{ \"model\": \"graduated\", \"tiers\": [{ \"up_to\": 10000, \"unit_price\": 0 }, { \"up_to\": null, \"unit_price\": 0.001 }] }'\n onChange={(event) => set('usageTieredJson', event.currentTarget.value)}\n />\n <span className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.items.form.rate.tiered_json.help',\n 'Models: volume / graduated / flat. Exactly one tier must have `up_to: null` (the open-ended top tier). Server-side validators reject malformed shapes.',\n )}\n </span>\n </label>\n )}\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.uom_code', 'UoM code')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.uomCode}\n placeholder=\"api_request, gb, seat, \u2026\"\n onChange={(event) => set('uomCode', event.currentTarget.value)}\n />\n <span className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.items.form.uom_code.help',\n 'Must exactly match the `uom_code` on usage records. No conversion.',\n )}\n </span>\n </label>\n </>\n ) : null}\n </div>\n\n <h3 className=\"text-sm font-semibold mt-6 mb-2\">\n {t('billing.items.form.refs.title', 'External references (optional)')}\n </h3>\n <div className=\"grid grid-cols-2 gap-4\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.subscription_id', 'Subscription ID')}\n </span>\n <Input\n value={values.subscriptionId}\n onChange={(event) => set('subscriptionId', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.items.form.subscription_item_id', 'Subscription item ID')}\n </span>\n <Input\n value={values.subscriptionItemId}\n onChange={(event) => set('subscriptionItemId', event.currentTarget.value)}\n />\n </label>\n </div>\n\n {isEdit ? (\n <div className=\"mt-6 flex items-center justify-between gap-3\">\n <div>\n <div className=\"text-sm font-medium\">\n {t('billing.items.form.active', 'Active')}\n </div>\n <div className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.items.form.active.help',\n 'Inactive items are skipped by the Bill Run engine.',\n )}\n </div>\n </div>\n <Switch\n checked={values.isActive}\n onCheckedChange={(next) => set('isActive', next)}\n />\n </div>\n ) : null}\n\n {error ? <div className=\"mt-4 text-sm text-destructive\">{error}</div> : null}\n\n <div className=\"mt-6 flex items-center justify-between gap-3\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} />{' '}\n {t('billing.items.form.submit_hint', 'to save,')} <Kbd>Esc</Kbd>{' '}\n {t('billing.items.form.cancel_hint', 'to discard')}\n </span>\n <div className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={onCancel}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n <Button type=\"button\" onClick={() => void handleSubmit()} disabled={submitting}>\n {submitting\n ? t('billing.items.form.saving', 'Saving\u2026')\n : isEdit\n ? t('billing.items.form.save', 'Save changes')\n : t('billing.items.form.create', 'Create item')}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAuRY,SAqIF,UAnII,KAFF;AAtRZ,YAAY,WAAW;AACvB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,KAAK,mBAAmB;AACjC,SAAS,YAAY;AA4ErB,MAAM,eAA+B;AAAA,EACnC,eAAe;AAAA,EACf,MAAM;AAAA,EACN,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,UAAU;AACZ;AAEA,SAAS,WAAmB;AAC1B,UAAO,oBAAI,KAAK,GAAE,YAAY,EAAE,MAAM,GAAG,EAAE;AAC7C;AAEA,SAAS,aAAa,SAA8D;AAClF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,aAAa,iBAAiB,SAAS;AAAA,IACtD,GAAG;AAAA,EACL;AACF;AAEA,SAAS,SAAS,KAA4B;AAC5C,MAAI,IAAI,KAAK,MAAM,GAAI,QAAO;AAC9B,QAAM,IAAI,OAAO,WAAW,GAAG;AAC/B,SAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAClC;AAEO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AACF,GAAkB;AAChB,QAAM,IAAI,KAAK;AACf,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAA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