@accounter/client 0.0.8-alpha-20251029232510-4bc0c8b8c08a26f0c27788725ae584e515236d20 → 0.0.8-alpha-20251029233659-8fb74309c9f1de4f20423db029c5740e2df4bb5d

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 (127) hide show
  1. package/CHANGELOG.md +1 -15
  2. package/dist/assets/{Checkbox-Cmx4P-eR.js → Checkbox-CSPHEKoR.js} +2 -2
  3. package/dist/assets/{MultiSelect-tfWMeMsf.js → MultiSelect-CszuVk07.js} +1 -1
  4. package/dist/assets/{Pagination-p2BVFuhf.js → Pagination-Cp6iKPSu.js} +1 -1
  5. package/dist/assets/{Progress-BwoJerOb.js → Progress-ByaKYSXX.js} +1 -1
  6. package/dist/assets/{Table-Cve82Lq5.js → Table-CQ4GTcIY.js} +1 -1
  7. package/dist/assets/{Typography-CAgQOS4U.js → Typography-Cn08y9HC.js} +1 -1
  8. package/dist/assets/{YearPickerInput-BPVLgEAY.js → YearPickerInput-BsQymTcP.js} +1 -1
  9. package/dist/assets/{accordion-Ca5XgpUz.js → accordion-CG93-Cqs.js} +1 -1
  10. package/dist/assets/accountant-approvals-Dxy1hGw7.js +1 -0
  11. package/dist/assets/{accounter-table-CBlUbpQl.js → accounter-table-Dgvw-xm_.js} +1 -1
  12. package/dist/assets/{addDays-ClGDfhvI.js → addDays-Di-hbHs3.js} +1 -1
  13. package/dist/assets/{all-charges-DV7V8QJ6.js → all-charges-DRl4EcMG.js} +1 -1
  14. package/dist/assets/{arrow-up-down-DMdWvrmz.js → arrow-up-down-Hh3TlLSU.js} +1 -1
  15. package/dist/assets/{building-2-Y3dys8Pf.js → building-2-DGfYgfU_.js} +1 -1
  16. package/dist/assets/business-aamFaOhr.js +27 -0
  17. package/dist/assets/business-extended-info-CeEMIazB.js +13 -0
  18. package/dist/assets/{business-header-S5R7Fq8P.js → business-header-BphijNiC.js} +1 -1
  19. package/dist/assets/business-transactions-filters-DYBvDjKs.js +1 -0
  20. package/dist/assets/business-transactions-single-B77wu9sA.js +1 -0
  21. package/dist/assets/business-trip-C1cYIMHX.js +1 -0
  22. package/dist/assets/{charge-C79C95t6.js → charge-D-99eJ1v.js} +1 -1
  23. package/dist/assets/{charges-filters-RFRXF1Oa.js → charges-filters-Dxaf2lVd.js} +1 -1
  24. package/dist/assets/{charges-ledger-validation-DTglElRA.js → charges-ledger-validation-BAY3PYth.js} +1 -1
  25. package/dist/assets/charges-table-CNWVDMmv.js +62 -0
  26. package/dist/assets/{chart-2MG3qLL8.js → chart-DM5P1yGj.js} +1 -1
  27. package/dist/assets/{data-table-pagination-Dhmbf7BR.js → data-table-pagination-TG7sqb1-.js} +1 -1
  28. package/dist/assets/download-csv-button-jQXIlRax.js +1 -0
  29. package/dist/assets/{editable-business-trip-BlqinsvU.js → editable-business-trip-DlAsZ0aQ.js} +2 -2
  30. package/dist/assets/{funnel-B2plvroD.js → funnel-BQEGwl1q.js} +1 -1
  31. package/dist/assets/{index-Csdsjvrl.js → index--OgMtW-2.js} +2 -2
  32. package/dist/assets/index-B-USUC2v.js +1 -0
  33. package/dist/assets/index-BYfofaiM.js +1 -0
  34. package/dist/assets/{index-C6OmHOHr.js → index-BmZql10x.js} +213 -213
  35. package/dist/assets/{index-Bs4RBq4h.js → index-CFY-4iKE.js} +1 -1
  36. package/dist/assets/{index-C4gCwrJJ.js → index-CGQclWiq.js} +1 -1
  37. package/dist/assets/index-CIY9x3TF.js +6 -0
  38. package/dist/assets/{index-arYAg9nt.js → index-CJEUQmMx.js} +1 -1
  39. package/dist/assets/{index-DKZGNBg3.js → index-CXRSu47J.js} +2 -2
  40. package/dist/assets/{index-DemO-kJJ.js → index-CiXTFJcq.js} +2 -2
  41. package/dist/assets/{index-CSEktEoZ.js → index-CkIv3Veq.js} +7 -7
  42. package/dist/assets/{index-BRNnfzgV.js → index-ClzPFBOc.js} +2 -2
  43. package/dist/assets/{index-qMYyjtmt.js → index-CzEcZ0Dn.js} +2 -2
  44. package/dist/assets/{index-HG5RXBPG.js → index-D9zE4pLO.js} +1 -1
  45. package/dist/assets/{index-DZ6Bqs7R.js → index-DKjsW6q7.js} +7 -7
  46. package/dist/assets/{index-C0ZATVhv.js → index-DOh5XsM3.js} +2 -2
  47. package/dist/assets/index-DROHY2Kd.js +1 -0
  48. package/dist/assets/index-DWXHJxFq.css +1 -0
  49. package/dist/assets/index-DgbPiRkF.js +1 -0
  50. package/dist/assets/{index-5R7-0kTp.js → index-DkKTDpFK.js} +1 -1
  51. package/dist/assets/{index-Cn4t95Q9.js → index-DnFwBDCa.js} +1 -1
  52. package/dist/assets/index-Dt4KpoN0.js +1 -0
  53. package/dist/assets/{index-BdRubi2c.js → index-IuUe41KG.js} +1 -1
  54. package/dist/assets/{index-eIVAASqp.js → index-NofRnQ8o.js} +1 -1
  55. package/dist/assets/{index-P9_YuS6e.js → index-WaN-m0WB.js} +1 -1
  56. package/dist/assets/index-juMfNCjV.js +1 -0
  57. package/dist/assets/{index.es-BrfHJ6Yj.js → index.es-BJEu0vdb.js} +1 -1
  58. package/dist/assets/{insert-business-trip-modal-COXHjjIY.js → insert-business-trip-modal-CXgUJdgl.js} +2 -2
  59. package/dist/assets/issue-document-BSkWYnI5.js +1 -0
  60. package/dist/assets/{list-plus-DbuCDPM8.js → list-plus-BlHtPDEN.js} +1 -1
  61. package/dist/assets/{login-page-ChNFTZLU.js → login-page-DmCLAM1G.js} +1 -1
  62. package/dist/assets/{match-document-modal-Cp2DKG3j.js → match-document-modal-KjnSxB69.js} +4 -4
  63. package/dist/assets/{missing-info-charges-IUzXIDY1.js → missing-info-charges-BiEeQwER.js} +1 -1
  64. package/dist/assets/{modal-CCAYjiOC.js → modal-dLkQjDNz.js} +1 -1
  65. package/dist/assets/{page-layout-DpwpZHY3.js → page-layout-DxGYaCiw.js} +1 -1
  66. package/dist/assets/{page-not-found-NbOMK1Jv.js → page-not-found-ChLEFKCs.js} +1 -1
  67. package/dist/assets/{panel-top-open-CNX1-h4c.js → panel-top-open-CWsfFRNu.js} +1 -1
  68. package/dist/assets/{pencil-Z4i9z0vF.js → pencil-BEefjySD.js} +1 -1
  69. package/dist/assets/{report-commentary-row-C4I-ATEX.js → report-commentary-row-Cci0ntye.js} +1 -1
  70. package/dist/assets/{save-D0kOxdMh.js → save-BkV97OA1.js} +1 -1
  71. package/dist/assets/similar-transactions-modal-8T9lL2yX.js +1 -0
  72. package/dist/assets/sub-DdivcKGZ.js +1 -0
  73. package/dist/assets/subMonths-Kz3NJUOL.js +1 -0
  74. package/dist/assets/{summary-CkpRtdVA.js → summary-DzLJ6sUY.js} +1 -1
  75. package/dist/assets/{toggle-expansion-button-Babot8nj.js → toggle-expansion-button-BzVlE1kb.js} +1 -1
  76. package/dist/assets/tooltip-Ht3m2Q26.js +1 -0
  77. package/dist/assets/{use-url-query-BSUiacze.js → use-url-query-DV9K0FAR.js} +1 -1
  78. package/dist/index.html +2 -2
  79. package/package.json +1 -1
  80. package/src/app.tsx +108 -0
  81. package/src/components/business/admin-business-section.tsx +103 -299
  82. package/src/components/business/index.tsx +1 -33
  83. package/src/components/business/transactions-section.tsx +2 -24
  84. package/src/components/{business-ledger → business-transactions}/business-extended-info.tsx +27 -25
  85. package/src/components/{business-ledger/business-ledger-filters.tsx → business-transactions/business-transactions-filters.tsx} +12 -12
  86. package/src/components/{business-ledger/business-ledger-single.tsx → business-transactions/business-transactions-single.tsx} +13 -13
  87. package/src/components/{business-ledger → business-transactions}/download-csv.tsx +25 -25
  88. package/src/components/{business-ledger → business-transactions}/index.tsx +15 -15
  89. package/src/components/charges/charge-extended-info.tsx +4 -45
  90. package/src/components/layout/sidelinks.tsx +2 -2
  91. package/src/components/ledger-table/columns.tsx +4 -4
  92. package/src/components/ledger-table/index.tsx +181 -141
  93. package/src/components/reports/conto/custom-node.tsx +1 -1
  94. package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
  95. package/src/components/tags/index.tsx +2 -4
  96. package/src/components/transactions-table/columns.tsx +9 -9
  97. package/src/components/transactions-table/index.tsx +21 -43
  98. package/src/gql/gql.ts +15 -33
  99. package/src/gql/graphql.ts +423 -234
  100. package/src/providers/index.tsx +56 -0
  101. package/src/router/config.tsx +14 -14
  102. package/src/router/routes.ts +2 -2
  103. package/dist/assets/accountant-approvals-BXTzXE96.js +0 -1
  104. package/dist/assets/business-CRd0ns94.js +0 -37
  105. package/dist/assets/business-extended-info-BKVk3weU.js +0 -13
  106. package/dist/assets/business-ledger-filters-C_x4y5uJ.js +0 -1
  107. package/dist/assets/business-ledger-single-Dku8gbU9.js +0 -1
  108. package/dist/assets/business-trip-CB51p6xt.js +0 -1
  109. package/dist/assets/charges-table-D3WwcB50.js +0 -62
  110. package/dist/assets/download-csv-button-BQSz29rY.js +0 -1
  111. package/dist/assets/index--xgmdJzW.js +0 -1
  112. package/dist/assets/index-BUJm5I0K.css +0 -1
  113. package/dist/assets/index-BgLtHIxa.js +0 -1
  114. package/dist/assets/index-CIdZZL-X.js +0 -1
  115. package/dist/assets/index-DA3Ccstm.js +0 -1
  116. package/dist/assets/index-DhRIY5eN.js +0 -1
  117. package/dist/assets/index-aEEtRfbo.js +0 -1
  118. package/dist/assets/index-nshyF-PE.js +0 -6
  119. package/dist/assets/issue-document-CBKTg1VC.js +0 -1
  120. package/dist/assets/similar-transactions-modal-DgD48GZ2.js +0 -1
  121. package/dist/assets/sub-BAZr7Qdd.js +0 -1
  122. package/dist/assets/subMonths-Df-03cZk.js +0 -1
  123. package/dist/assets/tooltip-DStdzzhK.js +0 -1
  124. package/src/components/business/balance-section.tsx +0 -26
  125. package/src/components/business/ledger-section.tsx +0 -49
  126. package/src/components/ui/pagination.tsx +0 -194
  127. package/src/providers/index.ts +0 -4
