@powerhousedao/contributor-billing 0.0.76 → 0.0.77

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.
Files changed (176) hide show
  1. package/dist/document-models/billing-statement/gen/general/actions.d.ts +13 -4
  2. package/dist/document-models/billing-statement/gen/general/actions.d.ts.map +1 -1
  3. package/dist/document-models/billing-statement/gen/general/object.d.ts +3 -3
  4. package/dist/document-models/billing-statement/gen/general/object.d.ts.map +1 -1
  5. package/dist/document-models/billing-statement/gen/index.d.ts +2 -0
  6. package/dist/document-models/billing-statement/gen/index.d.ts.map +1 -1
  7. package/dist/document-models/billing-statement/gen/index.js +1 -0
  8. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts +9 -3
  9. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts.map +1 -1
  10. package/dist/document-models/billing-statement/gen/line-items/object.d.ts +3 -3
  11. package/dist/document-models/billing-statement/gen/line-items/object.d.ts.map +1 -1
  12. package/dist/document-models/billing-statement/gen/object.d.ts +4 -5
  13. package/dist/document-models/billing-statement/gen/object.d.ts.map +1 -1
  14. package/dist/document-models/billing-statement/gen/object.js +2 -2
  15. package/dist/document-models/billing-statement/gen/ph-factories.d.ts +27 -0
  16. package/dist/document-models/billing-statement/gen/ph-factories.d.ts.map +1 -0
  17. package/dist/document-models/billing-statement/gen/ph-factories.js +58 -0
  18. package/dist/document-models/billing-statement/gen/reducer.d.ts +4 -2
  19. package/dist/document-models/billing-statement/gen/reducer.d.ts.map +1 -1
  20. package/dist/document-models/billing-statement/gen/reducer.js +4 -1
  21. package/dist/document-models/billing-statement/gen/schema/types.d.ts +4 -0
  22. package/dist/document-models/billing-statement/gen/schema/types.d.ts.map +1 -1
  23. package/dist/document-models/billing-statement/gen/tags/actions.d.ts +5 -2
  24. package/dist/document-models/billing-statement/gen/tags/actions.d.ts.map +1 -1
  25. package/dist/document-models/billing-statement/gen/tags/object.d.ts +3 -3
  26. package/dist/document-models/billing-statement/gen/tags/object.d.ts.map +1 -1
  27. package/dist/document-models/billing-statement/gen/types.d.ts +4 -4
  28. package/dist/document-models/billing-statement/gen/types.d.ts.map +1 -1
  29. package/dist/document-models/billing-statement/gen/utils.d.ts +18 -3
  30. package/dist/document-models/billing-statement/gen/utils.d.ts.map +1 -1
  31. package/dist/document-models/billing-statement/gen/utils.js +33 -29
  32. package/dist/document-models/billing-statement/index.d.ts +8 -9
  33. package/dist/document-models/billing-statement/index.d.ts.map +1 -1
  34. package/dist/document-models/integrations/gen/index.d.ts +2 -0
  35. package/dist/document-models/integrations/gen/index.d.ts.map +1 -1
  36. package/dist/document-models/integrations/gen/index.js +1 -0
  37. package/dist/document-models/integrations/gen/integrations/actions.d.ts +13 -4
  38. package/dist/document-models/integrations/gen/integrations/actions.d.ts.map +1 -1
  39. package/dist/document-models/integrations/gen/integrations/object.d.ts +3 -3
  40. package/dist/document-models/integrations/gen/integrations/object.d.ts.map +1 -1
  41. package/dist/document-models/integrations/gen/object.d.ts +4 -5
  42. package/dist/document-models/integrations/gen/object.d.ts.map +1 -1
  43. package/dist/document-models/integrations/gen/object.js +2 -2
  44. package/dist/document-models/integrations/gen/ph-factories.d.ts +27 -0
  45. package/dist/document-models/integrations/gen/ph-factories.d.ts.map +1 -0
  46. package/dist/document-models/integrations/gen/ph-factories.js +75 -0
  47. package/dist/document-models/integrations/gen/reducer.d.ts +4 -2
  48. package/dist/document-models/integrations/gen/reducer.d.ts.map +1 -1
  49. package/dist/document-models/integrations/gen/reducer.js +4 -1
  50. package/dist/document-models/integrations/gen/schema/types.d.ts +4 -0
  51. package/dist/document-models/integrations/gen/schema/types.d.ts.map +1 -1
  52. package/dist/document-models/integrations/gen/types.d.ts +4 -4
  53. package/dist/document-models/integrations/gen/types.d.ts.map +1 -1
  54. package/dist/document-models/integrations/gen/utils.d.ts +18 -3
  55. package/dist/document-models/integrations/gen/utils.d.ts.map +1 -1
  56. package/dist/document-models/integrations/gen/utils.js +36 -32
  57. package/dist/document-models/integrations/index.d.ts +8 -9
  58. package/dist/document-models/integrations/index.d.ts.map +1 -1
  59. package/dist/document-models/invoice/gen/general/actions.d.ts +21 -6
  60. package/dist/document-models/invoice/gen/general/actions.d.ts.map +1 -1
  61. package/dist/document-models/invoice/gen/general/object.d.ts +3 -3
  62. package/dist/document-models/invoice/gen/general/object.d.ts.map +1 -1
  63. package/dist/document-models/invoice/gen/index.d.ts +2 -0
  64. package/dist/document-models/invoice/gen/index.d.ts.map +1 -1
  65. package/dist/document-models/invoice/gen/index.js +1 -0
  66. package/dist/document-models/invoice/gen/items/actions.d.ts +21 -6
  67. package/dist/document-models/invoice/gen/items/actions.d.ts.map +1 -1
  68. package/dist/document-models/invoice/gen/items/object.d.ts +3 -3
  69. package/dist/document-models/invoice/gen/items/object.d.ts.map +1 -1
  70. package/dist/document-models/invoice/gen/object.d.ts +4 -5
  71. package/dist/document-models/invoice/gen/object.d.ts.map +1 -1
  72. package/dist/document-models/invoice/gen/object.js +2 -2
  73. package/dist/document-models/invoice/gen/parties/actions.d.ts +25 -7
  74. package/dist/document-models/invoice/gen/parties/actions.d.ts.map +1 -1
  75. package/dist/document-models/invoice/gen/parties/object.d.ts +3 -3
  76. package/dist/document-models/invoice/gen/parties/object.d.ts.map +1 -1
  77. package/dist/document-models/invoice/gen/ph-factories.d.ts +27 -0
  78. package/dist/document-models/invoice/gen/ph-factories.d.ts.map +1 -0
  79. package/dist/document-models/invoice/gen/ph-factories.js +190 -0
  80. package/dist/document-models/invoice/gen/reducer.d.ts +4 -2
  81. package/dist/document-models/invoice/gen/reducer.d.ts.map +1 -1
  82. package/dist/document-models/invoice/gen/reducer.js +4 -1
  83. package/dist/document-models/invoice/gen/schema/types.d.ts +4 -0
  84. package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -1
  85. package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -1
  86. package/dist/document-models/invoice/gen/transitions/actions.d.ts +49 -13
  87. package/dist/document-models/invoice/gen/transitions/actions.d.ts.map +1 -1
  88. package/dist/document-models/invoice/gen/transitions/object.d.ts +3 -3
  89. package/dist/document-models/invoice/gen/transitions/object.d.ts.map +1 -1
  90. package/dist/document-models/invoice/gen/types.d.ts +4 -4
  91. package/dist/document-models/invoice/gen/types.d.ts.map +1 -1
  92. package/dist/document-models/invoice/gen/utils.d.ts +18 -3
  93. package/dist/document-models/invoice/gen/utils.d.ts.map +1 -1
  94. package/dist/document-models/invoice/gen/utils.js +33 -29
  95. package/dist/document-models/invoice/index.d.ts +8 -9
  96. package/dist/document-models/invoice/index.d.ts.map +1 -1
  97. package/dist/editors/billing-statement/editor.d.ts +2 -3
  98. package/dist/editors/billing-statement/editor.d.ts.map +1 -1
  99. package/dist/editors/billing-statement/editor.js +11 -3
  100. package/dist/editors/billing-statement/index.d.ts +1 -2
  101. package/dist/editors/billing-statement/index.d.ts.map +1 -1
  102. package/dist/editors/billing-statement/lineItemTags/lineItemTags.js +1 -1
  103. package/dist/editors/contributor-billing/components/CreateDocument.d.ts +5 -7
  104. package/dist/editors/contributor-billing/components/CreateDocument.d.ts.map +1 -1
  105. package/dist/editors/contributor-billing/components/CreateDocument.js +18 -9
  106. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +6 -16
  107. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
  108. package/dist/editors/contributor-billing/components/DriveExplorer.js +190 -89
  109. package/dist/editors/contributor-billing/components/EditorContainer.d.ts +9 -13
  110. package/dist/editors/contributor-billing/components/EditorContainer.d.ts.map +1 -1
  111. package/dist/editors/contributor-billing/components/EditorContainer.js +37 -26
  112. package/dist/editors/contributor-billing/components/FolderTree.d.ts +7 -3
  113. package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -1
  114. package/dist/editors/contributor-billing/components/FolderTree.js +11 -4
  115. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +1 -2
  116. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
  117. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +4 -8
  118. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
  119. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +125 -119
  120. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts +1 -2
  121. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -1
  122. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +24 -4
  123. package/dist/editors/contributor-billing/editor.d.ts +9 -4
  124. package/dist/editors/contributor-billing/editor.d.ts.map +1 -1
  125. package/dist/editors/contributor-billing/editor.js +15 -41
  126. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +1 -2
  127. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -1
  128. package/dist/editors/contributor-billing/index.d.ts +1 -2
  129. package/dist/editors/contributor-billing/index.d.ts.map +1 -1
  130. package/dist/editors/integrations/editor.d.ts +1 -4
  131. package/dist/editors/integrations/editor.d.ts.map +1 -1
  132. package/dist/editors/integrations/editor.js +10 -1
  133. package/dist/editors/integrations/index.d.ts +1 -2
  134. package/dist/editors/integrations/index.d.ts.map +1 -1
  135. package/dist/editors/invoice/editor.d.ts +1 -4
  136. package/dist/editors/invoice/editor.d.ts.map +1 -1
  137. package/dist/editors/invoice/editor.js +10 -1
  138. package/dist/editors/invoice/index.d.ts +1 -2
  139. package/dist/editors/invoice/index.d.ts.map +1 -1
  140. package/dist/editors/invoice/ingestPDF.js +1 -1
  141. package/dist/editors/invoice/invoiceToGnosis.js +3 -3
  142. package/dist/editors/invoice/requestFinance.js +2 -2
  143. package/dist/editors/invoice/uploadPdfChunked.js +1 -1
  144. package/dist/index.d.ts +2 -2
  145. package/dist/index.d.ts.map +1 -1
  146. package/dist/reducers/general.d.ts +8 -0
  147. package/dist/reducers/general.d.ts.map +1 -0
  148. package/dist/reducers/general.js +73 -0
  149. package/dist/reducers/items.d.ts +8 -0
  150. package/dist/reducers/items.d.ts.map +1 -0
  151. package/dist/reducers/items.js +195 -0
  152. package/dist/reducers/parties.d.ts +8 -0
  153. package/dist/reducers/parties.d.ts.map +1 -0
  154. package/dist/reducers/parties.js +266 -0
  155. package/dist/reducers/transitions.d.ts +8 -0
  156. package/dist/reducers/transitions.d.ts.map +1 -0
  157. package/dist/reducers/transitions.js +162 -0
  158. package/dist/scripts/contributor-billing/createXeroCsv.js +2 -2
  159. package/dist/scripts/invoice/gnosisTransactionBuilder.js +1 -1
  160. package/dist/style.css +730 -108
  161. package/dist/subgraphs/billing-statement/index.d.ts +2 -1
  162. package/dist/subgraphs/billing-statement/index.d.ts.map +1 -1
  163. package/dist/subgraphs/billing-statement/resolvers.d.ts.map +1 -1
  164. package/dist/subgraphs/billing-statement/resolvers.js +101 -69
  165. package/dist/subgraphs/billing-statement/schema.js +3 -3
  166. package/dist/subgraphs/integrations/index.d.ts +2 -1
  167. package/dist/subgraphs/integrations/index.d.ts.map +1 -1
  168. package/dist/subgraphs/integrations/resolvers.d.ts.map +1 -1
  169. package/dist/subgraphs/integrations/resolvers.js +61 -46
  170. package/dist/subgraphs/integrations/schema.js +3 -3
  171. package/dist/subgraphs/invoice/index.d.ts +2 -1
  172. package/dist/subgraphs/invoice/index.d.ts.map +1 -1
  173. package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -1
  174. package/dist/subgraphs/invoice/resolvers.js +323 -181
  175. package/dist/subgraphs/invoice/schema.js +3 -3
  176. package/package.json +14 -14
