@zeniai/client-epic-state 5.0.84-betaVR1 → 5.0.85-beta0ND
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/lib/commonStateTypes/animations.d.ts +1 -1
- package/lib/commonStateTypes/animations.js +1 -0
- package/lib/entity/company/companyPayload.d.ts +2 -0
- package/lib/entity/company/companyPayload.js +2 -0
- package/lib/entity/company/companyStateTypes.d.ts +2 -0
- package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
- package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/tenantPayload.d.ts +19 -0
- package/lib/entity/tenant/tenantReducer.d.ts +49 -28
- package/lib/entity/tenant/tenantReducer.js +111 -5
- package/lib/entity/tenant/tenantState.d.ts +21 -0
- package/lib/epic.d.ts +8 -2
- package/lib/epic.js +9 -2
- package/lib/esm/commonStateTypes/animations.js +1 -0
- package/lib/esm/entity/company/companyPayload.js +2 -0
- package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
- package/lib/esm/entity/tenant/tenantReducer.js +108 -3
- package/lib/esm/epic.js +9 -2
- package/lib/esm/index.js +12 -11
- package/lib/esm/view/companyView/companyViewReducer.js +45 -1
- package/lib/esm/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +25 -0
- package/lib/esm/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +79 -0
- package/lib/esm/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
- package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +45 -0
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +168 -50
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +14 -0
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -0
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +49 -0
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +58 -0
- package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +12 -0
- package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
- package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +71 -52
- package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
- package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
- package/lib/index.d.ts +15 -14
- package/lib/index.js +56 -42
- package/lib/view/companyView/companyViewReducer.d.ts +11 -1
- package/lib/view/companyView/companyViewReducer.js +47 -3
- package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.d.ts +9 -0
- package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +29 -0
- package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.d.ts +10 -0
- package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +83 -0
- package/lib/view/companyView/types/companyPassport/companyPassportViewState.d.ts +1 -0
- package/lib/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +49 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +170 -51
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +7 -1
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +21 -1
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +37 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +14 -1
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +8 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +53 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +8 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +62 -0
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +27 -0
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +15 -0
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
- package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +24 -2
- package/lib/view/spendManagement/commonSetup/setupViewReducer.js +72 -53
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +4 -0
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
- package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +12 -0
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
- package/package.json +1 -1
- package/lib/esm/view/transactionDetail/journalEntryLinesViewModel.js +0 -113
- package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +0 -73
- package/lib/view/transactionDetail/journalEntryLinesViewModel.js +0 -124
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import orderBy from 'lodash/orderBy';
|
|
2
|
-
import { stringToUnion } from '../../commonStateTypes/stringToUnion';
|
|
3
|
-
/**
|
|
4
|
-
* View-model helpers for the new Journal Entry table view (see
|
|
5
|
-
* web-components `journalEntryTable`). Keeps presentation-agnostic
|
|
6
|
-
* logic — totals, sort, line-filter — colocated in epic-state so it
|
|
7
|
-
* is testable and reusable.
|
|
8
|
-
*/
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Sort keys
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
export const JOURNAL_ENTRY_SORT_KEYS = [
|
|
13
|
-
'description',
|
|
14
|
-
'name',
|
|
15
|
-
'category',
|
|
16
|
-
'class',
|
|
17
|
-
'debit',
|
|
18
|
-
'credit',
|
|
19
|
-
];
|
|
20
|
-
export const toJournalEntrySortKey = (v) => stringToUnion(v, JOURNAL_ENTRY_SORT_KEYS);
|
|
21
|
-
export const journalEntryDefaultSortConfig = {
|
|
22
|
-
sortKey: 'description',
|
|
23
|
-
sortOrder: 'ascending',
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Sums the `amount.amount` field of every line and returns an `Amount`
|
|
27
|
-
* whose currencyCode/currencySymbol are taken from the first line.
|
|
28
|
-
* Returns `undefined` for an empty list.
|
|
29
|
-
*
|
|
30
|
-
* Mirrors legacy `calculateTotal` in
|
|
31
|
-
* `web-components/src/components/transactionDetail/items/TransactionLinesJournalEntry.tsx`
|
|
32
|
-
* but without the `Object.assign` ceremony and with stable currency carry-over.
|
|
33
|
-
*/
|
|
34
|
-
export const sumJournalEntryAmounts = (lines) => {
|
|
35
|
-
if (lines.length === 0) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
const first = lines[0].amount;
|
|
39
|
-
let total = 0;
|
|
40
|
-
for (const line of lines) {
|
|
41
|
-
total += line.amount?.amount ?? 0;
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
amount: total,
|
|
45
|
-
currencyCode: first?.currencyCode ?? '',
|
|
46
|
-
currencySymbol: first?.currencySymbol ?? '',
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Splits `lines` by `postingType` into debit/credit totals.
|
|
51
|
-
*
|
|
52
|
-
* Fixes the operator-precedence bug from legacy
|
|
53
|
-
* `calculateCombinedTotalAmount` where
|
|
54
|
-
* `totalAmount?.amount ?? 0 + (...) + (...)` parses as
|
|
55
|
-
* `totalAmount?.amount ?? (0 + ... + ...)` so the `(...)`'s only get
|
|
56
|
-
* added when `totalAmount` is nullish. The new implementation just sums
|
|
57
|
-
* every debit (or credit) line including the un/miscategorized ones in
|
|
58
|
-
* one pass, so the result is always the true sum.
|
|
59
|
-
*/
|
|
60
|
-
export const journalEntryTotalsByPostingSide = (lines) => {
|
|
61
|
-
const debitLines = [];
|
|
62
|
-
const creditLines = [];
|
|
63
|
-
for (const line of lines) {
|
|
64
|
-
if (line.postingType === 'debit') {
|
|
65
|
-
debitLines.push(line);
|
|
66
|
-
}
|
|
67
|
-
else if (line.postingType === 'credit') {
|
|
68
|
-
creditLines.push(line);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
debitTotal: sumJournalEntryAmounts(debitLines),
|
|
73
|
-
creditTotal: sumJournalEntryAmounts(creditLines),
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
// ---------------------------------------------------------------------------
|
|
77
|
-
// Filter
|
|
78
|
-
// ---------------------------------------------------------------------------
|
|
79
|
-
/**
|
|
80
|
-
* Drops `linked_transaction_line` entries — equivalent to legacy
|
|
81
|
-
* `filterOutLinkedTransactionLine` in `transactionDetail.helpers.ts`.
|
|
82
|
-
*/
|
|
83
|
-
export const filterJournalEntryLinesExcludingLinked = (lines) => lines?.filter((line) => line.type !== 'linked_transaction_line') ?? [];
|
|
84
|
-
const sortOrderToLodash = (sortOrder) => sortOrder === 'descending' ? 'desc' : 'asc';
|
|
85
|
-
/**
|
|
86
|
-
* Stable, accessor-driven sort over arbitrary line shapes. Lines that
|
|
87
|
-
* resolve to the same key value preserve their original relative order
|
|
88
|
-
* thanks to lodash's stable `orderBy`.
|
|
89
|
-
*
|
|
90
|
-
* Strings are lower-cased before comparison so the order is predictable
|
|
91
|
-
* across mixed-case data. Numbers (debit/credit) compare directly.
|
|
92
|
-
*/
|
|
93
|
-
export const sortJournalEntryLines = (lines, config, accessors) => {
|
|
94
|
-
const accessor = (line) => {
|
|
95
|
-
switch (config.sortKey) {
|
|
96
|
-
case 'description':
|
|
97
|
-
return accessors.description(line).toLowerCase();
|
|
98
|
-
case 'name':
|
|
99
|
-
return accessors.name(line).toLowerCase();
|
|
100
|
-
case 'category':
|
|
101
|
-
return accessors.category(line).toLowerCase();
|
|
102
|
-
case 'class':
|
|
103
|
-
return accessors.class(line).toLowerCase();
|
|
104
|
-
case 'debit':
|
|
105
|
-
return accessors.debit(line);
|
|
106
|
-
case 'credit':
|
|
107
|
-
return accessors.credit(line);
|
|
108
|
-
default:
|
|
109
|
-
return accessors.description(line).toLowerCase();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
return orderBy([...lines], [accessor], [sortOrderToLodash(config.sortOrder)]);
|
|
113
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Amount } from '../../commonStateTypes/amount';
|
|
2
|
-
import { SortOrder } from '../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
3
|
-
import { JournalEntryTransactionLine, Line, TransactionLineBase } from '../../entity/transaction/stateTypes/transactionLine';
|
|
4
|
-
/**
|
|
5
|
-
* View-model helpers for the new Journal Entry table view (see
|
|
6
|
-
* web-components `journalEntryTable`). Keeps presentation-agnostic
|
|
7
|
-
* logic — totals, sort, line-filter — colocated in epic-state so it
|
|
8
|
-
* is testable and reusable.
|
|
9
|
-
*/
|
|
10
|
-
export declare const JOURNAL_ENTRY_SORT_KEYS: readonly ["description", "name", "category", "class", "debit", "credit"];
|
|
11
|
-
export declare const toJournalEntrySortKey: (v: string) => "name" | "description" | "category" | "class" | "credit" | "debit";
|
|
12
|
-
export type JournalEntrySortKey = ReturnType<typeof toJournalEntrySortKey>;
|
|
13
|
-
export interface JournalEntryRowSortConfig {
|
|
14
|
-
sortKey: JournalEntrySortKey;
|
|
15
|
-
sortOrder: SortOrder;
|
|
16
|
-
}
|
|
17
|
-
export declare const journalEntryDefaultSortConfig: JournalEntryRowSortConfig;
|
|
18
|
-
type AmountBearer = Pick<TransactionLineBase, 'amount'>;
|
|
19
|
-
/**
|
|
20
|
-
* Sums the `amount.amount` field of every line and returns an `Amount`
|
|
21
|
-
* whose currencyCode/currencySymbol are taken from the first line.
|
|
22
|
-
* Returns `undefined` for an empty list.
|
|
23
|
-
*
|
|
24
|
-
* Mirrors legacy `calculateTotal` in
|
|
25
|
-
* `web-components/src/components/transactionDetail/items/TransactionLinesJournalEntry.tsx`
|
|
26
|
-
* but without the `Object.assign` ceremony and with stable currency carry-over.
|
|
27
|
-
*/
|
|
28
|
-
export declare const sumJournalEntryAmounts: (lines: ReadonlyArray<AmountBearer>) => Amount | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Splits `lines` by `postingType` into debit/credit totals.
|
|
31
|
-
*
|
|
32
|
-
* Fixes the operator-precedence bug from legacy
|
|
33
|
-
* `calculateCombinedTotalAmount` where
|
|
34
|
-
* `totalAmount?.amount ?? 0 + (...) + (...)` parses as
|
|
35
|
-
* `totalAmount?.amount ?? (0 + ... + ...)` so the `(...)`'s only get
|
|
36
|
-
* added when `totalAmount` is nullish. The new implementation just sums
|
|
37
|
-
* every debit (or credit) line including the un/miscategorized ones in
|
|
38
|
-
* one pass, so the result is always the true sum.
|
|
39
|
-
*/
|
|
40
|
-
export declare const journalEntryTotalsByPostingSide: (lines: ReadonlyArray<Pick<JournalEntryTransactionLine, "amount" | "postingType">>) => {
|
|
41
|
-
creditTotal?: Amount;
|
|
42
|
-
debitTotal?: Amount;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Drops `linked_transaction_line` entries — equivalent to legacy
|
|
46
|
-
* `filterOutLinkedTransactionLine` in `transactionDetail.helpers.ts`.
|
|
47
|
-
*/
|
|
48
|
-
export declare const filterJournalEntryLinesExcludingLinked: <T extends Pick<Line, "type">>(lines?: ReadonlyArray<T>) => T[];
|
|
49
|
-
/**
|
|
50
|
-
* Accessor functions resolve the sort value for each column from a
|
|
51
|
-
* line. The new table reads display-formatted values from the form
|
|
52
|
-
* (selected option label, entity name, etc.), so callers pass in
|
|
53
|
-
* accessors that match their `LineInfo` shape rather than baking the
|
|
54
|
-
* column-to-form-field mapping into epic-state.
|
|
55
|
-
*/
|
|
56
|
-
export interface JournalEntrySortAccessors<T> {
|
|
57
|
-
category: (line: T) => string;
|
|
58
|
-
class: (line: T) => string;
|
|
59
|
-
credit: (line: T) => number;
|
|
60
|
-
debit: (line: T) => number;
|
|
61
|
-
description: (line: T) => string;
|
|
62
|
-
name: (line: T) => string;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Stable, accessor-driven sort over arbitrary line shapes. Lines that
|
|
66
|
-
* resolve to the same key value preserve their original relative order
|
|
67
|
-
* thanks to lodash's stable `orderBy`.
|
|
68
|
-
*
|
|
69
|
-
* Strings are lower-cased before comparison so the order is predictable
|
|
70
|
-
* across mixed-case data. Numbers (debit/credit) compare directly.
|
|
71
|
-
*/
|
|
72
|
-
export declare const sortJournalEntryLines: <T>(lines: ReadonlyArray<T>, config: JournalEntryRowSortConfig, accessors: JournalEntrySortAccessors<T>) => T[];
|
|
73
|
-
export {};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sortJournalEntryLines = exports.filterJournalEntryLinesExcludingLinked = exports.journalEntryTotalsByPostingSide = exports.sumJournalEntryAmounts = exports.journalEntryDefaultSortConfig = exports.toJournalEntrySortKey = exports.JOURNAL_ENTRY_SORT_KEYS = void 0;
|
|
7
|
-
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
8
|
-
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
9
|
-
/**
|
|
10
|
-
* View-model helpers for the new Journal Entry table view (see
|
|
11
|
-
* web-components `journalEntryTable`). Keeps presentation-agnostic
|
|
12
|
-
* logic — totals, sort, line-filter — colocated in epic-state so it
|
|
13
|
-
* is testable and reusable.
|
|
14
|
-
*/
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Sort keys
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
exports.JOURNAL_ENTRY_SORT_KEYS = [
|
|
19
|
-
'description',
|
|
20
|
-
'name',
|
|
21
|
-
'category',
|
|
22
|
-
'class',
|
|
23
|
-
'debit',
|
|
24
|
-
'credit',
|
|
25
|
-
];
|
|
26
|
-
const toJournalEntrySortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.JOURNAL_ENTRY_SORT_KEYS);
|
|
27
|
-
exports.toJournalEntrySortKey = toJournalEntrySortKey;
|
|
28
|
-
exports.journalEntryDefaultSortConfig = {
|
|
29
|
-
sortKey: 'description',
|
|
30
|
-
sortOrder: 'ascending',
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Sums the `amount.amount` field of every line and returns an `Amount`
|
|
34
|
-
* whose currencyCode/currencySymbol are taken from the first line.
|
|
35
|
-
* Returns `undefined` for an empty list.
|
|
36
|
-
*
|
|
37
|
-
* Mirrors legacy `calculateTotal` in
|
|
38
|
-
* `web-components/src/components/transactionDetail/items/TransactionLinesJournalEntry.tsx`
|
|
39
|
-
* but without the `Object.assign` ceremony and with stable currency carry-over.
|
|
40
|
-
*/
|
|
41
|
-
const sumJournalEntryAmounts = (lines) => {
|
|
42
|
-
if (lines.length === 0) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
const first = lines[0].amount;
|
|
46
|
-
let total = 0;
|
|
47
|
-
for (const line of lines) {
|
|
48
|
-
total += line.amount?.amount ?? 0;
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
amount: total,
|
|
52
|
-
currencyCode: first?.currencyCode ?? '',
|
|
53
|
-
currencySymbol: first?.currencySymbol ?? '',
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.sumJournalEntryAmounts = sumJournalEntryAmounts;
|
|
57
|
-
/**
|
|
58
|
-
* Splits `lines` by `postingType` into debit/credit totals.
|
|
59
|
-
*
|
|
60
|
-
* Fixes the operator-precedence bug from legacy
|
|
61
|
-
* `calculateCombinedTotalAmount` where
|
|
62
|
-
* `totalAmount?.amount ?? 0 + (...) + (...)` parses as
|
|
63
|
-
* `totalAmount?.amount ?? (0 + ... + ...)` so the `(...)`'s only get
|
|
64
|
-
* added when `totalAmount` is nullish. The new implementation just sums
|
|
65
|
-
* every debit (or credit) line including the un/miscategorized ones in
|
|
66
|
-
* one pass, so the result is always the true sum.
|
|
67
|
-
*/
|
|
68
|
-
const journalEntryTotalsByPostingSide = (lines) => {
|
|
69
|
-
const debitLines = [];
|
|
70
|
-
const creditLines = [];
|
|
71
|
-
for (const line of lines) {
|
|
72
|
-
if (line.postingType === 'debit') {
|
|
73
|
-
debitLines.push(line);
|
|
74
|
-
}
|
|
75
|
-
else if (line.postingType === 'credit') {
|
|
76
|
-
creditLines.push(line);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
debitTotal: (0, exports.sumJournalEntryAmounts)(debitLines),
|
|
81
|
-
creditTotal: (0, exports.sumJournalEntryAmounts)(creditLines),
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
exports.journalEntryTotalsByPostingSide = journalEntryTotalsByPostingSide;
|
|
85
|
-
// ---------------------------------------------------------------------------
|
|
86
|
-
// Filter
|
|
87
|
-
// ---------------------------------------------------------------------------
|
|
88
|
-
/**
|
|
89
|
-
* Drops `linked_transaction_line` entries — equivalent to legacy
|
|
90
|
-
* `filterOutLinkedTransactionLine` in `transactionDetail.helpers.ts`.
|
|
91
|
-
*/
|
|
92
|
-
const filterJournalEntryLinesExcludingLinked = (lines) => lines?.filter((line) => line.type !== 'linked_transaction_line') ?? [];
|
|
93
|
-
exports.filterJournalEntryLinesExcludingLinked = filterJournalEntryLinesExcludingLinked;
|
|
94
|
-
const sortOrderToLodash = (sortOrder) => sortOrder === 'descending' ? 'desc' : 'asc';
|
|
95
|
-
/**
|
|
96
|
-
* Stable, accessor-driven sort over arbitrary line shapes. Lines that
|
|
97
|
-
* resolve to the same key value preserve their original relative order
|
|
98
|
-
* thanks to lodash's stable `orderBy`.
|
|
99
|
-
*
|
|
100
|
-
* Strings are lower-cased before comparison so the order is predictable
|
|
101
|
-
* across mixed-case data. Numbers (debit/credit) compare directly.
|
|
102
|
-
*/
|
|
103
|
-
const sortJournalEntryLines = (lines, config, accessors) => {
|
|
104
|
-
const accessor = (line) => {
|
|
105
|
-
switch (config.sortKey) {
|
|
106
|
-
case 'description':
|
|
107
|
-
return accessors.description(line).toLowerCase();
|
|
108
|
-
case 'name':
|
|
109
|
-
return accessors.name(line).toLowerCase();
|
|
110
|
-
case 'category':
|
|
111
|
-
return accessors.category(line).toLowerCase();
|
|
112
|
-
case 'class':
|
|
113
|
-
return accessors.class(line).toLowerCase();
|
|
114
|
-
case 'debit':
|
|
115
|
-
return accessors.debit(line);
|
|
116
|
-
case 'credit':
|
|
117
|
-
return accessors.credit(line);
|
|
118
|
-
default:
|
|
119
|
-
return accessors.description(line).toLowerCase();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return (0, orderBy_1.default)([...lines], [accessor], [sortOrderToLodash(config.sortOrder)]);
|
|
123
|
-
};
|
|
124
|
-
exports.sortJournalEntryLines = sortJournalEntryLines;
|