@powerhousedao/contributor-billing 1.0.0-dev.4 → 1.0.0-dev.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/reducers/transitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAC;AA6B/G,eAAO,MAAM,4BAA4B,EAAE,4BAqK1C,CAAC"}
1
+ {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../../../../document-models/invoice/src/reducers/transitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAC;AA6B/G,eAAO,MAAM,4BAA4B,EAAE,4BA0K1C,CAAC"}
@@ -37,7 +37,10 @@ export const invoiceTransitionsOperations = {
37
37
  throw new Error("Invoice number and date issued are required");
38
38
  }
39
39
  const wallet = state.issuer?.paymentRouting?.wallet;
40
- if (!wallet?.address || (!wallet.chainName && !wallet.chainId)) {
40
+ const stablecoins = ["USDS", "DAI", "USDC"];
41
+ const isStablecoin = stablecoins.includes(state.currency.toUpperCase());
42
+ if (isStablecoin &&
43
+ (!wallet?.address || (!wallet.chainName && !wallet.chainId))) {
41
44
  throw new Error("Issuer wallet address and chain must be set before issuing an invoice");
42
45
  }
43
46
  if (permittedTransitions[state.status].includes("ISSUED")) {
@@ -1,10 +1,19 @@
1
1
  import { generateMock } from "@powerhousedao/codegen";
2
2
  import { describe, expect, it } from "vitest";
3
- import { reducer, utils, isInvoiceDocument, editInvoice, EditInvoiceInputSchema, editStatus, EditStatusInputSchema, editPaymentData, EditPaymentDataInputSchema, setExportedData, SetExportedDataInputSchema, addPayment, AddPaymentInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
3
+ import { reducer, utils, isInvoiceDocument, editInvoice, editStatus, EditStatusInputSchema, editPaymentData, EditPaymentDataInputSchema, setExportedData, SetExportedDataInputSchema, addPayment, AddPaymentInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
4
4
  describe("GeneralOperations", () => {
5
5
  it("should handle editInvoice operation", () => {
6
6
  const document = utils.createDocument();
7
- const input = generateMock(EditInvoiceInputSchema());
7
+ // Use explicit valid input: generateMock can produce invalid date strings
8
+ // that fail InvoiceStateSchema's z.iso.datetime() validation
9
+ const input = {
10
+ invoiceNo: "INV-001",
11
+ dateIssued: "2024-01-15",
12
+ dateDue: "2024-02-15",
13
+ dateDelivered: "2024-01-20",
14
+ currency: "USD",
15
+ notes: "Test notes",
16
+ };
8
17
  const updatedDocument = reducer(document, editInvoice(input));
9
18
  expect(isInvoiceDocument(updatedDocument)).toBe(true);
10
19
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -1,6 +1,6 @@
1
1
  import { generateMock } from "@powerhousedao/codegen";
2
2
  import { describe, expect, it } from "vitest";
3
- import { reducer, utils, isInvoiceDocument, cancel, CancelInputSchema, issue, IssueInputSchema, reset, ResetInputSchema, reject, accept, reinstate, RejectInputSchema, AcceptInputSchema, ReinstateInputSchema, schedulePayment, SchedulePaymentInputSchema, reapprovePayment, ReapprovePaymentInputSchema, registerPaymentTx, RegisterPaymentTxInputSchema, reportPaymentIssue, confirmPayment, closePayment, ReportPaymentIssueInputSchema, ConfirmPaymentInputSchema, ClosePaymentInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
3
+ import { reducer, utils, isInvoiceDocument, cancel, CancelInputSchema, issue, reset, ResetInputSchema, reject, accept, reinstate, RejectInputSchema, AcceptInputSchema, ReinstateInputSchema, schedulePayment, SchedulePaymentInputSchema, reapprovePayment, ReapprovePaymentInputSchema, registerPaymentTx, RegisterPaymentTxInputSchema, reportPaymentIssue, confirmPayment, closePayment, ReportPaymentIssueInputSchema, ConfirmPaymentInputSchema, ClosePaymentInputSchema, } from "@powerhousedao/contributor-billing/document-models/invoice";
4
4
  describe("TransitionsOperations", () => {
5
5
  it("should handle cancel operation", () => {
6
6
  const document = utils.createDocument();
@@ -14,7 +14,12 @@ describe("TransitionsOperations", () => {
14
14
  });
15
15
  it("should handle issue operation", () => {
16
16
  const document = utils.createDocument();
17
- const input = generateMock(IssueInputSchema());
17
+ // Use explicit valid input: generateMock can produce invalid date strings
18
+ // that fail InvoiceStateSchema's z.iso.datetime() validation
19
+ const input = {
20
+ invoiceNo: "INV-001",
21
+ dateIssued: "2024-01-15",
22
+ };
18
23
  const updatedDocument = reducer(document, issue(input));
19
24
  expect(isInvoiceDocument(updatedDocument)).toBe(true);
20
25
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -9,7 +9,7 @@ export type ValidationRule = {
9
9
  field: string;
10
10
  validate: (value: any, context?: any) => ValidationResult;
11
11
  appliesTo: {
12
- currencies: Array<string | "ALL">;
12
+ currencies: string[];
13
13
  statusTransitions: {
14
14
  from: Status[];
15
15
  to: Status[];
@@ -1 +1 @@
1
- {"version":3,"file":"validationManager.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/validation/validationManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAsBxE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,gBAAgB,CAAC;IAC1D,SAAS,EAAE;QACT,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;QAClC,iBAAiB,EAAE;YACjB,IAAI,EAAE,MAAM,EAAE,CAAC;YACf,EAAE,EAAE,MAAM,EAAE,CAAC;SACd,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAwCF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,iBAAiB,GACzB,gBAAgB,GAAG,IAAI,CAqBzB;AAGD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAalC;AAGD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAE5D;AAGD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAKxD"}
1
+ {"version":3,"file":"validationManager.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/validation/validationManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAqBxE,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,gBAAgB,CAAC;IAC1D,SAAS,EAAE;QACT,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,iBAAiB,EAAE;YACjB,IAAI,EAAE,MAAM,EAAE,CAAC;YACf,EAAE,EAAE,MAAM,EAAE,CAAC;SACd,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAuCF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,iBAAiB,GACzB,gBAAgB,GAAG,IAAI,CAqBzB;AAGD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAalC;AAGD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAE5D;AAGD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAKxD"}
@@ -1,5 +1,5 @@
1
1
  import {} from "../../../document-models/invoice/index.js";
2
- import { accountIbanRule, bicNumberRule, bankNameRule, currencyRule, ethereumAddressRule, invoiceNumberRule, issuerPostalCodeRule, issuerStreetAddressRule, issuerCityRule, payerEmailRule, lineItemRule, mainCountryRule, bankCountryRule, routingNumberRule, accountNumberRule, walletAddressRule, walletChainRule, } from "./validationRules.js";
2
+ import { accountIbanRule, bicNumberRule, bankNameRule, currencyRule, ethereumAddressRule, invoiceNumberRule, issuerPostalCodeRule, issuerStreetAddressRule, issuerCityRule, payerEmailRule, lineItemRule, mainCountryRule, bankCountryRule, routingNumberRule, accountNumberRule, walletChainRule, } from "./validationRules.js";
3
3
  // Validation rules registry
4
4
  const validationRules = [];
5
5
  // Register rules
@@ -18,7 +18,6 @@ validationRules.push(payerEmailRule);
18
18
  validationRules.push(lineItemRule);
19
19
  validationRules.push(routingNumberRule);
20
20
  validationRules.push(accountNumberRule);
21
- validationRules.push(walletAddressRule);
22
21
  validationRules.push(walletChainRule);
23
22
  // Helper to check if a rule applies to the current context
24
23
  function ruleAppliesToContext(rule, context) {
@@ -3,7 +3,6 @@ export declare function isValidIBAN(iban: string): boolean;
3
3
  export declare const invoiceNumberRule: ValidationRule;
4
4
  export declare const ethereumAddressRule: ValidationRule;
5
5
  export declare const walletChainRule: ValidationRule;
6
- export declare const walletAddressRule: ValidationRule;
7
6
  export declare const currencyRule: ValidationRule;
8
7
  export declare const mainCountryRule: ValidationRule;
9
8
  export declare const bankCountryRule: ValidationRule;
@@ -1 +1 @@
1
- {"version":3,"file":"validationRules.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/validation/validationRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAQ7D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAajD;AAQD,eAAO,MAAM,iBAAiB,EAAE,cAuB/B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,cA8BjC,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,cAuB7B,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,cAuB/B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAuB7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAuB7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cA+B7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAgC/B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,cAiC3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAuBrC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAuB5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,cAuBlC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cA8B5B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAqC/B,CAAC"}
1
+ {"version":3,"file":"validationRules.d.ts","sourceRoot":"","sources":["../../../../editors/invoice/validation/validationRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAQ7D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAajD;AAQD,eAAO,MAAM,iBAAiB,EAAE,cAuB/B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,cA8BjC,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,cAuB7B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAuB7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAuB7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cA+B7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAgC/B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,cAiC3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAuBrC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAuB5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,cAuBlC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cA8B5B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAuB1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAqC/B,CAAC"}
@@ -67,7 +67,7 @@ export const ethereumAddressRule = {
67
67
  };
68
68
  },
69
69
  appliesTo: {
70
- currencies: ["USDS", "DAI"], // Only apply for crypto currencies
70
+ currencies: ["USDS", "DAI", "USDC"], // Only apply for crypto currencies
71
71
  statusTransitions: {
72
72
  from: ["DRAFT"],
73
73
  to: ["ISSUED"],
@@ -92,32 +92,7 @@ export const walletChainRule = {
92
92
  };
93
93
  },
94
94
  appliesTo: {
95
- currencies: ["ALL"],
96
- statusTransitions: {
97
- from: ["DRAFT"],
98
- to: ["ISSUED"],
99
- },
100
- },
101
- };
102
- // Wallet address validation rule - address must be set for all currencies
103
- export const walletAddressRule = {
104
- field: "walletAddress",
105
- validate: (value) => {
106
- if (!value || value.trim() === "") {
107
- return {
108
- isValid: false,
109
- message: "Wallet address is required before issuing",
110
- severity: "warning",
111
- };
112
- }
113
- return {
114
- isValid: true,
115
- message: "",
116
- severity: "none",
117
- };
118
- },
119
- appliesTo: {
120
- currencies: ["ALL"],
95
+ currencies: ["USDS", "DAI", "USDC"],
121
96
  statusTransitions: {
122
97
  from: ["DRAFT"],
123
98
  to: ["ISSUED"],
package/package.json CHANGED
@@ -1,7 +1,7 @@
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": "1.0.0-dev.4",
4
+ "version": "1.0.0-dev.5",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
7
7
  "type": "git",