@zeniai/client-epic-state 5.1.80 → 5.1.81-betaAK1
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/viewAndReport/reportIDHelper.d.ts +1 -0
- package/lib/commonStateTypes/viewAndReport/reportIDHelper.js +13 -1
- package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +3 -0
- package/lib/entity/account/accountState.d.ts +1 -1
- package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
- package/lib/entity/class/classReducer.d.ts +4 -4
- package/lib/entity/class/classState.d.ts +1 -1
- package/lib/entity/forecast/forecastState.d.ts +1 -1
- package/lib/entity/invoicing/invoicingCommonPayload.d.ts +42 -0
- package/lib/entity/invoicing/invoicingCommonPayload.js +66 -1
- package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
- package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +21 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +5 -1
- package/lib/entity/tenant/clearAllEpic.js +8 -0
- package/lib/epic.d.ts +9 -1
- package/lib/epic.js +14 -1
- package/lib/esm/commonStateTypes/viewAndReport/reportIDHelper.js +11 -0
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +3 -0
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +61 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +21 -0
- package/lib/esm/entity/tenant/clearAllEpic.js +8 -0
- package/lib/esm/epic.js +14 -1
- package/lib/esm/index.js +19 -4
- package/lib/esm/reducer.js +12 -0
- package/lib/esm/view/dashboard/dashboardSelector.js +14 -10
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +4 -18
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +6 -1
- package/lib/esm/view/invoicing/createCreditNote/createCreditNotePayload.js +1 -8
- 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 +4 -5
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +10 -11
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +8 -10
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +2 -2
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +43 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +2 -5
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +1 -2
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +7 -1
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +3 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +25 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +15 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.js +15 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.js +15 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.js +1 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +26 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +18 -0
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewPayload.js +47 -0
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewReducer.js +128 -0
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +20 -0
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewState.js +1 -0
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNotePayload.js +4 -11
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +9 -12
- package/lib/esm/view/invoicing/recordPayment/recordPaymentFormConfig.js +0 -1
- package/lib/esm/view/invoicing/recordPayment/recordPaymentPayload.js +5 -14
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +26 -8
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/esm/view/netBurnOrIncomeProjectView/netBurnOrIncomeForTimeframeProjectViewEpic.js +45 -0
- package/lib/esm/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewEpic.js +30 -0
- package/lib/esm/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewPayload.js +1 -0
- package/lib/esm/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewReducer.js +111 -0
- package/lib/esm/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewSelector.js +65 -0
- package/lib/esm/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewSelectorTypes.js +1 -0
- package/lib/esm/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewState.js +1 -0
- package/lib/esm/view/opExProjectView/opExForTimeframeProjectViewEpic.js +43 -0
- package/lib/esm/view/opExProjectView/opExProjectViewEpic.js +30 -0
- package/lib/esm/view/opExProjectView/opExProjectViewPayload.js +1 -0
- package/lib/esm/view/opExProjectView/opExProjectViewReducer.js +111 -0
- package/lib/esm/view/opExProjectView/opExProjectViewSelector.js +52 -0
- package/lib/esm/view/opExProjectView/opExProjectViewSelectorTypes.js +1 -0
- package/lib/esm/view/opExProjectView/opExProjectViewState.js +1 -0
- package/lib/esm/view/reportsResync/reportsClassViewRefetchingEpic.js +0 -4
- package/lib/esm/view/reportsResync/reportsProjectViewRefetchingEpic.js +30 -0
- package/lib/esm/view/reportsResync/reportsResyncEpic.js +11 -3
- package/lib/esm/view/reportsResync/reportsResyncReducer.js +9 -1
- package/lib/esm/view/revenueProjectView/revenueForTimeframeProjectViewEpic.js +35 -0
- package/lib/esm/view/revenueProjectView/revenueProjectViewEpic.js +30 -0
- package/lib/esm/view/revenueProjectView/revenueProjectViewPayload.js +1 -0
- package/lib/esm/view/revenueProjectView/revenueProjectViewReducer.js +111 -0
- package/lib/esm/view/revenueProjectView/revenueProjectViewSelector.js +58 -0
- package/lib/esm/view/revenueProjectView/revenueProjectViewSelectorTypes.js +1 -0
- package/lib/esm/view/revenueProjectView/revenueProjectViewState.js +1 -0
- package/lib/index.d.ts +29 -5
- package/lib/index.js +106 -51
- package/lib/reducer.d.ts +12 -0
- package/lib/reducer.js +12 -0
- package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
- package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
- package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
- package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
- package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
- package/lib/view/dashboard/dashboardSelector.d.ts +2 -3
- package/lib/view/dashboard/dashboardSelector.js +13 -9
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +3 -17
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +6 -1
- package/lib/view/invoicing/createCreditNote/createCreditNotePayload.js +1 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteState.d.ts +3 -1
- 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 +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +4 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +10 -11
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +10 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +8 -10
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +2 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -3
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +2 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts +9 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +45 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +2 -5
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +1 -2
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +4 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +6 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +4 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +3 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +4 -1
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +29 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +19 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.js +19 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.js +19 -0
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.d.ts +2 -0
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.js +2 -0
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +30 -0
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +22 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewPayload.d.ts +79 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewPayload.js +52 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewReducer.d.ts +25 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewReducer.js +132 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +21 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +24 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewState.d.ts +14 -0
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewState.js +2 -0
- package/lib/view/invoicing/issueCreditNote/issueCreditNotePayload.js +4 -11
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.d.ts +15 -7
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +11 -15
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteState.d.ts +3 -2
- package/lib/view/invoicing/recordPayment/recordPaymentFormConfig.js +0 -1
- package/lib/view/invoicing/recordPayment/recordPaymentPayload.js +5 -14
- package/lib/view/invoicing/recordPayment/recordPaymentState.d.ts +4 -2
- 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/netBurnOrIncomeProjectView/netBurnOrIncomeForTimeframeProjectViewEpic.d.ts +9 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeForTimeframeProjectViewEpic.js +49 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewEpic.d.ts +6 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewEpic.js +34 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewPayload.d.ts +11 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewPayload.js +2 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewReducer.d.ts +33 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewReducer.js +115 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewSelector.d.ts +13 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewSelector.js +69 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewSelectorTypes.d.ts +21 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewSelectorTypes.js +2 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewState.d.ts +20 -0
- package/lib/view/netBurnOrIncomeProjectView/netBurnOrIncomeProjectViewState.js +2 -0
- package/lib/view/opExProjectView/opExForTimeframeProjectViewEpic.d.ts +9 -0
- package/lib/view/opExProjectView/opExForTimeframeProjectViewEpic.js +47 -0
- package/lib/view/opExProjectView/opExProjectViewEpic.d.ts +6 -0
- package/lib/view/opExProjectView/opExProjectViewEpic.js +34 -0
- package/lib/view/opExProjectView/opExProjectViewPayload.d.ts +6 -0
- package/lib/view/opExProjectView/opExProjectViewPayload.js +2 -0
- package/lib/view/opExProjectView/opExProjectViewReducer.d.ts +33 -0
- package/lib/view/opExProjectView/opExProjectViewReducer.js +115 -0
- package/lib/view/opExProjectView/opExProjectViewSelector.d.ts +12 -0
- package/lib/view/opExProjectView/opExProjectViewSelector.js +56 -0
- package/lib/view/opExProjectView/opExProjectViewSelectorTypes.d.ts +19 -0
- package/lib/view/opExProjectView/opExProjectViewSelectorTypes.js +2 -0
- package/lib/view/opExProjectView/opExProjectViewState.d.ts +20 -0
- package/lib/view/opExProjectView/opExProjectViewState.js +2 -0
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsClassViewRefetchingEpic.d.ts +1 -2
- package/lib/view/reportsResync/reportsClassViewRefetchingEpic.js +0 -4
- package/lib/view/reportsResync/reportsProjectViewRefetchingEpic.d.ts +10 -0
- package/lib/view/reportsResync/reportsProjectViewRefetchingEpic.js +34 -0
- package/lib/view/reportsResync/reportsResyncEpic.d.ts +2 -2
- package/lib/view/reportsResync/reportsResyncEpic.js +10 -2
- package/lib/view/reportsResync/reportsResyncReducer.d.ts +5 -3
- package/lib/view/reportsResync/reportsResyncReducer.js +10 -2
- package/lib/view/revenueProjectView/revenueForTimeframeProjectViewEpic.d.ts +9 -0
- package/lib/view/revenueProjectView/revenueForTimeframeProjectViewEpic.js +39 -0
- package/lib/view/revenueProjectView/revenueProjectViewEpic.d.ts +6 -0
- package/lib/view/revenueProjectView/revenueProjectViewEpic.js +34 -0
- package/lib/view/revenueProjectView/revenueProjectViewPayload.d.ts +9 -0
- package/lib/view/revenueProjectView/revenueProjectViewPayload.js +2 -0
- package/lib/view/revenueProjectView/revenueProjectViewReducer.d.ts +33 -0
- package/lib/view/revenueProjectView/revenueProjectViewReducer.js +115 -0
- package/lib/view/revenueProjectView/revenueProjectViewSelector.d.ts +12 -0
- package/lib/view/revenueProjectView/revenueProjectViewSelector.js +62 -0
- package/lib/view/revenueProjectView/revenueProjectViewSelectorTypes.d.ts +19 -0
- package/lib/view/revenueProjectView/revenueProjectViewSelectorTypes.js +2 -0
- package/lib/view/revenueProjectView/revenueProjectViewState.d.ts +20 -0
- package/lib/view/revenueProjectView/revenueProjectViewState.js +2 -0
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/package.json +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/invoicingCouponFormConfig.js +0 -44
- package/lib/view/invoicing/editInvoicingCouponDetailView/invoicingCouponFormConfig.d.ts +0 -5
- package/lib/view/invoicing/editInvoicingCouponDetailView/invoicingCouponFormConfig.js +0 -48
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
export const initialState = {
|
|
3
|
+
accountsByAccountTypes: {},
|
|
4
|
+
accountsFetchStateByAccountTypes: {},
|
|
5
|
+
backfillFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
6
|
+
classes: [],
|
|
7
|
+
classesFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
8
|
+
connection: undefined,
|
|
9
|
+
connectionFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
10
|
+
retryFetchStateByTaskId: {},
|
|
11
|
+
syncHealth: undefined,
|
|
12
|
+
syncHealthFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
13
|
+
};
|
|
14
|
+
const invoicingQboView = createSlice({
|
|
15
|
+
name: 'invoicingQboView',
|
|
16
|
+
initialState,
|
|
17
|
+
reducers: {
|
|
18
|
+
fetchInvoicingQboConnection(draft) {
|
|
19
|
+
draft.connectionFetchState = {
|
|
20
|
+
fetchState: 'In-Progress',
|
|
21
|
+
error: undefined,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
updateInvoicingQboConnection(draft, action) {
|
|
25
|
+
draft.connection = action.payload;
|
|
26
|
+
draft.connectionFetchState = { fetchState: 'Completed', error: undefined };
|
|
27
|
+
},
|
|
28
|
+
updateInvoicingQboConnectionFailure(draft, action) {
|
|
29
|
+
draft.connectionFetchState = { fetchState: 'Error', error: action.payload };
|
|
30
|
+
},
|
|
31
|
+
fetchInvoicingQboAccounts: {
|
|
32
|
+
reducer(draft, action) {
|
|
33
|
+
draft.accountsFetchStateByAccountTypes[action.payload.accountTypes] = {
|
|
34
|
+
fetchState: 'In-Progress',
|
|
35
|
+
error: undefined,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
prepare(accountTypes) {
|
|
39
|
+
return { payload: { accountTypes } };
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
updateInvoicingQboAccounts(draft, action) {
|
|
43
|
+
draft.accountsByAccountTypes[action.payload.accountTypes] =
|
|
44
|
+
action.payload.accounts;
|
|
45
|
+
draft.accountsFetchStateByAccountTypes[action.payload.accountTypes] = {
|
|
46
|
+
fetchState: 'Completed',
|
|
47
|
+
error: undefined,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
updateInvoicingQboAccountsFailure(draft, action) {
|
|
51
|
+
draft.accountsFetchStateByAccountTypes[action.payload.accountTypes] = {
|
|
52
|
+
fetchState: 'Error',
|
|
53
|
+
error: action.payload.status,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
fetchInvoicingQboClasses(draft) {
|
|
57
|
+
draft.classesFetchState = { fetchState: 'In-Progress', error: undefined };
|
|
58
|
+
},
|
|
59
|
+
updateInvoicingQboClasses(draft, action) {
|
|
60
|
+
draft.classes = action.payload;
|
|
61
|
+
draft.classesFetchState = { fetchState: 'Completed', error: undefined };
|
|
62
|
+
},
|
|
63
|
+
updateInvoicingQboClassesFailure(draft, action) {
|
|
64
|
+
draft.classesFetchState = { fetchState: 'Error', error: action.payload };
|
|
65
|
+
},
|
|
66
|
+
fetchInvoicingQboSyncHealth(draft) {
|
|
67
|
+
draft.syncHealthFetchState = {
|
|
68
|
+
fetchState: 'In-Progress',
|
|
69
|
+
error: undefined,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
updateInvoicingQboSyncHealth(draft, action) {
|
|
73
|
+
draft.syncHealth = action.payload;
|
|
74
|
+
draft.syncHealthFetchState = { fetchState: 'Completed', error: undefined };
|
|
75
|
+
},
|
|
76
|
+
updateInvoicingQboSyncHealthFailure(draft, action) {
|
|
77
|
+
draft.syncHealthFetchState = {
|
|
78
|
+
fetchState: 'Error',
|
|
79
|
+
error: action.payload,
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
retryInvoicingQboSyncTask: {
|
|
83
|
+
reducer(draft, action) {
|
|
84
|
+
draft.retryFetchStateByTaskId[action.payload.taskId] = {
|
|
85
|
+
fetchState: 'In-Progress',
|
|
86
|
+
error: undefined,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
prepare(taskId) {
|
|
90
|
+
return { payload: { taskId } };
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
retryInvoicingQboSyncTaskSuccess(draft, action) {
|
|
94
|
+
draft.retryFetchStateByTaskId[action.payload.taskId] = {
|
|
95
|
+
fetchState: 'Completed',
|
|
96
|
+
error: undefined,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
retryInvoicingQboSyncTaskFailure(draft, action) {
|
|
100
|
+
draft.retryFetchStateByTaskId[action.payload.taskId] = {
|
|
101
|
+
fetchState: 'Error',
|
|
102
|
+
error: action.payload.status,
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
startInvoicingQboBackfill: {
|
|
106
|
+
reducer(draft) {
|
|
107
|
+
draft.backfillFetchState = {
|
|
108
|
+
fetchState: 'In-Progress',
|
|
109
|
+
error: undefined,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
prepare(startDate) {
|
|
113
|
+
return { payload: { startDate } };
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
startInvoicingQboBackfillSuccess(draft) {
|
|
117
|
+
draft.backfillFetchState = { fetchState: 'Completed', error: undefined };
|
|
118
|
+
},
|
|
119
|
+
startInvoicingQboBackfillFailure(draft, action) {
|
|
120
|
+
draft.backfillFetchState = { fetchState: 'Error', error: action.payload };
|
|
121
|
+
},
|
|
122
|
+
clearInvoicingQboView(draft) {
|
|
123
|
+
Object.assign(draft, initialState);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
export const { fetchInvoicingQboConnection, updateInvoicingQboConnection, updateInvoicingQboConnectionFailure, fetchInvoicingQboAccounts, updateInvoicingQboAccounts, updateInvoicingQboAccountsFailure, fetchInvoicingQboClasses, updateInvoicingQboClasses, updateInvoicingQboClassesFailure, fetchInvoicingQboSyncHealth, updateInvoicingQboSyncHealth, updateInvoicingQboSyncHealthFailure, retryInvoicingQboSyncTask, retryInvoicingQboSyncTaskSuccess, retryInvoicingQboSyncTaskFailure, startInvoicingQboBackfill, startInvoicingQboBackfillSuccess, startInvoicingQboBackfillFailure, clearInvoicingQboView, } = invoicingQboView.actions;
|
|
128
|
+
export default invoicingQboView.reducer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single bundled view for the QBO integration settings screen — the
|
|
3
|
+
* connection, per-account-types account options, classes, sync health, and the
|
|
4
|
+
* fetch/action states for each of them.
|
|
5
|
+
*/
|
|
6
|
+
export const getInvoicingQboView = (state) => {
|
|
7
|
+
const qboState = state.invoicingQboViewState;
|
|
8
|
+
return {
|
|
9
|
+
accountsByAccountTypes: qboState.accountsByAccountTypes,
|
|
10
|
+
accountsFetchStateByAccountTypes: qboState.accountsFetchStateByAccountTypes,
|
|
11
|
+
backfillState: qboState.backfillFetchState,
|
|
12
|
+
classes: qboState.classes,
|
|
13
|
+
classesFetchState: qboState.classesFetchState,
|
|
14
|
+
connection: qboState.connection,
|
|
15
|
+
connectionFetchState: qboState.connectionFetchState,
|
|
16
|
+
retryFetchStateByTaskId: qboState.retryFetchStateByTaskId,
|
|
17
|
+
syncHealth: qboState.syncHealth,
|
|
18
|
+
syncHealthFetchState: qboState.syncHealthFetchState,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
const dollarsFromAmountString = (value) => {
|
|
2
|
-
const parsed = Number.parseFloat(value);
|
|
3
|
-
if (Number.isNaN(parsed)) {
|
|
4
|
-
return 0;
|
|
5
|
-
}
|
|
6
|
-
return parsed;
|
|
7
|
-
};
|
|
8
1
|
export const computeIssueCreditNoteTotal = (lineItems) => lineItems
|
|
9
2
|
.filter((lineItem) => lineItem.selected)
|
|
10
3
|
.reduce((total, lineItem) => {
|
|
11
4
|
const quantity = Number.parseFloat(lineItem.quantity);
|
|
12
|
-
const unitAmount =
|
|
5
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
13
6
|
if (Number.isNaN(quantity) || quantity <= 0 || unitAmount <= 0) {
|
|
14
7
|
return total;
|
|
15
8
|
}
|
|
@@ -20,7 +13,7 @@ export const localDataToIssueCreditNotePayload = (localData) => {
|
|
|
20
13
|
.filter((lineItem) => lineItem.selected)
|
|
21
14
|
.map((lineItem) => {
|
|
22
15
|
const quantity = Math.round(Number.parseFloat(lineItem.quantity));
|
|
23
|
-
const unitAmount =
|
|
16
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
24
17
|
return {
|
|
25
18
|
description: lineItem.description,
|
|
26
19
|
quantity,
|
|
@@ -43,9 +36,9 @@ export const initializeIssueCreditNoteDraftFromInvoice = (invoice) => ({
|
|
|
43
36
|
description: lineItem.description,
|
|
44
37
|
id: lineItem.id,
|
|
45
38
|
maxQuantity: lineItem.quantity,
|
|
46
|
-
maxUnitAmount: lineItem.unitAmount
|
|
39
|
+
maxUnitAmount: lineItem.unitAmount,
|
|
47
40
|
quantity: String(lineItem.quantity),
|
|
48
41
|
selected: true,
|
|
49
|
-
unitAmount: lineItem.unitAmount
|
|
42
|
+
unitAmount: lineItem.unitAmount,
|
|
50
43
|
})),
|
|
51
44
|
});
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
+
import { getInvoiceDetail } from '../invoiceDetail/invoiceDetailSelector';
|
|
1
2
|
import { INVOICING_CREDIT_NOTE_REASON_CODES } from './issueCreditNoteFormConfig';
|
|
2
|
-
export const getIssueCreditNoteView = (state) => {
|
|
3
|
-
const
|
|
3
|
+
export const getIssueCreditNoteView = (state, invoiceId) => {
|
|
4
|
+
const invoiceView = getInvoiceDetail(state, invoiceId);
|
|
5
|
+
const { draft, error, fetchState, issuedCreditNoteId } = state.invoicingIssueCreditNoteState;
|
|
4
6
|
return {
|
|
5
|
-
|
|
6
|
-
fetchState,
|
|
7
|
+
invoice: invoiceView.invoice,
|
|
8
|
+
isPageReady: invoiceView.fetchState === 'Completed' && draft.lineItems.length > 0,
|
|
7
9
|
issuedCreditNoteId,
|
|
8
|
-
version: 1.0,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export const getIssueCreditNoteFormView = (state) => {
|
|
12
|
-
const { draft, error, fetchState } = state.invoicingIssueCreditNoteState;
|
|
13
|
-
return {
|
|
14
10
|
localData: draft,
|
|
15
11
|
reasonCodeValues: [...INVOICING_CREDIT_NOTE_REASON_CODES],
|
|
16
|
-
error,
|
|
17
|
-
|
|
12
|
+
submitState: { error, fetchState },
|
|
13
|
+
error: invoiceView.error,
|
|
14
|
+
fetchState: invoiceView.fetchState,
|
|
18
15
|
version: 1.0,
|
|
19
16
|
};
|
|
20
17
|
};
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { dateNow } from '../../../zeniDayJS';
|
|
2
3
|
import { initialRecordPaymentFormLocalData } from './recordPaymentFormConfig';
|
|
3
4
|
const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
|
|
4
|
-
const
|
|
5
|
-
const parsed = Number.parseFloat(value);
|
|
6
|
-
if (Number.isNaN(parsed)) {
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
return parsed;
|
|
10
|
-
};
|
|
11
|
-
const amountDueDollarsFromInvoice = (invoice) => {
|
|
12
|
-
const amountDue = invoice.amountDue?.amount ?? 0;
|
|
13
|
-
return amountDue.toFixed(2);
|
|
14
|
-
};
|
|
5
|
+
const amountDueFromInvoice = (invoice) => invoice.amountDue ?? toAmount(0, 'USD', '$');
|
|
15
6
|
/**
|
|
16
7
|
* Build the invoice-scoped Record Payment body from the form draft. Amount stays
|
|
17
8
|
* in dollars for the invoice endpoint.
|
|
@@ -21,7 +12,7 @@ export const localDataToInvoiceRecordPaymentBody = (localData) => {
|
|
|
21
12
|
const date = localData.date.trim();
|
|
22
13
|
const referenceNumber = trimOrUndefined(localData.referenceNumber);
|
|
23
14
|
return {
|
|
24
|
-
amount:
|
|
15
|
+
amount: localData.amount?.amount ?? 0,
|
|
25
16
|
payment_method: localData.paymentMethod,
|
|
26
17
|
...(gateway != null ? { gateway } : {}),
|
|
27
18
|
...(date !== '' ? { date } : {}),
|
|
@@ -34,7 +25,7 @@ export const localDataToInvoiceRecordPaymentBody = (localData) => {
|
|
|
34
25
|
* and the linked invoice into `linked_invoices`. Currency is locked to USD.
|
|
35
26
|
*/
|
|
36
27
|
export const localDataToRecordPaymentPayload = (localData) => {
|
|
37
|
-
const amount =
|
|
28
|
+
const amount = localData.amount?.amount ?? 0;
|
|
38
29
|
const gateway = trimOrUndefined(localData.gateway);
|
|
39
30
|
const date = localData.date.trim();
|
|
40
31
|
const transactionId = trimOrUndefined(localData.transactionId);
|
|
@@ -60,7 +51,7 @@ export const localDataToRecordPaymentPayload = (localData) => {
|
|
|
60
51
|
};
|
|
61
52
|
export const initializeRecordPaymentDraftFromInvoice = (invoice) => ({
|
|
62
53
|
...initialRecordPaymentFormLocalData,
|
|
63
|
-
amount:
|
|
54
|
+
amount: amountDueFromInvoice(invoice),
|
|
64
55
|
customerId: invoice.customerID,
|
|
65
56
|
date: dateNow().format('YYYY-MM-DD'),
|
|
66
57
|
invoiceToLink: invoice.id,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
1
|
+
import { from, of } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
|
+
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
4
5
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
5
6
|
import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection, } from './settingsViewReducer';
|
|
6
7
|
export const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchInvoicingSettings.match), switchMap(() => {
|
|
@@ -57,15 +58,32 @@ export const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => act
|
|
|
57
58
|
}));
|
|
58
59
|
export const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveInvoicingSettings.match), mergeMap((action) => {
|
|
59
60
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
61
|
+
const { settings, snackbarSection } = action.payload;
|
|
62
|
+
const snackbar = (messageText) => snackbarSection == null
|
|
63
|
+
? []
|
|
64
|
+
: [
|
|
65
|
+
openSnackbar({
|
|
66
|
+
messageSection: snackbarSection,
|
|
67
|
+
messageText,
|
|
68
|
+
type: messageText === 'success' ? 'success' : 'error',
|
|
69
|
+
}),
|
|
70
|
+
];
|
|
60
71
|
return zeniAPI
|
|
61
|
-
.putAndGetJSON(apiUrl, {
|
|
62
|
-
...action.payload,
|
|
63
|
-
})
|
|
72
|
+
.putAndGetJSON(apiUrl, { ...settings })
|
|
64
73
|
.pipe(switchMap((response) => {
|
|
65
74
|
if (isSuccessResponse(response) && response.data != null) {
|
|
66
|
-
return
|
|
75
|
+
return from([
|
|
76
|
+
saveInvoicingSettingsSuccess(response.data),
|
|
77
|
+
...snackbar('success'),
|
|
78
|
+
]);
|
|
67
79
|
}
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
return from([
|
|
81
|
+
saveInvoicingSettingsFailure(response.status),
|
|
82
|
+
...snackbar('failed'),
|
|
83
|
+
]);
|
|
84
|
+
}), catchError((error) => from([
|
|
85
|
+
saveInvoicingSettingsFailure(createZeniAPIStatus('Unexpected Error', 'Save settings REST API call errored out ' +
|
|
86
|
+
JSON.stringify(error))),
|
|
87
|
+
...snackbar('failed'),
|
|
88
|
+
])));
|
|
71
89
|
}));
|
|
@@ -29,7 +29,7 @@ const settingsView = createSlice({
|
|
|
29
29
|
saveInvoicingSettings(draft, action) {
|
|
30
30
|
draft.saveFetchState = { fetchState: 'In-Progress', error: undefined };
|
|
31
31
|
if (draft.settings != null) {
|
|
32
|
-
draft.settings = { ...draft.settings, ...action.payload };
|
|
32
|
+
draft.settings = { ...draft.settings, ...action.payload.settings };
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
saveInvoicingSettingsSuccess(draft, action) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { from, of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { updateProjects } from '../../entity/project/projectReducer';
|
|
4
|
+
import { updateSectionProjectView } from '../../entity/sectionProjectView/sectionProjectViewReducer';
|
|
5
|
+
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
6
|
+
import { fetchNetBurnOrIncomeForTimeframeProjectView, updateNetBurnOrIncomeForTimeframeProjectView, updateNetBurnOrIncomeForTimeframeProjectViewFailure, } from './netBurnOrIncomeProjectViewReducer';
|
|
7
|
+
export const fetchNetBurnOrIncomeForTimeframeProjectViewEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(fetchNetBurnOrIncomeForTimeframeProjectView.match), mergeMap((action) => {
|
|
8
|
+
const getTimeSeriesGroup = (timeframe) => {
|
|
9
|
+
switch (timeframe) {
|
|
10
|
+
case 'month':
|
|
11
|
+
return 'months';
|
|
12
|
+
case 'quarter':
|
|
13
|
+
return 'quarters';
|
|
14
|
+
case 'year':
|
|
15
|
+
return 'years';
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const queryValue = {
|
|
19
|
+
is_full_response: action.payload.fetchFullReport,
|
|
20
|
+
time_series_groups: [getTimeSeriesGroup(action.payload.timeframe)],
|
|
21
|
+
is_group_by_project: true,
|
|
22
|
+
};
|
|
23
|
+
return zeniAPI
|
|
24
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/net_burn_or_income?query=${encodeURIComponent(JSON.stringify(queryValue))}`)
|
|
25
|
+
.pipe(mergeMap((response) => {
|
|
26
|
+
if (response.data != null && isSuccessResponse(response)) {
|
|
27
|
+
const actions = [];
|
|
28
|
+
const report = response.data.report;
|
|
29
|
+
const currency = report.currency;
|
|
30
|
+
actions.push(updateProjects(report.projects));
|
|
31
|
+
actions.push(updateSectionProjectView(action.payload.timeframe, 'cogs', 'net_burn_or_income_by_projects', report.cogs, report.accounts, currency));
|
|
32
|
+
actions.push(updateSectionProjectView(action.payload.timeframe, 'expenses', 'net_burn_or_income_by_projects', report.expenses, report.accounts, currency));
|
|
33
|
+
actions.push(updateSectionProjectView(action.payload.timeframe, 'income', 'net_burn_or_income_by_projects', report.income, report.accounts, currency));
|
|
34
|
+
actions.push(updateNetBurnOrIncomeForTimeframeProjectView({
|
|
35
|
+
timeframe: action.payload.timeframe,
|
|
36
|
+
report: response.data,
|
|
37
|
+
}));
|
|
38
|
+
return from(actions);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return of(updateNetBurnOrIncomeForTimeframeProjectViewFailure(response.status, action.payload.timeframe));
|
|
42
|
+
}
|
|
43
|
+
}), catchError((error) => of(updateNetBurnOrIncomeForTimeframeProjectViewFailure(createZeniAPIStatus('Unexpected Error', 'Net Burn by Projects REST API call errored out' +
|
|
44
|
+
(error instanceof Error ? error.message : String(error))), action.payload.timeframe))));
|
|
45
|
+
}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { filter, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchNetBurnOrIncomeForTimeframeProjectView, fetchNetBurnOrIncomeProjectView, } from './netBurnOrIncomeProjectViewReducer';
|
|
4
|
+
export const fetchNetBurnOrIncomeProjectViewEpic = (actions$, state) => actions$.pipe(filter(fetchNetBurnOrIncomeProjectView.match), switchMap((action) => {
|
|
5
|
+
const { cacheOverride } = action.payload;
|
|
6
|
+
if (cacheOverride === true) {
|
|
7
|
+
return from([
|
|
8
|
+
fetchNetBurnOrIncomeForTimeframeProjectView('month'),
|
|
9
|
+
fetchNetBurnOrIncomeForTimeframeProjectView('quarter'),
|
|
10
|
+
fetchNetBurnOrIncomeForTimeframeProjectView('year'),
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const fetchActions = [];
|
|
15
|
+
const projectFetchState = state.value.netBurnOrIncomeProjectViewState.fetchState;
|
|
16
|
+
if (projectFetchState['month'].fetchState !== 'In-Progress' &&
|
|
17
|
+
projectFetchState['month'].fetchState !== 'Completed') {
|
|
18
|
+
fetchActions.push(fetchNetBurnOrIncomeForTimeframeProjectView('month'));
|
|
19
|
+
}
|
|
20
|
+
if (projectFetchState['quarter'].fetchState !== 'In-Progress' &&
|
|
21
|
+
projectFetchState['quarter'].fetchState !== 'Completed') {
|
|
22
|
+
fetchActions.push(fetchNetBurnOrIncomeForTimeframeProjectView('quarter'));
|
|
23
|
+
}
|
|
24
|
+
if (projectFetchState['year'].fetchState !== 'In-Progress' &&
|
|
25
|
+
projectFetchState['year'].fetchState !== 'Completed') {
|
|
26
|
+
fetchActions.push(fetchNetBurnOrIncomeForTimeframeProjectView('year'));
|
|
27
|
+
}
|
|
28
|
+
return from(fetchActions);
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
import { mapReportPayloadV2ToReportV2 } from '../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
3
|
+
export const initialState = {
|
|
4
|
+
fetchState: {
|
|
5
|
+
month: {
|
|
6
|
+
fetchState: 'Not-Started',
|
|
7
|
+
error: undefined,
|
|
8
|
+
},
|
|
9
|
+
quarter: {
|
|
10
|
+
fetchState: 'Not-Started',
|
|
11
|
+
error: undefined,
|
|
12
|
+
},
|
|
13
|
+
year: {
|
|
14
|
+
fetchState: 'Not-Started',
|
|
15
|
+
error: undefined,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
firstMonthOfFY: 1,
|
|
19
|
+
projectIds: [],
|
|
20
|
+
reportId: 'net_burn_or_income_by_projects',
|
|
21
|
+
reportTitle: 'Net Income',
|
|
22
|
+
uiState: {
|
|
23
|
+
accountViewMode: 'account_group',
|
|
24
|
+
nodeCollapseState: {},
|
|
25
|
+
projectsToFilterOut: [],
|
|
26
|
+
scrollPosition: undefined,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const netBurnOrIncomeProjectView = createSlice({
|
|
30
|
+
name: 'netBurnOrIncomeProjectView',
|
|
31
|
+
initialState,
|
|
32
|
+
reducers: {
|
|
33
|
+
fetchNetBurnOrIncomeProjectView: {
|
|
34
|
+
prepare(cacheOverride = false) {
|
|
35
|
+
return { payload: { cacheOverride } };
|
|
36
|
+
},
|
|
37
|
+
reducer(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
|
+
_draft,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
41
|
+
_action) {
|
|
42
|
+
// nothing to do here
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
fetchNetBurnOrIncomeForTimeframeProjectView: {
|
|
46
|
+
prepare(timeframe, fetchFullReport = true, cacheOverride = false) {
|
|
47
|
+
return { payload: { timeframe, fetchFullReport, cacheOverride } };
|
|
48
|
+
},
|
|
49
|
+
reducer(draft, action) {
|
|
50
|
+
const timeframe = action.payload.timeframe;
|
|
51
|
+
draft.fetchState[timeframe].fetchState = 'In-Progress';
|
|
52
|
+
draft.fetchState[timeframe].error = undefined;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
updateNetBurnOrIncomeForTimeframeProjectView(draft, action) {
|
|
56
|
+
doUpdateNetBurnOrIncomeProjectView(draft, action.payload.timeframe, action.payload.report);
|
|
57
|
+
},
|
|
58
|
+
updateNetBurnOrIncomeForTimeframeProjectViewFailure: {
|
|
59
|
+
prepare(error, timeframe) {
|
|
60
|
+
return {
|
|
61
|
+
payload: {
|
|
62
|
+
error,
|
|
63
|
+
timeframe,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
reducer(draft, action) {
|
|
68
|
+
draft.fetchState[action.payload.timeframe] = {
|
|
69
|
+
fetchState: 'Error',
|
|
70
|
+
error: action.payload.error,
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
updateProjectsToFilterOut(draft, action) {
|
|
75
|
+
draft.uiState.projectsToFilterOut = action.payload.projectsToFilterOut;
|
|
76
|
+
},
|
|
77
|
+
updateNetBurnOrIncomeProjectViewUIState(draft, action) {
|
|
78
|
+
const { nodeCollapseState, scrollPosition } = action.payload;
|
|
79
|
+
if (nodeCollapseState != null) {
|
|
80
|
+
draft.uiState.nodeCollapseState = Object.assign({}, draft.uiState.nodeCollapseState, {
|
|
81
|
+
[nodeCollapseState.nodeId]: nodeCollapseState.isCollapsed,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (scrollPosition != null) {
|
|
85
|
+
draft.uiState.scrollPosition = scrollPosition;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
updateProjectViewAccountViewMode(draft, action) {
|
|
89
|
+
draft.uiState.accountViewMode = action.payload.viewMode;
|
|
90
|
+
},
|
|
91
|
+
resetProjectNodeCollapseState(draft) {
|
|
92
|
+
draft.uiState.nodeCollapseState = {};
|
|
93
|
+
},
|
|
94
|
+
clearNetBurnOrIncomeProjectView(draft) {
|
|
95
|
+
Object.assign(draft, initialState);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
export const { fetchNetBurnOrIncomeProjectView, fetchNetBurnOrIncomeForTimeframeProjectView, updateNetBurnOrIncomeForTimeframeProjectView, updateNetBurnOrIncomeForTimeframeProjectViewFailure, updateProjectsToFilterOut, updateNetBurnOrIncomeProjectViewUIState, updateProjectViewAccountViewMode, resetProjectNodeCollapseState, clearNetBurnOrIncomeProjectView, } = netBurnOrIncomeProjectView.actions;
|
|
100
|
+
export default netBurnOrIncomeProjectView.reducer;
|
|
101
|
+
const doUpdateNetBurnOrIncomeProjectView = (draft, timeframe, netBurnReport) => {
|
|
102
|
+
const report = mapReportPayloadV2ToReportV2(netBurnReport.report);
|
|
103
|
+
draft.dataAvailable = report.dataAvailable;
|
|
104
|
+
draft.firstMonthOfFY = report.firstMonthOfFY;
|
|
105
|
+
draft.bookCloseDate = report.bookCloseDate;
|
|
106
|
+
draft.status = report.status;
|
|
107
|
+
draft.fetchState[timeframe].fetchState = 'Completed';
|
|
108
|
+
if (draft.projectIds.length <= 0) {
|
|
109
|
+
draft.projectIds = netBurnReport.report.projects.map((project) => project.accounting_project_id);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createSelector } from '@reduxjs/toolkit';
|
|
2
|
+
import { getDifferenceOfBalancesGroupedByPeriod } from '../../commonStateTypes/coaBalance/classBalances/getDifferenceOfBalancesGroupedByPeriod';
|
|
3
|
+
import { getSumOfBalancesByGroupedByPeriod } from '../../commonStateTypes/coaBalance/classBalances/getSumOfBalancesGroupedByPeriod';
|
|
4
|
+
import { getCOABalances } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
5
|
+
import { newBalancesFilterProjectView, } from '../../commonStateTypes/coaBalance/coaBalancesFilterProjectView';
|
|
6
|
+
import { reduceFetchStateParallelTimeframes } from '../../commonStateTypes/reduceFetchState';
|
|
7
|
+
import { getProjectsByIds } from '../../entity/project/projectSelector';
|
|
8
|
+
import { getSectionProjectViewReport } from '../../entity/sectionProjectView/sectionProjectViewSelector';
|
|
9
|
+
import { ALL_NETBURN_OR_INCOME_CLASSES_VIEW_SECTION_IDS, } from '../netBurnOrIncomeClassesView/netBurnOrIncomeClassesViewSelectorTypes';
|
|
10
|
+
export const netBurnOrIncomeProjectIdsInOrder = ['income', 'cogs', 'expenses', 'grossBurn', 'netBurnOrIncome'];
|
|
11
|
+
export const getNetBurnOrIncomeProjectView = (filter, accountState, projectState, sectionsState, netBurnOrIncomeWithForecastState, netBurnOrIncomeProjectViewState) => {
|
|
12
|
+
const fetchState = reduceFetchStateParallelTimeframes([
|
|
13
|
+
netBurnOrIncomeProjectViewState.fetchState.month,
|
|
14
|
+
netBurnOrIncomeProjectViewState.fetchState.quarter,
|
|
15
|
+
netBurnOrIncomeProjectViewState.fetchState.year,
|
|
16
|
+
]);
|
|
17
|
+
const reportId = 'net_burn_or_income_by_projects';
|
|
18
|
+
const sections = {};
|
|
19
|
+
const calculatedSections = {};
|
|
20
|
+
if (fetchState.fetchState === 'Completed') {
|
|
21
|
+
ALL_NETBURN_OR_INCOME_CLASSES_VIEW_SECTION_IDS.forEach((sectionId) => {
|
|
22
|
+
sections[`${sectionId}`] = getSectionProjectViewReport(accountState, projectState, sectionsState, netBurnOrIncomeProjectViewState.projectIds, {
|
|
23
|
+
reportId,
|
|
24
|
+
sectionId,
|
|
25
|
+
}, filter);
|
|
26
|
+
});
|
|
27
|
+
const grossBurnBalancesByPeriod = getSumOfBalancesByGroupedByPeriod([
|
|
28
|
+
sections['expenses'].sectionBalancesTotalByPeriod,
|
|
29
|
+
sections['cogs'].sectionBalancesTotalByPeriod,
|
|
30
|
+
]);
|
|
31
|
+
calculatedSections['grossBurn'] = getCOABalances(grossBurnBalancesByPeriod, filter);
|
|
32
|
+
const netBurnOrIncomeBalances = getDifferenceOfBalancesGroupedByPeriod(sections['income'].sectionBalancesTotalByPeriod, grossBurnBalancesByPeriod);
|
|
33
|
+
calculatedSections['netBurnOrIncome'] = getCOABalances(netBurnOrIncomeBalances, filter);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
sections,
|
|
37
|
+
calculatedSections,
|
|
38
|
+
reportId: netBurnOrIncomeProjectViewState.reportId,
|
|
39
|
+
reportTitle: netBurnOrIncomeProjectViewState.reportTitle,
|
|
40
|
+
firstMonthOfFY: netBurnOrIncomeProjectViewState.firstMonthOfFY,
|
|
41
|
+
dataAvailable: netBurnOrIncomeProjectViewState.dataAvailable,
|
|
42
|
+
bookCloseDate: netBurnOrIncomeProjectViewState.bookCloseDate,
|
|
43
|
+
version: netBurnOrIncomeProjectViewState.version,
|
|
44
|
+
status: netBurnOrIncomeProjectViewState.status,
|
|
45
|
+
fetchState: fetchState.fetchState,
|
|
46
|
+
error: fetchState.error,
|
|
47
|
+
filter,
|
|
48
|
+
uiState: netBurnOrIncomeProjectViewState.uiState,
|
|
49
|
+
projects: getProjectsByIds(projectState, netBurnOrIncomeProjectViewState.projectIds),
|
|
50
|
+
projectsToFilterOut: netBurnOrIncomeProjectViewState.uiState.projectsToFilterOut,
|
|
51
|
+
idsInOrder: netBurnOrIncomeProjectIdsInOrder,
|
|
52
|
+
runwayAndAverages: netBurnOrIncomeWithForecastState.netBurnOrIncome.runwayAndAverages,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export const getNetBurnOrIncomeProjectViewForSelectedRange = createSelector((state) => state.accountState, (state) => state.projectState, (state) => state.sectionProjectViewState, (state) => state.netBurnOrIncomeState, (state) => state.netBurnOrIncomeProjectViewState, (accountState, projectState, sectionsState, netBurnOrIncomeState, netBurnOrIncomeProjectViewState) => {
|
|
56
|
+
const { timeframe, selectedCOABalancesRange, selectedAdditionalBalances } = netBurnOrIncomeState.uiState;
|
|
57
|
+
const noFilter = newBalancesFilterProjectView(netBurnOrIncomeState.netBurnOrIncome.firstMonthOfFY, timeframe, selectedCOABalancesRange.numberOfPeriods, selectedCOABalancesRange.thisPeriod, 'ascending_date', selectedAdditionalBalances, netBurnOrIncomeProjectViewState.uiState.projectsToFilterOut);
|
|
58
|
+
return getNetBurnOrIncomeProjectView(noFilter, accountState, projectState, sectionsState, netBurnOrIncomeState, netBurnOrIncomeProjectViewState);
|
|
59
|
+
});
|
|
60
|
+
export const getNetBurnOrIncomeProjectViewForHighlightedRange = createSelector((state) => state.accountState, (state) => state.projectState, (state) => state.sectionProjectViewState, (state) => state.netBurnOrIncomeState, (state) => state.netBurnOrIncomeProjectViewState, (accountState, projectState, sectionsState, netBurnOrIncomeState, netBurnOrIncomeProjectViewState) => {
|
|
61
|
+
const { timeframe, highlightedCOABalancesRange, selectedAdditionalBalances, maxNumOfPeriodsToHighlight, } = netBurnOrIncomeState.uiState;
|
|
62
|
+
const filter = newBalancesFilterProjectView(netBurnOrIncomeState.netBurnOrIncome.firstMonthOfFY, timeframe, highlightedCOABalancesRange?.numberOfPeriods ??
|
|
63
|
+
maxNumOfPeriodsToHighlight, highlightedCOABalancesRange?.thisPeriod, 'ascending_date', selectedAdditionalBalances, netBurnOrIncomeProjectViewState.uiState.projectsToFilterOut);
|
|
64
|
+
return getNetBurnOrIncomeProjectView(filter, accountState, projectState, sectionsState, netBurnOrIncomeState, netBurnOrIncomeProjectViewState);
|
|
65
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { from, of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { updateProjects } from '../../entity/project/projectReducer';
|
|
4
|
+
import { updateSectionProjectView } from '../../entity/sectionProjectView/sectionProjectViewReducer';
|
|
5
|
+
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
6
|
+
import { fetchOpExForTimeframeProjectView, updateOpExForTimeframeProjectView, updateOpExForTimeframeProjectViewFailure, } from './opExProjectViewReducer';
|
|
7
|
+
export const fetchOpExForTimeframeProjectViewEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(fetchOpExForTimeframeProjectView.match), mergeMap((action) => {
|
|
8
|
+
const getTimeSeriesGroup = (timeframe) => {
|
|
9
|
+
switch (timeframe) {
|
|
10
|
+
case 'month':
|
|
11
|
+
return 'months';
|
|
12
|
+
case 'quarter':
|
|
13
|
+
return 'quarters';
|
|
14
|
+
case 'year':
|
|
15
|
+
return 'years';
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const queryValue = {
|
|
19
|
+
is_full_response: action.payload.fetchFullReport,
|
|
20
|
+
time_series_groups: [getTimeSeriesGroup(action.payload.timeframe)],
|
|
21
|
+
is_group_by_project: true,
|
|
22
|
+
};
|
|
23
|
+
return zeniAPI
|
|
24
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses?query=${encodeURIComponent(JSON.stringify(queryValue))}`)
|
|
25
|
+
.pipe(mergeMap((response) => {
|
|
26
|
+
if (response.data != null && isSuccessResponse(response)) {
|
|
27
|
+
const actions = [];
|
|
28
|
+
const report = response.data.report;
|
|
29
|
+
const currency = report.currency;
|
|
30
|
+
actions.push(updateProjects(report.projects));
|
|
31
|
+
actions.push(updateSectionProjectView(action.payload.timeframe, 'expenses', 'operating_expenses_by_projects', report.expenses, report.accounts, currency));
|
|
32
|
+
actions.push(updateOpExForTimeframeProjectView({
|
|
33
|
+
timeframe: action.payload.timeframe,
|
|
34
|
+
report: response.data,
|
|
35
|
+
}));
|
|
36
|
+
return from(actions);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return of(updateOpExForTimeframeProjectViewFailure(response.status, action.payload.timeframe));
|
|
40
|
+
}
|
|
41
|
+
}), catchError((error) => of(updateOpExForTimeframeProjectViewFailure(createZeniAPIStatus('Unexpected Error', 'OpEx by Projects REST API call errored out' +
|
|
42
|
+
(error instanceof Error ? error.message : String(error))), action.payload.timeframe))));
|
|
43
|
+
}));
|