@@ -1,48 +1,22 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { DriveContextProvider } from "@powerhousedao/reactor-browser/hooks/useDriveContext";
3
- import { addFolder, deleteNode, updateNode, generateNodesCopy, copyNode, } from "document-drive";
4
2
  import { WagmiContext } from "@powerhousedao/design-system";
3
+ import { AnalyticsProvider, DriveContextProvider, useAppConfig, } from "@powerhousedao/reactor-browser";
5
4
  import { DriveExplorer } from "./components/DriveExplorer.js";
6
- import { useCallback, useState, useEffect } from "react";
7
- import { generateId } from "document-model";
5
+ /**
6
+ * Base editor component that renders the drive explorer interface.
7
+ * Customize document opening behavior and drive-level actions here.
8
+ */
8
9
  export function BaseEditor(props) {
9
- const { dispatch, context } = props;
10
- // Use state for nodes
11
- const [nodes, setNodes] = useState(props.document.state.global.nodes);
12
- // Keep nodes in sync with props (in case of external updates)
13
- useEffect(() => {
14
- setNodes(props.document.state.global.nodes);
15
- }, [props.document.state.global.nodes]);
16
- const onAddFolder = useCallback((name, parentFolder) => {
17
- dispatch(addFolder({
18
- id: generateId(),
19
- name,
20
- parentFolder,
21
- }));
22
- }, [dispatch]);
23
- const onDeleteNode = useCallback((nodeId) => {
24
- dispatch(deleteNode({ id: nodeId }));
25
- setNodes([...props.document.state.global.nodes]);
26
- }, [dispatch, props.document.state.global.nodes]);
27
- const renameNode = useCallback((nodeId, name) => {
28
- dispatch(updateNode({ id: nodeId, name }));
29
- }, [dispatch]);
30
- const onCopyNode = useCallback((nodeId, targetName, parentId) => {
31
- const generateIdWrapper = (prevId) => generateId();
32
- const copyNodesInput = generateNodesCopy({
33
- srcId: nodeId,
34
- targetParentFolder: parentId,
35
- targetName,
36
- }, generateIdWrapper, props.document.state.global.nodes);
37
- const copyNodesAction = copyNodesInput.map((input) => {
38
- return copyNode(input);
39
- });
40
- for (const copyNodeAction of copyNodesAction) {
41
- dispatch(copyNodeAction);
42
- }
43
- }, [dispatch, props.document.state.global.nodes]);
44
- return (_jsx("div", { className: "new-drive-explorer", children: _jsx(DriveExplorer, { driveId: props.document.header.id, nodes: nodes, onAddFolder: onAddFolder, onDeleteNode: onDeleteNode, renameNode: renameNode, onCopyNode: onCopyNode, context: context, document: props.document, dispatch: dispatch }, nodes.length) }));
10
+ const { context, document } = props;
11
+ return (_jsx("div", { className: "new-drive-explorer", style: { height: "100%" }, children: _jsx(DriveExplorer, { document: document, context: context }) }));
45
12
  }
