@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,500 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useParams } from "next/navigation";
|
|
6
|
+
import { Pencil, Plus, Trash2 } from "lucide-react";
|
|
7
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
8
|
+
import { Page, PageBody, PageHeader } from "@open-mercato/ui/backend/Page";
|
|
9
|
+
import { FormHeader } from "@open-mercato/ui/backend/forms";
|
|
10
|
+
import { DataTable } from "@open-mercato/ui/backend/DataTable";
|
|
11
|
+
import { Tag } from "@open-mercato/ui/primitives/tag";
|
|
12
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
13
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
14
|
+
import { LoadingMessage, ErrorMessage } from "@open-mercato/ui/backend/detail";
|
|
15
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
16
|
+
import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
|
|
17
|
+
import {
|
|
18
|
+
apiCallOrThrow,
|
|
19
|
+
readApiResultOrThrow
|
|
20
|
+
} from "@open-mercato/ui/backend/utils/apiCall";
|
|
21
|
+
import { normalizeCrudServerError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
22
|
+
import { LineFormDialog } from "../../../../components/LineFormDialog.js";
|
|
23
|
+
import {
|
|
24
|
+
DetailCard,
|
|
25
|
+
DetailField,
|
|
26
|
+
Stat,
|
|
27
|
+
StatCard
|
|
28
|
+
} from "../../../../components/DetailFields.js";
|
|
29
|
+
import { billRunName } from "../../../../lib/billRunLabel.js";
|
|
30
|
+
function statusVariant(status) {
|
|
31
|
+
switch (status) {
|
|
32
|
+
case "paid":
|
|
33
|
+
return "success";
|
|
34
|
+
case "posted":
|
|
35
|
+
return "warning";
|
|
36
|
+
case "void":
|
|
37
|
+
return "error";
|
|
38
|
+
case "draft":
|
|
39
|
+
default:
|
|
40
|
+
return "default";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function lineKindVariant(type) {
|
|
44
|
+
switch (type) {
|
|
45
|
+
case "one_time":
|
|
46
|
+
return "warning";
|
|
47
|
+
case "recurring":
|
|
48
|
+
return "success";
|
|
49
|
+
case "usage":
|
|
50
|
+
return "default";
|
|
51
|
+
default:
|
|
52
|
+
return "default";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function formatMoney(value, currency) {
|
|
56
|
+
const n = Number.parseFloat(value);
|
|
57
|
+
if (!Number.isFinite(n)) return value;
|
|
58
|
+
try {
|
|
59
|
+
return new Intl.NumberFormat("en-US", { style: "currency", currency }).format(n);
|
|
60
|
+
} catch {
|
|
61
|
+
return `${value} ${currency}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function BillingInvoiceDetailPage(props) {
|
|
65
|
+
const t = useT();
|
|
66
|
+
const urlParams = useParams();
|
|
67
|
+
const invoiceId = props.params?.id ?? urlParams?.id ?? "";
|
|
68
|
+
const [invoice, setInvoice] = React.useState(null);
|
|
69
|
+
const [lines, setLines] = React.useState([]);
|
|
70
|
+
const [accountName, setAccountName] = React.useState(null);
|
|
71
|
+
const [runName, setRunName] = React.useState(null);
|
|
72
|
+
const [error, setError] = React.useState(null);
|
|
73
|
+
const [loading, setLoading] = React.useState(true);
|
|
74
|
+
const [posting, setPosting] = React.useState(false);
|
|
75
|
+
const [wiping, setWiping] = React.useState(false);
|
|
76
|
+
const [linesPage, setLinesPage] = React.useState(1);
|
|
77
|
+
const linesPageSize = 100;
|
|
78
|
+
const visibleLines = React.useMemo(
|
|
79
|
+
() => lines.slice((linesPage - 1) * linesPageSize, linesPage * linesPageSize),
|
|
80
|
+
[lines, linesPage]
|
|
81
|
+
);
|
|
82
|
+
const linesTotalPages = Math.max(1, Math.ceil(lines.length / linesPageSize));
|
|
83
|
+
const [dialogMode, setDialogMode] = React.useState(null);
|
|
84
|
+
const [dialogTargetLine, setDialogTargetLine] = React.useState(null);
|
|
85
|
+
const [dialogSubmitting, setDialogSubmitting] = React.useState(false);
|
|
86
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog();
|
|
87
|
+
const load = React.useCallback(async () => {
|
|
88
|
+
if (!invoiceId) return;
|
|
89
|
+
setError(null);
|
|
90
|
+
setLoading(true);
|
|
91
|
+
try {
|
|
92
|
+
const data = await readApiResultOrThrow(
|
|
93
|
+
`/api/billing/invoices/${invoiceId}`
|
|
94
|
+
);
|
|
95
|
+
setInvoice(data.invoice);
|
|
96
|
+
setLines(data.lines ?? []);
|
|
97
|
+
} catch (err) {
|
|
98
|
+
const { message } = normalizeCrudServerError(err);
|
|
99
|
+
setError(message || t("billing.invoices.detail.error.load", "Failed to load invoice"));
|
|
100
|
+
} finally {
|
|
101
|
+
setLoading(false);
|
|
102
|
+
}
|
|
103
|
+
}, [invoiceId, t]);
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
void load();
|
|
106
|
+
}, [load]);
|
|
107
|
+
const billRunId = invoice?.metadata?.bill_run_id;
|
|
108
|
+
const billAccountId = invoice?.metadata?.bill_account_id;
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
if (billAccountId) {
|
|
111
|
+
readApiResultOrThrow(
|
|
112
|
+
`/api/billing/accounts?id=${billAccountId}&pageSize=1`
|
|
113
|
+
).then((r) => setAccountName(r.items?.[0]?.name ?? null)).catch(() => setAccountName(null));
|
|
114
|
+
}
|
|
115
|
+
if (billRunId) {
|
|
116
|
+
readApiResultOrThrow(
|
|
117
|
+
`/api/billing/runs?id=${billRunId}&pageSize=1`
|
|
118
|
+
).then((r) => {
|
|
119
|
+
const asOf = r.items?.[0]?.as_of_date;
|
|
120
|
+
setRunName(asOf ? billRunName(asOf) : null);
|
|
121
|
+
}).catch(() => setRunName(null));
|
|
122
|
+
}
|
|
123
|
+
}, [billAccountId, billRunId]);
|
|
124
|
+
const handlePost = React.useCallback(async () => {
|
|
125
|
+
if (!invoice) return;
|
|
126
|
+
setPosting(true);
|
|
127
|
+
try {
|
|
128
|
+
const call = await apiCallOrThrow(
|
|
129
|
+
"/api/billing/invoices/post",
|
|
130
|
+
{
|
|
131
|
+
method: "POST",
|
|
132
|
+
headers: { "Content-Type": "application/json" },
|
|
133
|
+
body: JSON.stringify({ invoiceId: invoice.id })
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
flash(
|
|
137
|
+
t("billing.invoices.post.success", "Invoice posted") + ` (${call.result?.invoiceNumber ?? invoice.invoice_number})`,
|
|
138
|
+
"success"
|
|
139
|
+
);
|
|
140
|
+
void load();
|
|
141
|
+
} catch (err) {
|
|
142
|
+
const { message } = normalizeCrudServerError(err);
|
|
143
|
+
flash(message || t("billing.invoices.post.error", "Post failed"), "error");
|
|
144
|
+
} finally {
|
|
145
|
+
setPosting(false);
|
|
146
|
+
}
|
|
147
|
+
}, [invoice, load, t]);
|
|
148
|
+
const handleWipeTest = React.useCallback(async () => {
|
|
149
|
+
if (!invoice) return;
|
|
150
|
+
const ok = await confirm({
|
|
151
|
+
title: t("billing.invoices.wipe.confirm.title", "Wipe test invoices?"),
|
|
152
|
+
text: t(
|
|
153
|
+
"billing.invoices.wipe.confirm.text",
|
|
154
|
+
"Every test invoice from this Bill Run will be permanently deleted. This cannot be undone."
|
|
155
|
+
),
|
|
156
|
+
confirmText: t("billing.invoices.wipe.confirm.button", "Delete test invoices"),
|
|
157
|
+
variant: "destructive"
|
|
158
|
+
});
|
|
159
|
+
if (!ok) return;
|
|
160
|
+
setWiping(true);
|
|
161
|
+
try {
|
|
162
|
+
const billRunId2 = invoice.metadata?.bill_run_id;
|
|
163
|
+
const call = await apiCallOrThrow(
|
|
164
|
+
"/api/billing/test-invoices/wipe",
|
|
165
|
+
{
|
|
166
|
+
method: "POST",
|
|
167
|
+
headers: { "Content-Type": "application/json" },
|
|
168
|
+
body: JSON.stringify(billRunId2 ? { billRunId: billRunId2 } : {})
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
flash(
|
|
172
|
+
t("billing.invoices.wipe.success", "Test invoices removed") + ` (${call.result?.invoicesRemoved ?? 0})`,
|
|
173
|
+
"success"
|
|
174
|
+
);
|
|
175
|
+
void load();
|
|
176
|
+
} catch (err) {
|
|
177
|
+
const { message } = normalizeCrudServerError(err);
|
|
178
|
+
flash(message || t("billing.invoices.wipe.error", "Wipe failed"), "error");
|
|
179
|
+
} finally {
|
|
180
|
+
setWiping(false);
|
|
181
|
+
}
|
|
182
|
+
}, [confirm, invoice, load, t]);
|
|
183
|
+
const handleSubmitLine = React.useCallback(
|
|
184
|
+
async (values) => {
|
|
185
|
+
if (!invoice) return;
|
|
186
|
+
setDialogSubmitting(true);
|
|
187
|
+
try {
|
|
188
|
+
if (dialogMode === "add") {
|
|
189
|
+
await apiCallOrThrow("/api/billing/invoices/add-line", {
|
|
190
|
+
method: "POST",
|
|
191
|
+
headers: { "Content-Type": "application/json" },
|
|
192
|
+
body: JSON.stringify({
|
|
193
|
+
invoiceId: invoice.id,
|
|
194
|
+
description: values.description,
|
|
195
|
+
quantity: values.quantity,
|
|
196
|
+
unitPriceNet: values.unitPriceNet
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
flash(t("billing.invoices.lines.add.success", "Line added"), "success");
|
|
200
|
+
} else if (dialogMode === "edit" && dialogTargetLine) {
|
|
201
|
+
await apiCallOrThrow("/api/billing/invoices/edit-line", {
|
|
202
|
+
method: "POST",
|
|
203
|
+
headers: { "Content-Type": "application/json" },
|
|
204
|
+
body: JSON.stringify({
|
|
205
|
+
invoiceId: invoice.id,
|
|
206
|
+
invoiceLineId: dialogTargetLine.id,
|
|
207
|
+
changes: {
|
|
208
|
+
description: values.description,
|
|
209
|
+
quantity: values.quantity,
|
|
210
|
+
unitPriceNet: values.unitPriceNet,
|
|
211
|
+
...values.totalNetAmount !== void 0 ? { totalNetAmount: values.totalNetAmount } : {}
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
flash(t("billing.invoices.lines.edit.success", "Line updated"), "success");
|
|
216
|
+
}
|
|
217
|
+
setDialogMode(null);
|
|
218
|
+
setDialogTargetLine(null);
|
|
219
|
+
void load();
|
|
220
|
+
} catch (err) {
|
|
221
|
+
const { message } = normalizeCrudServerError(err);
|
|
222
|
+
flash(message || t("billing.invoices.lines.save.error", "Save failed"), "error");
|
|
223
|
+
} finally {
|
|
224
|
+
setDialogSubmitting(false);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
[dialogMode, dialogTargetLine, invoice, load, t]
|
|
228
|
+
);
|
|
229
|
+
const handleRemoveLine = React.useCallback(
|
|
230
|
+
async (line) => {
|
|
231
|
+
if (!invoice) return;
|
|
232
|
+
const ok = await confirm({
|
|
233
|
+
title: t("billing.invoices.lines.remove.confirm.title", "Remove line?"),
|
|
234
|
+
text: t(
|
|
235
|
+
"billing.invoices.lines.remove.confirm.text",
|
|
236
|
+
"The line will be deleted and recorded in the draft-edit audit log."
|
|
237
|
+
),
|
|
238
|
+
confirmText: t("billing.invoices.lines.remove.confirm.button", "Remove line"),
|
|
239
|
+
variant: "destructive"
|
|
240
|
+
});
|
|
241
|
+
if (!ok) return;
|
|
242
|
+
try {
|
|
243
|
+
await apiCallOrThrow("/api/billing/invoices/remove-line", {
|
|
244
|
+
method: "POST",
|
|
245
|
+
headers: { "Content-Type": "application/json" },
|
|
246
|
+
body: JSON.stringify({
|
|
247
|
+
invoiceId: invoice.id,
|
|
248
|
+
invoiceLineId: line.id
|
|
249
|
+
})
|
|
250
|
+
});
|
|
251
|
+
flash(t("billing.invoices.lines.remove.success", "Line removed"), "success");
|
|
252
|
+
void load();
|
|
253
|
+
} catch (err) {
|
|
254
|
+
const { message } = normalizeCrudServerError(err);
|
|
255
|
+
flash(message || t("billing.invoices.lines.remove.error", "Remove failed"), "error");
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
[confirm, invoice, load, t]
|
|
259
|
+
);
|
|
260
|
+
const canEditLines = invoice?.status === "draft";
|
|
261
|
+
const lineColumns = React.useMemo(
|
|
262
|
+
() => [
|
|
263
|
+
{
|
|
264
|
+
accessorKey: "line_number",
|
|
265
|
+
header: "#"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
accessorKey: "description",
|
|
269
|
+
header: t("billing.invoices.lines.columns.description", "Description"),
|
|
270
|
+
cell: ({ row }) => {
|
|
271
|
+
const type = row.original.metadata?.billing_type;
|
|
272
|
+
const operatorAdded = row.original.metadata?.operator_added === true;
|
|
273
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
274
|
+
/* @__PURE__ */ jsx("span", { children: row.original.description ?? "\u2014" }),
|
|
275
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-wrap", children: [
|
|
276
|
+
type ? /* @__PURE__ */ jsx(Tag, { variant: lineKindVariant(type), children: type }) : null,
|
|
277
|
+
operatorAdded ? /* @__PURE__ */ jsx(Tag, { variant: "info", children: t("billing.invoices.lines.operator_added", "Operator-added") }) : null
|
|
278
|
+
] })
|
|
279
|
+
] });
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
accessorKey: "quantity",
|
|
284
|
+
header: t("billing.invoices.lines.columns.quantity", "Qty")
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
accessorKey: "unit_price_net",
|
|
288
|
+
header: t("billing.invoices.lines.columns.unit_price", "Unit price"),
|
|
289
|
+
cell: ({ row }) => formatMoney(row.original.unit_price_net, row.original.currency_code)
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
accessorKey: "total_net_amount",
|
|
293
|
+
header: t("billing.invoices.lines.columns.total", "Total net"),
|
|
294
|
+
cell: ({ row }) => formatMoney(row.original.total_net_amount, row.original.currency_code)
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
id: "actions",
|
|
298
|
+
header: "",
|
|
299
|
+
cell: ({ row }) => {
|
|
300
|
+
if (!canEditLines) return null;
|
|
301
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-1", children: [
|
|
302
|
+
/* @__PURE__ */ jsx(
|
|
303
|
+
IconButton,
|
|
304
|
+
{
|
|
305
|
+
type: "button",
|
|
306
|
+
variant: "ghost",
|
|
307
|
+
"aria-label": t("billing.invoices.lines.actions.edit", "Edit line"),
|
|
308
|
+
onClick: () => {
|
|
309
|
+
setDialogTargetLine(row.original);
|
|
310
|
+
setDialogMode("edit");
|
|
311
|
+
},
|
|
312
|
+
children: /* @__PURE__ */ jsx(Pencil, { size: 16 })
|
|
313
|
+
}
|
|
314
|
+
),
|
|
315
|
+
/* @__PURE__ */ jsx(
|
|
316
|
+
IconButton,
|
|
317
|
+
{
|
|
318
|
+
type: "button",
|
|
319
|
+
variant: "ghost",
|
|
320
|
+
"aria-label": t("billing.invoices.lines.actions.remove", "Remove line"),
|
|
321
|
+
onClick: () => void handleRemoveLine(row.original),
|
|
322
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 16 })
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
] });
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
[canEditLines, handleRemoveLine, t]
|
|
330
|
+
);
|
|
331
|
+
const dialogInitial = React.useMemo(() => {
|
|
332
|
+
if (dialogMode !== "edit" || !dialogTargetLine) return void 0;
|
|
333
|
+
return {
|
|
334
|
+
description: dialogTargetLine.description ?? "",
|
|
335
|
+
quantity: Number.parseFloat(dialogTargetLine.quantity),
|
|
336
|
+
unitPriceNet: Number.parseFloat(dialogTargetLine.unit_price_net)
|
|
337
|
+
};
|
|
338
|
+
}, [dialogMode, dialogTargetLine]);
|
|
339
|
+
if (error) {
|
|
340
|
+
return /* @__PURE__ */ jsxs(Page, { children: [
|
|
341
|
+
/* @__PURE__ */ jsx(PageHeader, { title: t("billing.invoices.detail.title", "Billing Invoice") }),
|
|
342
|
+
/* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(ErrorMessage, { label: error }) })
|
|
343
|
+
] });
|
|
344
|
+
}
|
|
345
|
+
if (loading || !invoice) {
|
|
346
|
+
return /* @__PURE__ */ jsxs(Page, { children: [
|
|
347
|
+
/* @__PURE__ */ jsx(PageHeader, { title: t("billing.invoices.detail.title", "Billing Invoice") }),
|
|
348
|
+
/* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(LoadingMessage, { label: t("billing.invoices.detail.loading", "Loading invoice\u2026") }) })
|
|
349
|
+
] });
|
|
350
|
+
}
|
|
351
|
+
const isTest = invoice.metadata?.test_run === true;
|
|
352
|
+
const isDraft = invoice.status === "draft";
|
|
353
|
+
return /* @__PURE__ */ jsxs(Page, { children: [
|
|
354
|
+
/* @__PURE__ */ jsx(
|
|
355
|
+
FormHeader,
|
|
356
|
+
{
|
|
357
|
+
mode: "detail",
|
|
358
|
+
backHref: "/backend/billing/invoices",
|
|
359
|
+
entityTypeLabel: t("billing.invoices.detail.title", "Billing Invoice"),
|
|
360
|
+
title: invoice.invoice_number,
|
|
361
|
+
statusBadge: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
362
|
+
/* @__PURE__ */ jsx(Tag, { variant: statusVariant(invoice.status), children: invoice.status ?? "\u2014" }),
|
|
363
|
+
isTest ? /* @__PURE__ */ jsx(Tag, { variant: "warning", children: "TEST" }) : null
|
|
364
|
+
] }),
|
|
365
|
+
actionsContent: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
366
|
+
isDraft && !isTest ? /* @__PURE__ */ jsx(Button, { onClick: handlePost, disabled: posting, children: posting ? t("billing.invoices.post.in_progress", "Posting\u2026") : t("billing.invoices.post.action", "Post invoice") }) : null,
|
|
367
|
+
isTest ? /* @__PURE__ */ jsx(
|
|
368
|
+
Button,
|
|
369
|
+
{
|
|
370
|
+
variant: "outline",
|
|
371
|
+
onClick: handleWipeTest,
|
|
372
|
+
disabled: wiping,
|
|
373
|
+
children: wiping ? t("billing.invoices.wipe.in_progress", "Wiping\u2026") : t("billing.invoices.wipe.action", "Wipe test invoices for this run")
|
|
374
|
+
}
|
|
375
|
+
) : null
|
|
376
|
+
] })
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
/* @__PURE__ */ jsxs(PageBody, { children: [
|
|
380
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
381
|
+
/* @__PURE__ */ jsxs(DetailCard, { children: [
|
|
382
|
+
/* @__PURE__ */ jsxs(DetailField, { label: t("billing.invoices.detail.field.period", "Bill period"), children: [
|
|
383
|
+
invoice.metadata?.bill_period_start ?? "\u2014",
|
|
384
|
+
" \u2192",
|
|
385
|
+
" ",
|
|
386
|
+
invoice.metadata?.bill_period_end ?? "\u2014"
|
|
387
|
+
] }),
|
|
388
|
+
/* @__PURE__ */ jsx(DetailField, { label: t("billing.invoices.detail.field.bill_run", "Bill Run"), children: invoice.metadata?.bill_run_id ? /* @__PURE__ */ jsx(
|
|
389
|
+
Link,
|
|
390
|
+
{
|
|
391
|
+
href: `/backend/billing/runs/${invoice.metadata.bill_run_id}`,
|
|
392
|
+
className: "text-primary hover:underline",
|
|
393
|
+
children: runName ?? invoice.metadata.bill_run_id
|
|
394
|
+
}
|
|
395
|
+
) : "\u2014" }),
|
|
396
|
+
/* @__PURE__ */ jsx(
|
|
397
|
+
DetailField,
|
|
398
|
+
{
|
|
399
|
+
label: t("billing.invoices.detail.field.account", "Billing Account"),
|
|
400
|
+
children: invoice.metadata?.bill_account_id ? /* @__PURE__ */ jsx(
|
|
401
|
+
Link,
|
|
402
|
+
{
|
|
403
|
+
href: `/backend/billing/accounts/${invoice.metadata.bill_account_id}`,
|
|
404
|
+
className: "text-primary hover:underline",
|
|
405
|
+
children: accountName ?? invoice.metadata.bill_account_id
|
|
406
|
+
}
|
|
407
|
+
) : "\u2014"
|
|
408
|
+
}
|
|
409
|
+
),
|
|
410
|
+
/* @__PURE__ */ jsx(DetailField, { label: t("billing.invoices.detail.field.issued", "Issued"), children: invoice.issue_date?.slice(0, 10) ?? "\u2014" }),
|
|
411
|
+
/* @__PURE__ */ jsx(DetailField, { label: t("billing.common.id", "ID"), children: /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: invoice.id }) })
|
|
412
|
+
] }),
|
|
413
|
+
/* @__PURE__ */ jsxs(StatCard, { children: [
|
|
414
|
+
/* @__PURE__ */ jsx(
|
|
415
|
+
Stat,
|
|
416
|
+
{
|
|
417
|
+
label: t("billing.invoices.detail.subtotal", "Subtotal net"),
|
|
418
|
+
value: formatMoney(invoice.subtotal_net_amount, invoice.currency_code)
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
/* @__PURE__ */ jsx(
|
|
422
|
+
Stat,
|
|
423
|
+
{
|
|
424
|
+
label: t("billing.invoices.detail.total", "Grand total"),
|
|
425
|
+
value: formatMoney(invoice.grand_total_gross_amount, invoice.currency_code)
|
|
426
|
+
}
|
|
427
|
+
),
|
|
428
|
+
/* @__PURE__ */ jsx(
|
|
429
|
+
Stat,
|
|
430
|
+
{
|
|
431
|
+
label: t("billing.invoices.detail.paid", "Paid"),
|
|
432
|
+
value: formatMoney(invoice.paid_total_amount, invoice.currency_code)
|
|
433
|
+
}
|
|
434
|
+
),
|
|
435
|
+
/* @__PURE__ */ jsx(
|
|
436
|
+
Stat,
|
|
437
|
+
{
|
|
438
|
+
label: t("billing.invoices.detail.outstanding", "Outstanding"),
|
|
439
|
+
value: formatMoney(invoice.outstanding_amount, invoice.currency_code)
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
] }),
|
|
443
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
444
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-2", children: [
|
|
445
|
+
/* @__PURE__ */ jsx("h2", { className: "text-base font-semibold", children: t("billing.invoices.lines.title", "Lines") }),
|
|
446
|
+
canEditLines ? /* @__PURE__ */ jsxs(
|
|
447
|
+
Button,
|
|
448
|
+
{
|
|
449
|
+
type: "button",
|
|
450
|
+
variant: "outline",
|
|
451
|
+
onClick: () => {
|
|
452
|
+
setDialogTargetLine(null);
|
|
453
|
+
setDialogMode("add");
|
|
454
|
+
},
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ jsx(Plus, { size: 16 }),
|
|
457
|
+
t("billing.invoices.lines.add.action", "Add line")
|
|
458
|
+
]
|
|
459
|
+
}
|
|
460
|
+
) : null
|
|
461
|
+
] }),
|
|
462
|
+
/* @__PURE__ */ jsx(
|
|
463
|
+
DataTable,
|
|
464
|
+
{
|
|
465
|
+
columns: lineColumns,
|
|
466
|
+
data: visibleLines,
|
|
467
|
+
isLoading: false,
|
|
468
|
+
pagination: {
|
|
469
|
+
page: linesPage,
|
|
470
|
+
pageSize: linesPageSize,
|
|
471
|
+
total: lines.length,
|
|
472
|
+
totalPages: linesTotalPages,
|
|
473
|
+
onPageChange: setLinesPage
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
)
|
|
477
|
+
] })
|
|
478
|
+
] }),
|
|
479
|
+
/* @__PURE__ */ jsx(
|
|
480
|
+
LineFormDialog,
|
|
481
|
+
{
|
|
482
|
+
open: dialogMode !== null,
|
|
483
|
+
mode: dialogMode ?? "add",
|
|
484
|
+
initial: dialogInitial,
|
|
485
|
+
submitting: dialogSubmitting,
|
|
486
|
+
onCancel: () => {
|
|
487
|
+
setDialogMode(null);
|
|
488
|
+
setDialogTargetLine(null);
|
|
489
|
+
},
|
|
490
|
+
onSubmit: handleSubmitLine
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
ConfirmDialogElement
|
|
494
|
+
] })
|
|
495
|
+
] });
|
|
496
|
+
}
|
|
497
|
+
export {
|
|
498
|
+
BillingInvoiceDetailPage as default
|
|
499
|
+
};
|
|
500
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/billing/backend/billing/invoices/%5Bid%5D/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useParams } from 'next/navigation'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { Pencil, Plus, Trash2 } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody, PageHeader } from '@open-mercato/ui/backend/Page'\nimport { FormHeader } from '@open-mercato/ui/backend/forms'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport {\n apiCallOrThrow,\n readApiResultOrThrow,\n} from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { LineFormDialog, type LineFormValues } from '../../../../components/LineFormDialog'\nimport {\n DetailCard,\n DetailField,\n Stat,\n StatCard,\n} from '../../../../components/DetailFields'\nimport { billRunName } from '../../../../lib/billRunLabel'\n\ntype BillingInvoice = {\n id: string\n invoice_number: string\n status: 'draft' | 'posted' | 'paid' | 'void' | null\n currency_code: string\n issue_date: string | null\n due_date: string | null\n subtotal_net_amount: string\n grand_total_net_amount: string\n grand_total_gross_amount: string\n paid_total_amount: string\n outstanding_amount: string\n metadata: {\n bill_run_id?: string\n bill_account_id?: string\n bill_period_start?: string\n bill_period_end?: string\n test_run?: boolean\n } | null\n created_at: string\n updated_at: string\n}\n\ntype InvoiceLine = {\n id: string\n line_number: number\n kind: string\n description: string | null\n quantity: string\n currency_code: string\n unit_price_net: string\n total_net_amount: string\n total_gross_amount: string\n metadata: {\n billing_item_id?: string\n billing_type?: 'one_time' | 'recurring' | 'usage'\n operator_added?: boolean\n usage_tier_breakdown?: unknown\n } | null\n}\n\ntype DetailResponse = {\n invoice: BillingInvoice\n lines: InvoiceLine[]\n}\n\nfunction statusVariant(\n status: BillingInvoice['status'],\n): 'default' | 'success' | 'warning' | 'error' {\n switch (status) {\n case 'paid':\n return 'success'\n case 'posted':\n return 'warning'\n case 'void':\n return 'error'\n case 'draft':\n default:\n return 'default'\n }\n}\n\nfunction lineKindVariant(\n type: InvoiceLine['metadata'] extends infer M\n ? M extends { billing_type?: infer T }\n ? T\n : never\n : never,\n): 'default' | 'success' | 'warning' | 'error' {\n switch (type) {\n case 'one_time':\n return 'warning'\n case 'recurring':\n return 'success'\n case 'usage':\n return 'default'\n default:\n return 'default'\n }\n}\n\nfunction formatMoney(value: string, currency: string): string {\n const n = Number.parseFloat(value)\n if (!Number.isFinite(n)) return value\n try {\n return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(n)\n } catch {\n return `${value} ${currency}`\n }\n}\n\nexport default function BillingInvoiceDetailPage(props: { params?: { id?: string } }) {\n const t = useT()\n // OM serves backend pages through a catch-all route \u2014 the dynamic\n // `[id]` segment arrives as a page prop; `useParams()` is the fallback.\n const urlParams = useParams<{ id: string }>()\n const invoiceId = (props.params?.id ?? urlParams?.id ?? '') as string\n\n const [invoice, setInvoice] = React.useState<BillingInvoice | null>(null)\n const [lines, setLines] = React.useState<InvoiceLine[]>([])\n // Bill Run + Billing Account are stored as FK ids in invoice metadata;\n // resolve their human names so the detail card shows names, not UUIDs.\n const [accountName, setAccountName] = React.useState<string | null>(null)\n const [runName, setRunName] = React.useState<string | null>(null)\n const [error, setError] = React.useState<string | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [posting, setPosting] = React.useState(false)\n const [wiping, setWiping] = React.useState(false)\n\n // Client-side pagination for invoice lines. Caps the table at 100 rows\n // per page (per the OM DataTable convention) \u2014 invoices typically have\n // <20 lines, but bulk import or a long-running usage-rated subscription\n // can exceed that.\n const [linesPage, setLinesPage] = React.useState(1)\n const linesPageSize = 100\n const visibleLines = React.useMemo(\n () => lines.slice((linesPage - 1) * linesPageSize, linesPage * linesPageSize),\n [lines, linesPage],\n )\n const linesTotalPages = Math.max(1, Math.ceil(lines.length / linesPageSize))\n\n // Inline line-edit dialog state. `dialogMode === null` \u2192 closed.\n const [dialogMode, setDialogMode] = React.useState<'add' | 'edit' | null>(null)\n const [dialogTargetLine, setDialogTargetLine] = React.useState<InvoiceLine | null>(null)\n const [dialogSubmitting, setDialogSubmitting] = React.useState(false)\n\n // Confirm flows: wipe-test + remove-line both use ConfirmDialog\n // (per UI AGENTS.md: NEVER `window.confirm`).\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n\n const load = React.useCallback(async () => {\n if (!invoiceId) return\n setError(null)\n setLoading(true)\n try {\n const data = await readApiResultOrThrow<DetailResponse>(\n `/api/billing/invoices/${invoiceId}`,\n )\n setInvoice(data.invoice)\n setLines(data.lines ?? [])\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n setError(message || t('billing.invoices.detail.error.load', 'Failed to load invoice'))\n } finally {\n setLoading(false)\n }\n }, [invoiceId, t])\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n // Resolve the FK names once the invoice is loaded (one bounded\n // request each \u2014 Bill Run name is derived from its as-of date).\n const billRunId = invoice?.metadata?.bill_run_id\n const billAccountId = invoice?.metadata?.bill_account_id\n React.useEffect(() => {\n if (billAccountId) {\n readApiResultOrThrow<{ items: Array<{ name: string }> }>(\n `/api/billing/accounts?id=${billAccountId}&pageSize=1`,\n )\n .then((r) => setAccountName(r.items?.[0]?.name ?? null))\n .catch(() => setAccountName(null))\n }\n if (billRunId) {\n readApiResultOrThrow<{ items: Array<{ as_of_date: string }> }>(\n `/api/billing/runs?id=${billRunId}&pageSize=1`,\n )\n .then((r) => {\n const asOf = r.items?.[0]?.as_of_date\n setRunName(asOf ? billRunName(asOf) : null)\n })\n .catch(() => setRunName(null))\n }\n }, [billAccountId, billRunId])\n\n const handlePost = React.useCallback(async () => {\n if (!invoice) return\n setPosting(true)\n try {\n const call = await apiCallOrThrow<{ status: string; invoiceNumber: string }>(\n '/api/billing/invoices/post',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ invoiceId: invoice.id }),\n },\n )\n flash(\n t('billing.invoices.post.success', 'Invoice posted') +\n ` (${call.result?.invoiceNumber ?? invoice.invoice_number})`,\n 'success',\n )\n void load()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.invoices.post.error', 'Post failed'), 'error')\n } finally {\n setPosting(false)\n }\n }, [invoice, load, t])\n\n const handleWipeTest = React.useCallback(async () => {\n if (!invoice) return\n const ok = await confirm({\n title: t('billing.invoices.wipe.confirm.title', 'Wipe test invoices?'),\n text: t(\n 'billing.invoices.wipe.confirm.text',\n 'Every test invoice from this Bill Run will be permanently deleted. This cannot be undone.',\n ),\n confirmText: t('billing.invoices.wipe.confirm.button', 'Delete test invoices'),\n variant: 'destructive',\n })\n if (!ok) return\n setWiping(true)\n try {\n const billRunId = invoice.metadata?.bill_run_id\n const call = await apiCallOrThrow<{ invoicesRemoved: number }>(\n '/api/billing/test-invoices/wipe',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(billRunId ? { billRunId } : {}),\n },\n )\n flash(\n t('billing.invoices.wipe.success', 'Test invoices removed') +\n ` (${call.result?.invoicesRemoved ?? 0})`,\n 'success',\n )\n // The invoice we were looking at is hard-deleted \u2014 navigate away\n // on success by reloading; the detail load will 404 and the\n // user clicks back.\n void load()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.invoices.wipe.error', 'Wipe failed'), 'error')\n } finally {\n setWiping(false)\n }\n }, [confirm, invoice, load, t])\n\n // \u2500\u2500\u2500 Line add / edit / remove \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n const handleSubmitLine = React.useCallback(\n async (values: LineFormValues) => {\n if (!invoice) return\n setDialogSubmitting(true)\n try {\n if (dialogMode === 'add') {\n await apiCallOrThrow('/api/billing/invoices/add-line', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n invoiceId: invoice.id,\n description: values.description,\n quantity: values.quantity,\n unitPriceNet: values.unitPriceNet,\n }),\n })\n flash(t('billing.invoices.lines.add.success', 'Line added'), 'success')\n } else if (dialogMode === 'edit' && dialogTargetLine) {\n await apiCallOrThrow('/api/billing/invoices/edit-line', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n invoiceId: invoice.id,\n invoiceLineId: dialogTargetLine.id,\n changes: {\n description: values.description,\n quantity: values.quantity,\n unitPriceNet: values.unitPriceNet,\n ...(values.totalNetAmount !== undefined\n ? { totalNetAmount: values.totalNetAmount }\n : {}),\n },\n }),\n })\n flash(t('billing.invoices.lines.edit.success', 'Line updated'), 'success')\n }\n setDialogMode(null)\n setDialogTargetLine(null)\n void load()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.invoices.lines.save.error', 'Save failed'), 'error')\n } finally {\n setDialogSubmitting(false)\n }\n },\n [dialogMode, dialogTargetLine, invoice, load, t],\n )\n\n const handleRemoveLine = React.useCallback(\n async (line: InvoiceLine) => {\n if (!invoice) return\n const ok = await confirm({\n title: t('billing.invoices.lines.remove.confirm.title', 'Remove line?'),\n text: t(\n 'billing.invoices.lines.remove.confirm.text',\n 'The line will be deleted and recorded in the draft-edit audit log.',\n ),\n confirmText: t('billing.invoices.lines.remove.confirm.button', 'Remove line'),\n variant: 'destructive',\n })\n if (!ok) return\n try {\n await apiCallOrThrow('/api/billing/invoices/remove-line', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n invoiceId: invoice.id,\n invoiceLineId: line.id,\n }),\n })\n flash(t('billing.invoices.lines.remove.success', 'Line removed'), 'success')\n void load()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.invoices.lines.remove.error', 'Remove failed'), 'error')\n }\n },\n [confirm, invoice, load, t],\n )\n\n const canEditLines = invoice?.status === 'draft'\n\n const lineColumns = React.useMemo<ColumnDef<InvoiceLine>[]>(\n () => [\n {\n accessorKey: 'line_number',\n header: '#',\n },\n {\n accessorKey: 'description',\n header: t('billing.invoices.lines.columns.description', 'Description'),\n cell: ({ row }) => {\n const type = row.original.metadata?.billing_type\n const operatorAdded = row.original.metadata?.operator_added === true\n return (\n <div className=\"flex flex-col gap-1\">\n <span>{row.original.description ?? '\u2014'}</span>\n <div className=\"flex items-center gap-1 flex-wrap\">\n {type ? <Tag variant={lineKindVariant(type)}>{type}</Tag> : null}\n {operatorAdded ? (\n <Tag variant=\"info\">\n {t('billing.invoices.lines.operator_added', 'Operator-added')}\n </Tag>\n ) : null}\n </div>\n </div>\n )\n },\n },\n {\n accessorKey: 'quantity',\n header: t('billing.invoices.lines.columns.quantity', 'Qty'),\n },\n {\n accessorKey: 'unit_price_net',\n header: t('billing.invoices.lines.columns.unit_price', 'Unit price'),\n cell: ({ row }) =>\n formatMoney(row.original.unit_price_net, row.original.currency_code),\n },\n {\n accessorKey: 'total_net_amount',\n header: t('billing.invoices.lines.columns.total', 'Total net'),\n cell: ({ row }) =>\n formatMoney(row.original.total_net_amount, row.original.currency_code),\n },\n {\n id: 'actions',\n header: '',\n cell: ({ row }) => {\n if (!canEditLines) return null\n return (\n <div className=\"flex items-center justify-end gap-1\">\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n aria-label={t('billing.invoices.lines.actions.edit', 'Edit line')}\n onClick={() => {\n setDialogTargetLine(row.original)\n setDialogMode('edit')\n }}\n >\n <Pencil size={16} />\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n aria-label={t('billing.invoices.lines.actions.remove', 'Remove line')}\n onClick={() => void handleRemoveLine(row.original)}\n >\n <Trash2 size={16} />\n </IconButton>\n </div>\n )\n },\n },\n ],\n [canEditLines, handleRemoveLine, t],\n )\n\n const dialogInitial = React.useMemo<Partial<LineFormValues> | undefined>(() => {\n if (dialogMode !== 'edit' || !dialogTargetLine) return undefined\n return {\n description: dialogTargetLine.description ?? '',\n quantity: Number.parseFloat(dialogTargetLine.quantity),\n unitPriceNet: Number.parseFloat(dialogTargetLine.unit_price_net),\n }\n }, [dialogMode, dialogTargetLine])\n\n if (error) {\n return (\n <Page>\n <PageHeader title={t('billing.invoices.detail.title', 'Billing Invoice')} />\n <PageBody>\n <ErrorMessage label={error} />\n </PageBody>\n </Page>\n )\n }\n if (loading || !invoice) {\n return (\n <Page>\n <PageHeader title={t('billing.invoices.detail.title', 'Billing Invoice')} />\n <PageBody>\n <LoadingMessage label={t('billing.invoices.detail.loading', 'Loading invoice\u2026')} />\n </PageBody>\n </Page>\n )\n }\n\n const isTest = invoice.metadata?.test_run === true\n const isDraft = invoice.status === 'draft'\n\n return (\n <Page>\n <FormHeader\n mode=\"detail\"\n backHref=\"/backend/billing/invoices\"\n entityTypeLabel={t('billing.invoices.detail.title', 'Billing Invoice')}\n title={invoice.invoice_number}\n statusBadge={\n <div className=\"flex items-center gap-2 flex-wrap\">\n <Tag variant={statusVariant(invoice.status)}>{invoice.status ?? '\u2014'}</Tag>\n {isTest ? <Tag variant=\"warning\">TEST</Tag> : null}\n </div>\n }\n actionsContent={\n <>\n {isDraft && !isTest ? (\n <Button onClick={handlePost} disabled={posting}>\n {posting\n ? t('billing.invoices.post.in_progress', 'Posting\u2026')\n : t('billing.invoices.post.action', 'Post invoice')}\n </Button>\n ) : null}\n {isTest ? (\n <Button\n variant=\"outline\"\n onClick={handleWipeTest}\n disabled={wiping}\n >\n {wiping\n ? t('billing.invoices.wipe.in_progress', 'Wiping\u2026')\n : t('billing.invoices.wipe.action', 'Wipe test invoices for this run')}\n </Button>\n ) : null}\n </>\n }\n />\n <PageBody>\n <div className=\"space-y-6\">\n <DetailCard>\n <DetailField label={t('billing.invoices.detail.field.period', 'Bill period')}>\n {invoice.metadata?.bill_period_start ?? '\u2014'} \u2192{' '}\n {invoice.metadata?.bill_period_end ?? '\u2014'}\n </DetailField>\n <DetailField label={t('billing.invoices.detail.field.bill_run', 'Bill Run')}>\n {invoice.metadata?.bill_run_id ? (\n <Link\n href={`/backend/billing/runs/${invoice.metadata.bill_run_id}`}\n className=\"text-primary hover:underline\"\n >\n {runName ?? invoice.metadata.bill_run_id}\n </Link>\n ) : (\n '\u2014'\n )}\n </DetailField>\n <DetailField\n label={t('billing.invoices.detail.field.account', 'Billing Account')}\n >\n {invoice.metadata?.bill_account_id ? (\n <Link\n href={`/backend/billing/accounts/${invoice.metadata.bill_account_id}`}\n className=\"text-primary hover:underline\"\n >\n {accountName ?? invoice.metadata.bill_account_id}\n </Link>\n ) : (\n '\u2014'\n )}\n </DetailField>\n <DetailField label={t('billing.invoices.detail.field.issued', 'Issued')}>\n {invoice.issue_date?.slice(0, 10) ?? '\u2014'}\n </DetailField>\n <DetailField label={t('billing.common.id', 'ID')}>\n <span className=\"font-mono text-xs\">{invoice.id}</span>\n </DetailField>\n </DetailCard>\n\n <StatCard>\n <Stat\n label={t('billing.invoices.detail.subtotal', 'Subtotal net')}\n value={formatMoney(invoice.subtotal_net_amount, invoice.currency_code)}\n />\n <Stat\n label={t('billing.invoices.detail.total', 'Grand total')}\n value={formatMoney(invoice.grand_total_gross_amount, invoice.currency_code)}\n />\n <Stat\n label={t('billing.invoices.detail.paid', 'Paid')}\n value={formatMoney(invoice.paid_total_amount, invoice.currency_code)}\n />\n <Stat\n label={t('billing.invoices.detail.outstanding', 'Outstanding')}\n value={formatMoney(invoice.outstanding_amount, invoice.currency_code)}\n />\n </StatCard>\n\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <h2 className=\"text-base font-semibold\">\n {t('billing.invoices.lines.title', 'Lines')}\n </h2>\n {canEditLines ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n setDialogTargetLine(null)\n setDialogMode('add')\n }}\n >\n <Plus size={16} />\n {t('billing.invoices.lines.add.action', 'Add line')}\n </Button>\n ) : null}\n </div>\n <DataTable\n columns={lineColumns}\n data={visibleLines}\n isLoading={false}\n pagination={{\n page: linesPage,\n pageSize: linesPageSize,\n total: lines.length,\n totalPages: linesTotalPages,\n onPageChange: setLinesPage,\n }}\n />\n </div>\n </div>\n\n <LineFormDialog\n open={dialogMode !== null}\n mode={dialogMode ?? 'add'}\n initial={dialogInitial}\n submitting={dialogSubmitting}\n onCancel={() => {\n setDialogMode(null)\n setDialogTargetLine(null)\n }}\n onSubmit={handleSubmitLine}\n />\n {ConfirmDialogElement}\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAmXc,SA8GJ,UA9GI,KACA,YADA;AAlXd,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAE1B,SAAS,QAAQ,MAAM,cAAc;AACrC,SAAS,YAAY;AACrB,SAAS,MAAM,UAAU,kBAAkB;AAC3C,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,WAAW;AACpB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB,oBAAoB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,oBAAoB,QAAQ,aAAa;AAAA;AAAA,UACtE;AAAA,WACF;AAAA,QAEA,qBAAC,SACC;AAAA,+BAAC,SAAI,WAAU,0CACb;AAAA,gCAAC,QAAG,WAAU,2BACX,YAAE,gCAAgC,OAAO,GAC5C;AAAA,YACC,eACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,SAAS,MAAM;AACb,sCAAoB,IAAI;AACxB,gCAAc,KAAK;AAAA,gBACrB;AAAA,gBAEA;AAAA,sCAAC,QAAK,MAAM,IAAI;AAAA,kBACf,EAAE,qCAAqC,UAAU;AAAA;AAAA;AAAA,YACpD,IACE;AAAA,aACN;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,SAAS;AAAA,cACT,MAAM;AAAA,cACN,WAAW;AAAA,cACX,YAAY;AAAA,gBACV,MAAM;AAAA,gBACN,UAAU;AAAA,gBACV,OAAO,MAAM;AAAA,gBACb,YAAY;AAAA,gBACZ,cAAc;AAAA,cAChB;AAAA;AAAA,UACF;AAAA,WACF;AAAA,SACF;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,eAAe;AAAA,UACrB,MAAM,cAAc;AAAA,UACpB,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,UAAU,MAAM;AACd,0BAAc,IAAI;AAClB,gCAAoB,IAAI;AAAA,UAC1B;AAAA,UACA,UAAU;AAAA;AAAA,MACZ;AAAA,MACC;AAAA,OACH;AAAA,KACF;AAEJ;",
|
|
6
|
+
"names": ["billRunId"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FileText } from "lucide-react";
|
|
3
|
+
const invoiceIcon = React.createElement(FileText, { size: 16 });
|
|
4
|
+
const metadata = {
|
|
5
|
+
requireAuth: true,
|
|
6
|
+
requireFeatures: ["billing.invoice.view"],
|
|
7
|
+
pageTitle: "Billing Invoice",
|
|
8
|
+
pageTitleKey: "billing.invoices.detail.title",
|
|
9
|
+
pageGroup: "Billing",
|
|
10
|
+
pageGroupKey: "billing.nav.group",
|
|
11
|
+
navHidden: true,
|
|
12
|
+
icon: invoiceIcon,
|
|
13
|
+
breadcrumb: [
|
|
14
|
+
{
|
|
15
|
+
label: "Billing Invoices",
|
|
16
|
+
labelKey: "billing.invoices.title",
|
|
17
|
+
href: "/backend/billing/invoices"
|
|
18
|
+
},
|
|
19
|
+
{ label: "Invoice", labelKey: "billing.invoices.detail.title" }
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
metadata
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=page.meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/billing/backend/billing/invoices/%5Bid%5D/page.meta.ts"],
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { FileText } from 'lucide-react'\n\nconst invoiceIcon = React.createElement(FileText, { size: 16 })\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['billing.invoice.view'],\n pageTitle: 'Billing Invoice',\n pageTitleKey: 'billing.invoices.detail.title',\n pageGroup: 'Billing',\n pageGroupKey: 'billing.nav.group',\n navHidden: true,\n icon: invoiceIcon,\n breadcrumb: [\n {\n label: 'Billing Invoices',\n labelKey: 'billing.invoices.title',\n href: '/backend/billing/invoices',\n },\n { label: 'Invoice', labelKey: 'billing.invoices.detail.title' },\n ],\n} as const\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AAEzB,MAAM,cAAc,MAAM,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAEvD,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,sBAAsB;AAAA,EACxC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,MACE,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,EAAE,OAAO,WAAW,UAAU,gCAAgC;AAAA,EAChE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|