@zeniai/client-epic-state 5.1.77 → 5.1.78
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/invoicing/invoicingCommonPayload.d.ts +42 -0
- package/lib/entity/invoicing/invoicingCommonPayload.js +66 -1
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
- package/lib/entity/tenant/clearAllEpic.js +2 -0
- package/lib/epic.d.ts +2 -1
- package/lib/epic.js +7 -1
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +61 -0
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -0
- package/lib/esm/epic.js +7 -1
- package/lib/esm/index.js +5 -1
- package/lib/esm/reducer.js +3 -0
- 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/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/recordPayment/recordPaymentFormConfig.js +0 -1
- package/lib/esm/view/invoicing/recordPayment/recordPaymentPayload.js +5 -14
- package/lib/index.d.ts +7 -1
- package/lib/index.js +20 -4
- package/lib/reducer.d.ts +3 -0
- package/lib/reducer.js +3 -0
- 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/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/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/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,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingQboViewActionType } from './invoicingQboViewActionType';
|
|
6
|
+
export declare const fetchInvoicingQboSyncHealthEpic: (actions$: ActionsObservable<InvoicingQboViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingQboViewActionType>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchInvoicingQboSyncHealthEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const invoicingQboViewPayload_1 = require("../invoicingQboViewPayload");
|
|
8
|
+
const invoicingQboViewReducer_1 = require("../invoicingQboViewReducer");
|
|
9
|
+
const fetchInvoicingQboSyncHealthEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoicingQboViewReducer_1.fetchInvoicingQboSyncHealth.match), (0, operators_1.switchMap)(() => {
|
|
10
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-health`;
|
|
11
|
+
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.map)((response) => {
|
|
12
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
13
|
+
return (0, invoicingQboViewReducer_1.updateInvoicingQboSyncHealth)((0, invoicingQboViewPayload_1.mapInvoicingQboSyncHealth)(response.data ?? {}));
|
|
14
|
+
}
|
|
15
|
+
return (0, invoicingQboViewReducer_1.updateInvoicingQboSyncHealthFailure)(response.status);
|
|
16
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboSyncHealthFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch QBO sync health REST API call errored out ' +
|
|
17
|
+
JSON.stringify(error))))));
|
|
18
|
+
}));
|
|
19
|
+
exports.fetchInvoicingQboSyncHealthEpic = fetchInvoicingQboSyncHealthEpic;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { fetchInvoicingQboAccounts, fetchInvoicingQboClasses, fetchInvoicingQboConnection, fetchInvoicingQboSyncHealth, retryInvoicingQboSyncTask, retryInvoicingQboSyncTaskFailure, retryInvoicingQboSyncTaskSuccess, startInvoicingQboBackfill, startInvoicingQboBackfillFailure, startInvoicingQboBackfillSuccess, updateInvoicingQboAccounts, updateInvoicingQboAccountsFailure, updateInvoicingQboClasses, updateInvoicingQboClassesFailure, updateInvoicingQboConnection, updateInvoicingQboConnectionFailure, updateInvoicingQboSyncHealth, updateInvoicingQboSyncHealthFailure } from '../invoicingQboViewReducer';
|
|
2
|
+
export type InvoicingQboViewActionType = ReturnType<typeof fetchInvoicingQboConnection> | ReturnType<typeof updateInvoicingQboConnection> | ReturnType<typeof updateInvoicingQboConnectionFailure> | ReturnType<typeof fetchInvoicingQboAccounts> | ReturnType<typeof updateInvoicingQboAccounts> | ReturnType<typeof updateInvoicingQboAccountsFailure> | ReturnType<typeof fetchInvoicingQboClasses> | ReturnType<typeof updateInvoicingQboClasses> | ReturnType<typeof updateInvoicingQboClassesFailure> | ReturnType<typeof fetchInvoicingQboSyncHealth> | ReturnType<typeof updateInvoicingQboSyncHealth> | ReturnType<typeof updateInvoicingQboSyncHealthFailure> | ReturnType<typeof retryInvoicingQboSyncTask> | ReturnType<typeof retryInvoicingQboSyncTaskSuccess> | ReturnType<typeof retryInvoicingQboSyncTaskFailure> | ReturnType<typeof startInvoicingQboBackfill> | ReturnType<typeof startInvoicingQboBackfillSuccess> | ReturnType<typeof startInvoicingQboBackfillFailure>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingQboViewActionType } from './invoicingQboViewActionType';
|
|
6
|
+
export declare const retryInvoicingQboSyncTaskEpic: (actions$: ActionsObservable<InvoicingQboViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingQboViewActionType>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retryInvoicingQboSyncTaskEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const invoicingQboViewReducer_1 = require("../invoicingQboViewReducer");
|
|
8
|
+
const retryInvoicingQboSyncTaskEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoicingQboViewReducer_1.retryInvoicingQboSyncTask.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
+
const { taskId } = action.payload;
|
|
10
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-tasks/${encodeURIComponent(taskId)}/retry`;
|
|
11
|
+
return zeniAPI
|
|
12
|
+
.postAndGetJSON(apiUrl, {})
|
|
13
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
14
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
15
|
+
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.retryInvoicingQboSyncTaskSuccess)({
|
|
16
|
+
status: response.data?.status ?? '',
|
|
17
|
+
taskId: response.data?.task_id ?? taskId,
|
|
18
|
+
}), (0, invoicingQboViewReducer_1.fetchInvoicingQboSyncHealth)());
|
|
19
|
+
}
|
|
20
|
+
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.retryInvoicingQboSyncTaskFailure)({
|
|
21
|
+
status: response.status,
|
|
22
|
+
taskId,
|
|
23
|
+
}));
|
|
24
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, invoicingQboViewReducer_1.retryInvoicingQboSyncTaskFailure)({
|
|
25
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Retry QBO sync task REST API call errored out ' +
|
|
26
|
+
JSON.stringify(error)),
|
|
27
|
+
taskId,
|
|
28
|
+
}))));
|
|
29
|
+
}));
|
|
30
|
+
exports.retryInvoicingQboSyncTaskEpic = retryInvoicingQboSyncTaskEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingQboViewActionType } from './invoicingQboViewActionType';
|
|
6
|
+
export declare const startInvoicingQboBackfillEpic: (actions$: ActionsObservable<InvoicingQboViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingQboViewActionType>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startInvoicingQboBackfillEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const invoicingQboViewReducer_1 = require("../invoicingQboViewReducer");
|
|
8
|
+
const startInvoicingQboBackfillEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoicingQboViewReducer_1.startInvoicingQboBackfill.match), (0, operators_1.switchMap)((action) => {
|
|
9
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/backfill`;
|
|
10
|
+
return zeniAPI
|
|
11
|
+
.postAndGetJSON(apiUrl, {
|
|
12
|
+
start_date: action.payload.startDate,
|
|
13
|
+
})
|
|
14
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
15
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
16
|
+
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.startInvoicingQboBackfillSuccess)(), (0, invoicingQboViewReducer_1.fetchInvoicingQboSyncHealth)());
|
|
17
|
+
}
|
|
18
|
+
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.startInvoicingQboBackfillFailure)(response.status));
|
|
19
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, invoicingQboViewReducer_1.startInvoicingQboBackfillFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Start QBO backfill REST API call errored out ' +
|
|
20
|
+
JSON.stringify(error))))));
|
|
21
|
+
}));
|
|
22
|
+
exports.startInvoicingQboBackfillEpic = startInvoicingQboBackfillEpic;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
2
|
+
export interface InvoicingQboConnectionPayload {
|
|
3
|
+
connected: boolean;
|
|
4
|
+
company_name?: string | null;
|
|
5
|
+
connection_id?: string | null;
|
|
6
|
+
realm_id?: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface InvoicingQboConnection {
|
|
9
|
+
connected: boolean;
|
|
10
|
+
companyName?: string;
|
|
11
|
+
connectionId?: string;
|
|
12
|
+
realmId?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function mapInvoicingQboConnection(payload: InvoicingQboConnectionPayload): InvoicingQboConnection;
|
|
15
|
+
/**
|
|
16
|
+
* A single row from the QBO accounts / classes endpoints. The rows carry the
|
|
17
|
+
* QBO id plus one or more name fields depending on the entity — inspect
|
|
18
|
+
* loosely, render the name, submit the id.
|
|
19
|
+
*/
|
|
20
|
+
export interface InvoicingQboAccountRowPayload {
|
|
21
|
+
account_id?: string | null;
|
|
22
|
+
account_name?: string | null;
|
|
23
|
+
account_type?: string | null;
|
|
24
|
+
accounting_class_name?: string | null;
|
|
25
|
+
fully_qualified_name?: string | null;
|
|
26
|
+
id?: string | null;
|
|
27
|
+
name?: string | null;
|
|
28
|
+
qbo_accounting_class_name?: string | null;
|
|
29
|
+
qbo_id?: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface InvoicingQboAccountOption {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
accountType?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function mapInvoicingQboAccountOptions(rows: InvoicingQboAccountRowPayload[]): InvoicingQboAccountOption[];
|
|
37
|
+
export interface InvoicingQboAccountsPayload {
|
|
38
|
+
accounts: InvoicingQboAccountRowPayload[];
|
|
39
|
+
}
|
|
40
|
+
export interface InvoicingQboFailedTaskPayload {
|
|
41
|
+
attempts: number;
|
|
42
|
+
entity_id: string;
|
|
43
|
+
entity_type: string;
|
|
44
|
+
task_id: string;
|
|
45
|
+
last_error?: string | null;
|
|
46
|
+
updated_at?: string | null;
|
|
47
|
+
}
|
|
48
|
+
export interface InvoicingQboFailedTask {
|
|
49
|
+
attempts: number;
|
|
50
|
+
entityId: string;
|
|
51
|
+
entityType: string;
|
|
52
|
+
taskId: string;
|
|
53
|
+
lastError?: string;
|
|
54
|
+
updatedAt?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface InvoicingQboSyncHealthPayload {
|
|
57
|
+
connection?: InvoicingQboConnectionPayload | null;
|
|
58
|
+
counts_by_status?: Record<string, number> | null;
|
|
59
|
+
failed_tasks?: InvoicingQboFailedTaskPayload[] | null;
|
|
60
|
+
}
|
|
61
|
+
export interface InvoicingQboSyncHealth {
|
|
62
|
+
countsByStatus: Record<string, number>;
|
|
63
|
+
failedTasks: InvoicingQboFailedTask[];
|
|
64
|
+
connection?: InvoicingQboConnection;
|
|
65
|
+
}
|
|
66
|
+
export declare function mapInvoicingQboSyncHealth(payload: InvoicingQboSyncHealthPayload): InvoicingQboSyncHealth;
|
|
67
|
+
export interface InvoicingQboRetryTaskPayload {
|
|
68
|
+
status: string;
|
|
69
|
+
task_id: string;
|
|
70
|
+
}
|
|
71
|
+
export interface InvoicingQboBackfillPayload {
|
|
72
|
+
enqueued?: Record<string, number> | null;
|
|
73
|
+
start_date?: string | null;
|
|
74
|
+
}
|
|
75
|
+
export type InvoicingQboConnectionResponse = ZeniAPIResponse<InvoicingQboConnectionPayload>;
|
|
76
|
+
export type InvoicingQboAccountsResponse = ZeniAPIResponse<InvoicingQboAccountsPayload>;
|
|
77
|
+
export type InvoicingQboSyncHealthResponse = ZeniAPIResponse<InvoicingQboSyncHealthPayload>;
|
|
78
|
+
export type InvoicingQboRetryTaskResponse = ZeniAPIResponse<InvoicingQboRetryTaskPayload>;
|
|
79
|
+
export type InvoicingQboBackfillResponse = ZeniAPIResponse<InvoicingQboBackfillPayload>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapInvoicingQboConnection = mapInvoicingQboConnection;
|
|
4
|
+
exports.mapInvoicingQboAccountOptions = mapInvoicingQboAccountOptions;
|
|
5
|
+
exports.mapInvoicingQboSyncHealth = mapInvoicingQboSyncHealth;
|
|
6
|
+
function mapInvoicingQboConnection(payload) {
|
|
7
|
+
return {
|
|
8
|
+
connected: payload.connected,
|
|
9
|
+
companyName: payload.company_name ?? undefined,
|
|
10
|
+
connectionId: payload.connection_id ?? undefined,
|
|
11
|
+
realmId: payload.realm_id ?? undefined,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function mapInvoicingQboAccountOptions(rows) {
|
|
15
|
+
return rows.flatMap((row) => {
|
|
16
|
+
// Only qbo_id is a valid QBO AccountRef/ClassRef value — platform-internal
|
|
17
|
+
// ids (account_id / id) are display metadata and must never be submitted.
|
|
18
|
+
const accountId = row.qbo_id ?? row.id ?? row.account_id ?? '';
|
|
19
|
+
if (accountId === '') {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const accountName = row.name ??
|
|
23
|
+
row.account_name ??
|
|
24
|
+
row.accounting_class_name ??
|
|
25
|
+
row.qbo_accounting_class_name ??
|
|
26
|
+
row.fully_qualified_name ??
|
|
27
|
+
accountId;
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
id: accountId,
|
|
31
|
+
name: accountName,
|
|
32
|
+
accountType: row.account_type ?? undefined,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function mapInvoicingQboSyncHealth(payload) {
|
|
38
|
+
return {
|
|
39
|
+
connection: payload.connection != null
|
|
40
|
+
? mapInvoicingQboConnection(payload.connection)
|
|
41
|
+
: undefined,
|
|
42
|
+
countsByStatus: payload.counts_by_status ?? {},
|
|
43
|
+
failedTasks: (payload.failed_tasks ?? []).map((task) => ({
|
|
44
|
+
attempts: task.attempts,
|
|
45
|
+
entityId: task.entity_id,
|
|
46
|
+
entityType: task.entity_type,
|
|
47
|
+
taskId: task.task_id,
|
|
48
|
+
lastError: task.last_error ?? undefined,
|
|
49
|
+
updatedAt: task.updated_at ?? undefined,
|
|
50
|
+
})),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
2
|
+
import { InvoicingQboAccountOption, InvoicingQboConnection, InvoicingQboSyncHealth } from './invoicingQboViewPayload';
|
|
3
|
+
import { InvoicingQboViewState } from './invoicingQboViewState';
|
|
4
|
+
export declare const initialState: InvoicingQboViewState;
|
|
5
|
+
export declare const fetchInvoicingQboConnection: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingQboView/fetchInvoicingQboConnection">, updateInvoicingQboConnection: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingQboConnection, "invoicingQboView/updateInvoicingQboConnection">, updateInvoicingQboConnectionFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingQboView/updateInvoicingQboConnectionFailure">, fetchInvoicingQboAccounts: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountTypes: string], {
|
|
6
|
+
accountTypes: string;
|
|
7
|
+
}, "invoicingQboView/fetchInvoicingQboAccounts", never, never>, updateInvoicingQboAccounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
8
|
+
accounts: InvoicingQboAccountOption[];
|
|
9
|
+
accountTypes: string;
|
|
10
|
+
}, "invoicingQboView/updateInvoicingQboAccounts">, updateInvoicingQboAccountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
11
|
+
accountTypes: string;
|
|
12
|
+
status: ZeniAPIStatus;
|
|
13
|
+
}, "invoicingQboView/updateInvoicingQboAccountsFailure">, fetchInvoicingQboClasses: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingQboView/fetchInvoicingQboClasses">, updateInvoicingQboClasses: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingQboAccountOption[], "invoicingQboView/updateInvoicingQboClasses">, updateInvoicingQboClassesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingQboView/updateInvoicingQboClassesFailure">, fetchInvoicingQboSyncHealth: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingQboView/fetchInvoicingQboSyncHealth">, updateInvoicingQboSyncHealth: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingQboSyncHealth, "invoicingQboView/updateInvoicingQboSyncHealth">, updateInvoicingQboSyncHealthFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingQboView/updateInvoicingQboSyncHealthFailure">, retryInvoicingQboSyncTask: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[taskId: string], {
|
|
14
|
+
taskId: string;
|
|
15
|
+
}, "invoicingQboView/retryInvoicingQboSyncTask", never, never>, retryInvoicingQboSyncTaskSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
16
|
+
status: string;
|
|
17
|
+
taskId: string;
|
|
18
|
+
}, "invoicingQboView/retryInvoicingQboSyncTaskSuccess">, retryInvoicingQboSyncTaskFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
19
|
+
status: ZeniAPIStatus;
|
|
20
|
+
taskId: string;
|
|
21
|
+
}, "invoicingQboView/retryInvoicingQboSyncTaskFailure">, startInvoicingQboBackfill: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[startDate: string], {
|
|
22
|
+
startDate: string;
|
|
23
|
+
}, "invoicingQboView/startInvoicingQboBackfill", never, never>, startInvoicingQboBackfillSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingQboView/startInvoicingQboBackfillSuccess">, startInvoicingQboBackfillFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingQboView/startInvoicingQboBackfillFailure">, clearInvoicingQboView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingQboView/clearInvoicingQboView">;
|
|
24
|
+
declare const _default: import("redux").Reducer<InvoicingQboViewState>;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.clearInvoicingQboView = exports.startInvoicingQboBackfillFailure = exports.startInvoicingQboBackfillSuccess = exports.startInvoicingQboBackfill = exports.retryInvoicingQboSyncTaskFailure = exports.retryInvoicingQboSyncTaskSuccess = exports.retryInvoicingQboSyncTask = exports.updateInvoicingQboSyncHealthFailure = exports.updateInvoicingQboSyncHealth = exports.fetchInvoicingQboSyncHealth = exports.updateInvoicingQboClassesFailure = exports.updateInvoicingQboClasses = exports.fetchInvoicingQboClasses = exports.updateInvoicingQboAccountsFailure = exports.updateInvoicingQboAccounts = exports.fetchInvoicingQboAccounts = exports.updateInvoicingQboConnectionFailure = exports.updateInvoicingQboConnection = exports.fetchInvoicingQboConnection = exports.initialState = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
exports.initialState = {
|
|
7
|
+
accountsByAccountTypes: {},
|
|
8
|
+
accountsFetchStateByAccountTypes: {},
|
|
9
|
+
backfillFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
10
|
+
classes: [],
|
|
11
|
+
classesFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
12
|
+
connection: undefined,
|
|
13
|
+
connectionFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
14
|
+
retryFetchStateByTaskId: {},
|
|
15
|
+
syncHealth: undefined,
|
|
16
|
+
syncHealthFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
17
|
+
};
|
|
18
|
+
const invoicingQboView = (0, toolkit_1.createSlice)({
|
|
19
|
+
name: 'invoicingQboView',
|
|
20
|
+
initialState: exports.initialState,
|
|
21
|
+
reducers: {
|
|
22
|
+
fetchInvoicingQboConnection(draft) {
|
|
23
|
+
draft.connectionFetchState = {
|
|
24
|
+
fetchState: 'In-Progress',
|
|
25
|
+
error: undefined,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
updateInvoicingQboConnection(draft, action) {
|
|
29
|
+
draft.connection = action.payload;
|
|
30
|
+
draft.connectionFetchState = { fetchState: 'Completed', error: undefined };
|
|
31
|
+
},
|
|
32
|
+
updateInvoicingQboConnectionFailure(draft, action) {
|
|
33
|
+
draft.connectionFetchState = { fetchState: 'Error', error: action.payload };
|
|
34
|
+
},
|
|
35
|
+
fetchInvoicingQboAccounts: {
|
|
36
|
+
reducer(draft, action) {
|
|
37
|
+
draft.accountsFetchStateByAccountTypes[action.payload.accountTypes] = {
|
|
38
|
+
fetchState: 'In-Progress',
|
|
39
|
+
error: undefined,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
prepare(accountTypes) {
|
|
43
|
+
return { payload: { accountTypes } };
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
updateInvoicingQboAccounts(draft, action) {
|
|
47
|
+
draft.accountsByAccountTypes[action.payload.accountTypes] =
|
|
48
|
+
action.payload.accounts;
|
|
49
|
+
draft.accountsFetchStateByAccountTypes[action.payload.accountTypes] = {
|
|
50
|
+
fetchState: 'Completed',
|
|
51
|
+
error: undefined,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
updateInvoicingQboAccountsFailure(draft, action) {
|
|
55
|
+
draft.accountsFetchStateByAccountTypes[action.payload.accountTypes] = {
|
|
56
|
+
fetchState: 'Error',
|
|
57
|
+
error: action.payload.status,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
fetchInvoicingQboClasses(draft) {
|
|
61
|
+
draft.classesFetchState = { fetchState: 'In-Progress', error: undefined };
|
|
62
|
+
},
|
|
63
|
+
updateInvoicingQboClasses(draft, action) {
|
|
64
|
+
draft.classes = action.payload;
|
|
65
|
+
draft.classesFetchState = { fetchState: 'Completed', error: undefined };
|
|
66
|
+
},
|
|
67
|
+
updateInvoicingQboClassesFailure(draft, action) {
|
|
68
|
+
draft.classesFetchState = { fetchState: 'Error', error: action.payload };
|
|
69
|
+
},
|
|
70
|
+
fetchInvoicingQboSyncHealth(draft) {
|
|
71
|
+
draft.syncHealthFetchState = {
|
|
72
|
+
fetchState: 'In-Progress',
|
|
73
|
+
error: undefined,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
updateInvoicingQboSyncHealth(draft, action) {
|
|
77
|
+
draft.syncHealth = action.payload;
|
|
78
|
+
draft.syncHealthFetchState = { fetchState: 'Completed', error: undefined };
|
|
79
|
+
},
|
|
80
|
+
updateInvoicingQboSyncHealthFailure(draft, action) {
|
|
81
|
+
draft.syncHealthFetchState = {
|
|
82
|
+
fetchState: 'Error',
|
|
83
|
+
error: action.payload,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
retryInvoicingQboSyncTask: {
|
|
87
|
+
reducer(draft, action) {
|
|
88
|
+
draft.retryFetchStateByTaskId[action.payload.taskId] = {
|
|
89
|
+
fetchState: 'In-Progress',
|
|
90
|
+
error: undefined,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
prepare(taskId) {
|
|
94
|
+
return { payload: { taskId } };
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
retryInvoicingQboSyncTaskSuccess(draft, action) {
|
|
98
|
+
draft.retryFetchStateByTaskId[action.payload.taskId] = {
|
|
99
|
+
fetchState: 'Completed',
|
|
100
|
+
error: undefined,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
retryInvoicingQboSyncTaskFailure(draft, action) {
|
|
104
|
+
draft.retryFetchStateByTaskId[action.payload.taskId] = {
|
|
105
|
+
fetchState: 'Error',
|
|
106
|
+
error: action.payload.status,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
startInvoicingQboBackfill: {
|
|
110
|
+
reducer(draft) {
|
|
111
|
+
draft.backfillFetchState = {
|
|
112
|
+
fetchState: 'In-Progress',
|
|
113
|
+
error: undefined,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
prepare(startDate) {
|
|
117
|
+
return { payload: { startDate } };
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
startInvoicingQboBackfillSuccess(draft) {
|
|
121
|
+
draft.backfillFetchState = { fetchState: 'Completed', error: undefined };
|
|
122
|
+
},
|
|
123
|
+
startInvoicingQboBackfillFailure(draft, action) {
|
|
124
|
+
draft.backfillFetchState = { fetchState: 'Error', error: action.payload };
|
|
125
|
+
},
|
|
126
|
+
clearInvoicingQboView(draft) {
|
|
127
|
+
Object.assign(draft, exports.initialState);
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
_a = invoicingQboView.actions, exports.fetchInvoicingQboConnection = _a.fetchInvoicingQboConnection, exports.updateInvoicingQboConnection = _a.updateInvoicingQboConnection, exports.updateInvoicingQboConnectionFailure = _a.updateInvoicingQboConnectionFailure, exports.fetchInvoicingQboAccounts = _a.fetchInvoicingQboAccounts, exports.updateInvoicingQboAccounts = _a.updateInvoicingQboAccounts, exports.updateInvoicingQboAccountsFailure = _a.updateInvoicingQboAccountsFailure, exports.fetchInvoicingQboClasses = _a.fetchInvoicingQboClasses, exports.updateInvoicingQboClasses = _a.updateInvoicingQboClasses, exports.updateInvoicingQboClassesFailure = _a.updateInvoicingQboClassesFailure, exports.fetchInvoicingQboSyncHealth = _a.fetchInvoicingQboSyncHealth, exports.updateInvoicingQboSyncHealth = _a.updateInvoicingQboSyncHealth, exports.updateInvoicingQboSyncHealthFailure = _a.updateInvoicingQboSyncHealthFailure, exports.retryInvoicingQboSyncTask = _a.retryInvoicingQboSyncTask, exports.retryInvoicingQboSyncTaskSuccess = _a.retryInvoicingQboSyncTaskSuccess, exports.retryInvoicingQboSyncTaskFailure = _a.retryInvoicingQboSyncTaskFailure, exports.startInvoicingQboBackfill = _a.startInvoicingQboBackfill, exports.startInvoicingQboBackfillSuccess = _a.startInvoicingQboBackfillSuccess, exports.startInvoicingQboBackfillFailure = _a.startInvoicingQboBackfillFailure, exports.clearInvoicingQboView = _a.clearInvoicingQboView;
|
|
132
|
+
exports.default = invoicingQboView.reducer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
2
|
+
import { RootState } from '../../../reducer';
|
|
3
|
+
import { InvoicingQboAccountOption, InvoicingQboConnection, InvoicingQboSyncHealth } from './invoicingQboViewPayload';
|
|
4
|
+
export interface InvoicingQboView {
|
|
5
|
+
accountsByAccountTypes: Record<string, InvoicingQboAccountOption[]>;
|
|
6
|
+
accountsFetchStateByAccountTypes: Record<string, FetchStateAndError>;
|
|
7
|
+
backfillState: FetchStateAndError;
|
|
8
|
+
classes: InvoicingQboAccountOption[];
|
|
9
|
+
classesFetchState: FetchStateAndError;
|
|
10
|
+
connectionFetchState: FetchStateAndError;
|
|
11
|
+
retryFetchStateByTaskId: Record<string, FetchStateAndError>;
|
|
12
|
+
syncHealthFetchState: FetchStateAndError;
|
|
13
|
+
connection?: InvoicingQboConnection;
|
|
14
|
+
syncHealth?: InvoicingQboSyncHealth;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Single bundled view for the QBO integration settings screen — the
|
|
18
|
+
* connection, per-account-types account options, classes, sync health, and the
|
|
19
|
+
* fetch/action states for each of them.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getInvoicingQboView: (state: RootState) => InvoicingQboView;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInvoicingQboView = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Single bundled view for the QBO integration settings screen — the
|
|
6
|
+
* connection, per-account-types account options, classes, sync health, and the
|
|
7
|
+
* fetch/action states for each of them.
|
|
8
|
+
*/
|
|
9
|
+
const getInvoicingQboView = (state) => {
|
|
10
|
+
const qboState = state.invoicingQboViewState;
|
|
11
|
+
return {
|
|
12
|
+
accountsByAccountTypes: qboState.accountsByAccountTypes,
|
|
13
|
+
accountsFetchStateByAccountTypes: qboState.accountsFetchStateByAccountTypes,
|
|
14
|
+
backfillState: qboState.backfillFetchState,
|
|
15
|
+
classes: qboState.classes,
|
|
16
|
+
classesFetchState: qboState.classesFetchState,
|
|
17
|
+
connection: qboState.connection,
|
|
18
|
+
connectionFetchState: qboState.connectionFetchState,
|
|
19
|
+
retryFetchStateByTaskId: qboState.retryFetchStateByTaskId,
|
|
20
|
+
syncHealth: qboState.syncHealth,
|
|
21
|
+
syncHealthFetchState: qboState.syncHealthFetchState,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.getInvoicingQboView = getInvoicingQboView;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
2
|
+
import { InvoicingQboAccountOption, InvoicingQboConnection, InvoicingQboSyncHealth } from './invoicingQboViewPayload';
|
|
3
|
+
export interface InvoicingQboViewState {
|
|
4
|
+
accountsByAccountTypes: Record<string, InvoicingQboAccountOption[]>;
|
|
5
|
+
accountsFetchStateByAccountTypes: Record<string, FetchStateAndError>;
|
|
6
|
+
backfillFetchState: FetchStateAndError;
|
|
7
|
+
classes: InvoicingQboAccountOption[];
|
|
8
|
+
classesFetchState: FetchStateAndError;
|
|
9
|
+
connectionFetchState: FetchStateAndError;
|
|
10
|
+
retryFetchStateByTaskId: Record<string, FetchStateAndError>;
|
|
11
|
+
syncHealthFetchState: FetchStateAndError;
|
|
12
|
+
connection?: InvoicingQboConnection;
|
|
13
|
+
syncHealth?: InvoicingQboSyncHealth;
|
|
14
|
+
}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initializeIssueCreditNoteDraftFromInvoice = exports.localDataToIssueCreditNotePayload = exports.computeIssueCreditNoteTotal = void 0;
|
|
4
|
-
const dollarsFromAmountString = (value) => {
|
|
5
|
-
const parsed = Number.parseFloat(value);
|
|
6
|
-
if (Number.isNaN(parsed)) {
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
return parsed;
|
|
10
|
-
};
|
|
11
4
|
const computeIssueCreditNoteTotal = (lineItems) => lineItems
|
|
12
5
|
.filter((lineItem) => lineItem.selected)
|
|
13
6
|
.reduce((total, lineItem) => {
|
|
14
7
|
const quantity = Number.parseFloat(lineItem.quantity);
|
|
15
|
-
const unitAmount =
|
|
8
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
16
9
|
if (Number.isNaN(quantity) || quantity <= 0 || unitAmount <= 0) {
|
|
17
10
|
return total;
|
|
18
11
|
}
|
|
@@ -24,7 +17,7 @@ const localDataToIssueCreditNotePayload = (localData) => {
|
|
|
24
17
|
.filter((lineItem) => lineItem.selected)
|
|
25
18
|
.map((lineItem) => {
|
|
26
19
|
const quantity = Math.round(Number.parseFloat(lineItem.quantity));
|
|
27
|
-
const unitAmount =
|
|
20
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
28
21
|
return {
|
|
29
22
|
description: lineItem.description,
|
|
30
23
|
quantity,
|
|
@@ -48,10 +41,10 @@ const initializeIssueCreditNoteDraftFromInvoice = (invoice) => ({
|
|
|
48
41
|
description: lineItem.description,
|
|
49
42
|
id: lineItem.id,
|
|
50
43
|
maxQuantity: lineItem.quantity,
|
|
51
|
-
maxUnitAmount: lineItem.unitAmount
|
|
44
|
+
maxUnitAmount: lineItem.unitAmount,
|
|
52
45
|
quantity: String(lineItem.quantity),
|
|
53
46
|
selected: true,
|
|
54
|
-
unitAmount: lineItem.unitAmount
|
|
47
|
+
unitAmount: lineItem.unitAmount,
|
|
55
48
|
})),
|
|
56
49
|
});
|
|
57
50
|
exports.initializeIssueCreditNoteDraftFromInvoice = initializeIssueCreditNoteDraftFromInvoice;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
export interface IssueCreditNoteLineItemDraft {
|
|
3
4
|
description: string;
|
|
4
5
|
maxQuantity: number;
|
|
5
|
-
maxUnitAmount:
|
|
6
|
+
maxUnitAmount: Amount;
|
|
6
7
|
quantity: string;
|
|
7
8
|
selected: boolean;
|
|
8
|
-
unitAmount:
|
|
9
|
+
unitAmount: Amount;
|
|
9
10
|
id?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface IssueCreditNoteFormLocalData {
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initializeRecordPaymentDraftFromInvoice = exports.localDataToRecordPaymentPayload = exports.localDataToInvoiceRecordPaymentBody = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
5
6
|
const recordPaymentFormConfig_1 = require("./recordPaymentFormConfig");
|
|
6
7
|
const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
|
|
7
|
-
const
|
|
8
|
-
const parsed = Number.parseFloat(value);
|
|
9
|
-
if (Number.isNaN(parsed)) {
|
|
10
|
-
return 0;
|
|
11
|
-
}
|
|
12
|
-
return parsed;
|
|
13
|
-
};
|
|
14
|
-
const amountDueDollarsFromInvoice = (invoice) => {
|
|
15
|
-
const amountDue = invoice.amountDue?.amount ?? 0;
|
|
16
|
-
return amountDue.toFixed(2);
|
|
17
|
-
};
|
|
8
|
+
const amountDueFromInvoice = (invoice) => invoice.amountDue ?? (0, amount_1.toAmount)(0, 'USD', '$');
|
|
18
9
|
/**
|
|
19
10
|
* Build the invoice-scoped Record Payment body from the form draft. Amount stays
|
|
20
11
|
* in dollars for the invoice endpoint.
|
|
@@ -24,7 +15,7 @@ const localDataToInvoiceRecordPaymentBody = (localData) => {
|
|
|
24
15
|
const date = localData.date.trim();
|
|
25
16
|
const referenceNumber = trimOrUndefined(localData.referenceNumber);
|
|
26
17
|
return {
|
|
27
|
-
amount:
|
|
18
|
+
amount: localData.amount?.amount ?? 0,
|
|
28
19
|
payment_method: localData.paymentMethod,
|
|
29
20
|
...(gateway != null ? { gateway } : {}),
|
|
30
21
|
...(date !== '' ? { date } : {}),
|
|
@@ -38,7 +29,7 @@ exports.localDataToInvoiceRecordPaymentBody = localDataToInvoiceRecordPaymentBod
|
|
|
38
29
|
* and the linked invoice into `linked_invoices`. Currency is locked to USD.
|
|
39
30
|
*/
|
|
40
31
|
const localDataToRecordPaymentPayload = (localData) => {
|
|
41
|
-
const amount =
|
|
32
|
+
const amount = localData.amount?.amount ?? 0;
|
|
42
33
|
const gateway = trimOrUndefined(localData.gateway);
|
|
43
34
|
const date = localData.date.trim();
|
|
44
35
|
const transactionId = trimOrUndefined(localData.transactionId);
|
|
@@ -65,7 +56,7 @@ const localDataToRecordPaymentPayload = (localData) => {
|
|
|
65
56
|
exports.localDataToRecordPaymentPayload = localDataToRecordPaymentPayload;
|
|
66
57
|
const initializeRecordPaymentDraftFromInvoice = (invoice) => ({
|
|
67
58
|
...recordPaymentFormConfig_1.initialRecordPaymentFormLocalData,
|
|
68
|
-
amount:
|
|
59
|
+
amount: amountDueFromInvoice(invoice),
|
|
69
60
|
customerId: invoice.customerID,
|
|
70
61
|
date: (0, zeniDayJS_1.dateNow)().format('YYYY-MM-DD'),
|
|
71
62
|
invoiceToLink: invoice.id,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
/**
|
|
3
4
|
* Draft form state for the Record Payment form. Held in CES so the form flows
|
|
4
5
|
* its data from here (mirrors the customer form pattern). Record payment is
|
|
5
6
|
* create-only, so there is a single draft (no per-id edit tree). The date is an
|
|
6
|
-
* ISO `YYYY-MM-DD` string; amount
|
|
7
|
+
* ISO `YYYY-MM-DD` string; the amount as an `Amount` (as on the invoice entity).
|
|
7
8
|
*/
|
|
8
9
|
export interface RecordPaymentFormLocalData {
|
|
9
|
-
amount: string;
|
|
10
10
|
comment: string;
|
|
11
11
|
customerId: string;
|
|
12
12
|
date: string;
|
|
@@ -15,6 +15,8 @@ export interface RecordPaymentFormLocalData {
|
|
|
15
15
|
paymentMethod: string;
|
|
16
16
|
referenceNumber: string;
|
|
17
17
|
transactionId: string;
|
|
18
|
+
/** Unset until entered, so a blank field is distinguishable from a real 0. */
|
|
19
|
+
amount?: Amount;
|
|
18
20
|
}
|
|
19
21
|
export interface RecordPaymentState extends FetchedState {
|
|
20
22
|
newPaymentDraft: RecordPaymentFormLocalData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.78",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|