@@ -6,10 +6,10 @@ import { useQuery } from 'urql';
6
6
  import { ROUTES } from '@/router/routes.js';
7
7
  import { Mark, Table, Tooltip } from '@mantine/core';
8
8
  import {
9
- BusinessLedgerInfoDocument,
9
+ BusinessTransactionsInfoDocument,
10
10
  Currency,
11
- type BusinessLedgerInfoQuery,
12
11
  type BusinessTransactionsFilter,
12
+ type BusinessTransactionsInfoQuery,
13
13
  } from '../../gql/graphql.js';
14
14
  import { FIAT_CURRENCIES, formatAmountWithCurrency } from '../../helpers/index.js';
15
15
  import { AccounterLoader } from '../common/index.js';
@@ -18,7 +18,7 @@ import { DownloadCSV } from './download-csv.js';
18
18
 
19
19
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
20
20
  /* GraphQL */ `
21
- query BusinessLedgerInfo($filters: BusinessTransactionsFilter) {
21
+ query BusinessTransactionsInfo($filters: BusinessTransactionsFilter) {
22
22
  businessTransactionsFromLedgerRecords(filters: $filters) {
23
23
  ... on BusinessTransactionsFromLedgerRecordsSuccessfulResult {
24
24
  businessTransactions {
@@ -54,8 +54,8 @@ import { DownloadCSV } from './download-csv.js';
54
54
  }
55
55
  `;