13
+ /**
14
+ * Main editor entry point with required providers.
15
+ */
46
16
  export default function Editor(props) {
47
- return (_jsx(DriveContextProvider, { value: props.context, children: _jsx(WagmiContext, { children: _jsx(BaseEditor, { ...props }) }) }));
17
+ const appConfig = useAppConfig();
18
+ const analyticsDatabaseName = appConfig?.analyticsDatabaseName;
19
+ return (
20
+ // Required context providers for drive functionality
21
+ _jsx(DriveContextProvider, { value: props.context, children: _jsx(WagmiContext, { children: _jsx(AnalyticsProvider, { databaseName: analyticsDatabaseName, children: _jsx(BaseEditor, { ...props }) }) }) }));
48
22
  }
@@ -1,4 +1,3 @@
1
1
  import type { Node } from "document-drive";
2
- import type { UiFileNode, UiFolderNode } from "@powerhousedao/design-system";
3
- export declare function useTransformedNodes(nodes: Node[], driveId: string): (UiFileNode | UiFolderNode)[];
2
+ export declare function useTransformedNodes(nodes: Node[], driveId: string): any[];
4
3
  //# sourceMappingURL=useTransformedNodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTransformedNodes.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/hooks/useTransformedNodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE7E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,iCA8BjE"}
