@accounter/client 0.0.8-alpha-20251029094652-37d24ebe6304860cfa001b18424cc588dbcf064d → 0.0.8-alpha-20251029111239-192c5afd2d66a4d11ea8217039b86666b6fff216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/assets/{Checkbox-CSPHEKoR.js → Checkbox-BfB2aYmM.js} +2 -2
- package/dist/assets/{MultiSelect-CszuVk07.js → MultiSelect-CGvaXcuH.js} +1 -1
- package/dist/assets/{Pagination-Cp6iKPSu.js → Pagination-D4fkmYTl.js} +1 -1
- package/dist/assets/{Progress-ByaKYSXX.js → Progress-CQs7EuQ2.js} +1 -1
- package/dist/assets/{Table-CQ4GTcIY.js → Table-C2EjuqpH.js} +1 -1
- package/dist/assets/{Typography-Cn08y9HC.js → Typography-bz4ZX5sI.js} +1 -1
- package/dist/assets/{YearPickerInput-BsQymTcP.js → YearPickerInput-CURoIYu6.js} +1 -1
- package/dist/assets/{accordion-CG93-Cqs.js → accordion-DWmBRtUi.js} +1 -1
- package/dist/assets/{accountant-approvals-Dxy1hGw7.js → accountant-approvals-C9FCfRoL.js} +1 -1
- package/dist/assets/{accounter-table-Dgvw-xm_.js → accounter-table-C70NKDaW.js} +1 -1
- package/dist/assets/{addDays-Di-hbHs3.js → addDays-BGYF7FkS.js} +1 -1
- package/dist/assets/{all-charges-DRl4EcMG.js → all-charges-CkPb7TjD.js} +1 -1
- package/dist/assets/{arrow-up-down-Hh3TlLSU.js → arrow-up-down-B-KqfJyD.js} +1 -1
- package/dist/assets/{building-2-DGfYgfU_.js → building-2-BAwr8r-2.js} +1 -1
- package/dist/assets/{business-aamFaOhr.js → business-DLu0ofgu.js} +17 -7
- package/dist/assets/business-extended-info-vAiMQKwm.js +13 -0
- package/dist/assets/{business-header-BphijNiC.js → business-header-B_qcrJW_.js} +1 -1
- package/dist/assets/business-ledger-filters-CNjRVS0K.js +1 -0
- package/dist/assets/business-ledger-single-BrattJvc.js +1 -0
- package/dist/assets/business-trip-DZqft86E.js +1 -0
- package/dist/assets/{charge-D-99eJ1v.js → charge-aBSxCGi3.js} +1 -1
- package/dist/assets/{charges-filters-Dxaf2lVd.js → charges-filters-BRuJ3XbB.js} +1 -1
- package/dist/assets/{charges-ledger-validation-BAY3PYth.js → charges-ledger-validation-DjuvGES2.js} +1 -1
- package/dist/assets/charges-table--gOKotyF.js +62 -0
- package/dist/assets/{chart-DM5P1yGj.js → chart-BSh0rsm7.js} +1 -1
- package/dist/assets/{data-table-pagination-TG7sqb1-.js → data-table-pagination-BCuaIseR.js} +1 -1
- package/dist/assets/download-csv-button-B0eh9bzg.js +1 -0
- package/dist/assets/{editable-business-trip-DlAsZ0aQ.js → editable-business-trip-BLWzKbN3.js} +1 -1
- package/dist/assets/{funnel-BQEGwl1q.js → funnel-XiON1wPY.js} +1 -1
- package/dist/assets/{index-CJEUQmMx.js → index-3Fyx3NBp.js} +1 -1
- package/dist/assets/{index-CIY9x3TF.js → index-B05N38w4.js} +2 -2
- package/dist/assets/{index-DkKTDpFK.js → index-BPLQ_Cjg.js} +1 -1
- package/dist/assets/index-BS5IhG6A.js +1 -0
- package/dist/assets/{index-CzEcZ0Dn.js → index-BVTpNGNk.js} +2 -2
- package/dist/assets/{index-DKjsW6q7.js → index-BYCdqffp.js} +7 -7
- package/dist/assets/{index-BmZql10x.js → index-BdnLryTF.js} +14 -14
- package/dist/assets/{index-CGQclWiq.js → index-BdzdEbUC.js} +1 -1
- package/dist/assets/{index-CXRSu47J.js → index-BwrF7ixX.js} +2 -2
- package/dist/assets/{index-DgbPiRkF.js → index-By2sHbGk.js} +1 -1
- package/dist/assets/{index-ClzPFBOc.js → index-C-RIsd1H.js} +2 -2
- package/dist/assets/{index-NofRnQ8o.js → index-CA6LHUxs.js} +1 -1
- package/dist/assets/{index-CkIv3Veq.js → index-CJP0f2Bm.js} +1 -1
- package/dist/assets/{index-IuUe41KG.js → index-CVNgfFi3.js} +1 -1
- package/dist/assets/{index-Dt4KpoN0.js → index-C_nLGgCr.js} +1 -1
- package/dist/assets/index-Ci8Rcu9T.js +1 -0
- package/dist/assets/{index-CFY-4iKE.js → index-CtDDVAsw.js} +1 -1
- package/dist/assets/{index-DROHY2Kd.js → index-CxE91GPE.js} +1 -1
- package/dist/assets/{index--OgMtW-2.js → index-D7GKOJU4.js} +2 -2
- package/dist/assets/{index-CiXTFJcq.js → index-D9RA6cVt.js} +2 -2
- package/dist/assets/{index-DnFwBDCa.js → index-DOSLXKPY.js} +1 -1
- package/dist/assets/{index-WaN-m0WB.js → index-DaSx2wiU.js} +1 -1
- package/dist/assets/{index-DOh5XsM3.js → index-DbbPcdZ7.js} +2 -2
- package/dist/assets/{index-D9zE4pLO.js → index-Diqx01g3.js} +1 -1
- package/dist/assets/{index-juMfNCjV.js → index-pjJUDHWQ.js} +1 -1
- package/dist/assets/{index.es-BJEu0vdb.js → index.es-BWSz-k0E.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-CXgUJdgl.js → insert-business-trip-modal-Bk-kugZI.js} +2 -2
- package/dist/assets/issue-document-BcWeUsrG.js +1 -0
- package/dist/assets/{list-plus-BlHtPDEN.js → list-plus-DINtfnSi.js} +1 -1
- package/dist/assets/{login-page-DmCLAM1G.js → login-page-DVwxXAvd.js} +1 -1
- package/dist/assets/{match-document-modal-KjnSxB69.js → match-document-modal--iAusdTp.js} +4 -4
- package/dist/assets/{missing-info-charges-BiEeQwER.js → missing-info-charges-CQNTClQ3.js} +1 -1
- package/dist/assets/{modal-dLkQjDNz.js → modal-BzwJJ2TM.js} +1 -1
- package/dist/assets/{page-layout-DxGYaCiw.js → page-layout-NF77oib6.js} +1 -1
- package/dist/assets/{page-not-found-ChLEFKCs.js → page-not-found-Cu_0zp5u.js} +1 -1
- package/dist/assets/{panel-top-open-CWsfFRNu.js → panel-top-open-BApXXBMD.js} +1 -1
- package/dist/assets/{pencil-BEefjySD.js → pencil-CLaFsm6E.js} +1 -1
- package/dist/assets/{report-commentary-row-Cci0ntye.js → report-commentary-row-BGN_tI-P.js} +1 -1
- package/dist/assets/{save-BkV97OA1.js → save-DsE11_Et.js} +1 -1
- package/dist/assets/{similar-transactions-modal-8T9lL2yX.js → similar-transactions-modal-CoZU6FU3.js} +1 -1
- package/dist/assets/sub-DLRNYZyc.js +1 -0
- package/dist/assets/subMonths-Bc9skHhr.js +1 -0
- package/dist/assets/{summary-DzLJ6sUY.js → summary-BasZ3QlN.js} +1 -1
- package/dist/assets/{toggle-expansion-button-BzVlE1kb.js → toggle-expansion-button-DPcDIe-2.js} +1 -1
- package/dist/assets/tooltip-CICdw5IX.js +1 -0
- package/dist/assets/{use-url-query-DV9K0FAR.js → use-url-query-Bp_LkJaa.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/business/balance-section.tsx +26 -0
- package/src/components/business/index.tsx +31 -1
- package/src/components/business/ledger-section.tsx +49 -0
- package/src/components/business/transactions-section.tsx +24 -2
- package/src/components/{business-transactions → business-ledger}/business-extended-info.tsx +25 -27
- package/src/components/{business-transactions/business-transactions-filters.tsx → business-ledger/business-ledger-filters.tsx} +12 -12
- package/src/components/{business-transactions/business-transactions-single.tsx → business-ledger/business-ledger-single.tsx} +13 -13
- package/src/components/{business-transactions → business-ledger}/download-csv.tsx +25 -25
- package/src/components/{business-transactions → business-ledger}/index.tsx +15 -15
- package/src/components/charges/charge-extended-info.tsx +45 -4
- package/src/components/layout/sidelinks.tsx +2 -2
- package/src/components/ledger-table/columns.tsx +4 -4
- package/src/components/ledger-table/index.tsx +152 -181
- package/src/components/reports/conto/custom-node.tsx +1 -1
- package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
- package/src/components/transactions-table/columns.tsx +9 -9
- package/src/components/transactions-table/index.tsx +56 -21
- package/src/gql/gql.ts +30 -12
- package/src/gql/graphql.ts +181 -406
- package/src/router/config.tsx +14 -14
- package/src/router/routes.ts +2 -2
- package/dist/assets/business-extended-info-CeEMIazB.js +0 -13
- package/dist/assets/business-transactions-filters-DYBvDjKs.js +0 -1
- package/dist/assets/business-transactions-single-B77wu9sA.js +0 -1
- package/dist/assets/business-trip-C1cYIMHX.js +0 -1
- package/dist/assets/charges-table-CNWVDMmv.js +0 -62
- package/dist/assets/download-csv-button-jQXIlRax.js +0 -1
- package/dist/assets/index-B-USUC2v.js +0 -1
- package/dist/assets/index-BYfofaiM.js +0 -1
- package/dist/assets/issue-document-BSkWYnI5.js +0 -1
- package/dist/assets/sub-DdivcKGZ.js +0 -1
- package/dist/assets/subMonths-Kz3NJUOL.js +0 -1
- package/dist/assets/tooltip-Ht3m2Q26.js +0 -1
- package/src/app.tsx +0 -108
|
@@ -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.
|
|
12
|
+
import { UserContext } from '../../providers/user-provider.jsx';
|
|
13
13
|
import { PopUpModal } from '../common/index.js';
|
|
14
|
-
import { Button } from '../ui/button.
|
|
14
|
+
import { Button } from '../ui/button.jsx';
|
|
15
15
|
|
|
16
|
-
export function
|
|
16
|
+
export function encodeLedgerRecordsFilters(
|
|
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
|
|
22
|
+
interface BusinessLedgerRecordsFilterFormProps {
|
|
23
23
|
filter: BusinessTransactionsFilter;
|
|
24
24
|
setFilter: (filter: BusinessTransactionsFilter) => void;
|
|
25
25
|
closeModal: () => void;
|
|
26
26
|
single?: boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function
|
|
29
|
+
function BusinessLedgerRecordsFilterForm({
|
|
30
30
|
filter,
|
|
31
31
|
setFilter,
|
|
32
32
|
closeModal,
|
|
33
33
|
single = false,
|
|
34
|
-
}:
|
|
34
|
+
}: BusinessLedgerRecordsFilterFormProps): ReactElement {
|
|
35
35
|
const { control, handleSubmit } = useForm<BusinessTransactionsFilter>({
|
|
36
36
|
defaultValues: { ...filter },
|
|
37
37
|
});
|
|
@@ -199,15 +199,15 @@ function BusinessTransactionsFilterForm({
|
|
|
199
199
|
);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
interface
|
|
202
|
+
interface BusinessLedgerRecordsFilterProps {
|
|
203
203
|
filter: BusinessTransactionsFilter;
|
|
204
204
|
setFilter: (filter: BusinessTransactionsFilter) => void;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
export function
|
|
207
|
+
export function BusinessLedgerRecordsFilters({
|
|
208
208
|
filter,
|
|
209
209
|
setFilter,
|
|
210
|
-
}:
|
|
210
|
+
}: BusinessLedgerRecordsFilterProps): 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 BusinessTransactionsFilters({
|
|
|
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('
|
|
235
|
+
const oldFilter = get('ledgerRecordsFilters');
|
|
236
236
|
if (newFilter !== oldFilter) {
|
|
237
|
-
set('
|
|
237
|
+
set('ledgerRecordsFilters', newFilter);
|
|
238
238
|
}
|
|
239
239
|
}, [filter, get, set]);
|
|
240
240
|
|
|
@@ -244,7 +244,7 @@ export function BusinessTransactionsFilters({
|
|
|
244
244
|
opened={opened}
|
|
245
245
|
onClose={(): void => setOpened(false)}
|
|
246
246
|
content={
|
|
247
|
-
<
|
|
247
|
+
<BusinessLedgerRecordsFilterForm
|
|
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
|
-
|
|
6
|
+
BusinessLedgerRecordsSummeryDocument,
|
|
7
7
|
Currency,
|
|
8
|
+
type BusinessLedgerRecordsSummeryQuery,
|
|
8
9
|
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 {
|
|
15
|
+
import { BusinessLedgerRecordsFilters } from './business-ledger-filters.js';
|
|
16
16
|
|
|
17
17
|
type Props = {
|
|
18
18
|
businessId?: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const BusinessLedgerRecordsSingle = ({ 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('
|
|
27
|
+
get('ledgerRecordsFilters')
|
|
28
28
|
? {
|
|
29
29
|
...(JSON.parse(
|
|
30
|
-
decodeURIComponent(get('
|
|
30
|
+
decodeURIComponent(get('ledgerRecordsFilters') as string),
|
|
31
31
|
) as BusinessTransactionsFilter),
|
|
32
32
|
businessIDs: id ? [id] : [],
|
|
33
33
|
}
|
|
@@ -36,17 +36,17 @@ export const BusinessTransactionsSingle = ({ businessId }: Props): ReactElement
|
|
|
36
36
|
},
|
|
37
37
|
);
|
|
38
38
|
const [{ data, fetching }] = useQuery({
|
|
39
|
-
query:
|
|
39
|
+
query: BusinessLedgerRecordsSummeryDocument,
|
|
40
40
|
variables: {
|
|
41
41
|
filters: filter,
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
|
-
setFiltersContext(<
|
|
46
|
+
setFiltersContext(<BusinessLedgerRecordsFilters filter={filter} setFilter={setFilter} />);
|
|
47
47
|
}, [data, filter, setFiltersContext, setFilter]);
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
const businessLedgerRecordsSum = useMemo(() => {
|
|
50
50
|
if (data?.businessTransactionsSumFromLedgerRecords.__typename === 'CommonError') {
|
|
51
51
|
return [];
|
|
52
52
|
}
|
|
@@ -68,7 +68,7 @@ export const BusinessTransactionsSingle = ({ businessId }: Props): ReactElement
|
|
|
68
68
|
striped
|
|
69
69
|
highlightOnHover
|
|
70
70
|
stickyHeader
|
|
71
|
-
items={
|
|
71
|
+
items={businessLedgerRecordsSum}
|
|
72
72
|
columns={[
|
|
73
73
|
{
|
|
74
74
|
title: 'Business Name',
|
|
@@ -106,14 +106,14 @@ export const BusinessTransactionsSingle = ({ businessId }: Props): ReactElement
|
|
|
106
106
|
);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
type
|
|
110
|
-
|
|
109
|
+
type BusinessLedgerRecordsSum = Extract<
|
|
110
|
+
BusinessLedgerRecordsSummeryQuery['businessTransactionsSumFromLedgerRecords'],
|
|
111
111
|
{ businessTransactionsSum: unknown }
|
|
112
112
|
>['businessTransactionsSum'][number];
|
|
113
113
|
|
|
114
114
|
type CellInfo = {
|
|
115
115
|
title: ReactNode;
|
|
116
|
-
value: (data:
|
|
116
|
+
value: (data: BusinessLedgerRecordsSum) => 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 {
|
|
6
|
+
import type { ExtendedLedger } from './business-extended-info.js';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
|
-
|
|
9
|
+
ledgerRecords: Array<ExtendedLedger>;
|
|
10
10
|
businessName: string;
|
|
11
11
|
fromDate?: TimelessDateString;
|
|
12
12
|
toDate?: TimelessDateString;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const DownloadCSV = ({
|
|
16
|
-
|
|
16
|
+
ledgerRecords,
|
|
17
17
|
businessName,
|
|
18
18
|
fromDate,
|
|
19
19
|
toDate,
|
|
20
20
|
}: Props): ReactElement => {
|
|
21
21
|
const createFileVariables = useCallback(async () => {
|
|
22
|
-
const csvData = convertToCSV(
|
|
23
|
-
const fileName = `business_${businessName}
|
|
22
|
+
const csvData = convertToCSV(ledgerRecords);
|
|
23
|
+
const fileName = `business_${businessName}_ledger_records${fromDate ? `_${fromDate}` : ''}${toDate ? `_${toDate}` : ''}`;
|
|
24
24
|
return {
|
|
25
25
|
fileName,
|
|
26
26
|
fileContent: csvData,
|
|
27
27
|
};
|
|
28
|
-
}, [
|
|
28
|
+
}, [ledgerRecords, businessName, fromDate, toDate]);
|
|
29
29
|
|
|
30
30
|
return <DownloadCSVButton createFileVariables={createFileVariables} />;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const convertToCSV = (
|
|
33
|
+
const convertToCSV = (ledgerRecords: Array<ExtendedLedger>): string => {
|
|
34
34
|
let csvString = '';
|
|
35
35
|
|
|
36
36
|
const currencies = Array.from(
|
|
37
37
|
new Set(
|
|
38
|
-
|
|
38
|
+
ledgerRecords.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
|
|
45
|
-
const
|
|
46
|
-
csvString +=
|
|
44
|
+
for (const record of ledgerRecords) {
|
|
45
|
+
const stringifiedRecord = handleLedgerRecord(record, currencies);
|
|
46
|
+
csvString += stringifiedRecord;
|
|
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
|
-
|
|
62
|
+
ledgerRecord: ExtendedLedger,
|
|
63
63
|
currencies: Array<Currency>,
|
|
64
64
|
): string {
|
|
65
65
|
let amounts = '';
|
|
66
66
|
currencies.map(currency => {
|
|
67
|
-
if (
|
|
68
|
-
amounts += `${
|
|
67
|
+
if (ledgerRecord.foreignAmount && ledgerRecord.foreignAmount.currency === currency) {
|
|
68
|
+
amounts += `${ledgerRecord.foreignAmount.raw},${ledgerRecord[`${currency.toLowerCase()}Balance` as keyof ExtendedLedger] ?? 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
|
|
77
|
-
let
|
|
76
|
+
function handleLedgerRecord(ledgerRecord: ExtendedLedger, currencies: Array<Currency>): string {
|
|
77
|
+
let ledgerRecordString = '';
|
|
78
78
|
|
|
79
|
-
const sortingDate =
|
|
80
|
-
? format(new Date(
|
|
79
|
+
const sortingDate = ledgerRecord.invoiceDate
|
|
80
|
+
? format(new Date(ledgerRecord.invoiceDate), 'yyy-MM-dd')
|
|
81
81
|
: null;
|
|
82
|
-
const date =
|
|
83
|
-
? format(new Date(
|
|
82
|
+
const date = ledgerRecord.invoiceDate
|
|
83
|
+
? format(new Date(ledgerRecord.invoiceDate), 'dd/MM/yy')
|
|
84
84
|
: null;
|
|
85
|
-
const ilsAmount =
|
|
86
|
-
const { ilsBalance, reference, details } =
|
|
87
|
-
const counterAccount =
|
|
85
|
+
const ilsAmount = ledgerRecord.amount.raw;
|
|
86
|
+
const { ilsBalance, reference, details } = ledgerRecord;
|
|
87
|
+
const counterAccount = ledgerRecord.counterAccount?.name ?? '';
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
return
|
|
89
|
+
ledgerRecordString += `${sortingDate},${date},${ilsAmount},${ilsBalance},${getAmountsFromForeignCurrencies(ledgerRecord, currencies)}${sanitizeString(reference ?? '')},${sanitizeString(details ?? '')},${sanitizeString(counterAccount)},\r\n`;
|
|
90
|
+
return ledgerRecordString;
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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
|
|
70
|
-
|
|
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:
|
|
77
|
+
value: (item: BusinessLedgerRecordsSum) => string | ReactNode;
|
|
78
78
|
style?: React.CSSProperties;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
export const
|
|
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('
|
|
87
|
+
get('ledgerRecordsFilters')
|
|
88
88
|
? (JSON.parse(
|
|
89
|
-
decodeURIComponent(get('
|
|
89
|
+
decodeURIComponent(get('ledgerRecordsFilters') as string),
|
|
90
90
|
) as BusinessTransactionsFilter)
|
|
91
91
|
: {},
|
|
92
92
|
);
|
|
93
93
|
const [{ data, fetching }] = useQuery({
|
|
94
|
-
query:
|
|
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
|
-
<
|
|
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
|
|
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
|
|
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
|
-
{
|
|
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
|
-
...
|
|
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
|
-
|
|
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 && <
|
|
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
|
|
168
|
+
title: 'Business Ledger',
|
|
169
169
|
label: '',
|
|
170
|
-
href: ROUTES.BUSINESSES.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
257
|
+
header: 'Credit Account (Secondary)',
|
|
258
258
|
columns: [
|
|
259
259
|
{
|
|
260
260
|
accessorKey: 'creditAccount2.name',
|