@zeniai/client-epic-state 5.2.72 → 5.2.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/entity/aiCfo/aiCfoState.d.ts +2 -2
- package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +2 -2
- package/lib/entity/chargeCardTransaction/chargeCardTransaction.d.ts +1 -1
- package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
- package/lib/entity/invoicing/plan/planPayload.d.ts +40 -0
- package/lib/entity/invoicing/plan/planPayload.js +51 -0
- package/lib/entity/invoicing/plan/planReducer.d.ts +14 -0
- package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogReducer.js → plan/planReducer.js} +21 -20
- package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogSelector.d.ts → plan/planSelector.d.ts} +6 -5
- package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogSelector.js → plan/planSelector.js} +12 -12
- package/lib/entity/invoicing/plan/planState.d.ts +43 -0
- package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogPayload.d.ts → product/productPayload.d.ts} +6 -44
- package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogPayload.js → product/productPayload.js} +6 -50
- package/lib/entity/invoicing/product/productReducer.d.ts +9 -0
- package/lib/entity/invoicing/product/productReducer.js +50 -0
- package/lib/entity/invoicing/product/productSelector.d.ts +4 -0
- package/lib/entity/invoicing/product/productSelector.js +17 -0
- package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogState.d.ts → product/productState.d.ts} +6 -42
- package/lib/entity/invoicing/product/productState.js +2 -0
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +4 -4
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/epic.d.ts +2 -3
- package/lib/epic.js +1 -3
- package/lib/esm/entity/invoicing/plan/planPayload.js +47 -0
- package/lib/esm/entity/invoicing/{invoicingCatalog/invoicingCatalogReducer.js → plan/planReducer.js} +20 -19
- package/lib/esm/entity/invoicing/{invoicingCatalog/invoicingCatalogSelector.js → plan/planSelector.js} +8 -8
- package/lib/esm/entity/invoicing/{invoicingCatalog/invoicingCatalogPayload.js → product/productPayload.js} +3 -46
- package/lib/esm/entity/invoicing/product/productReducer.js +43 -0
- package/lib/esm/entity/invoicing/product/productSelector.js +10 -0
- package/lib/esm/entity/invoicing/product/productState.js +1 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/esm/epic.js +1 -3
- package/lib/esm/index.js +9 -6
- package/lib/esm/reducer.js +7 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +1 -9
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +3 -5
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/fetchInvoicingCatalogItemDetailEpic.js +2 -2
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogPlanActionEpic.js +2 -2
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogProductActionEpic.js +4 -4
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +7 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +2 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +1 -5
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -5
- package/lib/esm/view/invoicing/invoiceList/invoiceListReducer.js +1 -8
- package/lib/esm/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogPlanListEpic.js +2 -2
- package/lib/esm/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogProductListEpic.js +2 -2
- package/lib/esm/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.js +22 -55
- package/lib/esm/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewState.js +20 -1
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewEpic.js +2 -2
- package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +1 -21
- package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +1 -2
- package/lib/index.d.ts +13 -9
- package/lib/index.js +45 -39
- package/lib/reducer.d.ts +2 -1
- package/lib/reducer.js +7 -4
- package/lib/rootStateTypes.d.ts +5 -3
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -2
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +2 -3
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +0 -8
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +2 -2
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +9 -8
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +3 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/fetchInvoicingCatalogItemDetailEpic.d.ts +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/fetchInvoicingCatalogItemDetailEpic.js +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormHelper.d.ts +4 -3
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogPlanActionEpic.d.ts +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogPlanActionEpic.js +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogProductActionEpic.d.ts +3 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogProductActionEpic.js +4 -4
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +3 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +7 -3
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +2 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +1 -3
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +2 -6
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +2 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +1 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -5
- package/lib/view/invoicing/invoiceList/invoiceListReducer.d.ts +1 -3
- package/lib/view/invoicing/invoiceList/invoiceListReducer.js +2 -9
- package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogListPageEpic.d.ts +2 -2
- package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogPlanListEpic.d.ts +2 -2
- package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogPlanListEpic.js +2 -2
- package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogProductListEpic.d.ts +2 -2
- package/lib/view/invoicing/invoicingCatalogListView/epics/fetchInvoicingCatalogProductListEpic.js +2 -2
- package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewPayload.d.ts +3 -3
- package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.d.ts +15 -33
- package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.js +23 -57
- package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewState.d.ts +15 -0
- package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewState.js +22 -0
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts +1 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +1 -1
- package/lib/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewEpic.js +2 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +5 -5
- package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
- package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.d.ts +2 -2
- package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +1 -1
- package/lib/view/spendManagement/commonSetup/setupViewReducer.js +2 -22
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +0 -1
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +1 -2
- package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +0 -1
- package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewReducer.d.ts +2 -2
- package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +5 -5
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +2 -2
- package/package.json +1 -1
- package/lib/entity/invoicing/invoicingCatalog/invoicingCatalogReducer.d.ts +0 -12
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.js +0 -37
- package/lib/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.d.ts +0 -8
- package/lib/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.js +0 -41
- /package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogState.js → plan/planState.js} +0 -0
- /package/lib/esm/entity/invoicing/{invoicingCatalog/invoicingCatalogState.js → plan/planState.js} +0 -0
|
@@ -140,9 +140,9 @@ export interface AiCfoVisualization {
|
|
|
140
140
|
data: TableVisualization | ChartVisualization | InteractiveFormVisualization;
|
|
141
141
|
type: AiCfoVisualizationType;
|
|
142
142
|
}
|
|
143
|
-
export declare const toMessageSender: (v: string) => "
|
|
143
|
+
export declare const toMessageSender: (v: string) => "user" | "agent";
|
|
144
144
|
export declare const toMessageType: (v: string) => "plain_text" | "json";
|
|
145
|
-
export declare const toMessageSenderStrict: (v: string) => "
|
|
145
|
+
export declare const toMessageSenderStrict: (v: string) => "user" | "agent" | undefined;
|
|
146
146
|
export declare const toMessageTypeStrict: (v: string) => "plain_text" | "json" | undefined;
|
|
147
147
|
export type MessageSender = ReturnType<typeof toMessageSender>;
|
|
148
148
|
export type MessageType = ReturnType<typeof toMessageType>;
|
|
@@ -108,9 +108,9 @@ export interface BulkProcessingDetail {
|
|
|
108
108
|
};
|
|
109
109
|
inProgressMessage?: string;
|
|
110
110
|
}
|
|
111
|
-
declare const toBillStageCodeType: (v: string) => "
|
|
111
|
+
declare const toBillStageCodeType: (v: string) => "paid" | "pending_approval" | "scheduled" | "draft";
|
|
112
112
|
export type BillStageCodeType = ReturnType<typeof toBillStageCodeType>;
|
|
113
|
-
declare const toBillPaymentStatusCodeType: (v: string) => "failed" | "
|
|
113
|
+
declare const toBillPaymentStatusCodeType: (v: string) => "failed" | "cancelled" | "paid" | "returned" | "processing" | "posted" | "pending_vendor_action" | "awaiting_to_be_marked_as_paid" | "mark_as_paid";
|
|
114
114
|
export type BillPaymentStatusCodeType = ReturnType<typeof toBillPaymentStatusCodeType>;
|
|
115
115
|
declare const toBillPaymentRefundStatusCodeType: (v: string) => "failed" | "completed" | "cancelled" | "returned" | "processing";
|
|
116
116
|
export type BillPaymentRefundStatusCodeType = ReturnType<typeof toBillPaymentRefundStatusCodeType>;
|
|
@@ -36,6 +36,6 @@ export interface ChargeCardTransactionState {
|
|
|
36
36
|
}
|
|
37
37
|
export declare const toCardTransactionTypeCode: (v: string) => "expense" | "credit_card_credit" | "transfer" | "purchase";
|
|
38
38
|
export type ChargeCardTransactionTypeCode = ReturnType<typeof toCardTransactionTypeCode>;
|
|
39
|
-
export declare const toCardTransactionStatusCode: (v: string) => "
|
|
39
|
+
export declare const toCardTransactionStatusCode: (v: string) => "paid" | "authorized" | "canceled" | "declined";
|
|
40
40
|
export type ChargeCardTransactionStatusCode = ReturnType<typeof toCardTransactionStatusCode>;
|
|
41
41
|
export {};
|
|
@@ -28,6 +28,6 @@ export interface DepositAccountTransactionState {
|
|
|
28
28
|
}
|
|
29
29
|
export declare const toDepositAccountTransactionType: (v: string) => "wire" | "purchase" | "originated_ach" | "ach_originating" | "received_ach" | "returned_ach" | "dishonored_ach" | "book" | "atm" | "fee" | "reversal" | "card_transaction" | "batch_release" | "dispute" | "adjustment" | "interest" | "check_deposit" | "returned_check_deposit" | "payment_canceled";
|
|
30
30
|
type DepositAccountTransactionType = ReturnType<typeof toDepositAccountTransactionType>;
|
|
31
|
-
export declare const toDepositTransactionStatusCode: (v: string) => "pending_review" | "pending" | "failed" | "
|
|
31
|
+
export declare const toDepositTransactionStatusCode: (v: string) => "pending_review" | "pending" | "failed" | "rejected" | "returned" | "canceled" | "clearing" | "sent" | undefined;
|
|
32
32
|
export type DepositTransactionStatusCode = ReturnType<typeof toDepositTransactionStatusCode>;
|
|
33
33
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InvoicingPlanTierPayload, InvoicingProductPayload } from '../product/productPayload';
|
|
2
|
+
import { InvoicingPlan } from './planState';
|
|
3
|
+
export interface InvoicingPlanPayload {
|
|
4
|
+
id: string;
|
|
5
|
+
applicable_items?: string[];
|
|
6
|
+
archived_at?: string;
|
|
7
|
+
billing_cycles?: number;
|
|
8
|
+
created_at?: string;
|
|
9
|
+
currency_code?: string;
|
|
10
|
+
currency_symbol?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
enabled_for_checkout?: boolean;
|
|
13
|
+
enabled_in_portal?: boolean;
|
|
14
|
+
external_id?: string;
|
|
15
|
+
external_name?: string;
|
|
16
|
+
gift_claim_redirect_url?: string;
|
|
17
|
+
included_in_mrr?: boolean;
|
|
18
|
+
is_giftable?: boolean;
|
|
19
|
+
is_shippable?: boolean;
|
|
20
|
+
item_applicability?: string;
|
|
21
|
+
item_family_id?: string;
|
|
22
|
+
item_type?: string;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
metered?: boolean;
|
|
25
|
+
name?: string;
|
|
26
|
+
period?: number;
|
|
27
|
+
period_unit?: string;
|
|
28
|
+
price?: number;
|
|
29
|
+
product_code?: string;
|
|
30
|
+
status?: string;
|
|
31
|
+
sub_families?: InvoicingProductPayload[];
|
|
32
|
+
tiers?: InvoicingPlanTierPayload[];
|
|
33
|
+
trial_period?: number;
|
|
34
|
+
trial_period_unit?: string;
|
|
35
|
+
type?: string;
|
|
36
|
+
unit?: string;
|
|
37
|
+
updated_at?: string;
|
|
38
|
+
usage_calculation?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare const mapInvoicingPlanPayloadToState: (payload: InvoicingPlanPayload) => InvoicingPlan;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapInvoicingPlanPayloadToState = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
|
+
const currencyHelper_1 = require("../../../commonStateTypes/currencyHelper");
|
|
6
|
+
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
7
|
+
const productPayload_1 = require("../product/productPayload");
|
|
8
|
+
// ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
|
|
9
|
+
const mapInvoicingPlanPayloadToState = (payload) => {
|
|
10
|
+
const currencyCode = payload.currency_code ?? currencyHelper_1.defaultCustomerCurrency.currencyCode;
|
|
11
|
+
const currencySymbol = payload.currency_symbol ?? currencyHelper_1.defaultCustomerCurrency.currencySymbol;
|
|
12
|
+
return {
|
|
13
|
+
id: payload.id,
|
|
14
|
+
applicableItems: payload.applicable_items,
|
|
15
|
+
archivedAt: payload.archived_at != null ? (0, zeniDayJS_1.date)(payload.archived_at) : undefined,
|
|
16
|
+
billingCycles: payload.billing_cycles,
|
|
17
|
+
createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
|
|
18
|
+
currencyCode: payload.currency_code,
|
|
19
|
+
description: payload.description,
|
|
20
|
+
enabledForCheckout: payload.enabled_for_checkout,
|
|
21
|
+
enabledInPortal: payload.enabled_in_portal,
|
|
22
|
+
externalId: payload.external_id,
|
|
23
|
+
externalName: payload.external_name,
|
|
24
|
+
giftClaimRedirectUrl: payload.gift_claim_redirect_url,
|
|
25
|
+
includedInMrr: payload.included_in_mrr,
|
|
26
|
+
isGiftable: payload.is_giftable,
|
|
27
|
+
isShippable: payload.is_shippable,
|
|
28
|
+
itemApplicability: payload.item_applicability,
|
|
29
|
+
itemFamilyID: payload.item_family_id,
|
|
30
|
+
itemType: payload.item_type,
|
|
31
|
+
metadata: payload.metadata,
|
|
32
|
+
metered: payload.metered,
|
|
33
|
+
name: payload.name,
|
|
34
|
+
period: payload.period,
|
|
35
|
+
periodUnit: payload.period_unit,
|
|
36
|
+
productCode: payload.product_code,
|
|
37
|
+
price: payload.price != null
|
|
38
|
+
? (0, amount_1.toAmount)(payload.price, currencyCode, currencySymbol)
|
|
39
|
+
: undefined,
|
|
40
|
+
subFamilies: payload.sub_families?.map(productPayload_1.mapInvoicingProductPayloadToState),
|
|
41
|
+
status: payload.status,
|
|
42
|
+
tiers: payload.tiers?.map((tier) => (0, productPayload_1.mapInvoicingPlanTierPayloadToState)(tier, currencyCode, currencySymbol)),
|
|
43
|
+
trialPeriod: payload.trial_period,
|
|
44
|
+
trialPeriodUnit: payload.trial_period_unit,
|
|
45
|
+
type: payload.type,
|
|
46
|
+
unit: payload.unit,
|
|
47
|
+
updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
|
|
48
|
+
usageCalculation: payload.usage_calculation,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
exports.mapInvoicingPlanPayloadToState = mapInvoicingPlanPayloadToState;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UpdateType } from '../../../commonStateTypes/common';
|
|
2
|
+
import { InvoicingProductPayload } from '../product/productPayload';
|
|
3
|
+
import { InvoicingProduct } from '../product/productState';
|
|
4
|
+
import { InvoicingPlanPayload } from './planPayload';
|
|
5
|
+
import { InvoicingPlanState } from './planState';
|
|
6
|
+
export declare const initialState: InvoicingPlanState;
|
|
7
|
+
export declare const updateInvoicingPlans: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InvoicingPlanPayload[], updateType?: UpdateType | undefined], InvoicingPlanPayload[], "invoicingPlan/updateInvoicingPlans", never, {
|
|
8
|
+
updateType: UpdateType;
|
|
9
|
+
}>, mergeInvoicingPlanSubFamily: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[planId: string, subFamilyPayload: InvoicingProductPayload], {
|
|
10
|
+
planId: string;
|
|
11
|
+
subFamily: InvoicingProduct;
|
|
12
|
+
}, "invoicingPlan/mergeInvoicingPlanSubFamily", never, never>, removeInvoicingPlan: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingPlan/removeInvoicingPlan">;
|
|
13
|
+
declare const _default: import("redux").Reducer<InvoicingPlanState>;
|
|
14
|
+
export default _default;
|
package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogReducer.js → plan/planReducer.js}
RENAMED
|
@@ -4,47 +4,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.removeInvoicingPlan = exports.mergeInvoicingPlanSubFamily = exports.updateInvoicingPlans = exports.initialState = void 0;
|
|
8
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
9
|
const assignWith_1 = __importDefault(require("lodash/assignWith"));
|
|
10
10
|
const rootActions_1 = require("../../../rootActions");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const productPayload_1 = require("../product/productPayload");
|
|
12
|
+
const planPayload_1 = require("./planPayload");
|
|
13
|
+
exports.initialState = { planByID: {} };
|
|
14
|
+
const plan = (0, toolkit_1.createSlice)({
|
|
15
|
+
name: 'invoicingPlan',
|
|
15
16
|
initialState: exports.initialState,
|
|
16
17
|
reducers: {
|
|
17
|
-
|
|
18
|
+
updateInvoicingPlans: {
|
|
18
19
|
reducer(draft, action) {
|
|
19
|
-
doUpdateInvoicingPlans(draft.
|
|
20
|
+
doUpdateInvoicingPlans(draft.planByID, action.payload, action.meta.updateType);
|
|
20
21
|
},
|
|
21
22
|
prepare(payload, updateType = 'replace') {
|
|
22
23
|
return { payload, meta: { updateType } };
|
|
23
24
|
},
|
|
24
25
|
},
|
|
25
|
-
|
|
26
|
-
delete draft.
|
|
26
|
+
removeInvoicingPlan(draft, action) {
|
|
27
|
+
delete draft.planByID[action.payload];
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
+
mergeInvoicingPlanSubFamily: {
|
|
29
30
|
reducer(draft, action) {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
31
|
+
const plan = draft.planByID[action.payload.planId];
|
|
32
|
+
if (plan == null) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
|
-
const existing =
|
|
35
|
+
const existing = plan.subFamilies ?? [];
|
|
35
36
|
const index = existing.findIndex((subFamily) => subFamily.id === action.payload.subFamily.id);
|
|
36
|
-
|
|
37
|
+
plan.subFamilies =
|
|
37
38
|
index >= 0
|
|
38
39
|
? existing.map((subFamily, subFamilyIndex) => subFamilyIndex === index
|
|
39
40
|
? { ...subFamily, ...action.payload.subFamily }
|
|
40
41
|
: subFamily)
|
|
41
42
|
: [...existing, action.payload.subFamily];
|
|
42
43
|
},
|
|
43
|
-
prepare(
|
|
44
|
+
prepare(planId, subFamilyPayload) {
|
|
44
45
|
return {
|
|
45
46
|
payload: {
|
|
46
|
-
|
|
47
|
-
subFamily: (0,
|
|
47
|
+
planId,
|
|
48
|
+
subFamily: (0, productPayload_1.mapInvoicingProductPayloadToState)(subFamilyPayload),
|
|
48
49
|
},
|
|
49
50
|
};
|
|
50
51
|
},
|
|
@@ -56,14 +57,14 @@ const invoicingCatalog = (0, toolkit_1.createSlice)({
|
|
|
56
57
|
});
|
|
57
58
|
},
|
|
58
59
|
});
|
|
59
|
-
_a =
|
|
60
|
-
exports.default =
|
|
60
|
+
_a = plan.actions, exports.updateInvoicingPlans = _a.updateInvoicingPlans, exports.mergeInvoicingPlanSubFamily = _a.mergeInvoicingPlanSubFamily, exports.removeInvoicingPlan = _a.removeInvoicingPlan;
|
|
61
|
+
exports.default = plan.reducer;
|
|
61
62
|
/**
|
|
62
63
|
* Helper functions.
|
|
63
64
|
*/
|
|
64
65
|
function doUpdateInvoicingPlans(draft, payload, updateType) {
|
|
65
66
|
payload.forEach((planPayload) => {
|
|
66
|
-
const latestPlan = (0,
|
|
67
|
+
const latestPlan = (0, planPayload_1.mapInvoicingPlanPayloadToState)(planPayload);
|
|
67
68
|
if (latestPlan.id in draft && updateType === 'merge') {
|
|
68
69
|
(0, assignWith_1.default)(draft[latestPlan.id], latestPlan, (objValue, srcValue) => srcValue == null ? objValue : srcValue);
|
|
69
70
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
2
|
import { ID } from '../../../commonStateTypes/common';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
3
|
+
import { InvoicingProduct } from '../product/productState';
|
|
4
|
+
import { InvoicingPlan, InvoicingPlanState } from './planState';
|
|
5
|
+
export declare function getInvoicingPlansByIds(planState: InvoicingPlanState, ids: ID[]): InvoicingPlan[];
|
|
6
|
+
export declare function getInvoicingPlanById(planState: InvoicingPlanState, id: ID): InvoicingPlan | undefined;
|
|
6
7
|
/**
|
|
7
8
|
* The amount to show for one price point: what the service computed for a
|
|
8
9
|
* single unit. `price` is only a fallback for responses predating
|
|
@@ -10,7 +11,7 @@ export declare function getInvoicingCatalogItemById(catalogState: InvoicingCatal
|
|
|
10
11
|
* and stairstep model, whose configured price is legitimately zero because the
|
|
11
12
|
* money lives in its tiers.
|
|
12
13
|
*/
|
|
13
|
-
export declare const invoicingPricePointDisplayAmount: (pricePoint:
|
|
14
|
+
export declare const invoicingPricePointDisplayAmount: (pricePoint: InvoicingProduct) => Amount | undefined;
|
|
14
15
|
/**
|
|
15
16
|
* The lowest amount a catalog item can be bought at: the smallest single-unit
|
|
16
17
|
* price across its active price points.
|
|
@@ -20,4 +21,4 @@ export declare const invoicingPricePointDisplayAmount: (pricePoint: InvoicingCat
|
|
|
20
21
|
* points are priced in different currencies, where the smallest number is not
|
|
21
22
|
* the lowest price. A zero is a real price and wins on its merits.
|
|
22
23
|
*/
|
|
23
|
-
export declare const
|
|
24
|
+
export declare const getLowestInvoicingPlanPricePointAmount: (plan: InvoicingPlan | undefined) => Amount | undefined;
|
package/lib/entity/invoicing/{invoicingCatalog/invoicingCatalogSelector.js → plan/planSelector.js}
RENAMED
|
@@ -3,18 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
6
|
+
exports.getLowestInvoicingPlanPricePointAmount = exports.invoicingPricePointDisplayAmount = void 0;
|
|
7
|
+
exports.getInvoicingPlansByIds = getInvoicingPlansByIds;
|
|
8
|
+
exports.getInvoicingPlanById = getInvoicingPlanById;
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
.map((id) =>
|
|
10
|
+
function getInvoicingPlansByIds(planState, ids) {
|
|
11
|
+
const plans = ids
|
|
12
|
+
.map((id) => getInvoicingPlanById(planState, id))
|
|
13
13
|
.filter((value) => value != null);
|
|
14
|
-
return
|
|
14
|
+
return plans;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return (0, get_1.default)(
|
|
16
|
+
function getInvoicingPlanById(planState, id) {
|
|
17
|
+
return (0, get_1.default)(planState.planByID, id);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* A price point counts while it is active. A missing status is treated as
|
|
@@ -39,8 +39,8 @@ exports.invoicingPricePointDisplayAmount = invoicingPricePointDisplayAmount;
|
|
|
39
39
|
* points are priced in different currencies, where the smallest number is not
|
|
40
40
|
* the lowest price. A zero is a real price and wins on its merits.
|
|
41
41
|
*/
|
|
42
|
-
const
|
|
43
|
-
const amounts = (
|
|
42
|
+
const getLowestInvoicingPlanPricePointAmount = (plan) => {
|
|
43
|
+
const amounts = (plan?.subFamilies ?? [])
|
|
44
44
|
.filter(isActiveInvoicingPricePoint)
|
|
45
45
|
.map(exports.invoicingPricePointDisplayAmount)
|
|
46
46
|
.filter((amount) => amount != null);
|
|
@@ -56,4 +56,4 @@ const getLowestInvoicingCatalogPricePointAmount = (item) => {
|
|
|
56
56
|
// to visit last.
|
|
57
57
|
return amounts.reduce((lowest, amount) => amount.amount < lowest.amount ? amount : lowest);
|
|
58
58
|
};
|
|
59
|
-
exports.
|
|
59
|
+
exports.getLowestInvoicingPlanPricePointAmount = getLowestInvoicingPlanPricePointAmount;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
|
+
import { ID } from '../../../commonStateTypes/common';
|
|
3
|
+
import { ZeniDate } from '../../../zeniDayJS';
|
|
4
|
+
import { InvoicingPlanTier, InvoicingProduct } from '../product/productState';
|
|
5
|
+
export interface InvoicingPlan {
|
|
6
|
+
id: ID;
|
|
7
|
+
applicableItems?: ID[];
|
|
8
|
+
archivedAt?: ZeniDate;
|
|
9
|
+
billingCycles?: number;
|
|
10
|
+
createdAt?: ZeniDate;
|
|
11
|
+
currencyCode?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
enabledForCheckout?: boolean;
|
|
14
|
+
enabledInPortal?: boolean;
|
|
15
|
+
externalId?: string;
|
|
16
|
+
externalName?: string;
|
|
17
|
+
giftClaimRedirectUrl?: string;
|
|
18
|
+
includedInMrr?: boolean;
|
|
19
|
+
isGiftable?: boolean;
|
|
20
|
+
isShippable?: boolean;
|
|
21
|
+
itemApplicability?: string;
|
|
22
|
+
itemFamilyID?: ID;
|
|
23
|
+
itemType?: string;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
metered?: boolean;
|
|
26
|
+
name?: string;
|
|
27
|
+
period?: number;
|
|
28
|
+
periodUnit?: string;
|
|
29
|
+
price?: Amount;
|
|
30
|
+
productCode?: string;
|
|
31
|
+
status?: string;
|
|
32
|
+
subFamilies?: InvoicingProduct[];
|
|
33
|
+
tiers?: InvoicingPlanTier[];
|
|
34
|
+
trialPeriod?: number;
|
|
35
|
+
trialPeriodUnit?: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
unit?: string;
|
|
38
|
+
updatedAt?: ZeniDate;
|
|
39
|
+
usageCalculation?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface InvoicingPlanState {
|
|
42
|
+
planByID: Record<ID, InvoicingPlan>;
|
|
43
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountBasePayload } from '../../account/accountPayload';
|
|
2
2
|
import { ClassBasePayload } from '../../class/classPayload';
|
|
3
|
-
import {
|
|
4
|
-
export interface
|
|
3
|
+
import { InvoicingPlanTier, InvoicingProduct } from './productState';
|
|
4
|
+
export interface InvoicingPlanTierPayload {
|
|
5
5
|
price: number;
|
|
6
6
|
starting_unit: number;
|
|
7
7
|
ending_unit?: number;
|
|
@@ -24,7 +24,7 @@ export interface InvoicingAccountingDetailPayload {
|
|
|
24
24
|
accounting_code?: string;
|
|
25
25
|
sku?: string;
|
|
26
26
|
}
|
|
27
|
-
export interface
|
|
27
|
+
export interface InvoicingProductPayload {
|
|
28
28
|
id: string;
|
|
29
29
|
accounting_detail?: InvoicingAccountingDetailPayload;
|
|
30
30
|
applicable_items?: string[];
|
|
@@ -69,7 +69,7 @@ export interface InvoicingCatalogPricePointPayload {
|
|
|
69
69
|
show_description_in_quotes?: boolean;
|
|
70
70
|
status?: string;
|
|
71
71
|
subscription_count?: number;
|
|
72
|
-
tiers?:
|
|
72
|
+
tiers?: InvoicingPlanTierPayload[];
|
|
73
73
|
trial_end_action?: string;
|
|
74
74
|
trial_period?: number;
|
|
75
75
|
trial_period_unit?: string;
|
|
@@ -79,43 +79,5 @@ export interface InvoicingCatalogPricePointPayload {
|
|
|
79
79
|
usage_accumulation_reset_frequency?: string;
|
|
80
80
|
usage_calculation?: string;
|
|
81
81
|
}
|
|
82
|
-
export declare const
|
|
83
|
-
export declare const
|
|
84
|
-
export interface InvoicingCatalogItemPayload {
|
|
85
|
-
id: string;
|
|
86
|
-
applicable_items?: string[];
|
|
87
|
-
archived_at?: string;
|
|
88
|
-
billing_cycles?: number;
|
|
89
|
-
created_at?: string;
|
|
90
|
-
currency_code?: string;
|
|
91
|
-
currency_symbol?: string;
|
|
92
|
-
description?: string;
|
|
93
|
-
enabled_for_checkout?: boolean;
|
|
94
|
-
enabled_in_portal?: boolean;
|
|
95
|
-
external_id?: string;
|
|
96
|
-
external_name?: string;
|
|
97
|
-
gift_claim_redirect_url?: string;
|
|
98
|
-
included_in_mrr?: boolean;
|
|
99
|
-
is_giftable?: boolean;
|
|
100
|
-
is_shippable?: boolean;
|
|
101
|
-
item_applicability?: string;
|
|
102
|
-
item_family_id?: string;
|
|
103
|
-
item_type?: string;
|
|
104
|
-
metadata?: Record<string, unknown>;
|
|
105
|
-
metered?: boolean;
|
|
106
|
-
name?: string;
|
|
107
|
-
period?: number;
|
|
108
|
-
period_unit?: string;
|
|
109
|
-
price?: number;
|
|
110
|
-
product_code?: string;
|
|
111
|
-
status?: string;
|
|
112
|
-
sub_families?: InvoicingCatalogPricePointPayload[];
|
|
113
|
-
tiers?: InvoicingCatalogTierPayload[];
|
|
114
|
-
trial_period?: number;
|
|
115
|
-
trial_period_unit?: string;
|
|
116
|
-
type?: string;
|
|
117
|
-
unit?: string;
|
|
118
|
-
updated_at?: string;
|
|
119
|
-
usage_calculation?: string;
|
|
120
|
-
}
|
|
121
|
-
export declare const mapInvoicingCatalogItemPayloadToState: (payload: InvoicingCatalogItemPayload) => InvoicingCatalogItem;
|
|
82
|
+
export declare const mapInvoicingPlanTierPayloadToState: (payload: InvoicingPlanTierPayload, currencyCode: string, currencySymbol: string) => InvoicingPlanTier;
|
|
83
|
+
export declare const mapInvoicingProductPayloadToState: (payload: InvoicingProductPayload) => InvoicingProduct;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mapInvoicingProductPayloadToState = exports.mapInvoicingPlanTierPayloadToState = void 0;
|
|
4
4
|
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
5
|
const currencyHelper_1 = require("../../../commonStateTypes/currencyHelper");
|
|
6
6
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
7
7
|
const invoicingCommonPayload_1 = require("../invoicingCommonPayload");
|
|
8
8
|
// ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
|
|
9
|
-
const
|
|
9
|
+
const mapInvoicingPlanTierPayloadToState = (payload, currencyCode, currencySymbol) => ({
|
|
10
10
|
price: (0, amount_1.toAmount)(payload.price, currencyCode, currencySymbol),
|
|
11
11
|
startingUnit: payload.starting_unit,
|
|
12
12
|
endingUnit: payload.ending_unit,
|
|
13
13
|
packageSize: payload.package_size,
|
|
14
14
|
pricingType: payload.pricing_type,
|
|
15
15
|
});
|
|
16
|
-
exports.
|
|
16
|
+
exports.mapInvoicingPlanTierPayloadToState = mapInvoicingPlanTierPayloadToState;
|
|
17
17
|
const mapInvoicingAccountingDetailPayloadToState = (payload) => ({
|
|
18
18
|
// The QuickBooks id first in both, for the reason `firstSelectableInvoicingId`
|
|
19
19
|
// documents: the form's pickers are keyed on it, so reading the internal id
|
|
@@ -33,7 +33,7 @@ const mapInvoicingAccountingDetailPayloadToState = (payload) => ({
|
|
|
33
33
|
]),
|
|
34
34
|
sku: payload.sku,
|
|
35
35
|
});
|
|
36
|
-
const
|
|
36
|
+
const mapInvoicingProductPayloadToState = (payload) => {
|
|
37
37
|
const currencyCode = payload.currency_code ?? currencyHelper_1.defaultCustomerCurrency.currencyCode;
|
|
38
38
|
const currencySymbol = payload.currency_symbol ?? currencyHelper_1.defaultCustomerCurrency.currencySymbol;
|
|
39
39
|
return {
|
|
@@ -80,7 +80,7 @@ const mapInvoicingCatalogPricePointPayloadToState = (payload) => {
|
|
|
80
80
|
showDescriptionInQuotes: payload.show_description_in_quotes,
|
|
81
81
|
status: payload.status,
|
|
82
82
|
subscriptionCount: payload.subscription_count ?? 0,
|
|
83
|
-
tiers: payload.tiers?.map((tier) => (0, exports.
|
|
83
|
+
tiers: payload.tiers?.map((tier) => (0, exports.mapInvoicingPlanTierPayloadToState)(tier, currencyCode, currencySymbol)),
|
|
84
84
|
trialEndAction: payload.trial_end_action,
|
|
85
85
|
trialPeriod: payload.trial_period,
|
|
86
86
|
trialPeriodUnit: payload.trial_period_unit,
|
|
@@ -91,48 +91,4 @@ const mapInvoicingCatalogPricePointPayloadToState = (payload) => {
|
|
|
91
91
|
usageCalculation: payload.usage_calculation,
|
|
92
92
|
};
|
|
93
93
|
};
|
|
94
|
-
exports.
|
|
95
|
-
// ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
|
|
96
|
-
const mapInvoicingCatalogItemPayloadToState = (payload) => {
|
|
97
|
-
const currencyCode = payload.currency_code ?? currencyHelper_1.defaultCustomerCurrency.currencyCode;
|
|
98
|
-
const currencySymbol = payload.currency_symbol ?? currencyHelper_1.defaultCustomerCurrency.currencySymbol;
|
|
99
|
-
return {
|
|
100
|
-
id: payload.id,
|
|
101
|
-
applicableItems: payload.applicable_items,
|
|
102
|
-
archivedAt: payload.archived_at != null ? (0, zeniDayJS_1.date)(payload.archived_at) : undefined,
|
|
103
|
-
billingCycles: payload.billing_cycles,
|
|
104
|
-
createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
|
|
105
|
-
currencyCode: payload.currency_code,
|
|
106
|
-
description: payload.description,
|
|
107
|
-
enabledForCheckout: payload.enabled_for_checkout,
|
|
108
|
-
enabledInPortal: payload.enabled_in_portal,
|
|
109
|
-
externalId: payload.external_id,
|
|
110
|
-
externalName: payload.external_name,
|
|
111
|
-
giftClaimRedirectUrl: payload.gift_claim_redirect_url,
|
|
112
|
-
includedInMrr: payload.included_in_mrr,
|
|
113
|
-
isGiftable: payload.is_giftable,
|
|
114
|
-
isShippable: payload.is_shippable,
|
|
115
|
-
itemApplicability: payload.item_applicability,
|
|
116
|
-
itemFamilyID: payload.item_family_id,
|
|
117
|
-
itemType: payload.item_type,
|
|
118
|
-
metadata: payload.metadata,
|
|
119
|
-
metered: payload.metered,
|
|
120
|
-
name: payload.name,
|
|
121
|
-
period: payload.period,
|
|
122
|
-
periodUnit: payload.period_unit,
|
|
123
|
-
productCode: payload.product_code,
|
|
124
|
-
price: payload.price != null
|
|
125
|
-
? (0, amount_1.toAmount)(payload.price, currencyCode, currencySymbol)
|
|
126
|
-
: undefined,
|
|
127
|
-
subFamilies: payload.sub_families?.map(exports.mapInvoicingCatalogPricePointPayloadToState),
|
|
128
|
-
status: payload.status,
|
|
129
|
-
tiers: payload.tiers?.map((tier) => (0, exports.mapInvoicingCatalogTierPayloadToState)(tier, currencyCode, currencySymbol)),
|
|
130
|
-
trialPeriod: payload.trial_period,
|
|
131
|
-
trialPeriodUnit: payload.trial_period_unit,
|
|
132
|
-
type: payload.type,
|
|
133
|
-
unit: payload.unit,
|
|
134
|
-
updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
|
|
135
|
-
usageCalculation: payload.usage_calculation,
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
exports.mapInvoicingCatalogItemPayloadToState = mapInvoicingCatalogItemPayloadToState;
|
|
94
|
+
exports.mapInvoicingProductPayloadToState = mapInvoicingProductPayloadToState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UpdateType } from '../../../commonStateTypes/common';
|
|
2
|
+
import { InvoicingProductPayload } from './productPayload';
|
|
3
|
+
import { InvoicingProductState } from './productState';
|
|
4
|
+
export declare const initialState: InvoicingProductState;
|
|
5
|
+
export declare const updateInvoicingProducts: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InvoicingProductPayload[], updateType?: UpdateType | undefined], InvoicingProductPayload[], "invoicingProduct/updateInvoicingProducts", never, {
|
|
6
|
+
updateType: UpdateType;
|
|
7
|
+
}>, removeInvoicingProduct: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingProduct/removeInvoicingProduct">;
|
|
8
|
+
declare const _default: import("redux").Reducer<InvoicingProductState>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.removeInvoicingProduct = exports.updateInvoicingProducts = exports.initialState = void 0;
|
|
8
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
+
const assignWith_1 = __importDefault(require("lodash/assignWith"));
|
|
10
|
+
const rootActions_1 = require("../../../rootActions");
|
|
11
|
+
const productPayload_1 = require("./productPayload");
|
|
12
|
+
exports.initialState = { productByID: {} };
|
|
13
|
+
const product = (0, toolkit_1.createSlice)({
|
|
14
|
+
name: 'invoicingProduct',
|
|
15
|
+
initialState: exports.initialState,
|
|
16
|
+
reducers: {
|
|
17
|
+
updateInvoicingProducts: {
|
|
18
|
+
reducer(draft, action) {
|
|
19
|
+
doUpdateInvoicingProducts(draft.productByID, action.payload, action.meta.updateType);
|
|
20
|
+
},
|
|
21
|
+
prepare(payload, updateType = 'replace') {
|
|
22
|
+
return { payload, meta: { updateType } };
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
removeInvoicingProduct(draft, action) {
|
|
26
|
+
delete draft.productByID[action.payload];
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
extraReducers: (builder) => {
|
|
30
|
+
builder.addCase(rootActions_1.clearAll, (draft) => {
|
|
31
|
+
Object.assign(draft, exports.initialState);
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
_a = product.actions, exports.updateInvoicingProducts = _a.updateInvoicingProducts, exports.removeInvoicingProduct = _a.removeInvoicingProduct;
|
|
36
|
+
exports.default = product.reducer;
|
|
37
|
+
/**
|
|
38
|
+
* Helper functions.
|
|
39
|
+
*/
|
|
40
|
+
function doUpdateInvoicingProducts(draft, payload, updateType) {
|
|
41
|
+
payload.forEach((productPayload) => {
|
|
42
|
+
const latestProduct = (0, productPayload_1.mapInvoicingProductPayloadToState)(productPayload);
|
|
43
|
+
if (latestProduct.id in draft && updateType === 'merge') {
|
|
44
|
+
(0, assignWith_1.default)(draft[latestProduct.id], latestProduct, (objValue, srcValue) => (srcValue == null ? objValue : srcValue));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
draft[latestProduct.id] = latestProduct;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ID } from '../../../commonStateTypes/common';
|
|
2
|
+
import { InvoicingProduct, InvoicingProductState } from './productState';
|
|
3
|
+
export declare function getInvoicingProductsByIds(productState: InvoicingProductState, ids: ID[]): InvoicingProduct[];
|
|
4
|
+
export declare function getInvoicingProductById(productState: InvoicingProductState, id: ID): InvoicingProduct | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getInvoicingProductsByIds = getInvoicingProductsByIds;
|
|
7
|
+
exports.getInvoicingProductById = getInvoicingProductById;
|
|
8
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
function getInvoicingProductsByIds(productState, ids) {
|
|
10
|
+
const products = ids
|
|
11
|
+
.map((id) => getInvoicingProductById(productState, id))
|
|
12
|
+
.filter((value) => value != null);
|
|
13
|
+
return products;
|
|
14
|
+
}
|
|
15
|
+
function getInvoicingProductById(productState, id) {
|
|
16
|
+
return (0, get_1.default)(productState.productByID, id);
|
|
17
|
+
}
|