1
+ {"version":3,"file":"useTransformedNodes.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/hooks/useTransformedNodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,gBAAgB,CAAC;AAGrD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,SA8BjE"}
@@ -1,5 +1,4 @@
1
1
  import { type DriveEditorModule } from "@powerhousedao/reactor-browser";
2
- import { type DocumentDriveDocument } from "document-drive";
3
- export declare const module: DriveEditorModule<DocumentDriveDocument>;
2
+ export declare const module: DriveEditorModule;
4
3
  export default module;
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editors/contributor-billing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAG5D,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,qBAAqB,CAS3D,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editors/contributor-billing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,eAAO,MAAM,MAAM,EAAE,iBASpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,5 +1,2 @@
1
- import type { EditorProps } from "document-model";
2
- import { type IntegrationsDocument } from "../../document-models/integrations/index.js";
3
- export type IProps = EditorProps<IntegrationsDocument>;
4
- export default function Editor(props: IProps): import("react/jsx-runtime").JSX.Element;
1
+ export default function Editor(props: any): import("react/jsx-runtime").JSX.Element;
5
2
  //# sourceMappingURL=editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/integrations/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,6CAA6C,CAAC;AAIrD,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAQvD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,MAAM,2CAsT3C"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/integrations/editor.tsx"],"names":[],"mappings":"AAeA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,GAAG,2CA8TxC"}
@@ -2,13 +2,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { actions, } from "../../document-models/integrations/index.js";
3
3
  import { Button } from "@powerhousedao/document-engineering";
4
4
  import { useState } from "react";
5
+ import { useSelectedDocument } from "@powerhousedao/reactor-browser";
5
6
  const TABS = [
6
7
  { key: "requestFinance", label: "Request Finance" },
7
8
  { key: "gnosisSafe", label: "Gnosis Safe" },
8
9
  { key: "googleCloud", label: "Google Cloud" },
9
10
  ];