56
56
 
57
- export type ExtendedLedger = Extract<
58
- BusinessLedgerInfoQuery['businessTransactionsFromLedgerRecords'],
57
+ export type ExtendedTransaction = Extract<
58
+ BusinessTransactionsInfoQuery['businessTransactionsFromLedgerRecords'],
59
59
  { __typename?: 'BusinessTransactionsFromLedgerRecordsSuccessfulResult' }
60
60
  >['businessTransactions'][number] & {
61
61
  ilsBalance: number;
@@ -71,7 +71,7 @@ export function BusinessExtendedInfo({ businessID, filter }: Props): ReactElemen
71
71
  const [isExtendAllCurrencies, setISExtendAllCurrencies] = useState(false);
72
72
  const { fromDate, ownerIds, toDate } = filter ?? {};
73
73
  const [{ data, fetching }] = useQuery({
74
- query: BusinessLedgerInfoDocument,
74
+ query: BusinessTransactionsInfoDocument,
75
75
  variables: {
76
76
  filters: {
77
77
  fromDate,
@@ -82,42 +82,44 @@ export function BusinessExtendedInfo({ businessID, filter }: Props): ReactElemen
82
82
  },
83
83
  });
84
84
 
85
- const ledgerRecords =
85
+ const transactions =
86
86
  data?.businessTransactionsFromLedgerRecords.__typename === 'CommonError'
87
87
  ? []
88
88
  : (data?.businessTransactionsFromLedgerRecords.businessTransactions.sort((a, b) =>
89
89
  a.invoiceDate > b.invoiceDate ? 1 : -1,
90
90
  ) ?? []);
91
91
 
92
- const extendedLedgerRecords: Array<ExtendedLedger> = [];
93
- for (let i = 0; i < ledgerRecords.length; i++) {
94
- const { __typename, ...coreRecord } = ledgerRecords[i];
92
+ const extendedTransactions: Array<ExtendedTransaction> = [];
93
+ for (let i = 0; i < transactions.length; i++) {
94
+ const { __typename, ...coreTransaction } = transactions[i];
95
95
  const ilsBalance =
96
96
  i === 0
97
- ? coreRecord.amount.raw
98
- : (extendedLedgerRecords[i - 1].ilsBalance ?? 0) + coreRecord.amount.raw;
97
+ ? coreTransaction.amount.raw
98
+ : (extendedTransactions[i - 1].ilsBalance ?? 0) + coreTransaction.amount.raw;
99
99
  const foreignCurrenciesBalance: Record<string, number> = {};
100
100
  Object.values(Currency).map(currency => {
101
101
  if (currency !== Currency.Ils) {
102
102
  const key = `${currency.toLowerCase()}Balance`;
103
103
  foreignCurrenciesBalance[key] =
104
104
  i === 0
105
- ? ((coreRecord.foreignAmount?.currency === currency
106
- ? coreRecord.foreignAmount?.raw
105
+ ? ((coreTransaction.foreignAmount?.currency === currency
106
+ ? coreTransaction.foreignAmount?.raw
107
107
  : 0) ?? 0)
108
- : (extendedLedgerRecords[i - 1]?.[key] ?? 0) +
109
- (coreRecord.foreignAmount?.currency === currency ? coreRecord.foreignAmount?.raw : 0);
108
+ : (extendedTransactions[i - 1]?.[key] ?? 0) +
109
+ (coreTransaction.foreignAmount?.currency === currency
110
+ ? coreTransaction.foreignAmount?.raw
111
+ : 0);
110
112
  }
111
113
  });
112
- extendedLedgerRecords.push({
113
- ...coreRecord,
114
+ extendedTransactions.push({
115
+ ...coreTransaction,
114
116
  ilsBalance,
115
117
  ...foreignCurrenciesBalance,
116
- } as (typeof extendedLedgerRecords)[number]);
118
+ } as (typeof extendedTransactions)[number]);
117
119
  }
118
120
 
119
121
  const currencies = new Set(
120
- ledgerRecords.filter(t => t.foreignAmount?.currency).map(t => t.foreignAmount!.currency),
122
+ transactions.filter(t => t.foreignAmount?.currency).map(t => t.foreignAmount!.currency),
121
123
  );
122
124
  const isEur = isExtendAllCurrencies || currencies.has(Currency.Eur);
123
125
  const isUsd = isExtendAllCurrencies || currencies.has(Currency.Usd);
@@ -127,7 +129,7 @@ export function BusinessExtendedInfo({ businessID, filter }: Props): ReactElemen
127
129
  const isAud = isExtendAllCurrencies || currencies.has(Currency.Aud);
128
130
  const isSek = isExtendAllCurrencies || currencies.has(Currency.Sek);
129
131
 
130
- const businessName = ledgerRecords[0]?.business.name ?? 'unknown';
132
+ const businessName = transactions[0]?.business.name ?? 'unknown';
131
133
 
132
134
  return (
133
135
  <div className="flex flex-row gap-5">
@@ -214,7 +216,7 @@ export function BusinessExtendedInfo({ businessID, filter }: Props): ReactElemen
214
216
  <th>Counter Account</th>
215
217
  <th>
216
218
  <DownloadCSV
217
- ledgerRecords={extendedLedgerRecords}
219
+ transactions={extendedTransactions}
218
220
  businessName={businessName}
219
221
  fromDate={filter?.fromDate ?? undefined}
220
222
  toDate={filter?.toDate ?? undefined}
@@ -223,7 +225,7 @@ export function BusinessExtendedInfo({ businessID, filter }: Props): ReactElemen
223
225
  </tr>
224
226
  </thead>
225
227
  <tbody>
226
- {extendedLedgerRecords.map((row, index) => (
228
+ {extendedTransactions.map((row, index) => (
227
229
  <tr
228
230
  key={index}
229
231
  className="cursor-pointer"
@@ -297,7 +299,7 @@ export function CurrencyCells({
297
299
  data,
298
300
  }: {
299
301
  currency: Currency;
300
- data: ExtendedLedger;
302
+ data: ExtendedTransaction;
301
303
  }): ReactElement {
302
304
  const foreignAmount =
303
305
  data.foreignAmount && data.foreignAmount.currency === currency ? data.foreignAmount : null;
@@ -327,7 +329,7 @@ const currenciesToExtend = Object.values(Currency).filter(
327
329
  currency => !FIAT_CURRENCIES.includes(currency),
328
330
  );
329
331
 
330
- export function ExtendedCurrencyCells({ data }: { data: ExtendedLedger }): ReactElement {
332
+ export function ExtendedCurrencyCells({ data }: { data: ExtendedTransaction }): ReactElement {
331
333
  return (
332
334
  <>
333
335
  {currenciesToExtend.map(currency => (
@@ -9,29 +9,29 @@ import { type BusinessTransactionsFilter } from '../../gql/graphql.js';
9
9
  import { isObjectEmpty, TIMELESS_DATE_REGEX } from '../../helpers/index.js';
10
10
  import { useGetBusinesses } from '../../hooks/use-get-businesses.js';
11
11
  import { useUrlQuery } from '../../hooks/use-url-query.js';
12
- import { UserContext } from '../../providers/user-provider.jsx';
12
+ import { UserContext } from '../../providers/user-provider.js';
13
13
  import { PopUpModal } from '../common/index.js';
14
- import { Button } from '../ui/button.jsx';
14
+ import { Button } from '../ui/button.js';
15
15
 
16
- export function encodeLedgerRecordsFilters(
16
+ export function encodeTransactionsFilters(
17
17
  filter?: BusinessTransactionsFilter | null,
18
18
  ): string | null {
19
19
  return !filter || isObjectEmpty(filter) ? null : encodeURIComponent(JSON.stringify(filter));
20
20
  }
21
21
 
22
- interface BusinessLedgerRecordsFilterFormProps {
22
+ interface BusinessTransactionsFilterFormProps {
23
23
  filter: BusinessTransactionsFilter;
24
24
  setFilter: (filter: BusinessTransactionsFilter) => void;
25
25
  closeModal: () => void;
26
26
  single?: boolean;
27
27
  }
28
28
 
29
- function BusinessLedgerRecordsFilterForm({
29
+ function BusinessTransactionsFilterForm({
30
30
  filter,
31
31
  setFilter,
32
32
  closeModal,
33
33
  single = false,
34
- }: BusinessLedgerRecordsFilterFormProps): ReactElement {
34
+ }: BusinessTransactionsFilterFormProps): ReactElement {
35
35
  const { control, handleSubmit } = useForm<BusinessTransactionsFilter>({
36
36
  defaultValues: { ...filter },
37
37
  });
@@ -199,15 +199,15 @@ function BusinessLedgerRecordsFilterForm({
199
199
  );
200
200
  }
201
201
 
202
- interface BusinessLedgerRecordsFilterProps {
202
+ interface BusinessTransactionsFilterProps {
203
203
  filter: BusinessTransactionsFilter;
204
204
  setFilter: (filter: BusinessTransactionsFilter) => void;
205
205
  }
206
206
 
207
- export function BusinessLedgerRecordsFilters({
207
+ export function BusinessTransactionsFilters({
208
208
  filter,
209
209
  setFilter,
210
- }: BusinessLedgerRecordsFilterProps): ReactElement {
210
+ }: BusinessTransactionsFilterProps): ReactElement {
211
211
  const [opened, setOpened] = useState(false);
212
212
  const [isFiltered, setIsFiltered] = useState(!isObjectEmpty(filter));
213
213
  const { get, set } = useUrlQuery();
@@ -232,9 +232,9 @@ export function BusinessLedgerRecordsFilters({
232
232
  // update url on filter change
233
233
  useEffect(() => {
234
234
  const newFilter = isObjectEmpty(filter) ? null : encodeURIComponent(JSON.stringify(filter));
235
- const oldFilter = get('ledgerRecordsFilters');
235
+ const oldFilter = get('transactionsFilters');
236
236
  if (newFilter !== oldFilter) {
237
- set('ledgerRecordsFilters', newFilter);
237
+ set('transactionsFilters', newFilter);
238
238
  }
239
239
  }, [filter, get, set]);
240
240
 
@@ -244,7 +244,7 @@ export function BusinessLedgerRecordsFilters({
244
244
  opened={opened}
245
245
  onClose={(): void => setOpened(false)}
246
246
  content={
247
- <BusinessLedgerRecordsFilterForm
247
+ <BusinessTransactionsFilterForm
248
248
  single
249
249
  filter={filter}
250
250
  setFilter={onSetFilter}
@@ -3,31 +3,31 @@ import { useParams } from 'react-router-dom';
3
3
  import { useQuery } from 'urql';
4
4
  import { Mark } from '@mantine/core';
5
5
  import {
6
- BusinessLedgerRecordsSummeryDocument,
6
+ BusinessTransactionsSummeryDocument,
7
7
  Currency,
8
- type BusinessLedgerRecordsSummeryQuery,
9
8
  type BusinessTransactionsFilter,
9
+ type BusinessTransactionsSummeryQuery,
10
10
  } from '../../gql/graphql.js';
11
11
  import { useUrlQuery } from '../../hooks/use-url-query.js';
12
12
  import { FiltersContext } from '../../providers/filters-context.js';
13
13
  import { AccounterLoader, AccounterTable } from '../common/index.js';
14
14
  import { BusinessExtendedInfo } from './business-extended-info.js';
15
- import { BusinessLedgerRecordsFilters } from './business-ledger-filters.js';
15
+ import { BusinessTransactionsFilters } from './business-transactions-filters.js';
16
16
 
17
17
  type Props = {
18
18
  businessId?: string;
19
19
  };
20
20
 
21
- export const BusinessLedgerRecordsSingle = ({ businessId }: Props): ReactElement => {
21
+ export const BusinessTransactionsSingle = ({ businessId }: Props): ReactElement => {
22
22
  const { businessId: businessIdFromUrl } = useParams<{ businessId: string }>();
23
23
  const { get } = useUrlQuery();
24
24
  const { setFiltersContext } = useContext(FiltersContext);
25
25
  const id = businessId || businessIdFromUrl;
26
26
  const [filter, setFilter] = useState<BusinessTransactionsFilter>(
27
- get('ledgerRecordsFilters')
27
+ get('transactionsFilters')
28
28
  ? {
29
29
  ...(JSON.parse(
30
- decodeURIComponent(get('ledgerRecordsFilters') as string),
30
+ decodeURIComponent(get('transactionsFilters') as string),
31
31
  ) as BusinessTransactionsFilter),
32
32
  businessIDs: id ? [id] : [],
33
33
  }
@@ -36,17 +36,17 @@ export const BusinessLedgerRecordsSingle = ({ businessId }: Props): ReactElement
36
36
  },
37
37
  );
38
38
  const [{ data, fetching }] = useQuery({
39
- query: BusinessLedgerRecordsSummeryDocument,
39
+ query: BusinessTransactionsSummeryDocument,
40
40
  variables: {
41
41
  filters: filter,
42
42
  },
43
43
  });
44
44
 
45
45
  useEffect(() => {
46
- setFiltersContext(<BusinessLedgerRecordsFilters filter={filter} setFilter={setFilter} />);
46
+ setFiltersContext(<BusinessTransactionsFilters filter={filter} setFilter={setFilter} />);
47
47
  }, [data, filter, setFiltersContext, setFilter]);
48
48
 
49
- const businessLedgerRecordsSum = useMemo(() => {
49
+ const businessTransactionsSum = useMemo(() => {
50
50
  if (data?.businessTransactionsSumFromLedgerRecords.__typename === 'CommonError') {
51
51
  return [];
52
52
  }
@@ -68,7 +68,7 @@ export const BusinessLedgerRecordsSingle = ({ businessId }: Props): ReactElement
68
68
  striped
69
69
  highlightOnHover
70
70
  stickyHeader
71
- items={businessLedgerRecordsSum}
71
+ items={businessTransactionsSum}
72
72
  columns={[
73
73
  {
74
74
  title: 'Business Name',
@@ -106,14 +106,14 @@ export const BusinessLedgerRecordsSingle = ({ businessId }: Props): ReactElement
106
106
  );
107
107
  };
108
108
 
109
- type BusinessLedgerRecordsSum = Extract<
110
- BusinessLedgerRecordsSummeryQuery['businessTransactionsSumFromLedgerRecords'],
109
+ type BusinessTransactionsSum = Extract<
110
+ BusinessTransactionsSummeryQuery['businessTransactionsSumFromLedgerRecords'],
111
111
  { businessTransactionsSum: unknown }
112
112
  >['businessTransactionsSum'][number];
113
113
 
114
114
  type CellInfo = {
115
115
  title: ReactNode;
116
- value: (data: BusinessLedgerRecordsSum) => string | ReactNode;
116
+ value: (data: BusinessTransactionsSum) => string | ReactNode;
117
117
  style?: React.CSSProperties;
118
118
  };
119
119
 
@@ -3,47 +3,47 @@ import { format } from 'date-fns';
3
3
  import { Currency } from '../../gql/graphql.js';
4
4
  import { currencyCodeToSymbol, type TimelessDateString } from '../../helpers/index.js';
5
5
  import { DownloadCSVButton } from '../common/index.js';
6
- import type { ExtendedLedger } from './business-extended-info.js';
6
+ import type { ExtendedTransaction } from './business-extended-info.js';
7
7
 
8
8
  interface Props {
9
- ledgerRecords: Array<ExtendedLedger>;
9
+ transactions: Array<ExtendedTransaction>;
10
10
  businessName: string;
11
11
  fromDate?: TimelessDateString;
12
12
  toDate?: TimelessDateString;
13
13
  }
14
14
 
15
15
  export const DownloadCSV = ({
16
- ledgerRecords,
16
+ transactions,
17
17
  businessName,
18
18
  fromDate,
19
19
  toDate,
20
20
  }: Props): ReactElement => {
21
21
  const createFileVariables = useCallback(async () => {
22
- const csvData = convertToCSV(ledgerRecords);
23
- const fileName = `business_${businessName}_ledger_records${fromDate ? `_${fromDate}` : ''}${toDate ? `_${toDate}` : ''}`;
22
+ const csvData = convertToCSV(transactions);
23
+ const fileName = `business_${businessName}_transactions${fromDate ? `_${fromDate}` : ''}${toDate ? `_${toDate}` : ''}`;
24
24
  return {
25
25
  fileName,
26
26
  fileContent: csvData,
27
27
  };
28
- }, [ledgerRecords, businessName, fromDate, toDate]);
28
+ }, [transactions, businessName, fromDate, toDate]);
29
29
 
30
30
  return <DownloadCSVButton createFileVariables={createFileVariables} />;
31
31
  };
32
32
 
33
- const convertToCSV = (ledgerRecords: Array<ExtendedLedger>): string => {
33
+ const convertToCSV = (transactions: Array<ExtendedTransaction>): string => {
34
34
  let csvString = '';
35
35
 
36
36
  const currencies = Array.from(
37
37
  new Set(
38
- ledgerRecords.filter(t => t.foreignAmount?.currency).map(t => t.foreignAmount!.currency),
38
+ transactions.filter(t => t.foreignAmount?.currency).map(t => t.foreignAmount!.currency),
39
39
  ),
40
40
  );
41
41
 
42
42
  csvString += `Sorting Date,Date,Amount,Amount Balance,${getHeadersFromForeignCurrencies(currencies)}Reference,Details,Counter Account\r\n`;
43
43
 
44
- for (const record of ledgerRecords) {
45
- const stringifiedRecord = handleLedgerRecord(record, currencies);
46
- csvString += stringifiedRecord;
44
+ for (const transaction of transactions) {
45
+ const stringifiedTransaction = handleTransaction(transaction, currencies);
46
+ csvString += stringifiedTransaction;
47
47
  }
48
48
 
49
49
  return csvString;
@@ -59,13 +59,13 @@ function getHeadersFromForeignCurrencies(currencies: Array<Currency>): string {
59
59
  }
60
60
 
61
61
  function getAmountsFromForeignCurrencies(
62
- ledgerRecord: ExtendedLedger,
62
+ transaction: ExtendedTransaction,
63
63
  currencies: Array<Currency>,
64
64
  ): string {
65
65
  let amounts = '';
66
66
  currencies.map(currency => {
67
- if (ledgerRecord.foreignAmount && ledgerRecord.foreignAmount.currency === currency) {
68
- amounts += `${ledgerRecord.foreignAmount.raw},${ledgerRecord[`${currency.toLowerCase()}Balance` as keyof ExtendedLedger] ?? 0},`;
67
+ if (transaction.foreignAmount && transaction.foreignAmount.currency === currency) {
68
+ amounts += `${transaction.foreignAmount.raw},${transaction[`${currency.toLowerCase()}Balance` as keyof ExtendedTransaction] ?? 0},`;
69
69
  } else {
70
70
  amounts += ',,';
71
71
  }
@@ -73,21 +73,21 @@ function getAmountsFromForeignCurrencies(
73
73
  return amounts;
74
74
  }
75
75
 
76
- function handleLedgerRecord(ledgerRecord: ExtendedLedger, currencies: Array<Currency>): string {
77
- let ledgerRecordString = '';
76
+ function handleTransaction(transaction: ExtendedTransaction, currencies: Array<Currency>): string {
77
+ let transactionString = '';
78
78
 
79
- const sortingDate = ledgerRecord.invoiceDate
80
- ? format(new Date(ledgerRecord.invoiceDate), 'yyy-MM-dd')
79
+ const sortingDate = transaction.invoiceDate
80
+ ? format(new Date(transaction.invoiceDate), 'yyy-MM-dd')
81
81
  : null;
82
- const date = ledgerRecord.invoiceDate
83
- ? format(new Date(ledgerRecord.invoiceDate), 'dd/MM/yy')
82
+ const date = transaction.invoiceDate
83
+ ? format(new Date(transaction.invoiceDate), 'dd/MM/yy')
84
84
  : null;
85
- const ilsAmount = ledgerRecord.amount.raw;
86
- const { ilsBalance, reference, details } = ledgerRecord;
87
- const counterAccount = ledgerRecord.counterAccount?.name ?? '';
85
+ const ilsAmount = transaction.amount.raw;
86
+ const { ilsBalance, reference, details } = transaction;
87
+ const counterAccount = transaction.counterAccount?.name ?? '';
88
88
 
89
- ledgerRecordString += `${sortingDate},${date},${ilsAmount},${ilsBalance},${getAmountsFromForeignCurrencies(ledgerRecord, currencies)}${sanitizeString(reference ?? '')},${sanitizeString(details ?? '')},${sanitizeString(counterAccount)},\r\n`;
90
- return ledgerRecordString;
89
+ transactionString += `${sortingDate},${date},${ilsAmount},${ilsBalance},${getAmountsFromForeignCurrencies(transaction, currencies)}${sanitizeString(reference ?? '')},${sanitizeString(details ?? '')},${sanitizeString(counterAccount)},\r\n`;
90
+ return transactionString;
91
91
  }
92
92
 
93
93
  function sanitizeString(content: string | number): string {
@@ -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
- BusinessLedgerRecordsSummeryDocument,
12
+ BusinessTransactionsSummeryDocument,
13
13
  Currency,
14
- type BusinessLedgerRecordsSummeryQuery,
15
14
  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 { BusinessLedgerRecordsFilters } from './business-ledger-filters.js';
24
+ import { BusinessTransactionsFilters } from './business-transactions-filters.js';
25
25
 
26
26
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- used by codegen
27
27
  /* GraphQL */ `
28
- query BusinessLedgerRecordsSummery($filters: BusinessTransactionsFilter) {
28
+ query BusinessTransactionsSummery($filters: BusinessTransactionsFilter) {
29
29
  businessTransactionsSumFromLedgerRecords(filters: $filters) {
30
30
  ... on BusinessTransactionsSumFromLedgerRecordsSuccessfulResult {
31
31
  businessTransactionsSum {
@@ -66,32 +66,32 @@ import { BusinessLedgerRecordsFilters } from './business-ledger-filters.js';
66
66
  }
67
67
  `;
68
68
 
69
- type BusinessLedgerRecordsSum = Extract<
70
- BusinessLedgerRecordsSummeryQuery['businessTransactionsSumFromLedgerRecords'],
69
+ type BusinessTransactionsSum = Extract<
70
+ BusinessTransactionsSummeryQuery['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: BusinessLedgerRecordsSum) => string | ReactNode;
77
+ value: (item: BusinessTransactionsSum) => string | ReactNode;
78
78
  style?: React.CSSProperties;
79
79
  };
80
80
 
81
- export const BusinessLedgerRecordsSummery = (): ReactElement => {
81
+ export const BusinessTransactionsSummery = (): 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('ledgerRecordsFilters')
87
+ get('transactionsFilters')
88
88
  ? (JSON.parse(
89
- decodeURIComponent(get('ledgerRecordsFilters') as string),
89
+ decodeURIComponent(get('transactionsFilters') as string),
90
90
  ) as BusinessTransactionsFilter)
91
91
  : {},
92
92
  );
93
93
  const [{ data, fetching }] = useQuery({
94
- query: BusinessLedgerRecordsSummeryDocument,
94
+ query: BusinessTransactionsSummeryDocument,
95
95
  variables: {
96
96
  filters: filter,
97
97
  },
@@ -100,7 +100,7 @@ export const BusinessLedgerRecordsSummery = (): ReactElement => {
100
100
  useEffect(() => {
101
101
  setFiltersContext(
102
102
  <div className="flex flex-row gap-x-5">
103
- <BusinessLedgerRecordsFilters filter={filter} setFilter={setFilter} />
103
+ <BusinessTransactionsFilters filter={filter} setFilter={setFilter} />
104
104
  <Tooltip label="Expand all accounts">
105
105
  <Button
106
106
  variant="outline"
@@ -141,7 +141,7 @@ export const BusinessLedgerRecordsSummery = (): ReactElement => {
141
141
  isExpandedCurrencies,
142
142
  ]);
143
143
 
144
- const businessLedgerRecordsSum = useMemo(() => {
144
+ const businessTransactionsSum = useMemo(() => {
145
145
  if (data?.businessTransactionsSumFromLedgerRecords.__typename === 'CommonError') {
146
146
  return [];
147
147
  }
@@ -195,7 +195,7 @@ export const BusinessLedgerRecordsSummery = (): ReactElement => {
195
195
  ];
196
196
 
197
197
  return (
198
- <PageLayout title="Business Ledger Records" description="Business Ledger Records Summary">
198
+ <PageLayout title="Business Transactions" description="Business Transactions Summery">
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 BusinessLedgerRecordsSummery = (): ReactElement => {
209
209
  </tr>
210
210
  </thead>
211
211
  <tbody>
212
- {businessLedgerRecordsSum.map((item, index) => (
212
+ {businessTransactionsSum.map((item, index) => (
213
213
  <AccounterTableRow
214
214
  key={index}
215
215
  columns={columns}
@@ -4,7 +4,6 @@ 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,
8
7
  ChargesTableErrorsFieldsFragmentDoc,
9
8
  ChargeTableTransactionsFieldsFragmentDoc,
10
9
  ConversionChargeInfoFragmentDoc,
@@ -13,6 +12,7 @@ import {
13
12
  ExchangeRatesInfoFragmentDoc,
14
13
  FetchChargeDocument,
15
14
  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
- ...ChargeLedgerRecordsTableFields @defer
58
+ ...TableLedgerRecordsFields @defer
59
59
  ...ChargeTableTransactionsFields @defer
60
60
  ...ConversionChargeInfo @defer
61
61
  ...CreditcardBankChargeInfo @defer
@@ -89,31 +89,6 @@ 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
-
117
92
  interface Props {
118
93
  chargeID: string;
119
94
  onChange?: () => void;
@@ -216,7 +191,7 @@ export function ChargeExtendedInfo({
216
191
 
217
192
  const ledgerRecordsAreReady = isFragmentReady(
218
193
  FetchChargeDocument,
219
- ChargeLedgerRecordsTableFieldsFragmentDoc,
194
+ TableLedgerRecordsFieldsFragmentDoc,
220
195
  charge,
221
196
  );
222
197
 
@@ -467,7 +442,7 @@ export function ChargeExtendedInfo({
467
442
  </div>
468
443
  </Accordion.Control>
469
444
  <Accordion.Panel>
470
- {ledgerRecordsAreReady && <ChargeLedgerTable data={charge} />}
445
+ {ledgerRecordsAreReady && <LedgerTable ledgerFragment={charge} />}
471
446
  </Accordion.Panel>
472
447
  </Accordion.Item>
473
448
  )}
@@ -485,19 +460,3 @@ export function ChargeExtendedInfo({
485
460
  </div>
486
461
  );
487
462
  }
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 Ledger',
168
+ title: 'Business Transactions',
169
169
  label: '',
170
- href: ROUTES.BUSINESSES.LEDGER,
170
+ href: ROUTES.BUSINESSES.TRANSACTIONS,
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 Account (Main)',
56
+ header: 'Debit Account1',
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 Account (Main)',
123
+ header: 'Credit Account1',
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 Account (Secondary)',
190
+ header: 'Debit Account2',
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 Account (Secondary)',
257
+ header: 'Credit Account2',
258
258
  columns: [
259
259
  {
260
260
  accessorKey: 'creditAccount2.name',