@zeniai/client-epic-state 5.1.86 → 5.1.88-betaRD0
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/entity/aiCfo/aiCfoPayload.d.ts +7 -0
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +3 -2
- package/lib/entity/aiCfo/aiCfoReducer.js +25 -2
- package/lib/entity/aiCfo/aiCfoState.d.ts +9 -2
- package/lib/entity/customerSatisfaction/customerSatisfactionReducer.d.ts +1 -1
- package/lib/entity/customerSatisfaction/customerSatisfactionReducer.js +6 -2
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +2 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +34 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +68 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +24 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +10 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +28 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +41 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +12 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +40 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
- package/lib/epic.d.ts +6 -1
- package/lib/epic.js +8 -1
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +23 -1
- package/lib/esm/entity/customerSatisfaction/customerSatisfactionReducer.js +4 -1
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +68 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +24 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +26 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +34 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +8 -1
- package/lib/esm/index.js +14 -8
- package/lib/esm/view/companyHealthMetricView/companyHealthMetricConfigReducer.js +4 -1
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +34 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +81 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +21 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +73 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +187 -28
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +102 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +260 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +33 -9
- package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +35 -9
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +32 -5
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +23 -3
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +20 -3
- package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +60 -17
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/esm/view/invoicing/invoicingDunningCaseDetailView/fetchInvoicingDunningEmailPreviewEpic.js +26 -0
- package/lib/esm/view/invoicing/invoicingDunningCaseDetailView/fetchInvoicingDunningEmailPreviewPageEpic.js +16 -0
- package/lib/esm/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewPayload.js +9 -1
- package/lib/esm/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewReducer.js +50 -1
- package/lib/esm/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewSelector.js +14 -1
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +29 -10
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +28 -5
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +22 -14
- package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +46 -7
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +26 -8
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +41 -9
- package/lib/esm/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.js +4 -1
- package/lib/esm/view/vendorTabView/vendorTabViewReducer.js +4 -1
- package/lib/index.d.ts +23 -17
- package/lib/index.js +84 -50
- package/lib/view/companyHealthMetricView/companyHealthMetricConfigReducer.d.ts +1 -1
- package/lib/view/companyHealthMetricView/companyHealthMetricConfigReducer.js +5 -2
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +32 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +85 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +77 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +44 -2
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +49 -10
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +189 -28
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +40 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +34 -8
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +20 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +108 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +10 -1
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +266 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +79 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +2 -1
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +22 -8
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/view/invoicing/discountAction/discountActionEpic.d.ts +2 -1
- package/lib/view/invoicing/discountAction/discountActionEpic.js +32 -8
- package/lib/view/invoicing/dunningAction/dunningActionEpic.d.ts +2 -1
- package/lib/view/invoicing/dunningAction/dunningActionEpic.js +34 -8
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +31 -4
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +22 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +19 -2
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.d.ts +2 -1
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +59 -16
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +13 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +11 -31
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +15 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/fetchInvoicingDunningEmailPreviewEpic.d.ts +7 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/fetchInvoicingDunningEmailPreviewEpic.js +30 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/fetchInvoicingDunningEmailPreviewPageEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/fetchInvoicingDunningEmailPreviewPageEpic.js +20 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewEpics.d.ts +2 -2
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewPayload.d.ts +12 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewPayload.js +11 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewReducer.d.ts +21 -4
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewReducer.js +51 -2
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewSelector.d.ts +3 -0
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewSelector.js +16 -2
- package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewState.d.ts +13 -0
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.d.ts +2 -1
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +28 -9
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +27 -4
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.d.ts +24 -7
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +23 -16
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.d.ts +2 -1
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +45 -6
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +2 -1
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +25 -7
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +10 -1
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +4 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.d.ts +2 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +40 -8
- package/lib/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.d.ts +1 -1
- package/lib/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.js +5 -2
- package/lib/view/vendorTabView/vendorTabViewReducer.d.ts +1 -1
- package/lib/view/vendorTabView/vendorTabViewReducer.js +5 -2
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
2
|
+
import { DEFAULT_DATE_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
3
|
+
import { MONTH_YEAR_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
4
|
+
import { LAST_SCHEDULE_DAY_OF_MONTH } from '../../../commonStateTypes/timePeriod';
|
|
5
|
+
import { getPostingDateAndStatusForIndex } from '../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper';
|
|
6
|
+
import { mapScheduleTransactionToBaseScheduleTransactionPayload, } from '../../scheduleView/scheduleDetailView/scheduleDetailPayload';
|
|
7
|
+
const getNewScheduleMemo = (vendorName, schedulePostingDate, currentPeriod, totalPeriod, assetId) => {
|
|
8
|
+
const addAsset = assetId != null && assetId !== '' ? ` - ${assetId}` : '';
|
|
9
|
+
return `${vendorName} - ${schedulePostingDate.format(MONTH_YEAR_FORMAT)} (${currentPeriod} of ${totalPeriod})${addAsset}`;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Computes the month-by-month JE schedule breakdown for a brand-new schedule
|
|
13
|
+
* (no linked transaction yet) — replicates createNewSchedulesHelper's math
|
|
14
|
+
* (scheduleDetailLocalDataHelper.ts) exactly: lump-sum total split evenly
|
|
15
|
+
* across months with the rounding remainder absorbed by the last month, and a
|
|
16
|
+
* running balance that decrements each month and is forced to exactly 0 on
|
|
17
|
+
* the last row.
|
|
18
|
+
*/
|
|
19
|
+
export const computeNewScheduleJeDetails = (localData, totalAmount, vendorName) => {
|
|
20
|
+
const period = localData.selectedMonths;
|
|
21
|
+
const startingMonth = localData.selectedDate;
|
|
22
|
+
if (startingMonth == null || period == null) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const assetId = 'assetId' in localData ? localData.assetId : undefined;
|
|
26
|
+
const averageAmount = Math.abs(Math.round((totalAmount.amount / period) * 100) / 100);
|
|
27
|
+
const lastMonthAmount = Math.abs(Math.round((Math.abs(totalAmount.amount) - averageAmount * (period - 1)) * 100) / 100);
|
|
28
|
+
let runningBalance = Math.abs(totalAmount.amount);
|
|
29
|
+
const negativeNumbers = totalAmount.amount < 0 || runningBalance < 0;
|
|
30
|
+
const newJeDetails = [];
|
|
31
|
+
for (let index = 0; index < period; index++) {
|
|
32
|
+
if (runningBalance > averageAmount) {
|
|
33
|
+
runningBalance = Math.round((runningBalance - averageAmount) * 100) / 100;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
runningBalance = 0;
|
|
37
|
+
}
|
|
38
|
+
const amount = index === period - 1 ? lastMonthAmount : averageAmount;
|
|
39
|
+
runningBalance = index === period - 1 ? 0 : runningBalance;
|
|
40
|
+
const schedulePostingDate = startingMonth.add(index, 'month');
|
|
41
|
+
const { postingDate, postingStatus } = getPostingDateAndStatusForIndex(schedulePostingDate.month(), schedulePostingDate.year(), localData.lastDayOfMonth === true
|
|
42
|
+
? undefined
|
|
43
|
+
: localData.selectedDayOfMonth);
|
|
44
|
+
newJeDetails.push({
|
|
45
|
+
postingDate,
|
|
46
|
+
amount: toAmount(negativeNumbers ? -amount : amount, totalAmount.currencyCode, totalAmount.currencySymbol),
|
|
47
|
+
runningBalance: toAmount(negativeNumbers ? -runningBalance : runningBalance, totalAmount.currencyCode, totalAmount.currencySymbol),
|
|
48
|
+
postingStatus,
|
|
49
|
+
memo: getNewScheduleMemo(vendorName, schedulePostingDate, index + 1, period, assetId),
|
|
50
|
+
jeLink: { type: 'unknown' },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return newJeDetails;
|
|
54
|
+
};
|
|
55
|
+
const mapNewJeDetailsToScheduledJournalEntryPayload = (jeScheduleDetails) => jeScheduleDetails.map((journalEntry) => ({
|
|
56
|
+
status: {
|
|
57
|
+
code: journalEntry.postingStatus,
|
|
58
|
+
label: journalEntry.postingStatus,
|
|
59
|
+
},
|
|
60
|
+
transaction_memo: journalEntry.memo,
|
|
61
|
+
third_party_id: journalEntry.jeLink.thirdPartyTransactionId ?? null,
|
|
62
|
+
expected_post_date: journalEntry.postingDate.format(DEFAULT_DATE_FORMAT),
|
|
63
|
+
amount: journalEntry.amount.amount,
|
|
64
|
+
balance: journalEntry.runningBalance.amount,
|
|
65
|
+
// Brand-new schedule — there is no prior scheduled-journal-entry history
|
|
66
|
+
// to cross-reference (unlike the legacy edit flow's equivalent mapper).
|
|
67
|
+
scheduled_journal_entry_id: null,
|
|
68
|
+
actual_post_date: null,
|
|
69
|
+
is_platform_generated: null,
|
|
70
|
+
je_schedule_id: null,
|
|
71
|
+
update_time: null,
|
|
72
|
+
create_time: null,
|
|
73
|
+
}));
|
|
74
|
+
/**
|
|
75
|
+
* Builds a savable schedule payload directly from a Base Transaction search
|
|
76
|
+
* result and the New Schedule form's local data — bypassing the legacy
|
|
77
|
+
* getJEScheduledTransactionByJEScheduleTransactionKey selector entirely,
|
|
78
|
+
* since that selector throws unless the entity has already round-tripped
|
|
79
|
+
* through a real GET /1.0/schedules/:id. A brand-new schedule has no such
|
|
80
|
+
* history, so this reads only from data already in hand (the selected
|
|
81
|
+
* transaction/line plus what the user filled into the form).
|
|
82
|
+
*/
|
|
83
|
+
export const prepareNewSchedulePayload = (transaction, localData, scheduleType) => {
|
|
84
|
+
if (transaction.thirdPartyTransactionId == null ||
|
|
85
|
+
transaction.thirdPartyTransactionId === '') {
|
|
86
|
+
return { ok: false, reason: 'missing_third_party_id' };
|
|
87
|
+
}
|
|
88
|
+
const scheduleTransaction = transaction;
|
|
89
|
+
const vendorId = localData.selectedVendor?.id ?? transaction.vendorId ?? '';
|
|
90
|
+
const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
|
|
91
|
+
if (vendorId === '' || vendorName === '') {
|
|
92
|
+
return { ok: false, reason: 'missing_vendor' };
|
|
93
|
+
}
|
|
94
|
+
const vendor = {
|
|
95
|
+
vendor_id: vendorId,
|
|
96
|
+
vendor_name: vendorName,
|
|
97
|
+
};
|
|
98
|
+
const jeScheduleDetails = computeNewScheduleJeDetails(localData, scheduleTransaction.amount, vendorName);
|
|
99
|
+
const postingDate = localData.selectedDayOfMonth ??
|
|
100
|
+
(localData.lastDayOfMonth === true ? LAST_SCHEDULE_DAY_OF_MONTH : null);
|
|
101
|
+
const firstJEScheduleDate = jeScheduleDetails.length > 0
|
|
102
|
+
? jeScheduleDetails[0].postingDate.format(DEFAULT_DATE_FORMAT)
|
|
103
|
+
: null;
|
|
104
|
+
const lastJEScheduleDate = jeScheduleDetails.length > 0
|
|
105
|
+
? jeScheduleDetails[jeScheduleDetails.length - 1].postingDate.format(DEFAULT_DATE_FORMAT)
|
|
106
|
+
: null;
|
|
107
|
+
const isFixedAssets = scheduleType === 'fixed_assets';
|
|
108
|
+
const assetId = 'assetId' in localData ? localData.assetId : undefined;
|
|
109
|
+
const selectedAccumulatedDepreciationCategory = 'selectedAccumulatedDepreciationCategory' in localData
|
|
110
|
+
? localData.selectedAccumulatedDepreciationCategory
|
|
111
|
+
: undefined;
|
|
112
|
+
const status = { code: 'new', label: 'New' };
|
|
113
|
+
const jeSchedulePayload = {
|
|
114
|
+
status,
|
|
115
|
+
vendor,
|
|
116
|
+
currency_code: scheduleTransaction.currency.currencyCode,
|
|
117
|
+
currency_symbol: scheduleTransaction.currency.currencySymbol,
|
|
118
|
+
period: localData.selectedMonths ?? null,
|
|
119
|
+
je_schedule_type: scheduleType,
|
|
120
|
+
posting_date: postingDate,
|
|
121
|
+
balance: scheduleTransaction.amount.amount,
|
|
122
|
+
start_date: firstJEScheduleDate,
|
|
123
|
+
end_date: lastJEScheduleDate,
|
|
124
|
+
je_credit_accounting_class_id: scheduleTransaction.classBase?.classId ?? null,
|
|
125
|
+
je_credit_account_id: isFixedAssets
|
|
126
|
+
? (selectedAccumulatedDepreciationCategory ?? null)
|
|
127
|
+
: scheduleTransaction.account.accountId,
|
|
128
|
+
je_debit_account_id: localData.selectedAccount ?? null,
|
|
129
|
+
je_debit_accounting_class_id: localData.selectedClass ?? null,
|
|
130
|
+
other_attributes: assetId != null ? { asset_id: assetId } : {},
|
|
131
|
+
base_transaction: mapScheduleTransactionToBaseScheduleTransactionPayload(scheduleTransaction),
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
ok: true,
|
|
135
|
+
payload: {
|
|
136
|
+
je_schedules: [jeSchedulePayload],
|
|
137
|
+
scheduled_journal_entries: mapNewJeDetailsToScheduledJournalEntryPayload(jeScheduleDetails),
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
};
|
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import { DEFAULT_DATE_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
2
|
+
import { getClassList } from '../../classList/classListSelector';
|
|
2
3
|
import { mapScheduleTransactionToBaseScheduleTransactionPayload, mapVendorToVendorPayload, } from '../../scheduleView/scheduleDetailView/scheduleDetailPayload';
|
|
4
|
+
const BALANCE_SHEET_CLASS_LABEL = 'balance_sheet';
|
|
5
|
+
const SERVICE_MONTH_FORMAT = 'YYYY-MM';
|
|
6
|
+
/**
|
|
7
|
+
* The credit line is the accrued liability, which always sits on the balance sheet — the
|
|
8
|
+
* recurring accrued path resolves the same class the same way (see
|
|
9
|
+
* prepareNewScheduleAccruedDetailPayload). Omitted rather than sent empty when the tenant has
|
|
10
|
+
* no balance_sheet class, since the API treats the field as optional.
|
|
11
|
+
*/
|
|
12
|
+
export const prepareCreateOneTimeAccrualPayload = (state, localData) => {
|
|
13
|
+
const { classListState, classState } = state;
|
|
14
|
+
const balanceSheetClass = getClassList(classState, classListState).classes.find((accountingClass) => accountingClass.labels?.includes(BALANCE_SHEET_CLASS_LABEL) === true);
|
|
15
|
+
// reverse_next_month alone decides reversal_policy server-side, so reversal_policy is
|
|
16
|
+
// deliberately not sent — the API documents it only as an alternate way to say on_bill_match,
|
|
17
|
+
// and sending both would be two sources of truth for one toggle.
|
|
18
|
+
const reversalFields = localData.reverseNextMonth
|
|
19
|
+
? {
|
|
20
|
+
reverse_next_month: true,
|
|
21
|
+
expected_reversal_date: getExpectedReversalDate(localData.serviceMonth).format(DEFAULT_DATE_FORMAT),
|
|
22
|
+
}
|
|
23
|
+
: { reverse_next_month: false };
|
|
24
|
+
return {
|
|
25
|
+
vendor_id: localData.vendorId,
|
|
26
|
+
vendor_name: localData.vendorName,
|
|
27
|
+
service_month: localData.serviceMonth.format(SERVICE_MONTH_FORMAT),
|
|
28
|
+
amount: localData.amount,
|
|
29
|
+
memo: localData.memo,
|
|
30
|
+
je_debit_account_id: localData.debitAccountId,
|
|
31
|
+
je_credit_account_id: localData.creditAccountId,
|
|
32
|
+
...(localData.debitAccountName != null
|
|
33
|
+
? { je_debit_account_name: localData.debitAccountName }
|
|
34
|
+
: {}),
|
|
35
|
+
...(localData.creditAccountName != null
|
|
36
|
+
? { je_credit_account_name: localData.creditAccountName }
|
|
37
|
+
: {}),
|
|
38
|
+
...(localData.debitClassId != null
|
|
39
|
+
? { je_debit_accounting_class_id: localData.debitClassId }
|
|
40
|
+
: {}),
|
|
41
|
+
...(localData.debitClassName != null
|
|
42
|
+
? { je_debit_accounting_class_name: localData.debitClassName }
|
|
43
|
+
: {}),
|
|
44
|
+
...(balanceSheetClass != null
|
|
45
|
+
? {
|
|
46
|
+
je_credit_accounting_class_id: balanceSheetClass.classId,
|
|
47
|
+
je_credit_accounting_class_name: balanceSheetClass.className,
|
|
48
|
+
}
|
|
49
|
+
: {}),
|
|
50
|
+
...reversalFields,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The API defaults this to the 1st of the month after service_month. We send it explicitly so the
|
|
55
|
+
* date the form promised the user is the date that gets stored.
|
|
56
|
+
*/
|
|
57
|
+
export const getExpectedReversalDate = (serviceMonth) => serviceMonth.add(1, 'month').startOf('month');
|
|
3
58
|
export const prepareIgnoreSchedulePayload = (scheduleType, jeScheduleTransaction, state) => {
|
|
4
59
|
const { vendorState } = state;
|
|
5
60
|
const { vendor, currencyCode, currencySymbol, baseTransaction, status, balanceAsOfToday, period, startDate, endDate, jeCredit, jeDebit, } = jeScheduleTransaction;
|
|
@@ -2,9 +2,16 @@ import { createSlice } from '@reduxjs/toolkit';
|
|
|
2
2
|
import { geNestedAccountIDHierarchyForReport } from '../../../commonStateTypes/accountView/getNestedAccountIDHierarchyForReport';
|
|
3
3
|
import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
4
4
|
import { mapAccountBasePayloadToAccountBase, mapAccountMetadataPayloadToAccountMetadata, } from '../../../entity/account/accountPayload';
|
|
5
|
-
import {
|
|
5
|
+
import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
|
|
6
|
+
import { getJEScheduleKey, getJEScheduleTransactionDetailKeyPayload, } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
6
7
|
import { clearAll } from '../../../rootActions';
|
|
7
8
|
import { mapAccountTypeRecommendationPayloadToAccountRecommendationByType, } from '../../accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload';
|
|
9
|
+
import { MIN_NEW_SCHEDULE_SEARCH_LENGTH, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
|
|
10
|
+
function removeKeyFromEveryTabSlot(keysByPeriodAndTab, keyToRemove) {
|
|
11
|
+
for (const periodTabKey of Object.keys(keysByPeriodAndTab)) {
|
|
12
|
+
keysByPeriodAndTab[periodTabKey] = keysByPeriodAndTab[periodTabKey].filter((jeScheduleKey) => jeScheduleKey !== keyToRemove);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
export const accountSettingsInitialState = {
|
|
9
16
|
localData: {
|
|
10
17
|
selectedPrepaidExpensesAccountIds: [],
|
|
@@ -36,16 +43,34 @@ export const accountSettingsInitialState = {
|
|
|
36
43
|
accruedExpensesNestedAccountListHierarchy: [],
|
|
37
44
|
accruedExpensesRecommendations: [],
|
|
38
45
|
};
|
|
46
|
+
export const getBaseNewScheduleLocalData = (scheduleType) => ({
|
|
47
|
+
scheduleType,
|
|
48
|
+
jeScheduleDetails: [],
|
|
49
|
+
});
|
|
50
|
+
export const newScheduleInitialState = {
|
|
51
|
+
fixed_assets: getBaseNewScheduleLocalData('fixed_assets'),
|
|
52
|
+
prepaid_expenses: getBaseNewScheduleLocalData('prepaid_expenses'),
|
|
53
|
+
};
|
|
54
|
+
export const searchTransactionsInitialState = {
|
|
55
|
+
searchResults: [],
|
|
56
|
+
fetchState: 'Not-Started',
|
|
57
|
+
error: undefined,
|
|
58
|
+
};
|
|
39
59
|
export const initialState = {
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
jeScheduleTransactionKeysByPeriodAndTab: {},
|
|
61
|
+
jeScheduleAccruedKeysByPeriodAndTab: {},
|
|
62
|
+
jeScheduleOneTimeAccrualKeysByPeriodAndTab: {},
|
|
63
|
+
failedJeScheduleTransactionKeysByPeriodAndTab: {},
|
|
42
64
|
postStatusById: {},
|
|
43
65
|
ignoreStatusById: {},
|
|
44
66
|
jeScheduleLocalDataById: {},
|
|
45
67
|
uiState: {
|
|
46
|
-
|
|
68
|
+
createdGroupCollapsed: false,
|
|
69
|
+
pendingGroupCollapsed: false,
|
|
47
70
|
scrollPosition: { scrollTop: 0, scrollLeft: undefined },
|
|
48
|
-
|
|
71
|
+
searchString: '',
|
|
72
|
+
selectedJETypeFilter: null,
|
|
73
|
+
selectedPageTab: 'schedules',
|
|
49
74
|
sortKey: 'transactionDate',
|
|
50
75
|
sortOrder: 'descending',
|
|
51
76
|
totalCount: 0,
|
|
@@ -56,6 +81,14 @@ export const initialState = {
|
|
|
56
81
|
error: undefined,
|
|
57
82
|
},
|
|
58
83
|
accountSettings: accountSettingsInitialState,
|
|
84
|
+
newSchedule: {
|
|
85
|
+
createOneTimeAccrualStatus: { fetchState: 'Not-Started', error: undefined },
|
|
86
|
+
newScheduleState: newScheduleInitialState,
|
|
87
|
+
saveStatus: { fetchState: 'Not-Started', error: undefined },
|
|
88
|
+
searchTransactions: searchTransactionsInitialState,
|
|
89
|
+
fetchState: 'Not-Started',
|
|
90
|
+
error: undefined,
|
|
91
|
+
},
|
|
59
92
|
fetchState: 'Not-Started',
|
|
60
93
|
error: undefined,
|
|
61
94
|
hasValidState() {
|
|
@@ -100,9 +133,12 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
100
133
|
},
|
|
101
134
|
},
|
|
102
135
|
fetchJeSchedulesSuccess(draft, action) {
|
|
103
|
-
const { jeSchedules, selectedPeriod, failedJeSchedules, refreshViewInBackground, } = action.payload;
|
|
136
|
+
const { jeSchedules, selectedPeriod, selectedPageTab, failedJeSchedules, accruedJeSchedules, oneTimeAccruals, refreshViewInBackground, } = action.payload;
|
|
137
|
+
const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
|
|
104
138
|
const jeScheduleTransactionKeys = jeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
|
|
105
139
|
const failedJeScheduleTransactionKeys = failedJeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
|
|
140
|
+
const jeScheduleAccruedKeys = accruedJeSchedules.map((schedule) => getJEScheduleKey(schedule));
|
|
141
|
+
const jeScheduleOneTimeAccrualKeys = oneTimeAccruals.map((accrual) => generateJEOneTimeAccrualKey(accrual._id));
|
|
106
142
|
if (refreshViewInBackground === true &&
|
|
107
143
|
draft.refreshStatus.fetchState === 'In-Progress') {
|
|
108
144
|
draft.refreshStatus = { fetchState: 'Completed', error: undefined };
|
|
@@ -111,19 +147,28 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
111
147
|
draft.fetchState = 'Completed';
|
|
112
148
|
draft.error = undefined;
|
|
113
149
|
}
|
|
114
|
-
draft.
|
|
115
|
-
|
|
150
|
+
draft.jeScheduleTransactionKeysByPeriodAndTab[periodTabKey] =
|
|
151
|
+
jeScheduleTransactionKeys;
|
|
152
|
+
draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] =
|
|
153
|
+
jeScheduleAccruedKeys;
|
|
154
|
+
draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] =
|
|
155
|
+
jeScheduleOneTimeAccrualKeys;
|
|
156
|
+
draft.failedJeScheduleTransactionKeysByPeriodAndTab[periodTabKey] =
|
|
157
|
+
failedJeScheduleTransactionKeys;
|
|
116
158
|
},
|
|
117
159
|
fetchJeSchedulesFailure(draft, action) {
|
|
118
|
-
const { status, selectedPeriod } = action.payload;
|
|
160
|
+
const { status, selectedPeriod, selectedPageTab } = action.payload;
|
|
161
|
+
const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
|
|
119
162
|
if (draft.refreshStatus.fetchState === 'In-Progress') {
|
|
120
163
|
draft.refreshStatus = { fetchState: 'Error', error: status };
|
|
121
164
|
}
|
|
122
165
|
else {
|
|
123
166
|
draft.fetchState = 'Error';
|
|
124
167
|
draft.error = status;
|
|
168
|
+
draft.jeScheduleTransactionKeysByPeriodAndTab[periodTabKey] = [];
|
|
169
|
+
draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] = [];
|
|
170
|
+
draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] = [];
|
|
125
171
|
}
|
|
126
|
-
draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = [];
|
|
127
172
|
},
|
|
128
173
|
retryJeSchedule(draft, action) {
|
|
129
174
|
const { scheduledJournalEntryID } = action.payload;
|
|
@@ -211,17 +256,18 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
211
256
|
};
|
|
212
257
|
},
|
|
213
258
|
updateJeScheduleTransactionKeys: {
|
|
214
|
-
prepare(jeScheduleKeys, selectedPeriod) {
|
|
259
|
+
prepare(jeScheduleKeys, selectedPeriod, selectedPageTab) {
|
|
215
260
|
return {
|
|
216
261
|
payload: {
|
|
217
262
|
jeScheduleKeys: jeScheduleKeys,
|
|
218
263
|
selectedPeriod: selectedPeriod,
|
|
264
|
+
selectedPageTab: selectedPageTab,
|
|
219
265
|
},
|
|
220
266
|
};
|
|
221
267
|
},
|
|
222
268
|
reducer(draft, action) {
|
|
223
|
-
const { selectedPeriod, jeScheduleKeys } = action.payload;
|
|
224
|
-
draft.
|
|
269
|
+
const { selectedPeriod, selectedPageTab, jeScheduleKeys } = action.payload;
|
|
270
|
+
draft.jeScheduleTransactionKeysByPeriodAndTab[getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod))] = jeScheduleKeys;
|
|
225
271
|
},
|
|
226
272
|
},
|
|
227
273
|
removeJeScheduleTransactionKey: {
|
|
@@ -234,12 +280,10 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
234
280
|
};
|
|
235
281
|
},
|
|
236
282
|
reducer(draft, action) {
|
|
237
|
-
const {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const filteredKeys = prevData.filter((jeKey) => jeKey !== jeScheduleKey);
|
|
242
|
-
draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = filteredKeys;
|
|
283
|
+
const { jeScheduleKey } = action.payload;
|
|
284
|
+
// Dropped from every tab's slot, not just the visible one: once a schedule is ignored or
|
|
285
|
+
// resolved it must not reappear when the user switches tabs and hits a cached list.
|
|
286
|
+
removeKeyFromEveryTabSlot(draft.jeScheduleTransactionKeysByPeriodAndTab, jeScheduleKey);
|
|
243
287
|
},
|
|
244
288
|
},
|
|
245
289
|
removeFailedJeScheduleTransactionKey: {
|
|
@@ -252,12 +296,8 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
252
296
|
};
|
|
253
297
|
},
|
|
254
298
|
reducer(draft, action) {
|
|
255
|
-
const {
|
|
256
|
-
|
|
257
|
-
...(draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] ?? []),
|
|
258
|
-
];
|
|
259
|
-
const filteredKeys = prevData.filter((jeKey) => jeKey !== failedJeScheduleKey);
|
|
260
|
-
draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = filteredKeys;
|
|
299
|
+
const { failedJeScheduleKey } = action.payload;
|
|
300
|
+
removeKeyFromEveryTabSlot(draft.failedJeScheduleTransactionKeysByPeriodAndTab, failedJeScheduleKey);
|
|
261
301
|
},
|
|
262
302
|
},
|
|
263
303
|
initializeJeScheduleLocalData: {
|
|
@@ -369,6 +409,114 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
369
409
|
clearJeAccountSettingsLocalData(draft) {
|
|
370
410
|
draft.accountSettings.localData = accountSettingsInitialState.localData;
|
|
371
411
|
},
|
|
412
|
+
initializeNewSchedule: {
|
|
413
|
+
prepare({ scheduleType, }) {
|
|
414
|
+
return { payload: { scheduleType } };
|
|
415
|
+
},
|
|
416
|
+
reducer() {
|
|
417
|
+
// Purely an epic-trigger action — the epic fans out the account/class
|
|
418
|
+
// list fetches plus resetNewScheduleLocalData.
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
resetNewScheduleLocalData: {
|
|
422
|
+
prepare({ scheduleType, }) {
|
|
423
|
+
return { payload: { scheduleType } };
|
|
424
|
+
},
|
|
425
|
+
reducer(draft, action) {
|
|
426
|
+
const { scheduleType } = action.payload;
|
|
427
|
+
draft.newSchedule.newScheduleState[scheduleType] =
|
|
428
|
+
getBaseNewScheduleLocalData(scheduleType);
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
updateNewScheduleLocalData(draft, action) {
|
|
432
|
+
const { scheduleType, localData } = action.payload;
|
|
433
|
+
draft.newSchedule.newScheduleState[scheduleType] = {
|
|
434
|
+
...draft.newSchedule.newScheduleState[scheduleType],
|
|
435
|
+
...localData,
|
|
436
|
+
};
|
|
437
|
+
},
|
|
438
|
+
searchTransactionsForNewSchedule: {
|
|
439
|
+
prepare({ query, scheduleType, }) {
|
|
440
|
+
return { payload: { query, scheduleType } };
|
|
441
|
+
},
|
|
442
|
+
reducer(draft, action) {
|
|
443
|
+
const trimmed = action.payload.query.trim();
|
|
444
|
+
// Cleared or too-short query: no API (see epic) — reset immediately.
|
|
445
|
+
if (trimmed.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
446
|
+
draft.newSchedule.searchTransactions = searchTransactionsInitialState;
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
draft.newSchedule.searchTransactions = {
|
|
450
|
+
...draft.newSchedule.searchTransactions,
|
|
451
|
+
searchString: action.payload.query,
|
|
452
|
+
fetchState: 'In-Progress',
|
|
453
|
+
};
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
searchTransactionsForNewScheduleSuccess(draft, action) {
|
|
457
|
+
draft.newSchedule.searchTransactions = {
|
|
458
|
+
...draft.newSchedule.searchTransactions,
|
|
459
|
+
searchResults: action.payload.searchResults,
|
|
460
|
+
fetchState: 'Completed',
|
|
461
|
+
error: undefined,
|
|
462
|
+
};
|
|
463
|
+
},
|
|
464
|
+
searchTransactionsForNewScheduleFailure(draft, action) {
|
|
465
|
+
draft.newSchedule.searchTransactions = {
|
|
466
|
+
...draft.newSchedule.searchTransactions,
|
|
467
|
+
fetchState: 'Error',
|
|
468
|
+
error: action.payload.status,
|
|
469
|
+
};
|
|
470
|
+
},
|
|
471
|
+
clearSearchTransactionsForNewSchedule(draft) {
|
|
472
|
+
draft.newSchedule.searchTransactions = searchTransactionsInitialState;
|
|
473
|
+
},
|
|
474
|
+
saveNewSchedule: {
|
|
475
|
+
prepare({ scheduleType, }) {
|
|
476
|
+
return { payload: { scheduleType } };
|
|
477
|
+
},
|
|
478
|
+
reducer(draft) {
|
|
479
|
+
draft.newSchedule.saveStatus = {
|
|
480
|
+
fetchState: 'In-Progress',
|
|
481
|
+
error: undefined,
|
|
482
|
+
};
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
saveNewScheduleSuccess(draft) {
|
|
486
|
+
draft.newSchedule.saveStatus = {
|
|
487
|
+
fetchState: 'Completed',
|
|
488
|
+
error: undefined,
|
|
489
|
+
};
|
|
490
|
+
},
|
|
491
|
+
saveNewScheduleFailure(draft, action) {
|
|
492
|
+
draft.newSchedule.saveStatus = {
|
|
493
|
+
fetchState: 'Error',
|
|
494
|
+
error: action.payload.status,
|
|
495
|
+
};
|
|
496
|
+
},
|
|
497
|
+
createOneTimeAccrual: {
|
|
498
|
+
prepare(localData) {
|
|
499
|
+
return { payload: { localData } };
|
|
500
|
+
},
|
|
501
|
+
reducer(draft) {
|
|
502
|
+
draft.newSchedule.createOneTimeAccrualStatus = {
|
|
503
|
+
fetchState: 'In-Progress',
|
|
504
|
+
error: undefined,
|
|
505
|
+
};
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
createOneTimeAccrualSuccess(draft) {
|
|
509
|
+
draft.newSchedule.createOneTimeAccrualStatus = {
|
|
510
|
+
fetchState: 'Completed',
|
|
511
|
+
error: undefined,
|
|
512
|
+
};
|
|
513
|
+
},
|
|
514
|
+
createOneTimeAccrualFailure(draft, action) {
|
|
515
|
+
draft.newSchedule.createOneTimeAccrualStatus = {
|
|
516
|
+
fetchState: 'Error',
|
|
517
|
+
error: action.payload.status,
|
|
518
|
+
};
|
|
519
|
+
},
|
|
372
520
|
updateJESchedulesUIState(draft, action) {
|
|
373
521
|
if (action.payload.sortKey != null) {
|
|
374
522
|
draft.uiState.sortKey = action.payload.sortKey;
|
|
@@ -382,10 +530,21 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
382
530
|
if (action.payload.scrollPosition != null) {
|
|
383
531
|
draft.uiState.scrollPosition = action.payload.scrollPosition;
|
|
384
532
|
}
|
|
385
|
-
if (action.payload.
|
|
386
|
-
draft.uiState.
|
|
533
|
+
if (action.payload.selectedPageTab != null) {
|
|
534
|
+
draft.uiState.selectedPageTab = action.payload.selectedPageTab;
|
|
387
535
|
}
|
|
388
536
|
},
|
|
537
|
+
updateJEScheduleTypeFilter(draft, action) {
|
|
538
|
+
draft.uiState.selectedJETypeFilter = action.payload;
|
|
539
|
+
},
|
|
540
|
+
toggleJEPendingGroupCollapsed(draft) {
|
|
541
|
+
draft.uiState.pendingGroupCollapsed =
|
|
542
|
+
!draft.uiState.pendingGroupCollapsed;
|
|
543
|
+
},
|
|
544
|
+
toggleJECreatedGroupCollapsed(draft) {
|
|
545
|
+
draft.uiState.createdGroupCollapsed =
|
|
546
|
+
!draft.uiState.createdGroupCollapsed;
|
|
547
|
+
},
|
|
389
548
|
clearExpenseAutomationJESchedulesView(draft) {
|
|
390
549
|
Object.assign(draft, initialState);
|
|
391
550
|
},
|
|
@@ -396,7 +555,7 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
396
555
|
});
|
|
397
556
|
},
|
|
398
557
|
});
|
|
399
|
-
export const { clearExpenseAutomationJESchedulesView, clearJeAccountSettingsLocalData, clearJeScheduleLocalData, fetchAccountSettingsListForAccountTypes, fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesPage, fetchJeSchedulesSuccess, fetchRecommendationForAccountSettings, ignoreRecommendedJeSchedule, ignoreRecommendedJeScheduleFailure, ignoreRecommendedJeScheduleSuccess, initializeAccountSettingsView, initializeJeScheduleLocalData, removeFailedJeScheduleTransactionKey, removeJeScheduleLocalDataById, removeJeScheduleTransactionKey, retryJeSchedule, retryJeScheduleFailure, retryJeScheduleSuccess, saveAccountSettings, saveAccountSettingsFailure, saveAccountSettingsLocalData, saveAccountSettingsSuccess, updateAccountSettingsListForAccountTypes, updateAccountSettingsListForAccountTypesFailure, updateJESchedulesUIState, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, updateRecommendationForAccountSettings, updateRecommendationForAccountSettingsFailure, } = expenseAutomationJESchedulesView.actions;
|
|
558
|
+
export const { clearExpenseAutomationJESchedulesView, clearJeAccountSettingsLocalData, clearJeScheduleLocalData, clearSearchTransactionsForNewSchedule, createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchAccountSettingsListForAccountTypes, fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesPage, fetchJeSchedulesSuccess, fetchRecommendationForAccountSettings, ignoreRecommendedJeSchedule, ignoreRecommendedJeScheduleFailure, ignoreRecommendedJeScheduleSuccess, initializeAccountSettingsView, initializeJeScheduleLocalData, initializeNewSchedule, removeFailedJeScheduleTransactionKey, removeJeScheduleLocalDataById, removeJeScheduleTransactionKey, resetNewScheduleLocalData, retryJeSchedule, retryJeScheduleFailure, retryJeScheduleSuccess, saveAccountSettings, saveAccountSettingsFailure, saveAccountSettingsLocalData, saveAccountSettingsSuccess, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, toggleJECreatedGroupCollapsed, toggleJEPendingGroupCollapsed, updateAccountSettingsListForAccountTypes, updateAccountSettingsListForAccountTypesFailure, updateJESchedulesUIState, updateJEScheduleTypeFilter, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, updateNewScheduleLocalData, updateRecommendationForAccountSettings, updateRecommendationForAccountSettingsFailure, } = expenseAutomationJESchedulesView.actions;
|
|
400
559
|
export default expenseAutomationJESchedulesView.reducer;
|
|
401
560
|
const doUpdateRecommendationForAccountSettings = (draft, payload) => {
|
|
402
561
|
const { prepaidExpensesRecommendations, fixedAssetsRecommendations, accruedExpensesRecommendations, } = mapAccountTypeRecommendationPayloadToAccountRecommendationByType(payload);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { getAccountIdsForLabels, getAccountIdsForTypes, } from '../../../entity/account/accountSelector';
|
|
2
|
+
import { getScheduleTransactionById } from '../../../entity/transaction/transactionSelector';
|
|
3
|
+
import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, } from '../../accountList/accountListSelector';
|
|
4
|
+
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
5
|
+
import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper';
|
|
6
|
+
import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
|
|
7
|
+
import { getAccountLabelForScheduleType, getAccountsTypesForScheduleEpics, } from '../../scheduleView/scheduleListView/scheduleListHelper';
|
|
8
|
+
/**
|
|
9
|
+
* The Base Transaction search is shared across schedule types (one search
|
|
10
|
+
* box, not one per prepaid_expenses/fixed_assets) — split out from
|
|
11
|
+
* getNewScheduleView so a consumer can read it without supplying an
|
|
12
|
+
* otherwise-irrelevant scheduleType.
|
|
13
|
+
*/
|
|
14
|
+
export const getNewScheduleSearchTransactionsView = (state) => {
|
|
15
|
+
const { searchTransactions } = state.expenseAutomationJESchedulesViewState.newSchedule;
|
|
16
|
+
const searchTransactionsResults = searchTransactions.searchResults
|
|
17
|
+
.map((key) => getScheduleTransactionById(state.transactionState, key))
|
|
18
|
+
.filter((transaction) => transaction != null);
|
|
19
|
+
return {
|
|
20
|
+
searchTransactionsResults,
|
|
21
|
+
searchTransactionsFetchState: {
|
|
22
|
+
fetchState: searchTransactions.fetchState,
|
|
23
|
+
error: searchTransactions.error,
|
|
24
|
+
},
|
|
25
|
+
searchTransactionsString: searchTransactions.searchString,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const ACCRUED_EXPENSE_ACCOUNT_LABELS = ['accrued_expenses'];
|
|
29
|
+
/**
|
|
30
|
+
* Account + class options for the one-time accrual creation form.
|
|
31
|
+
*
|
|
32
|
+
* getAccountsTypesForScheduleDetails('accrued_expenses') deliberately includes
|
|
33
|
+
* other_current_liabilities, because the accrued liability accounts live there —
|
|
34
|
+
* so the debit list has to subtract them back out, and the credit list keeps only
|
|
35
|
+
* them. Mirrors getScheduleAccruedDetailView, which is the form this one is
|
|
36
|
+
* modelled on.
|
|
37
|
+
*/
|
|
38
|
+
export const getNewOneTimeAccrualView = (state) => {
|
|
39
|
+
const { accountState, accountListState, classState, classListState } = state;
|
|
40
|
+
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
41
|
+
const accountType = getAccountsTypesForScheduleEpics();
|
|
42
|
+
const accrualAccountIds = getAccountIdsForTypes(accountState, getAccountsTypesForScheduleDetails('accrued_expenses'));
|
|
43
|
+
const accruedCategoryIds = getAccountIdsForLabels(accountState, ACCRUED_EXPENSE_ACCOUNT_LABELS);
|
|
44
|
+
const allAccountList = getAccountList(accountState, accountListState, accountType.accountListKey);
|
|
45
|
+
const nestedAccountHierarchy = getNestedAccountListHierarchy(accountListState, accountType.accountListKey);
|
|
46
|
+
const debitAccounts = allAccountList.accounts.filter((account) => accrualAccountIds.includes(account.accountId) &&
|
|
47
|
+
!accruedCategoryIds.includes(account.accountId));
|
|
48
|
+
const creditAccounts = allAccountList.accounts.filter((account) => accruedCategoryIds.includes(account.accountId));
|
|
49
|
+
const allClassList = getClassList(classState, classListState);
|
|
50
|
+
return {
|
|
51
|
+
accountListNestedAccountHierarchy: filterNestedAccountHierarchyById(nestedAccountHierarchy, debitAccounts.map((account) => account.accountId)),
|
|
52
|
+
accruedAccountListNestedAccountHierarchy: filterNestedAccountHierarchyById(nestedAccountHierarchy, creditAccounts.map((account) => account.accountId)),
|
|
53
|
+
allAccountList: debitAccounts,
|
|
54
|
+
allAccruedExpenseList: creditAccounts,
|
|
55
|
+
allClassList: allClassList.classes,
|
|
56
|
+
classListNestedAccountHierarchy: getNestedClassListHierarchy(classListState),
|
|
57
|
+
createStatus: newSchedule.createOneTimeAccrualStatus,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export const getNewScheduleView = (state, scheduleType) => {
|
|
61
|
+
const { accountState, accountListState, classState, classListState } = state;
|
|
62
|
+
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
63
|
+
const searchTransactionsView = getNewScheduleSearchTransactionsView(state);
|
|
64
|
+
const accountType = getAccountsTypesForScheduleEpics();
|
|
65
|
+
const newScheduleAccountTypes = getAccountsTypesForScheduleDetails(scheduleType);
|
|
66
|
+
const newScheduleAccountIds = getAccountIdsForTypes(accountState, newScheduleAccountTypes);
|
|
67
|
+
const allAccountList = getAccountList(accountState, accountListState, accountType.accountListKey);
|
|
68
|
+
const filteredAccounts = allAccountList.accounts.filter((account) => newScheduleAccountIds.includes(account.accountId));
|
|
69
|
+
const accountListNestedAccountHierarchy = filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), filteredAccounts.map((account) => account.accountId));
|
|
70
|
+
const allClassList = getClassList(classState, classListState);
|
|
71
|
+
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
72
|
+
let allDepreciationAccountList;
|
|
73
|
+
let allDepreciationAccountListNestedAccountHierarchy;
|
|
74
|
+
if (scheduleType === 'fixed_assets') {
|
|
75
|
+
const depreciationCategoryIds = getAccountIdsForTypes(accountState, [
|
|
76
|
+
'fixed_assets',
|
|
77
|
+
'other_assets',
|
|
78
|
+
]);
|
|
79
|
+
const accountLabel = getAccountLabelForScheduleType('fixed_assets');
|
|
80
|
+
const fixedAssetLabelAccountIds = accountLabel != null
|
|
81
|
+
? getAccountIdsForLabel(accountListState, accountType.accountListKey, accountLabel)
|
|
82
|
+
: [];
|
|
83
|
+
allDepreciationAccountList = allAccountList.accounts.filter((account) => depreciationCategoryIds.includes(account.accountId) &&
|
|
84
|
+
!fixedAssetLabelAccountIds.includes(account.accountId));
|
|
85
|
+
allDepreciationAccountListNestedAccountHierarchy =
|
|
86
|
+
filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), allDepreciationAccountList.map((account) => account.accountId));
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
scheduleType,
|
|
90
|
+
accountListNestedAccountHierarchy,
|
|
91
|
+
allAccountList: filteredAccounts,
|
|
92
|
+
allClassList: allClassList.classes,
|
|
93
|
+
allDepreciationAccountList,
|
|
94
|
+
allDepreciationAccountListNestedAccountHierarchy,
|
|
95
|
+
classListNestedAccountHierarchy,
|
|
96
|
+
newScheduleLocalData: newSchedule.newScheduleState[scheduleType],
|
|
97
|
+
saveStatus: newSchedule.saveStatus,
|
|
98
|
+
...searchTransactionsView,
|
|
99
|
+
fetchState: newSchedule.fetchState,
|
|
100
|
+
error: newSchedule.error,
|
|
101
|
+
};
|
|
102
|
+
};
|