10
11
  export default function Editor(props) {
11
- const { document, dispatch } = props;
12
+ let dispatch;
13
+ const { document } = props;
14
+ if (props?.dispatch) {
15
+ dispatch = props.dispatch;
16
+ }
17
+ else {
18
+ const selectedDocument = useSelectedDocument();
19
+ dispatch = selectedDocument[1];
20
+ }
12
21
  const [activeTab, setActiveTab] = useState("requestFinance");
13
22
  // State for each form
14
23
  const [requestFinance, setRequestFinance] = useState(() => ({
@@ -1,5 +1,4 @@
1
1
  import type { EditorModule } from "document-model";
2
- import type { IntegrationsDocument } from "../../document-models/integrations/index.js";
3
- export declare const module: EditorModule<IntegrationsDocument>;
2
+ export declare const module: EditorModule;
4
3
  export default module;
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editors/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAExF,eAAO,MAAM,MAAM,EAAE,YAAY,CAAC,oBAAoB,CASrD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editors/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,MAAM,EAAE,YASpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,5 +1,2 @@
1
- import { type EditorProps } from "document-model";
2
- import { type InvoiceDocument } from "../../document-models/invoice/index.js";
3
- export type IProps = EditorProps<InvoiceDocument>;
4
- export default function Editor(props: IProps): import("react/jsx-runtime").JSX.Element;
1
+ export default function Editor(props: any): import("react/jsx-runtime").JSX.Element;
5
2
  //# sourceMappingURL=editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/invoice/editor.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,wCAAwC,CAAC;AAqChD,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,MAAM,2CA26B3C"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/invoice/editor.tsx"],"names":[],"mappings":"AA6CA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,GAAG,2CAk7BxC"}
@@ -23,11 +23,20 @@ import ConfirmationModal from "./components/confirmationModal.js";
23
23
  import { ClosePaymentModalContent, ConfirmPaymentModalContent, FinalRejectionModalContent, IssueInvoiceModalContent, RegisterPaymentTxModalContent, RejectInvoiceModalContent, ReportPaymentIssueModalContent, SchedulePaymentModalContent, } from "./components/statusModalComponents.js";
24
24
  import { InvoiceStateSchema } from "../../document-models/invoice/gen/schema/zod.js";
25
25
  import validateStatusBeforeContinue from "./validation/validationHandler.js";
26
+ import { useSelectedDocument } from "@powerhousedao/reactor-browser";
26
27
  function isFiatCurrency(currency) {
27
28
  return currencyList.find((c) => c.ticker === currency)?.crypto === false;
28
29
  }
29
30
  export default function Editor(props) {
30
- const { document: doc, dispatch } = props;
31
+ let dispatch;
32
+ const { document: doc } = props;
33
+ if (props?.dispatch) {
34
+ dispatch = props.dispatch;
35
+ }
36
+ else {
37
+ const selectedDocument = useSelectedDocument();
38
+ dispatch = selectedDocument[1];
39
+ }
31
40
  const state = doc.state.global;
32
41
  // Dynamic property check based on the actual schema
33
42
  try {
@@ -1,5 +1,4 @@
1
1
  import type { EditorModule } from "document-model";
2
- import type { InvoiceDocument } from "../../document-models/invoice/index.js";
3
- export declare const module: EditorModule<InvoiceDocument>;
2
+ export declare const module: EditorModule;
4
3
  export default module;
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editors/invoice/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAE9E,eAAO,MAAM,MAAM,EAAE,YAAY,CAAC,eAAe,CAShD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../editors/invoice/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,MAAM,EAAE,YASpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -6,7 +6,7 @@ import { uploadPdfChunked } from "./uploadPdfChunked.js";
6
6
  import { getCountryCodeFromName } from "./utils/utils.js";
7
7
  let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
8
8
  if (!window.document.baseURI.includes('localhost')) {
9
- GRAPHQL_URL = 'https://switchboard.powerhouse.xyz/graphql/invoice';
9
+ GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
10
10
  }
11
11
  export async function loadPDFFile({ file, dispatch, }) {
12
12
  if (!file)
@@ -3,8 +3,8 @@ import { useState } from "react";
3
3
  import { actions } from "../../document-models/invoice/index.js";
4
4
  import { generateId } from "document-model";
5
5
  let GRAPHQL_URL = "http://localhost:4001/graphql/invoice";
6
- if (!window.document.baseURI.includes('localhost')) {
7
- GRAPHQL_URL = 'https://switchboard.powerhouse.xyz/graphql/invoice';
6
+ if (!window.document.baseURI.includes("localhost")) {
7
+ GRAPHQL_URL = "https://switchboard-dev.powerhouse.xyz/graphql/invoice";
8
8
  }
9
9
  const InvoiceToGnosis = ({ docState, dispatch, }) => {
10
10
  const [isLoading, setIsLoading] = useState(false);
@@ -157,7 +157,7 @@ const InvoiceToGnosis = ({ docState, dispatch, }) => {
157
157
  ? "Processing..."
158
158
  : invoiceStatus === "ACCEPTED"
159
159
  ? "Schedule Payment in Gnosis Safe"
160
- : "Reschedule Payment in Gnosis Safe" })), error && (_jsx("div", { className: "text-red-500 bg-red-50 p-3 rounded-md", children: error })), safeTxHash && (_jsxs("div", { className: "bg-gray-50 mt-4 rounded-md space-y-2", children: [_jsx("a", { href: `https://app.safe.global/transactions/queue?safe=${urlChainName}:0xF130f741d4E3185b29412c65397363f8c23A0460`, target: "_blank", rel: "noopener noreferrer", className: "text-blue-500 hover:text-blue-600 underline block", children: linkText }), _jsxs("p", { className: "font-medium", children: ["Safe Transaction Hash:", _jsx("span", { className: "font-mono text-sm ml-2 break-all", children: safeTxHash })] })] })), !safeTxHash &&
160
+ : "Reschedule Payment in Gnosis Safe" })), error && (_jsx("div", { className: "text-red-500 bg-red-50 p-3 rounded-md", children: error })), safeTxHash && (_jsxs("div", { className: "bg-gray-50 mt-4 rounded-md space-y-2", children: [_jsx("a", { href: `https://app.safe.global/transactions/queue?safe=${urlChainName}:0x1FB6bEF04230d67aF0e3455B997a28AFcCe1F45e`, target: "_blank", rel: "noopener noreferrer", className: "text-blue-500 hover:text-blue-600 underline block", children: linkText }), _jsxs("p", { className: "font-medium", children: ["Safe Transaction Hash:", _jsx("span", { className: "font-mono text-sm ml-2 break-all", children: safeTxHash })] })] })), !safeTxHash &&
161
161
  !error &&
162
162
  invoiceStatus === "PAYMENTSCHEDULED" &&
163
163
  docState.payments.length > 0 && (_jsx(_Fragment, { children: docState.payments[docState.payments.length - 1].issue !== "" ? (_jsx("div", { className: "mt-4", children: _jsxs("p", { className: "text-red-700 font-medium", children: ["Issue: ", docState.payments[docState.payments.length - 1].issue] }) })) : (_jsxs("div", { className: "mt-4", children: [_jsx("div", { className: "invoice-link text-blue-900 hover:text-blue-600", children: _jsx("a", { className: "view-invoice-button", href: `https://app.safe.global/transactions/queue?safe=${urlChainName}:0x1FB6bEF04230d67aF0e3455B997a28AFcCe1F45e`, target: "_blank", rel: "noopener noreferrer", children: linkText }) }), _jsxs("p", { className: "mt-4 font-medium", children: ["Safe Transaction Hash:", _jsx("span", { className: "font-mono text-sm ml-2 break-all", children: docState.payments[docState.payments.length - 1]
@@ -3,8 +3,8 @@ import { useState } from "react";
3
3
  import { actions } from "../../document-models/invoice/index.js";
4
4
  import { generateId } from "document-model";
5
5
  let GRAPHQL_URL = "http://localhost:4001/graphql/invoice";
6
- if (!window.document.baseURI.includes('localhost')) {
7
- GRAPHQL_URL = 'https://switchboard.powerhouse.xyz/graphql/invoice';
6
+ if (!window.document.baseURI.includes("localhost")) {
7
+ GRAPHQL_URL = "https://switchboard-dev.powerhouse.xyz/graphql/invoice";
8
8
  }
9
9
  const RequestFinance = ({ docState, dispatch, }) => {
10
10
  const [isLoading, setIsLoading] = useState(false);
@@ -7,7 +7,7 @@
7
7
  */
8
8
  let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
9
9
  if (!window.document.baseURI.includes('localhost')) {
10
- GRAPHQL_URL = 'https://switchboard.powerhouse.xyz/graphql/invoice';
10
+ GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
11
11
  }
12
12
  export async function uploadPdfChunked(pdfData, endpoint = GRAPHQL_URL, chunkSize = 500 * 1024, // 500KB chunks
13
13
  onProgress) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Manifest } from "document-model";
2
2
  export declare const manifest: Manifest;
3
- export declare const documentModels: (import("document-model").DocumentModelModule<import("./document-models/invoice/index.js").InvoiceDocument> | import("document-model").DocumentModelModule<import("./document-models/billing-statement/index.js").BillingStatementDocument> | import("document-model").DocumentModelModule<import("./document-models/integrations/index.js").IntegrationsDocument>)[];
4
- export declare const editors: (import("document-model").EditorModule<import("./document-models/invoice/index.js").InvoiceDocument> | import("@powerhousedao/reactor-browser").DriveEditorModule<import("document-drive").DocumentDriveDocument> | import("document-model").EditorModule<import("./document-models/billing-statement/index.js").BillingStatementDocument> | import("document-model").EditorModule<import("./document-models/integrations/index.js").IntegrationsDocument>)[];
3
+ export declare const documentModels: (import("document-model").DocumentModelModule<import("./document-models/invoice/gen/ph-factories.js").InvoicePHState> | import("document-model").DocumentModelModule<import("./document-models/billing-statement/gen/ph-factories.js").BillingStatementPHState> | import("document-model").DocumentModelModule<import("./document-models/integrations/gen/ph-factories.js").IntegrationsPHState>)[];
4
+ export declare const editors: (import("document-model").EditorModule | import("@powerhousedao/reactor-browser").DriveEditorModule)[];
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,eAAO,MAAM,QAAQ,EAAE,QAAuB,CAAC;AAC/C,eAAO,MAAM,cAAc,uWAAuC,CAAC;AACnE,eAAO,MAAM,OAAO,+bAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,eAAO,MAAM,QAAQ,EAAE,QAAuB,CAAC;AAC/C,eAAO,MAAM,cAAc,qYAAuC,CAAC;AACnE,eAAO,MAAM,OAAO,wGAAgC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ import type { InvoiceGeneralOperations } from "../../gen/general/operations.js";
7
+ export declare const reducer: InvoiceGeneralOperations;
8
+ //# sourceMappingURL=general.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../reducers/general.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,eAAO,MAAM,OAAO,EAAE,wBAkErB,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ export const reducer = {
7
+ editInvoiceOperation(state, action, dispatch) {
8
+ try {
9
+ const newState = { ...state };
10
+ newState.currency = action.input.currency ?? state.currency;
11
+ newState.dateDue = action.input.dateDue ?? state.dateDue;
12
+ newState.dateIssued = action.input.dateIssued ?? state.dateIssued;
13
+ newState.invoiceNo = action.input.invoiceNo ?? state.invoiceNo;
14
+ newState.notes = action.input.notes ?? state.notes;
15
+ state = Object.assign(state, newState);
16
+ }
17
+ catch (e) {
18
+ console.error(e);
19
+ }
20
+ },
21
+ editStatusOperation(state, action, dispatch) {
22
+ try {
23
+ state.status = action.input.status;
24
+ }
25
+ catch (e) {
26
+ console.error(e);
27
+ }
28
+ },
29
+ editPaymentDataOperation(state, action, dispatch) {
30
+ try {
31
+ const payment = state.payments.find((payment) => payment.id === action.input.id);
32
+ if (payment) {
33
+ payment.processorRef = action.input.processorRef ?? payment.processorRef;
34
+ payment.paymentDate = action.input.paymentDate ?? payment.paymentDate;
35
+ payment.txnRef = action.input.txnRef ?? payment.txnRef;
36
+ payment.confirmed = action.input.confirmed ?? payment.confirmed;
37
+ payment.issue = action.input.issue ?? payment.issue;
38
+ }
39
+ }
40
+ catch (e) {
41
+ console.error(e);
42
+ }
43
+ },
44
+ addPaymentOperation(state, action, dispatch) {
45
+ try {
46
+ const payment = {
47
+ id: action.input.id,
48
+ processorRef: action.input.processorRef ?? "",
49
+ paymentDate: action.input.paymentDate ?? "",
50
+ txnRef: action.input.txnRef ?? "",
51
+ confirmed: action.input.confirmed ?? false,
52
+ issue: action.input.issue ?? "",
53
+ amount: 0,
54
+ };
55
+ state.payments.push(payment);
56
+ }
57
+ catch (e) {
58
+ console.error(e);
59
+ }
60
+ },
61
+ setExportedDataOperation(state, action, dispatch) {
62
+ try {
63
+ const exportedData = {
64
+ timestamp: action.input.timestamp,
65
+ exportedLineItems: action.input.exportedLineItems,
66
+ };
67
+ state.exported = exportedData;
68
+ }
69
+ catch (e) {
70
+ console.error(e);
71
+ }
72
+ }
73
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ import type { InvoiceItemsOperations } from "../../gen/items/operations.js";
7
+ export declare const reducer: InvoiceItemsOperations;
8
+ //# sourceMappingURL=items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../reducers/items.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,eAAO,MAAM,OAAO,EAAE,sBA6GrB,CAAC"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ export const reducer = {
7
+ addLineItemOperation(state, action, dispatch) {
8
+ try {
9
+ const item = {
10
+ ...action.input,
11
+ lineItemTag: [],
12
+ };
13
+ if (state.lineItems.find((x) => x.id === item.id))
14
+ throw new Error("Duplicate input.id");
15
+ validatePrices(item);
16
+ state.lineItems.push(item);
17
+ updateTotals(state);
18
+ }
19
+ catch (e) {
20
+ console.error(e);
21
+ }
22
+ },
23
+ editLineItemOperation(state, action, dispatch) {
24
+ try {
25
+ const stateItem = state.lineItems.find((x) => x.id === action.input.id);
26
+ if (!stateItem)
27
+ throw new Error("Item matching input.id not found");
28
+ const sanitizedInput = Object.fromEntries(Object.entries(action.input).filter(([, value]) => value !== null));
29
+ // Ensure lineItemTag is always an array if provided
30
+ if ('lineItemTag' in action.input) {
31
+ sanitizedInput.lineItemTag = (action.input.lineItemTag ?? []);
32
+ }
33
+ const nextItem = {
34
+ ...stateItem,
35
+ ...sanitizedInput,
36
+ };
37
+ validatePrices(nextItem);
38
+ applyInvariants(state, nextItem);
39
+ Object.assign(stateItem, nextItem);
40
+ updateTotals(state);
41
+ }
42
+ catch (e) {
43
+ console.error(e);
44
+ }
45
+ },
46
+ deleteLineItemOperation(state, action, dispatch) {
47
+ try {
48
+ state.lineItems = state.lineItems.filter((x) => x.id !== action.input.id);
49
+ updateTotals(state);
50
+ }
51
+ catch (e) {
52
+ console.error(e);
53
+ }
54
+ },
55
+ setLineItemTagOperation(state, action, dispatch) {
56
+ try {
57
+ const stateItem = state.lineItems.find((x) => x.id === action.input.lineItemId);
58
+ if (!stateItem)
59
+ throw new Error("Item matching input.id not found");
60
+ // if tag already exists with the same dimension, update the value and label
61
+ const existingTag = stateItem.lineItemTag?.find((tag) => tag.dimension === action.input.dimension);
62
+ if (existingTag) {
63
+ existingTag.value = action.input.value;
64
+ existingTag.label = action.input.label || null;
65
+ }
66
+ else {
67
+ // if tag does not exist, add it
68
+ const newTag = {
69
+ dimension: action.input.dimension,
70
+ value: action.input.value,
71
+ label: action.input.label || null,
72
+ };
73
+ if (!stateItem.lineItemTag) {
74
+ stateItem.lineItemTag = [];
75
+ }
76
+ // Add the new tag
77
+ stateItem.lineItemTag?.push(newTag);
78
+ }
79
+ }
80
+ catch (e) {
81
+ console.error(e);
82
+ }
83
+ },
84
+ setInvoiceTagOperation(state, action, dispatch) {
85
+ try {
86
+ // if tag already exists with the same dimension, update the value and label
87
+ const existingTag = state.invoiceTags?.find((tag) => tag.dimension === action.input.dimension);
88
+ if (existingTag) {
89
+ existingTag.value = action.input.value;
90
+ existingTag.label = action.input.label || null;
91
+ }
92
+ else {
93
+ // if tag does not exist, add it
94
+ const newTag = {
95
+ dimension: action.input.dimension,
96
+ value: action.input.value,
97
+ label: action.input.label || null,
98
+ };
99
+ if (!state.invoiceTags) {
100
+ state.invoiceTags = [];
101
+ }
102
+ // Add the new tag
103
+ state.invoiceTags.push(newTag);
104
+ }
105
+ }
106
+ catch (e) {
107
+ console.error(e);
108
+ }
109
+ },
110
+ };
111
+ function updateTotals(state) {
112
+ state.totalPriceTaxExcl = state.lineItems.reduce((total, lineItem) => {
113
+ return total + lineItem.quantity * lineItem.unitPriceTaxExcl;
114
+ }, 0.0);
115
+ state.totalPriceTaxIncl = state.lineItems.reduce((total, lineItem) => {
116
+ return total + lineItem.quantity * lineItem.unitPriceTaxIncl;
117
+ }, 0.0);
118
+ }
119
+ function validatePrices(item) {
120
+ const EPSILON = 0.00001; // Small value for floating point comparisons
121
+ // Calculate total prices from unit prices and quantity
122
+ const calcPriceIncl = item.quantity * item.unitPriceTaxIncl;
123
+ const calcPriceExcl = item.quantity * item.unitPriceTaxExcl;
124
+ // Convert tax percentage to decimal rate
125
+ const taxRate = item.taxPercent / 100;
126
+ // Helper function to compare floating point numbers
127
+ const isClose = (a, b) => Math.abs(a - b) < EPSILON;
128
+ // Validate unit prices (tax-exclusive should equal tax-inclusive / (1 + taxRate))
129
+ const expectedUnitPriceExcl = item.unitPriceTaxIncl / (1 + taxRate);
130
+ if (!isClose(item.unitPriceTaxExcl, expectedUnitPriceExcl)) {
131
+ throw new Error("Tax inclusive/exclusive unit prices failed comparison.");
132
+ }
133
+ // Validate total prices
134
+ if (!isClose(calcPriceIncl, item.totalPriceTaxIncl)) {
135
+ throw new Error("Calculated unitPriceTaxIncl does not match input total");
136
+ }
137
+ if (!isClose(calcPriceExcl, item.totalPriceTaxExcl)) {
138
+ throw new Error("Calculated unitPriceTaxExcl does not match input total");
139
+ }
140
+ // Validate total prices using the tax rate
141
+ const expectedTotalPriceExcl = calcPriceIncl / (1 + taxRate);
142
+ if (!isClose(calcPriceExcl, expectedTotalPriceExcl)) {
143
+ throw new Error("Tax inclusive/exclusive totals failed comparison.");
144
+ }
145
+ }
146
+ const applyInvariants = (state, nextItem) => {
147
+ const EPSILON = 0.00001; // Small value for floating point comparisons
148
+ // Helper function to compare floating point numbers
149
+ const isClose = (a, b) => Math.abs(a - b) < EPSILON;
150
+ // Helper function to check if a value has changed significantly
151
+ const hasChanged = (oldValue, newValue) => !isClose(oldValue, newValue);
152
+ // Find the current state of this line item
153
+ const currentItem = state.lineItems.find(item => item.id === nextItem.id);
154
+ if (!currentItem) {
155
+ // New item, no comparison needed
156
+ return;
157
+ }
158
+ const taxRate = nextItem.taxPercent / 100;
159
+ // Check if totalPriceTaxExcl was changed and update unitPriceTaxExcl accordingly
160
+ const expectedTotalPriceTaxExcl = nextItem.quantity * nextItem.unitPriceTaxExcl;
161
+ if (hasChanged(expectedTotalPriceTaxExcl, nextItem.totalPriceTaxExcl)) {
162
+ // Total was changed, update unit price
163
+ nextItem.unitPriceTaxExcl = nextItem.totalPriceTaxExcl / nextItem.quantity;
164
+ // Update tax-inclusive unit price to maintain tax relationship
165
+ nextItem.unitPriceTaxIncl = nextItem.unitPriceTaxExcl * (1 + taxRate);
166
+ // Update tax-inclusive total to maintain consistency
167
+ nextItem.totalPriceTaxIncl = nextItem.quantity * nextItem.unitPriceTaxIncl;
168
+ }
169
+ // Check if totalPriceTaxIncl was changed and update unitPriceTaxIncl accordingly
170
+ const expectedTotalPriceTaxIncl = nextItem.quantity * nextItem.unitPriceTaxIncl;
171
+ if (hasChanged(expectedTotalPriceTaxIncl, nextItem.totalPriceTaxIncl)) {
172
+ // Total was changed, update unit price
173
+ nextItem.unitPriceTaxIncl = nextItem.totalPriceTaxIncl / nextItem.quantity;
174
+ // Update tax-exclusive unit price to maintain tax relationship
175
+ nextItem.unitPriceTaxExcl = nextItem.unitPriceTaxIncl / (1 + taxRate);
176
+ // Update tax-exclusive total to maintain consistency
177
+ nextItem.totalPriceTaxExcl = nextItem.quantity * nextItem.unitPriceTaxExcl;
178
+ }
179
+ // Check if unitPriceTaxExcl was changed and update totals accordingly
180
+ const expectedUnitPriceTaxIncl = nextItem.unitPriceTaxExcl * (1 + taxRate);
181
+ if (hasChanged(expectedUnitPriceTaxIncl, nextItem.unitPriceTaxIncl)) {
182
+ // Unit price was changed, update tax-inclusive unit price and totals
183
+ nextItem.unitPriceTaxIncl = nextItem.unitPriceTaxExcl * (1 + taxRate);
184
+ nextItem.totalPriceTaxExcl = nextItem.quantity * nextItem.unitPriceTaxExcl;
185
+ nextItem.totalPriceTaxIncl = nextItem.quantity * nextItem.unitPriceTaxIncl;
186
+ }
187
+ // Check if unitPriceTaxIncl was changed and update totals accordingly
188
+ const expectedUnitPriceTaxExcl = nextItem.unitPriceTaxIncl / (1 + taxRate);
189
+ if (hasChanged(expectedUnitPriceTaxExcl, nextItem.unitPriceTaxExcl)) {
190
+ // Unit price was changed, update tax-exclusive unit price and totals
191
+ nextItem.unitPriceTaxExcl = nextItem.unitPriceTaxIncl / (1 + taxRate);
192
+ nextItem.totalPriceTaxExcl = nextItem.quantity * nextItem.unitPriceTaxExcl;
193
+ nextItem.totalPriceTaxIncl = nextItem.quantity * nextItem.unitPriceTaxIncl;
194
+ }
195
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - modify it by implementing the reducer functions
4
+ * - delete the file and run the code generator again to have it reset
5
+ */
6
+ import type { InvoicePartiesOperations } from "../../gen/parties/operations.js";
7
+ export declare const reducer: InvoicePartiesOperations;
8
+ //# sourceMappingURL=parties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parties.d.ts","sourceRoot":"","sources":["../../reducers/parties.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAShF,eAAO,MAAM,OAAO,EAAE,wBAwarB,CAAC"}