@accounter/client 0.0.8-alpha-20251029124401-d15137847e8450b1ecf3e3cfa6b68dda7239ca45 → 0.0.8-alpha-20251029124558-c1dac18cef0a90c88021bcb6e06319cc55ec33d9

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 (113) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-Cxbop3qM.js → Checkbox-w99PhJ6L.js} +2 -2
  3. package/dist/assets/{MultiSelect-D1XVjXLN.js → MultiSelect-9BbcXHjB.js} +1 -1
  4. package/dist/assets/{Pagination-DMimIHM4.js → Pagination-BVQu3Yj6.js} +1 -1
  5. package/dist/assets/{Progress-CP4jnh2x.js → Progress-BKRQuJXK.js} +1 -1
  6. package/dist/assets/{Table-DTU12O53.js → Table-CR8S5Pp5.js} +1 -1
  7. package/dist/assets/{Typography-IL0wuZeq.js → Typography-D1_XzAPj.js} +1 -1
  8. package/dist/assets/{YearPickerInput-CPL_XozD.js → YearPickerInput-dCiPlZqk.js} +1 -1
  9. package/dist/assets/{accordion-DKLV9b0H.js → accordion-QkFWsf0a.js} +1 -1
  10. package/dist/assets/{accountant-approvals-CdX2nUgB.js → accountant-approvals-AD_TNBTH.js} +1 -1
  11. package/dist/assets/{accounter-table-CeZ4q0re.js → accounter-table-CBigzB_s.js} +1 -1
  12. package/dist/assets/{addDays-sGeEkIxC.js → addDays-CjlJbHpj.js} +1 -1
  13. package/dist/assets/{all-charges-BJvp1ecZ.js → all-charges-BdHR-QjC.js} +1 -1
  14. package/dist/assets/{arrow-up-down-DkEXGAin.js → arrow-up-down-Cq3mRkaO.js} +1 -1
  15. package/dist/assets/{building-2-BcYhLAVP.js → building-2-BE02hpsM.js} +1 -1
  16. package/dist/assets/{business-CO7M6XNI.js → business-CX0D-23F.js} +17 -7
  17. package/dist/assets/business-extended-info-BRde-LSv.js +13 -0
  18. package/dist/assets/{business-header-BG2B-PcM.js → business-header-CMH3yBZc.js} +1 -1
  19. package/dist/assets/business-ledger-filters-DQ4D4mv8.js +1 -0
  20. package/dist/assets/business-ledger-single-BSeNj9f2.js +1 -0
  21. package/dist/assets/business-trip-CX-3yJmB.js +1 -0
  22. package/dist/assets/{charge-Bm0hPNT7.js → charge-BzCN_Szu.js} +1 -1
  23. package/dist/assets/{charges-filters-DjnsiGzC.js → charges-filters-C7YlWAFn.js} +1 -1
  24. package/dist/assets/{charges-ledger-validation-CoHDjCf2.js → charges-ledger-validation-DqM92cc-.js} +1 -1
  25. package/dist/assets/charges-table-BOnvwci9.js +62 -0
  26. package/dist/assets/{chart-SbwWAyei.js → chart-OVHXA3Uy.js} +1 -1
  27. package/dist/assets/{data-table-pagination-DtnUvTOC.js → data-table-pagination-BLbPHs4o.js} +1 -1
  28. package/dist/assets/download-csv-button-C5J9ow3I.js +1 -0
  29. package/dist/assets/{editable-business-trip-xFRu5fSA.js → editable-business-trip-Ito1rWaY.js} +1 -1
  30. package/dist/assets/{funnel-WdA7f2As.js → funnel-IYKnhWOy.js} +1 -1
  31. package/dist/assets/{index-BOhdfO95.js → index-2j4tFkfX.js} +1 -1
  32. package/dist/assets/{index-VzPCd0L-.js → index-4YPOH-A_.js} +2 -2
  33. package/dist/assets/index-B3W0RNqC.js +1 -0
  34. package/dist/assets/{index-Vq1FAgYe.js → index-BOmTn4-L.js} +1 -1
  35. package/dist/assets/{index-BaEmw40f.js → index-C8HkbFzQ.js} +1 -1
  36. package/dist/assets/{index-9JObwNSb.js → index-CP5LZIWs.js} +1 -1
  37. package/dist/assets/{index-Ct0AJEN9.js → index-CY5Ok8zP.js} +2 -2
  38. package/dist/assets/{index-DPvrbbz9.js → index-CcJvt1sI.js} +119 -119
  39. package/dist/assets/{index-BIdEjDD3.js → index-Cn-lknzD.js} +1 -1
  40. package/dist/assets/{index-Ey6XKYuP.js → index-CnlrBGcj.js} +2 -2
  41. package/dist/assets/{index-1loWF1jV.js → index-D1Hpe746.js} +1 -1
  42. package/dist/assets/{index-BxnmQCT9.js → index-D31j2-8X.js} +1 -1
  43. package/dist/assets/{index-mN2sZqiu.js → index-D68aCDMG.js} +7 -7
  44. package/dist/assets/index-DE0nwhFR.js +1 -0
  45. package/dist/assets/{index-CwbqTlM4.js → index-DGxxgGxy.js} +2 -2
  46. package/dist/assets/{index-W6Xv87pg.js → index-DKVhuSlP.js} +1 -1
  47. package/dist/assets/{index-DjQIiDMo.js → index-DeFWFAwx.js} +1 -1
  48. package/dist/assets/{index-Bw5hpWBz.js → index-DjPei962.js} +2 -2
  49. package/dist/assets/{index-CdAUtS2Q.js → index-Dvp0RPEc.js} +1 -1
  50. package/dist/assets/{index-CfsTscFv.js → index-a32atud-.js} +1 -1
  51. package/dist/assets/{index-CXH_lcpK.js → index-kSig9eXf.js} +2 -2
  52. package/dist/assets/index-ofME77ND.js +6 -0
  53. package/dist/assets/{index-Bm3ZL2dx.js → index-ofu4jqHf.js} +1 -1
  54. package/dist/assets/{index--LMZMPY_.js → index-qLJISPWb.js} +1 -1
  55. package/dist/assets/{index-p1BcqxXQ.js → index-smNUtwvf.js} +1 -1
  56. package/dist/assets/{index.es-C3XngPKv.js → index.es-D7_nzQqR.js} +1 -1
  57. package/dist/assets/{insert-business-trip-modal-BHY3QQup.js → insert-business-trip-modal-D08ePEzY.js} +2 -2
  58. package/dist/assets/issue-document-D2L9kG1u.js +1 -0
  59. package/dist/assets/{list-plus-ZvPwjqZn.js → list-plus-Cv8qnwZd.js} +1 -1
  60. package/dist/assets/{login-page-CsXdm3AZ.js → login-page-sUXp3XoV.js} +1 -1
  61. package/dist/assets/{match-document-modal-Cqimg0VE.js → match-document-modal-D2TgC0aR.js} +4 -4
  62. package/dist/assets/{missing-info-charges-DxLGt6Xs.js → missing-info-charges-BJnQHRZs.js} +1 -1
  63. package/dist/assets/{modal-Nvfe-DMu.js → modal-DOtlViK5.js} +1 -1
  64. package/dist/assets/{page-layout-SHFb6rY4.js → page-layout-BNHKLJFL.js} +1 -1
  65. package/dist/assets/{page-not-found-BZ6s-Q5n.js → page-not-found-j9vQhz-c.js} +1 -1
  66. package/dist/assets/{panel-top-open-C3Q9X7Tg.js → panel-top-open-DQ1wo5PZ.js} +1 -1
  67. package/dist/assets/{pencil-CPPx1BhC.js → pencil-BWTnh6hj.js} +1 -1
  68. package/dist/assets/{report-commentary-row-DpYgprQr.js → report-commentary-row-DBOCwi7X.js} +1 -1
  69. package/dist/assets/{save-D-W46u2J.js → save-DuIXDTLc.js} +1 -1
  70. package/dist/assets/{similar-transactions-modal-zQY2R-sr.js → similar-transactions-modal-DDVojjq0.js} +1 -1
  71. package/dist/assets/sub-CIKovQuv.js +1 -0
  72. package/dist/assets/subMonths-GbNm9rnx.js +1 -0
  73. package/dist/assets/{summary-DwX_dmjr.js → summary-BV3HUEgI.js} +1 -1
  74. package/dist/assets/{toggle-expansion-button-Bh24n-cz.js → toggle-expansion-button-Bdpb_YfG.js} +1 -1
  75. package/dist/assets/tooltip-Cy3vJ3fy.js +1 -0
  76. package/dist/assets/{use-url-query-COmN7DHP.js → use-url-query-D-GsTMWL.js} +1 -1
  77. package/dist/index.html +1 -1
  78. package/package.json +1 -1
  79. package/src/components/business/balance-section.tsx +26 -0
  80. package/src/components/business/index.tsx +31 -1
  81. package/src/components/business/ledger-section.tsx +49 -0
  82. package/src/components/business/transactions-section.tsx +24 -2
  83. package/src/components/{business-transactions → business-ledger}/business-extended-info.tsx +25 -27
  84. package/src/components/{business-transactions/business-transactions-filters.tsx → business-ledger/business-ledger-filters.tsx} +12 -12
  85. package/src/components/{business-transactions/business-transactions-single.tsx → business-ledger/business-ledger-single.tsx} +13 -13
  86. package/src/components/{business-transactions → business-ledger}/download-csv.tsx +25 -25
  87. package/src/components/{business-transactions → business-ledger}/index.tsx +15 -15
  88. package/src/components/charges/charge-extended-info.tsx +45 -4
  89. package/src/components/layout/sidelinks.tsx +2 -2
  90. package/src/components/ledger-table/columns.tsx +4 -4
  91. package/src/components/ledger-table/index.tsx +141 -181
  92. package/src/components/reports/conto/custom-node.tsx +1 -1
  93. package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
  94. package/src/components/transactions-table/columns.tsx +9 -9
  95. package/src/components/transactions-table/index.tsx +45 -21
  96. package/src/gql/gql.ts +30 -12
  97. package/src/gql/graphql.ts +181 -406
  98. package/src/router/config.tsx +14 -14
  99. package/src/router/routes.ts +2 -2
  100. package/dist/assets/business-extended-info-MUfOmQ_B.js +0 -13
  101. package/dist/assets/business-transactions-filters-Cijy7ryl.js +0 -1
  102. package/dist/assets/business-transactions-single-DZqMwNkv.js +0 -1
  103. package/dist/assets/business-trip-C7G814AY.js +0 -1
  104. package/dist/assets/charges-table-C_4dY1Ic.js +0 -62
  105. package/dist/assets/download-csv-button-D9_6J2pA.js +0 -1
  106. package/dist/assets/index-Bx-qi8fd.js +0 -1
  107. package/dist/assets/index-D3-tv-Kb.js +0 -1
  108. package/dist/assets/index-DFgRsYAU.js +0 -6
  109. package/dist/assets/issue-document-BpzcqnRu.js +0 -1
  110. package/dist/assets/sub-7frHBT3Y.js +0 -1
  111. package/dist/assets/subMonths-CY79vHaS.js +0 -1
  112. package/dist/assets/tooltip-BaULIFLC.js +0 -1
  113. package/src/app.tsx +0 -108
