@powerhousedao/contributor-billing 0.1.53 → 1.0.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document-models/account-transactions/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/account-transactions/gen/schema/zod.js +3 -3
- package/dist/document-models/account-transactions/module.d.ts +1 -1
- package/dist/document-models/account-transactions/module.d.ts.map +1 -1
- package/dist/document-models/account-transactions/module.js +1 -1
- package/dist/document-models/accounts/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/accounts/module.d.ts +1 -1
- package/dist/document-models/accounts/module.d.ts.map +1 -1
- package/dist/document-models/accounts/module.js +1 -1
- package/dist/document-models/billing-statement/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/billing-statement/gen/schema/zod.js +4 -4
- package/dist/document-models/billing-statement/module.d.ts +1 -1
- package/dist/document-models/billing-statement/module.d.ts.map +1 -1
- package/dist/document-models/billing-statement/module.js +1 -1
- package/dist/document-models/expense-report/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/expense-report/gen/schema/zod.js +38 -18
- package/dist/document-models/expense-report/module.d.ts +1 -1
- package/dist/document-models/expense-report/module.d.ts.map +1 -1
- package/dist/document-models/expense-report/module.js +1 -1
- package/dist/document-models/invoice/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/document-model.js +150 -150
- package/dist/document-models/invoice/gen/schema/types.d.ts +3 -6
- package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/schema/zod.d.ts +2 -8
- package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/invoice/gen/schema/zod.js +14 -25
- package/dist/document-models/invoice/module.d.ts +1 -1
- package/dist/document-models/invoice/module.d.ts.map +1 -1
- package/dist/document-models/invoice/module.js +1 -1
- package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/items.js +2 -1
- package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/parties.js +6 -2
- package/dist/document-models/invoice/src/reducers/transitions.d.ts +0 -5
- package/dist/document-models/invoice/src/reducers/transitions.d.ts.map +1 -1
- package/dist/document-models/invoice/src/reducers/transitions.js +12 -6
- package/dist/document-models/invoice/tests/general.test.js +1 -1
- package/dist/document-models/invoice/tests/items.test.js +1 -1
- package/dist/document-models/invoice/tests/parties.test.js +1 -1
- package/dist/document-models/invoice/tests/transitions.test.js +1 -1
- package/dist/document-models/operational-hub-profile/module.d.ts +1 -1
- package/dist/document-models/operational-hub-profile/module.d.ts.map +1 -1
- package/dist/document-models/operational-hub-profile/module.js +1 -1
- package/dist/document-models/snapshot-report/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/snapshot-report/gen/schema/zod.js +12 -12
- package/dist/document-models/snapshot-report/module.d.ts +1 -1
- package/dist/document-models/snapshot-report/module.d.ts.map +1 -1
- package/dist/document-models/snapshot-report/module.js +1 -1
- package/dist/editors/accounts-editor/editor.d.ts.map +1 -1
- package/dist/editors/accounts-editor/editor.js +2 -2
- package/dist/editors/contributor-billing/components/DocumentDropZone.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DocumentDropZone.js +37 -8
- package/dist/editors/contributor-billing/components/DriveContents.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DriveContents.js +4 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/DriveExplorer.js +2 -2
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +2 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +41 -6
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +16 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableContainer.d.ts +3 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableContainer.d.ts.map +1 -1
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableContainer.js +13 -11
- package/dist/editors/contributor-billing/components/ToastRenderer.d.ts +2 -0
- package/dist/editors/contributor-billing/components/ToastRenderer.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/ToastRenderer.js +14 -0
- package/dist/editors/contributor-billing/components/cbToast.d.ts +16 -0
- package/dist/editors/contributor-billing/components/cbToast.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/cbToast.js +29 -0
- package/dist/editors/invoice/InvoicePDF.d.ts.map +1 -1
- package/dist/editors/invoice/InvoicePDF.js +12 -9
- package/dist/editors/invoice/editor.d.ts.map +1 -1
- package/dist/editors/invoice/editor.js +3 -8
- package/dist/editors/invoice/exportUBL.d.ts.map +1 -1
- package/dist/editors/invoice/exportUBL.js +1 -2
- package/dist/editors/invoice/ingestPDF.js +1 -1
- package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -1
- package/dist/editors/invoice/invoiceToGnosis.js +25 -22
- package/dist/editors/invoice/invoiceToast.d.ts +4 -0
- package/dist/editors/invoice/invoiceToast.d.ts.map +1 -0
- package/dist/editors/invoice/invoiceToast.js +6 -0
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -1
- package/dist/editors/invoice/legalEntity/legalEntity.js +1 -12
- package/dist/editors/invoice/lineItems.js +1 -1
- package/dist/editors/invoice/requestFinance.d.ts +3 -2
- package/dist/editors/invoice/requestFinance.d.ts.map +1 -1
- package/dist/editors/invoice/requestFinance.js +38 -42
- package/dist/editors/invoice/validation/validationHandler.js +1 -1
- package/dist/scripts/download-all-drive-documents/download-drive-documents.d.ts +33 -0
- package/dist/scripts/download-all-drive-documents/download-drive-documents.d.ts.map +1 -0
- package/dist/scripts/download-all-drive-documents/download-drive-documents.js +583 -0
- package/dist/scripts/invoice/requestFinance.d.ts +18 -1
- package/dist/scripts/invoice/requestFinance.d.ts.map +1 -1
- package/dist/scripts/invoice/requestFinance.js +17 -5
- package/dist/scripts/upload-phd-documents/upload-phd-documents.d.ts +20 -0
- package/dist/scripts/upload-phd-documents/upload-phd-documents.d.ts.map +1 -0
- package/dist/scripts/upload-phd-documents/upload-phd-documents.js +313 -0
- package/dist/style.css +21 -0
- package/dist/subgraphs/invoice-addon/customResolvers.d.ts +70 -11
- package/dist/subgraphs/invoice-addon/customResolvers.d.ts.map +1 -1
- package/dist/subgraphs/invoice-addon/customResolvers.js +12 -27
- package/package.json +33 -26
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts +0 -10
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts.map +0 -1
- package/dist/document-models/invoice/src/tests/document-model.test.js +0 -104
- package/dist/document-models/invoice/src/tests/general.test.d.ts +0 -6
- package/dist/document-models/invoice/src/tests/general.test.d.ts.map +0 -1
- package/dist/document-models/invoice/src/tests/general.test.js +0 -49
- package/dist/document-models/invoice/src/tests/items.test.d.ts +0 -6
- package/dist/document-models/invoice/src/tests/items.test.d.ts.map +0 -1
- package/dist/document-models/invoice/src/tests/items.test.js +0 -59
- package/dist/document-models/invoice/src/tests/parties.test.d.ts +0 -6
- package/dist/document-models/invoice/src/tests/parties.test.d.ts.map +0 -1
- package/dist/document-models/invoice/src/tests/parties.test.js +0 -69
- package/dist/document-models/invoice/src/tests/transitions.test.d.ts +0 -6
- package/dist/document-models/invoice/src/tests/transitions.test.d.ts.map +0 -1
- package/dist/document-models/invoice/src/tests/transitions.test.js +0 -59
- package/dist/document-models/invoice/utils/statusTransitions.d.ts +0 -13
- package/dist/document-models/invoice/utils/statusTransitions.d.ts.map +0 -1
- package/dist/document-models/invoice/utils/statusTransitions.js +0 -13
- package/dist/editors/builder-team-admin/components/overview/SubscriptionsStats.d.ts +0 -15
- package/dist/editors/builder-team-admin/components/overview/SubscriptionsStats.d.ts.map +0 -1
- package/dist/editors/builder-team-admin/components/overview/SubscriptionsStats.js +0 -61
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/contributor-billing",
|
|
3
3
|
"description": "Document models that help contributors of open organisations get paid anonymously for their work on a monthly basis.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0-dev.3",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/powerhouse-inc/contributor-billing"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"files": [
|
|
8
12
|
"/dist"
|
|
@@ -52,7 +56,7 @@
|
|
|
52
56
|
"lint:fix": "npm run lint -- --fix",
|
|
53
57
|
"tsc": "tsc",
|
|
54
58
|
"tsc:watch": "tsc --watch",
|
|
55
|
-
"tailwind": "
|
|
59
|
+
"tailwind": "bunx tailwindcss -i ./style.css -o ./dist/style.css",
|
|
56
60
|
"prepublishOnly": "npm run build",
|
|
57
61
|
"check-circular-imports": "npx dpdm -T ./index.ts",
|
|
58
62
|
"generate": "ph-cli generate",
|
|
@@ -65,13 +69,13 @@
|
|
|
65
69
|
"migrate": "ph-cli migrate"
|
|
66
70
|
},
|
|
67
71
|
"dependencies": {
|
|
68
|
-
"@powerhousedao/builder-profile": "
|
|
69
|
-
"@powerhousedao/builder-tools": "5.3.
|
|
70
|
-
"@powerhousedao/common": "5.3.
|
|
71
|
-
"@powerhousedao/design-system": "5.3.
|
|
72
|
-
"@powerhousedao/document-engineering": "^1.40.
|
|
72
|
+
"@powerhousedao/builder-profile": "1.0.2",
|
|
73
|
+
"@powerhousedao/builder-tools": "5.3.2",
|
|
74
|
+
"@powerhousedao/common": "5.3.2",
|
|
75
|
+
"@powerhousedao/design-system": "5.3.2",
|
|
76
|
+
"@powerhousedao/document-engineering": "^1.40.1",
|
|
73
77
|
"@powerhousedao/service-offering": "^0.0.1",
|
|
74
|
-
"@powerhousedao/vetra": "^5.3.
|
|
78
|
+
"@powerhousedao/vetra": "^5.3.2",
|
|
75
79
|
"@react-pdf/renderer": "^4.3.1",
|
|
76
80
|
"@safe-global/api-kit": "^4.0.0",
|
|
77
81
|
"@safe-global/protocol-kit": "^6.0.3",
|
|
@@ -80,7 +84,7 @@
|
|
|
80
84
|
"@types/cors": "^2.8.17",
|
|
81
85
|
"axios": "^1.9.0",
|
|
82
86
|
"cors": "^2.8.5",
|
|
83
|
-
"document-model": "5.3.
|
|
87
|
+
"document-model": "5.3.2",
|
|
84
88
|
"dotenv": "^16.5.0",
|
|
85
89
|
"error": "^10.4.0",
|
|
86
90
|
"ethers": "^6.14.0",
|
|
@@ -96,22 +100,22 @@
|
|
|
96
100
|
"@electric-sql/pglite": "^0.2.12",
|
|
97
101
|
"@eslint/js": "^9.38.0",
|
|
98
102
|
"@powerhousedao/analytics-engine-core": "^0.5.0",
|
|
99
|
-
"@powerhousedao/codegen": "5.3.
|
|
100
|
-
"@powerhousedao/config": "5.3.
|
|
101
|
-
"@powerhousedao/connect": "5.3.
|
|
102
|
-
"@powerhousedao/ph-cli": "5.3.
|
|
103
|
-
"@powerhousedao/reactor-api": "5.3.
|
|
104
|
-
"@powerhousedao/reactor-browser": "5.3.
|
|
105
|
-
"@powerhousedao/reactor-local": "5.3.
|
|
106
|
-
"@powerhousedao/scalars": "
|
|
107
|
-
"@powerhousedao/switchboard": "5.3.
|
|
103
|
+
"@powerhousedao/codegen": "5.3.2",
|
|
104
|
+
"@powerhousedao/config": "5.3.2",
|
|
105
|
+
"@powerhousedao/connect": "5.3.2",
|
|
106
|
+
"@powerhousedao/ph-cli": "5.3.2",
|
|
107
|
+
"@powerhousedao/reactor-api": "5.3.2",
|
|
108
|
+
"@powerhousedao/reactor-browser": "5.3.2",
|
|
109
|
+
"@powerhousedao/reactor-local": "5.3.2",
|
|
110
|
+
"@powerhousedao/scalars": "^2.0.1",
|
|
111
|
+
"@powerhousedao/switchboard": "5.3.2",
|
|
108
112
|
"@tailwindcss/cli": "^4.1.4",
|
|
109
113
|
"@testing-library/react": "^16.3.0",
|
|
110
114
|
"@types/node": "^24.9.2",
|
|
111
115
|
"@types/react": "^19.2.2",
|
|
112
116
|
"@types/react-dom": "^19.2.2",
|
|
113
117
|
"@vitejs/plugin-react": "^5.1.0",
|
|
114
|
-
"document-drive": "5.3.
|
|
118
|
+
"document-drive": "5.3.2",
|
|
115
119
|
"eslint": "^9.38.0",
|
|
116
120
|
"eslint-config-prettier": "^10.1.8",
|
|
117
121
|
"eslint-plugin-prettier": "^5.5.4",
|
|
@@ -148,14 +152,17 @@
|
|
|
148
152
|
}
|
|
149
153
|
],
|
|
150
154
|
"plugins": [
|
|
151
|
-
"@semantic-release/changelog",
|
|
152
|
-
"@semantic-release/git",
|
|
153
155
|
"@semantic-release/commit-analyzer",
|
|
154
156
|
"@semantic-release/release-notes-generator",
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
"@semantic-release/changelog",
|
|
158
|
+
[
|
|
159
|
+
"@semantic-release/npm",
|
|
160
|
+
{
|
|
161
|
+
"npmPublish": false
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"@semantic-release/github",
|
|
165
|
+
"@semantic-release/git"
|
|
159
166
|
]
|
|
160
167
|
}
|
|
161
|
-
}
|
|
168
|
+
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a scaffold file meant for customization:
|
|
3
|
-
* - change it by adding new tests or modifying the existing ones
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* This is a scaffold file meant for customization:
|
|
7
|
-
* - change it by adding new tests or modifying the existing ones
|
|
8
|
-
*/
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=document-model.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-model.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/document-model.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;GAGG"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a scaffold file meant for customization:
|
|
3
|
-
* - change it by adding new tests or modifying the existing ones
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* This is a scaffold file meant for customization:
|
|
7
|
-
* - change it by adding new tests or modifying the existing ones
|
|
8
|
-
*/
|
|
9
|
-
import { describe, it, expect } from "vitest";
|
|
10
|
-
import { utils, initialGlobalState, initialLocalState, invoiceDocumentType, isInvoiceDocument, assertIsInvoiceDocument, isInvoiceState, assertIsInvoiceState, } from "@powerhousedao/contributor-billing/document-models/invoice";
|
|
11
|
-
import { ZodError } from "zod";
|
|
12
|
-
describe("Invoice Document Model", () => {
|
|
13
|
-
it("should create a new Invoice document", () => {
|
|
14
|
-
const document = utils.createDocument();
|
|
15
|
-
expect(document).toBeDefined();
|
|
16
|
-
expect(document.header.documentType).toBe(invoiceDocumentType);
|
|
17
|
-
});
|
|
18
|
-
it("should create a new Invoice document with a valid initial state", () => {
|
|
19
|
-
const document = utils.createDocument();
|
|
20
|
-
expect(document.state.global).toStrictEqual(initialGlobalState);
|
|
21
|
-
expect(document.state.local).toStrictEqual(initialLocalState);
|
|
22
|
-
expect(isInvoiceDocument(document)).toBe(true);
|
|
23
|
-
expect(isInvoiceState(document.state)).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
it("should reject a document that is not a Invoice document", () => {
|
|
26
|
-
const wrongDocumentType = utils.createDocument();
|
|
27
|
-
wrongDocumentType.header.documentType = "the-wrong-thing-1234";
|
|
28
|
-
try {
|
|
29
|
-
expect(assertIsInvoiceDocument(wrongDocumentType)).toThrow();
|
|
30
|
-
expect(isInvoiceDocument(wrongDocumentType)).toBe(false);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
expect(error).toBeInstanceOf(ZodError);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
const wrongState = utils.createDocument();
|
|
37
|
-
// @ts-expect-error - we are testing the error case
|
|
38
|
-
wrongState.state.global = {
|
|
39
|
-
...{ notWhat: "you want" },
|
|
40
|
-
};
|
|
41
|
-
try {
|
|
42
|
-
expect(isInvoiceState(wrongState.state)).toBe(false);
|
|
43
|
-
expect(assertIsInvoiceState(wrongState.state)).toThrow();
|
|
44
|
-
expect(isInvoiceDocument(wrongState)).toBe(false);
|
|
45
|
-
expect(assertIsInvoiceDocument(wrongState)).toThrow();
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
expect(error).toBeInstanceOf(ZodError);
|
|
49
|
-
}
|
|
50
|
-
const wrongInitialState = utils.createDocument();
|
|
51
|
-
// @ts-expect-error - we are testing the error case
|
|
52
|
-
wrongInitialState.initialState.global = {
|
|
53
|
-
...{ notWhat: "you want" },
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
expect(isInvoiceState(wrongInitialState.state)).toBe(false);
|
|
57
|
-
expect(assertIsInvoiceState(wrongInitialState.state)).toThrow();
|
|
58
|
-
expect(isInvoiceDocument(wrongInitialState)).toBe(false);
|
|
59
|
-
expect(assertIsInvoiceDocument(wrongInitialState)).toThrow();
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
expect(error).toBeInstanceOf(ZodError);
|
|
63
|
-
}
|
|
64
|
-
const missingIdInHeader = utils.createDocument();
|
|
65
|
-
// @ts-expect-error - we are testing the error case
|
|
66
|
-
delete missingIdInHeader.header.id;
|
|
67
|
-
try {
|
|
68
|
-
expect(isInvoiceDocument(missingIdInHeader)).toBe(false);
|
|
69
|
-
expect(assertIsInvoiceDocument(missingIdInHeader)).toThrow();
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
expect(error).toBeInstanceOf(ZodError);
|
|
73
|
-
}
|
|
74
|
-
const missingNameInHeader = utils.createDocument();
|
|
75
|
-
// @ts-expect-error - we are testing the error case
|
|
76
|
-
delete missingNameInHeader.header.name;
|
|
77
|
-
try {
|
|
78
|
-
expect(isInvoiceDocument(missingNameInHeader)).toBe(false);
|
|
79
|
-
expect(assertIsInvoiceDocument(missingNameInHeader)).toThrow();
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
expect(error).toBeInstanceOf(ZodError);
|
|
83
|
-
}
|
|
84
|
-
const missingCreatedAtUtcIsoInHeader = utils.createDocument();
|
|
85
|
-
// @ts-expect-error - we are testing the error case
|
|
86
|
-
delete missingCreatedAtUtcIsoInHeader.header.createdAtUtcIso;
|
|
87
|
-
try {
|
|
88
|
-
expect(isInvoiceDocument(missingCreatedAtUtcIsoInHeader)).toBe(false);
|
|
89
|
-
expect(assertIsInvoiceDocument(missingCreatedAtUtcIsoInHeader)).toThrow();
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
expect(error).toBeInstanceOf(ZodError);
|
|
93
|
-
}
|
|
94
|
-
const missingLastModifiedAtUtcIsoInHeader = utils.createDocument();
|
|
95
|
-
// @ts-expect-error - we are testing the error case
|
|
96
|
-
delete missingLastModifiedAtUtcIsoInHeader.header.lastModifiedAtUtcIso;
|
|
97
|
-
try {
|
|
98
|
-
expect(isInvoiceDocument(missingLastModifiedAtUtcIsoInHeader)).toBe(false);
|
|
99
|
-
expect(assertIsInvoiceDocument(missingLastModifiedAtUtcIsoInHeader)).toThrow();
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
expect(error).toBeInstanceOf(ZodError);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"general.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/general.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a scaffold file meant for customization:
|
|
3
|
-
* - change it by adding new tests or modifying the existing ones
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from "vitest";
|
|
6
|
-
import { generateMock } from "@powerhousedao/codegen";
|
|
7
|
-
import { reducer, utils, isInvoiceDocument, editInvoice, EditInvoiceInputSchema, editStatus, EditStatusInputSchema, editPaymentData, EditPaymentDataInputSchema, setExportedData, SetExportedDataInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
|
|
8
|
-
describe("General Operations", () => {
|
|
9
|
-
it("should handle editInvoice operation", () => {
|
|
10
|
-
const document = utils.createDocument();
|
|
11
|
-
const input = generateMock(EditInvoiceInputSchema());
|
|
12
|
-
const updatedDocument = reducer(document, editInvoice(input));
|
|
13
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
14
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
15
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_INVOICE");
|
|
16
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
17
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
18
|
-
});
|
|
19
|
-
it("should handle editStatus operation", () => {
|
|
20
|
-
const document = utils.createDocument();
|
|
21
|
-
const input = generateMock(EditStatusInputSchema());
|
|
22
|
-
const updatedDocument = reducer(document, editStatus(input));
|
|
23
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
24
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
25
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_STATUS");
|
|
26
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
27
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
28
|
-
});
|
|
29
|
-
it("should handle editPaymentData operation", () => {
|
|
30
|
-
const document = utils.createDocument();
|
|
31
|
-
const input = generateMock(EditPaymentDataInputSchema());
|
|
32
|
-
const updatedDocument = reducer(document, editPaymentData(input));
|
|
33
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
34
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
35
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_PAYMENT_DATA");
|
|
36
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
37
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
38
|
-
});
|
|
39
|
-
it("should handle setExportedData operation", () => {
|
|
40
|
-
const document = utils.createDocument();
|
|
41
|
-
const input = generateMock(SetExportedDataInputSchema());
|
|
42
|
-
const updatedDocument = reducer(document, setExportedData(input));
|
|
43
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
44
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
45
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("SET_EXPORTED_DATA");
|
|
46
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
47
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"items.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/items.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a scaffold file meant for customization:
|
|
3
|
-
* - change it by adding new tests or modifying the existing ones
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from "vitest";
|
|
6
|
-
import { generateMock } from "@powerhousedao/codegen";
|
|
7
|
-
import { reducer, utils, isInvoiceDocument, addLineItem, AddLineItemInputSchema, editLineItem, EditLineItemInputSchema, deleteLineItem, DeleteLineItemInputSchema, setLineItemTag, SetLineItemTagInputSchema, setInvoiceTag, SetInvoiceTagInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
|
|
8
|
-
describe("Items Operations", () => {
|
|
9
|
-
it("should handle addLineItem operation", () => {
|
|
10
|
-
const document = utils.createDocument();
|
|
11
|
-
const input = generateMock(AddLineItemInputSchema());
|
|
12
|
-
const updatedDocument = reducer(document, addLineItem(input));
|
|
13
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
14
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
15
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("ADD_LINE_ITEM");
|
|
16
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
17
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
18
|
-
});
|
|
19
|
-
it("should handle editLineItem operation", () => {
|
|
20
|
-
const document = utils.createDocument();
|
|
21
|
-
const input = generateMock(EditLineItemInputSchema());
|
|
22
|
-
const updatedDocument = reducer(document, editLineItem(input));
|
|
23
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
24
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
25
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_LINE_ITEM");
|
|
26
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
27
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
28
|
-
});
|
|
29
|
-
it("should handle deleteLineItem operation", () => {
|
|
30
|
-
const document = utils.createDocument();
|
|
31
|
-
const input = generateMock(DeleteLineItemInputSchema());
|
|
32
|
-
const updatedDocument = reducer(document, deleteLineItem(input));
|
|
33
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
34
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
35
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("DELETE_LINE_ITEM");
|
|
36
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
37
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
38
|
-
});
|
|
39
|
-
it("should handle setLineItemTag operation", () => {
|
|
40
|
-
const document = utils.createDocument();
|
|
41
|
-
const input = generateMock(SetLineItemTagInputSchema());
|
|
42
|
-
const updatedDocument = reducer(document, setLineItemTag(input));
|
|
43
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
44
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
45
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("SET_LINE_ITEM_TAG");
|
|
46
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
47
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
48
|
-
});
|
|
49
|
-
it("should handle setInvoiceTag operation", () => {
|
|
50
|
-
const document = utils.createDocument();
|
|
51
|
-
const input = generateMock(SetInvoiceTagInputSchema());
|
|
52
|
-
const updatedDocument = reducer(document, setInvoiceTag(input));
|
|
53
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
54
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
55
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("SET_INVOICE_TAG");
|
|
56
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
57
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parties.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/parties.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a scaffold file meant for customization:
|
|
3
|
-
* - change it by adding new tests or modifying the existing ones
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from "vitest";
|
|
6
|
-
import { generateMock } from "@powerhousedao/codegen";
|
|
7
|
-
import { reducer, utils, isInvoiceDocument, editIssuer, EditIssuerInputSchema, editIssuerBank, EditIssuerBankInputSchema, editIssuerWallet, EditIssuerWalletInputSchema, editPayer, EditPayerInputSchema, editPayerBank, EditPayerBankInputSchema, editPayerWallet, EditPayerWalletInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
|
|
8
|
-
describe("Parties Operations", () => {
|
|
9
|
-
it("should handle editIssuer operation", () => {
|
|
10
|
-
const document = utils.createDocument();
|
|
11
|
-
const input = generateMock(EditIssuerInputSchema());
|
|
12
|
-
const updatedDocument = reducer(document, editIssuer(input));
|
|
13
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
14
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
15
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_ISSUER");
|
|
16
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
17
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
18
|
-
});
|
|
19
|
-
it("should handle editIssuerBank operation", () => {
|
|
20
|
-
const document = utils.createDocument();
|
|
21
|
-
const input = generateMock(EditIssuerBankInputSchema());
|
|
22
|
-
const updatedDocument = reducer(document, editIssuerBank(input));
|
|
23
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
24
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
25
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_ISSUER_BANK");
|
|
26
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
27
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
28
|
-
});
|
|
29
|
-
it("should handle editIssuerWallet operation", () => {
|
|
30
|
-
const document = utils.createDocument();
|
|
31
|
-
const input = generateMock(EditIssuerWalletInputSchema());
|
|
32
|
-
const updatedDocument = reducer(document, editIssuerWallet(input));
|
|
33
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
34
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
35
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_ISSUER_WALLET");
|
|
36
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
37
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
38
|
-
});
|
|
39
|
-
it("should handle editPayer operation", () => {
|
|
40
|
-
const document = utils.createDocument();
|
|
41
|
-
const input = generateMock(EditPayerInputSchema());
|
|
42
|
-
const updatedDocument = reducer(document, editPayer(input));
|
|
43
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
44
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
45
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_PAYER");
|
|
46
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
47
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
48
|
-
});
|
|
49
|
-
it("should handle editPayerBank operation", () => {
|
|
50
|
-
const document = utils.createDocument();
|
|
51
|
-
const input = generateMock(EditPayerBankInputSchema());
|
|
52
|
-
const updatedDocument = reducer(document, editPayerBank(input));
|
|
53
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
54
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
55
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_PAYER_BANK");
|
|
56
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
57
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
58
|
-
});
|
|
59
|
-
it("should handle editPayerWallet operation", () => {
|
|
60
|
-
const document = utils.createDocument();
|
|
61
|
-
const input = generateMock(EditPayerWalletInputSchema());
|
|
62
|
-
const updatedDocument = reducer(document, editPayerWallet(input));
|
|
63
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
64
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
65
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("EDIT_PAYER_WALLET");
|
|
66
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
67
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transitions.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/tests/transitions.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a scaffold file meant for customization:
|
|
3
|
-
* - change it by adding new tests or modifying the existing ones
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from "vitest";
|
|
6
|
-
import { generateMock } from "@powerhousedao/codegen";
|
|
7
|
-
import { reducer, utils, isInvoiceDocument, cancel, CancelInputSchema, issue, IssueInputSchema, reset, ResetInputSchema, reject, RejectInputSchema, accept, AcceptInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
|
|
8
|
-
describe("Transitions Operations", () => {
|
|
9
|
-
it("should handle cancel operation", () => {
|
|
10
|
-
const document = utils.createDocument();
|
|
11
|
-
const input = generateMock(CancelInputSchema());
|
|
12
|
-
const updatedDocument = reducer(document, cancel(input));
|
|
13
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
14
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
15
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("CANCEL");
|
|
16
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
17
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
18
|
-
});
|
|
19
|
-
it("should handle issue operation", () => {
|
|
20
|
-
const document = utils.createDocument();
|
|
21
|
-
const input = generateMock(IssueInputSchema());
|
|
22
|
-
const updatedDocument = reducer(document, issue(input));
|
|
23
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
24
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
25
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("ISSUE");
|
|
26
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
27
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
28
|
-
});
|
|
29
|
-
it("should handle reset operation", () => {
|
|
30
|
-
const document = utils.createDocument();
|
|
31
|
-
const input = generateMock(ResetInputSchema());
|
|
32
|
-
const updatedDocument = reducer(document, reset(input));
|
|
33
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
34
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
35
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("RESET");
|
|
36
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
37
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
38
|
-
});
|
|
39
|
-
it("should handle reject operation", () => {
|
|
40
|
-
const document = utils.createDocument();
|
|
41
|
-
const input = generateMock(RejectInputSchema());
|
|
42
|
-
const updatedDocument = reducer(document, reject(input));
|
|
43
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
44
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
45
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("REJECT");
|
|
46
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
47
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
48
|
-
});
|
|
49
|
-
it("should handle accept operation", () => {
|
|
50
|
-
const document = utils.createDocument();
|
|
51
|
-
const input = generateMock(AcceptInputSchema());
|
|
52
|
-
const updatedDocument = reducer(document, accept(input));
|
|
53
|
-
expect(isInvoiceDocument(updatedDocument)).toBe(true);
|
|
54
|
-
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
55
|
-
expect(updatedDocument.operations.global[0].action.type).toBe("ACCEPT");
|
|
56
|
-
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
57
|
-
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const permittedTransitions: {
|
|
2
|
-
DRAFT: string[];
|
|
3
|
-
CANCELLED: string[];
|
|
4
|
-
ISSUED: string[];
|
|
5
|
-
REJECTED: string[];
|
|
6
|
-
ACCEPTED: string[];
|
|
7
|
-
PAYMENTSCHEDULED: string[];
|
|
8
|
-
PAYMENTSENT: string[];
|
|
9
|
-
PAYMENTISSUE: string[];
|
|
10
|
-
PAYMENTRECEIVED: string[];
|
|
11
|
-
PAYMENTCLOSED: string[];
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=statusTransitions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"statusTransitions.d.ts","sourceRoot":"","sources":["../../../../document-models/invoice/utils/statusTransitions.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAWhC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Status transitions mapping
|
|
2
|
-
export const permittedTransitions = {
|
|
3
|
-
DRAFT: ["CANCELLED", "ISSUED"],
|
|
4
|
-
CANCELLED: ["DRAFT"],
|
|
5
|
-
ISSUED: ["REJECTED", "ACCEPTED"],
|
|
6
|
-
REJECTED: ["ISSUED"],
|
|
7
|
-
ACCEPTED: ["PAYMENTSCHEDULED", "PAYMENTCLOSED"],
|
|
8
|
-
PAYMENTSCHEDULED: ["PAYMENTSENT", "PAYMENTISSUE", "PAYMENTCLOSED"],
|
|
9
|
-
PAYMENTSENT: ["PAYMENTISSUE", "PAYMENTRECEIVED"],
|
|
10
|
-
PAYMENTISSUE: ["ACCEPTED", "PAYMENTCLOSED"],
|
|
11
|
-
PAYMENTRECEIVED: ["PAYMENTISSUE"],
|
|
12
|
-
PAYMENTCLOSED: ["ACCEPTED"],
|
|
13
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ServiceSubscription } from "../../../../document-models/service-subscriptions/gen/types.js";
|
|
2
|
-
type SubscriptionsStatsProps = {
|
|
3
|
-
subscriptions: ServiceSubscription[];
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Displays subscription statistics in a 4-column card grid.
|
|
7
|
-
* Shows: Active count, Trial count, Monthly cost estimate, Seats usage.
|
|
8
|
-
*/
|
|
9
|
-
export declare function SubscriptionsStats({ subscriptions }: SubscriptionsStatsProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
/**
|
|
11
|
-
* Empty state placeholder when no subscriptions document exists.
|
|
12
|
-
*/
|
|
13
|
-
export declare function SubscriptionsEmptyState(): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=SubscriptionsStats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionsStats.d.ts","sourceRoot":"","sources":["../../../../../editors/builder-team-admin/components/overview/SubscriptionsStats.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gEAAgE,CAAC;AAE1G,KAAK,uBAAuB,GAAG;IAC7B,aAAa,EAAE,mBAAmB,EAAE,CAAC;CACtC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,aAAa,EAAE,EAAE,uBAAuB,2CA+E5E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,4CA6BtC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Displays subscription statistics in a 4-column card grid.
|
|
4
|
-
* Shows: Active count, Trial count, Monthly cost estimate, Seats usage.
|
|
5
|
-
*/
|
|
6
|
-
export function SubscriptionsStats({ subscriptions }) {
|
|
7
|
-
const activeCount = subscriptions.filter((s) => s.status === "ACTIVE").length;
|
|
8
|
-
const trialCount = subscriptions.filter((s) => s.status === "TRIAL").length;
|
|
9
|
-
// Calculate estimated monthly cost by normalizing all billing cycles
|
|
10
|
-
const totalMonthly = subscriptions.reduce((sum, sub) => {
|
|
11
|
-
if (!sub.amount)
|
|
12
|
-
return sum;
|
|
13
|
-
const amount = sub.amount;
|
|
14
|
-
switch (sub.billingCycle) {
|
|
15
|
-
case "MONTHLY":
|
|
16
|
-
return sum + amount;
|
|
17
|
-
case "QUARTERLY":
|
|
18
|
-
return sum + amount / 3;
|
|
19
|
-
case "ANNUAL":
|
|
20
|
-
return sum + amount / 12;
|
|
21
|
-
case "BIENNIAL":
|
|
22
|
-
return sum + amount / 24;
|
|
23
|
-
default:
|
|
24
|
-
return sum;
|
|
25
|
-
}
|
|
26
|
-
}, 0);
|
|
27
|
-
const totalSeats = subscriptions.reduce((sum, sub) => sum + (sub.seats?.total ?? 0), 0);
|
|
28
|
-
const usedSeats = subscriptions.reduce((sum, sub) => sum + (sub.seats?.assignedMembers.length ?? 0), 0);
|
|
29
|
-
const stats = [
|
|
30
|
-
{
|
|
31
|
-
label: "Active Subscriptions",
|
|
32
|
-
value: activeCount.toString(),
|
|
33
|
-
color: "text-emerald-600",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
label: "Trial Subscriptions",
|
|
37
|
-
value: trialCount.toString(),
|
|
38
|
-
color: "text-amber-600",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
label: "Monthly Cost (est.)",
|
|
42
|
-
value: `$${totalMonthly.toLocaleString(undefined, {
|
|
43
|
-
minimumFractionDigits: 0,
|
|
44
|
-
maximumFractionDigits: 0,
|
|
45
|
-
})}`,
|
|
46
|
-
color: "text-slate-900",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: "Seats Used",
|
|
50
|
-
value: `${usedSeats}/${totalSeats}`,
|
|
51
|
-
color: "text-slate-900",
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx("h2", { className: "text-lg font-semibold text-slate-900", children: "Service Subscriptions" }), _jsx("div", { className: "grid grid-cols-2 gap-4 sm:grid-cols-4", children: stats.map((stat) => (_jsxs("div", { className: "rounded-xl border border-slate-200 bg-white p-5 shadow-sm transition-shadow hover:shadow-md", children: [_jsx("p", { className: "text-sm font-medium text-slate-500", children: stat.label }), _jsx("p", { className: `mt-2 text-3xl font-semibold tracking-tight ${stat.color}`, children: stat.value })] }, stat.label))) })] }));
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Empty state placeholder when no subscriptions document exists.
|
|
58
|
-
*/
|
|
59
|
-
export function SubscriptionsEmptyState() {
|
|
60
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx("h2", { className: "text-lg font-semibold text-slate-900", children: "Service Subscriptions" }), _jsxs("div", { className: "rounded-xl border border-dashed border-slate-300 bg-slate-50/50 p-8 text-center", children: [_jsx("div", { className: "mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-full bg-slate-100", children: _jsx("svg", { className: "h-6 w-6 text-slate-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 1.5, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 002.25-2.25V6.75A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25v10.5A2.25 2.25 0 004.5 19.5z" }) }) }), _jsx("p", { className: "text-sm text-slate-500", children: "No subscriptions document found. Create one to track your team's services." })] })] }));
|
|
61
|
-
}
|