@@ -9,10 +9,10 @@ import {
9
9
  import { useQuery } from 'urql';
10
10
  import { Mark, Table, Text, Tooltip } from '@mantine/core';
11
11
  import {
12
- BusinessTransactionsSummeryDocument,
12
+ BusinessLedgerRecordsSummeryDocument,
13
13
  Currency,
14
+ type BusinessLedgerRecordsSummeryQuery,
14
15
  type BusinessTransactionsFilter,
15
- type BusinessTransactionsSummeryQuery,
16
16
  } from '../../gql/graphql.js';
17
17
  import { FIAT_CURRENCIES } from '../../helpers/index.js';
18
18
  import { useUrlQuery } from '../../hooks/use-url-query.js';
@@ -21,11 +21,11 @@ import { AccounterTableRow } from '../common/index.js';
21
21
  import { PageLayout } from '../layout/page-layout.js';
22
22
  import { Button } from '../ui/button.js';
23
23
  import { BusinessExtendedInfo } from './business-extended-info.js';
24
- import { BusinessTransactionsFilters } from './business-transactions-filters.js';
24
+ import { BusinessLedgerRecordsFilters } from './business-ledger-filters.js';
25
25
 
26
26
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
27
27
  /* GraphQL */ `
28
- query BusinessTransactionsSummery($filters: BusinessTransactionsFilter) {
28
+ query BusinessLedgerRecordsSummery($filters: BusinessTransactionsFilter) {
29
29
  businessTransactionsSumFromLedgerRecords(filters: $filters) {
30
30
  ... on BusinessTransactionsSumFromLedgerRecordsSuccessfulResult {
31
31
  businessTransactionsSum {
@@ -66,32 +66,32 @@ import { BusinessTransactionsFilters } from './business-transactions-filters.js'
66
66
  }
67
67
  `;
68
68
 
69
- type BusinessTransactionsSum = Extract<
70
- BusinessTransactionsSummeryQuery['businessTransactionsSumFromLedgerRecords'],
69
+ type BusinessLedgerRecordsSum = Extract<
70
+ BusinessLedgerRecordsSummeryQuery['businessTransactionsSumFromLedgerRecords'],
71
71
  { businessTransactionsSum: unknown }
72
72
  >['businessTransactionsSum'][number];
73
73
 
74
74
  type CellInfo = {
75
75
  title: string | ReactNode;
76
76
  disabled?: boolean;
77
- value: (item: BusinessTransactionsSum) => string | ReactNode;
77
+ value: (item: BusinessLedgerRecordsSum) => string | ReactNode;
78
78
  style?: React.CSSProperties;
79
79
  };
80
80
 
81
- export const BusinessTransactionsSummery = (): ReactElement => {
81
+ export const BusinessLedgerRecordsSummery = (): ReactElement => {
82
82
  const { get } = useUrlQuery();
83
83
  const { setFiltersContext } = useContext(FiltersContext);
84
84
  const [isAllOpened, setIsAllOpened] = useState<boolean>(false);
85
85
  const [isExpandedCurrencies, setIsExpandedCurrencies] = useState<boolean>(false);
86
86
  const [filter, setFilter] = useState<BusinessTransactionsFilter>(
87
- get('transactionsFilters')
87
+ get('ledgerRecordsFilters')
88
88
  ? (JSON.parse(
89
- decodeURIComponent(get('transactionsFilters') as string),
89
+ decodeURIComponent(get('ledgerRecordsFilters') as string),
90
90
  ) as BusinessTransactionsFilter)
91
91
  : {},
92
92
  );
93
93
  const [{ data, fetching }] = useQuery({
94
- query: BusinessTransactionsSummeryDocument,
94
+ query: BusinessLedgerRecordsSummeryDocument,
95
95
  variables: {
96
96
  filters: filter,
97
97
  },
@@ -100,7 +100,7 @@ export const BusinessTransactionsSummery = (): ReactElement => {
100
100
  useEffect(() => {
101
101
  setFiltersContext(
102
102
  <div className="flex flex-row gap-x-5">
103
- <BusinessTransactionsFilters filter={filter} setFilter={setFilter} />
103
+ <BusinessLedgerRecordsFilters filter={filter} setFilter={setFilter} />
104
104
  <Tooltip label="Expand all accounts">
105
105
  <Button
106
106
  variant="outline"
@@ -141,7 +141,7 @@ export const BusinessTransactionsSummery = (): ReactElement => {
141
141
  isExpandedCurrencies,
142
142
  ]);
143
143
 
144
- const businessTransactionsSum = useMemo(() => {
144
+ const businessLedgerRecordsSum = useMemo(() => {
145
145
  if (data?.businessTransactionsSumFromLedgerRecords.__typename === 'CommonError') {
146
146
  return [];
147
147
  }
@@ -195,7 +195,7 @@ export const BusinessTransactionsSummery = (): ReactElement => {
195
195
  ];
196
196
 
197
197
  return (
198
- <PageLayout title="Business Transactions" description="Business Transactions Summery">
198
+ <PageLayout title="Business Ledger Records" description="Business Ledger Records Summary">
199
199
  {fetching ? (
200
200
  <Loader2 className="h-10 w-10 animate-spin mr-2 self-center" />
201
201
  ) : (
@@ -209,7 +209,7 @@ export const BusinessTransactionsSummery = (): ReactElement => {
209
209
  </tr>
210
210
  </thead>
211
211
  <tbody>
212
- {businessTransactionsSum.map((item, index) => (
212
+ {businessLedgerRecordsSum.map((item, index) => (
213
213
  <AccounterTableRow
214
214
  key={index}
215
215
  columns={columns}
@@ -4,6 +4,7 @@ import { useQuery } from 'urql';
4
4
  import { Accordion, Box, Collapse, Loader, Tooltip } from '@mantine/core';
5
5
  import { useDisclosure } from '@mantine/hooks';
6
6
  import {
7
+ ChargeLedgerRecordsTableFieldsFragmentDoc,
7
8
  ChargesTableErrorsFieldsFragmentDoc,
8
9
  ChargeTableTransactionsFieldsFragmentDoc,
9
10
  ConversionChargeInfoFragmentDoc,
@@ -12,7 +13,6 @@ import {
12
13
  ExchangeRatesInfoFragmentDoc,
13
14
  FetchChargeDocument,
14
15
  TableDocumentsFieldsFragmentDoc,
15
- TableLedgerRecordsFieldsFragmentDoc,
16
16
  TableMiscExpensesFieldsFragmentDoc,
17
17
  TableSalariesFieldsFragmentDoc,
18
18
  type FetchChargeQuery,
@@ -55,7 +55,7 @@ import { SalariesTable } from './extended-info/salaries-info.jsx';
55
55
  }
56
56
  ...DocumentsGalleryFields @defer
57
57
  ...TableDocumentsFields @defer
58
- ...TableLedgerRecordsFields @defer
58
+ ...ChargeLedgerRecordsTableFields @defer
59
59
  ...ChargeTableTransactionsFields @defer
60
60
  ...ConversionChargeInfo @defer
61
61
  ...CreditcardBankChargeInfo @defer
@@ -89,6 +89,31 @@ import { SalariesTable } from './extended-info/salaries-info.jsx';
89
89
  }
90
90
  `;
91
91
 
92
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
93
+ /* GraphQL */ `
94
+ fragment ChargeLedgerRecordsTableFields on Charge {
95
+ id
96
+ ledger {
97
+ __typename
98
+ records {
99
+ id
100
+ ...LedgerRecordsTableFields
101
+ }
102
+ ... on Ledger @defer {
103
+ validate {
104
+ ... on LedgerValidation @defer {
105
+ matches
106
+ differences {
107
+ id
108
+ ...LedgerRecordsTableFields
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ `;
116
+
92
117
  interface Props {
93
118
  chargeID: string;
94
119
  onChange?: () => void;
@@ -191,7 +216,7 @@ export function ChargeExtendedInfo({
191
216
 
192
217
  const ledgerRecordsAreReady = isFragmentReady(
193
218
  FetchChargeDocument,
194
- TableLedgerRecordsFieldsFragmentDoc,
219
+ ChargeLedgerRecordsTableFieldsFragmentDoc,
195
220
  charge,
196
221
  );
197
222
 
@@ -442,7 +467,7 @@ export function ChargeExtendedInfo({
442
467
  </div>
443
468
  </Accordion.Control>
444
469
  <Accordion.Panel>
445
- {ledgerRecordsAreReady && <LedgerTable ledgerFragment={charge} />}
470
+ {ledgerRecordsAreReady && <ChargeLedgerTable data={charge} />}
446
471
  </Accordion.Panel>
447
472
  </Accordion.Item>
448
473
  )}
@@ -460,3 +485,19 @@ export function ChargeExtendedInfo({
460
485
  </div>
461
486
  );
462
487
  }
488
+
489
+ type ChargeLedgerTableProps = {
490
+ data: FragmentType<typeof ChargeLedgerRecordsTableFieldsFragmentDoc>;
491
+ };
492
+
493
+ export const ChargeLedgerTable = ({ data }: ChargeLedgerTableProps): ReactElement => {
494
+ const { ledger } = getFragmentData(ChargeLedgerRecordsTableFieldsFragmentDoc, data);
495
+
496
+ return (
497
+ <LedgerTable
498
+ ledgerRecordsData={ledger.records}
499
+ ledgerDiffData={ledger.validate?.differences}
500
+ matches={ledger.validate?.matches}
501
+ />
502
+ );
503
+ };
@@ -165,9 +165,9 @@ export const sidelinks: SideLink[] = [
165
165
  icon: <Factory size={18} />,
166
166
  },
167
167
  {
168
- title: 'Business Transactions',
168
+ title: 'Business Ledger',
169
169
  label: '',
170
- href: ROUTES.BUSINESSES.TRANSACTIONS,
170
+ href: ROUTES.BUSINESSES.LEDGER,
171
171
  icon: <ArrowLeftRight size={18} />,
172
172
  },
173
173
  {
@@ -53,7 +53,7 @@ export const columns: ColumnDef<LedgerRecordRow>[] = [
53
53
  },
54
54
  },
55
55
  {
56
- header: 'Debit Account1',
56
+ header: 'Debit Account (Main)',
57
57
  columns: [
58
58
  {
59
59
  accessorKey: 'debitAccount1.name',
@@ -120,7 +120,7 @@ export const columns: ColumnDef<LedgerRecordRow>[] = [
120
120
  ],
121
121
  },
122
122
  {
123
- header: 'Credit Account1',
123
+ header: 'Credit Account (Main)',
124
124
  columns: [
125
125
  {
126
126
  accessorKey: 'creditAccount1.name',
@@ -187,7 +187,7 @@ export const columns: ColumnDef<LedgerRecordRow>[] = [
187
187
  ],
188
188
  },
189
189
  {
190
- header: 'Debit Account2',
190
+ header: 'Debit Account (Secondary)',
191
191
  columns: [
192
192
  {
193
193
  accessorKey: 'debitAccount2.name',
@@ -254,7 +254,7 @@ export const columns: ColumnDef<LedgerRecordRow>[] = [
254
254
  ],
255
255
  },
256
256
  {
257
- header: 'Credit Account2',
257
+ header: 'Credit Account (Secondary)',
258
258
  columns: [
259
259
  {
260
260
  accessorKey: 'creditAccount2.name',
@@ -2,151 +2,81 @@ import { useMemo, useState, type ReactElement } from 'react';
2
2
  import {
3
3
  flexRender,
4
4
  getCoreRowModel,
5
+ getPaginationRowModel,
5
6
  getSortedRowModel,
6
7
  useReactTable,
7
8
  type SortingState,
8
9
  } from '@tanstack/react-table';
9
10
  import {
10
- TableLedgerRecordsFieldsFragmentDoc,
11
- type TableLedgerRecordsFieldsFragment,
11
+ LedgerRecordsTableFieldsFragmentDoc,
12
+ type LedgerRecordsTableFieldsFragment,
12
13
  } from '../../gql/graphql.js';
13
14
  import { getFragmentData, type FragmentType } from '../../gql/index.js';
14
15
  import { EMPTY_UUID } from '../../helpers/consts.js';
16
+ import { Pagination } from '../ui/pagination.js';
15
17
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '../ui/table.js';
16
18
  import { columns } from './columns.js';
17
19
 
18
20
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
19
21
  /* GraphQL */ `
20
- fragment TableLedgerRecordsFields on Charge {
22
+ fragment LedgerRecordsTableFields on LedgerRecord {
21
23
  id
22
- ledger {
24
+ creditAccount1 {
23
25
  __typename
24
- records {
25
- id
26
- creditAccount1 {
27
- __typename
28
- id
29
- name
30
- }
31
- creditAccount2 {
32
- __typename
33
- id
34
- name
35
- }
36
- debitAccount1 {
37
- __typename
38
- id
39
- name
40
- }
41
- debitAccount2 {
42
- __typename
43
- id
44
- name
45
- }
46
- creditAmount1 {
47
- formatted
48
- currency
49
- }
50
- creditAmount2 {
51
- formatted
52
- currency
53
- }
54
- debitAmount1 {
55
- formatted
56
- currency
57
- }
58
- debitAmount2 {
59
- formatted
60
- currency
61
- }
62
- localCurrencyCreditAmount1 {
63
- formatted
64
- raw
65
- }
66
- localCurrencyCreditAmount2 {
67
- formatted
68
- raw
69
- }
70
- localCurrencyDebitAmount1 {
71
- formatted
72
- raw
73
- }
74
- localCurrencyDebitAmount2 {
75
- formatted
76
- raw
77
- }
78
- invoiceDate
79
- valueDate
80
- description
81
- reference
82
- }
83
- ... on Ledger @defer {
84
- validate {
85
- ... on LedgerValidation @defer {
86
- matches
87
- differences {
88
- id
89
- creditAccount1 {
90
- __typename
91
- id
92
- name
93
- }
94
- creditAccount2 {
95
- __typename
96
- id
97
- name
98
- }
99
- debitAccount1 {
100
- __typename
101
- id
102
- name
103
- }
104
- debitAccount2 {
105
- __typename
106
- id
107
- name
108
- }
109
- creditAmount1 {
110
- formatted
111
- currency
112
- }
113
- creditAmount2 {
114
- formatted
115
- currency
116
- }
117
- debitAmount1 {
118
- formatted
119
- currency
120
- }
121
- debitAmount2 {
122
- formatted
123
- currency
124
- }
125
- localCurrencyCreditAmount1 {
126
- formatted
127
- raw
128
- }
129
- localCurrencyCreditAmount2 {
130
- formatted
131
- raw
132
- }
133
- localCurrencyDebitAmount1 {
134
- formatted
135
- raw
136
- }
137
- localCurrencyDebitAmount2 {
138
- formatted
139
- raw
140
- }
141
- invoiceDate
142
- valueDate
143
- description
144
- reference
145
- }
146
- }
147
- }
148
- }
26
+ id
27
+ name
149
28
  }
29
+ creditAccount2 {
30
+ __typename
31
+ id
32
+ name
33
+ }
34
+ debitAccount1 {
35
+ __typename
36
+ id
37
+ name
38
+ }
39
+ debitAccount2 {
40
+ __typename
41
+ id
42
+ name
43
+ }
44
+ creditAmount1 {
45
+ formatted
46
+ currency
47
+ }
48
+ creditAmount2 {
49
+ formatted
50
+ currency
51
+ }
52
+ debitAmount1 {
53
+ formatted
54
+ currency
55
+ }
56
+ debitAmount2 {
57
+ formatted
58
+ currency
59
+ }
60
+ localCurrencyCreditAmount1 {
61
+ formatted
62
+ raw
63
+ }
64
+ localCurrencyCreditAmount2 {
65
+ formatted
66
+ raw
67
+ }
68
+ localCurrencyDebitAmount1 {
69
+ formatted
70
+ raw
71
+ }
72
+ localCurrencyDebitAmount2 {
73
+ formatted
74
+ raw
75
+ }
76
+ invoiceDate
77
+ valueDate
78
+ description
79
+ reference
150
80
  }
151
81
  `;
152
82
 
@@ -166,43 +96,51 @@ function getRowColorByStatus(status?: 'New' | 'Diff' | 'Deleted'): string {
166
96
  return rowStyle;
167
97
  }
168
98
 
169
- export type LedgerRecordRow = TableLedgerRecordsFieldsFragment['ledger']['records'][number] & {
99
+ export type LedgerRecordRow = LedgerRecordsTableFieldsFragment & {
170
100
  matchingStatus?: 'New' | 'Diff' | 'Deleted';
171
- diff?: TableLedgerRecordsFieldsFragment['ledger']['records'][number];
101
+ diff?: LedgerRecordsTableFieldsFragment;
172
102
  };
173
103
 
174
104
  type Props = {
175
- ledgerFragment: FragmentType<typeof TableLedgerRecordsFieldsFragmentDoc>;
105
+ ledgerRecordsData: FragmentType<typeof LedgerRecordsTableFieldsFragmentDoc>[];
106
+ ledgerDiffData?: FragmentType<typeof LedgerRecordsTableFieldsFragmentDoc>[];
107
+ matches?: string[];
176
108
  };
177
109
 
178
- export const LedgerTable = ({ ledgerFragment }: Props): ReactElement => {
179
- const { ledger } = getFragmentData(TableLedgerRecordsFieldsFragmentDoc, ledgerFragment);
110
+ export const LedgerTable = ({
111
+ ledgerRecordsData,
112
+ ledgerDiffData,
113
+ matches,
114
+ }: Props): ReactElement => {
180
115
  const [sorting, setSorting] = useState<SortingState>([]);
181
116
 
182
117
  const data = useMemo(() => {
183
- const records: LedgerRecordRow[] = ledger.records.map(record => {
184
- const diff = ledger.validate?.differences?.find(diffRecord => diffRecord.id === record.id);
118
+ const records = ledgerRecordsData.map(recordData =>
119
+ getFragmentData(LedgerRecordsTableFieldsFragmentDoc, recordData),
120
+ );
121
+ const differences = ledgerDiffData?.map(recordData =>
122
+ getFragmentData(LedgerRecordsTableFieldsFragmentDoc, recordData),
123
+ );
124
+
125
+ const currentRecords: LedgerRecordRow[] = records.map(record => {
126
+ const diff = differences?.find(diffRecord => diffRecord.id === record.id);
185
127
  return {
186
128
  ...record,
187
129
  matchingStatus:
188
- !ledger.validate?.matches || ledger.validate.matches?.includes(record.id)
189
- ? undefined
190
- : diff
191
- ? 'Diff'
192
- : 'Deleted',
130
+ !matches || matches?.includes(record.id) ? undefined : diff ? 'Diff' : 'Deleted',
193
131
  diff,
194
132
  };
195
133
  });
196
134
  const newRecords: LedgerRecordRow[] =
197
- ledger?.validate?.differences
135
+ differences
198
136
  ?.filter(record => record.id === EMPTY_UUID)
199
137
  .map(record => ({
200
138
  ...record,
201
139
  matchingStatus: 'New',
202
140
  })) ?? [];
203
- records.push(...newRecords);
204
- return records;
205
- }, [ledger]);
141
+ currentRecords.push(...newRecords);
142
+ return currentRecords;
143
+ }, [ledgerRecordsData, ledgerDiffData, matches]);
206
144
 
207
145
  const table = useReactTable({
208
146
  data,
@@ -210,49 +148,71 @@ export const LedgerTable = ({ ledgerFragment }: Props): ReactElement => {
210
148
  getCoreRowModel: getCoreRowModel(),
211
149
  onSortingChange: setSorting,
212
150
  getSortedRowModel: getSortedRowModel(),
151
+ getPaginationRowModel: getPaginationRowModel(),
213
152
  state: {
214
153
  sorting,
215
154
  },
155
+ initialState: {
156
+ pagination: {
157
+ pageIndex: 0,
158
+ pageSize: 10,
159
+ },
160
+ sorting: [
161
+ {
162
+ id: 'invoiceDate',
163
+ desc: true,
164
+ },
165
+ ],
166
+ },
216
167
  });
217
168
 
218
169
  return (
219
- <Table>
220
- <TableHeader>
221
- {table.getHeaderGroups().map(headerGroup => (
222
- <TableRow key={headerGroup.id}>
223
- {headerGroup.headers.map(header => (
224
- <TableHead key={header.id} colSpan={header.colSpan}>
225
- {header.isPlaceholder
226
- ? null
227
- : flexRender(header.column.columnDef.header, header.getContext())}
228
- </TableHead>
229
- ))}
230
- </TableRow>
231
- ))}
232
- </TableHeader>
233
- <TableBody>
234
- {table.getRowModel().rows?.length ? (
235
- table.getRowModel().rows.map(row => (
236
- <TableRow
237
- key={row.id}
238
- data-state={row.getIsSelected() && 'selected'}
239
- className={getRowColorByStatus(row.original.matchingStatus)}
240
- >
241
- {row.getVisibleCells().map(cell => (
242
- <TableCell key={cell.id}>
243
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
244
- </TableCell>
170
+ <>
171
+ <Table>
172
+ <TableHeader>
173
+ {table.getHeaderGroups().map(headerGroup => (
174
+ <TableRow key={headerGroup.id}>
175
+ {headerGroup.headers.map(header => (
176
+ <TableHead className="text-center" key={header.id} colSpan={header.colSpan}>
177
+ {header.isPlaceholder
178
+ ? null
179
+ : flexRender(header.column.columnDef.header, header.getContext())}
180
+ </TableHead>
245
181
  ))}
246
182
  </TableRow>
247
- ))
248
- ) : (
249
- <TableRow>
250
- <TableCell colSpan={columns.length} className="h-24 text-center">
251
- No results.
252
- </TableCell>
253
- </TableRow>
254
- )}
255
- </TableBody>
256
- </Table>
183
+ ))}
184
+ </TableHeader>
185
+ <TableBody>
186
+ {table.getRowModel().rows?.length ? (
187
+ table.getRowModel().rows.map(row => (
188
+ <TableRow
189
+ key={row.id}
190
+ data-state={row.getIsSelected() && 'selected'}
191
+ className={getRowColorByStatus(row.original.matchingStatus)}
192
+ >
193
+ {row.getVisibleCells().map(cell => (
194
+ <TableCell key={cell.id}>
195
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
196
+ </TableCell>
197
+ ))}
198
+ </TableRow>
199
+ ))
200
+ ) : (
201
+ <TableRow>
202
+ <TableCell colSpan={columns.length} className="h-24 text-center">
203
+ No results.
204
+ </TableCell>
205
+ </TableRow>
206
+ )}
207
+ </TableBody>
208
+ </Table>
209
+ <div className="flex items-center justify-end space-x-2 py-4">
210
+ <Pagination
211
+ value={table.getState().pagination.pageIndex}
212
+ total={table.getPageCount()}
213
+ onChange={page => table.setPageIndex(page)}
214
+ />
215
+ </div>
216
+ </>
257
217
  );
258
218
  };
@@ -13,7 +13,7 @@ import IconButton from '@mui/material/IconButton';
13
13
  import Typography from '@mui/material/Typography';
14
14
  import { Currency } from '../../../gql/graphql.js';
15
15
  import { getCurrencyFormatter } from '../../../helpers/index.js';
16
- import { BusinessExtendedInfo } from '../../business-transactions/business-extended-info.js';
16
+ import { BusinessExtendedInfo } from '../../business-ledger/business-extended-info.js';
17
17
  import { Tooltip } from '../../common/index.js';
18
18
  import { Badge } from '../../ui/badge.js';
19
19
  import { Button } from '../../ui/button.js';
@@ -2,7 +2,7 @@ import { useState, type ReactElement } from 'react';
2
2
  import { PanelTopClose, PanelTopOpen } from 'lucide-react';
3
3
  import { Text, Tooltip } from '@mantine/core';
4
4
  import type { TrialBalanceTableFieldsFragment } from '../../../gql/graphql.js';
5
- import { BusinessExtendedInfo } from '../../business-transactions/business-extended-info.js';
5
+ import { BusinessExtendedInfo } from '../../business-ledger/business-extended-info.js';
6
6
  import { Button } from '../../ui/button.js';
7
7
  import { TrialBalanceReportFilters } from './trial-balance-report-filters.js';
8
8