@zeniai/client-epic-state 5.2.68 → 5.2.69-beta0MM
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/{product/productPayload.d.ts → invoicingCatalog/invoicingCatalogPayload.d.ts} +44 -6
- package/lib/entity/invoicing/{product/productPayload.js → invoicingCatalog/invoicingCatalogPayload.js} +50 -6
- package/lib/entity/invoicing/invoicingCatalog/invoicingCatalogReducer.d.ts +12 -0
- package/lib/entity/invoicing/{plan/planReducer.js → invoicingCatalog/invoicingCatalogReducer.js} +20 -21
- package/lib/entity/invoicing/{plan/planSelector.d.ts → invoicingCatalog/invoicingCatalogSelector.d.ts} +5 -6
- package/lib/entity/invoicing/{plan/planSelector.js → invoicingCatalog/invoicingCatalogSelector.js} +12 -12
- package/lib/entity/invoicing/{product/productState.d.ts → invoicingCatalog/invoicingCatalogState.d.ts} +42 -6
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +1 -0
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -0
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +4 -4
- package/lib/esm/entity/invoicing/{product/productPayload.js → invoicingCatalog/invoicingCatalogPayload.js} +46 -3
- package/lib/esm/entity/invoicing/{plan/planReducer.js → invoicingCatalog/invoicingCatalogReducer.js} +19 -20
- package/lib/esm/entity/invoicing/{plan/planSelector.js → invoicingCatalog/invoicingCatalogSelector.js} +8 -8
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +1 -0
- package/lib/esm/index.js +2 -4
- package/lib/esm/reducer.js +4 -7
- package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +19 -16
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +5 -3
- 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 +3 -7
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +2 -2
- 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 +4 -4
- package/lib/index.d.ts +5 -8
- package/lib/index.js +9 -15
- package/lib/reducer.d.ts +1 -2
- package/lib/reducer.js +4 -7
- package/lib/rootStateTypes.d.ts +3 -5
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +2 -1
- package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +19 -16
- package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +2 -3
- 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 +8 -9
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +2 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +5 -3
- 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 +3 -4
- 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 +2 -3
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/runInvoicingCatalogProductActionEpic.js +4 -4
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +2 -3
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -7
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +2 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +2 -2
- 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 +4 -5
- package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.js +4 -4
- package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewState.d.ts +1 -1
- 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/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/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/plan/planPayload.d.ts +0 -40
- package/lib/entity/invoicing/plan/planPayload.js +0 -51
- package/lib/entity/invoicing/plan/planReducer.d.ts +0 -14
- package/lib/entity/invoicing/plan/planState.d.ts +0 -43
- package/lib/entity/invoicing/product/productReducer.d.ts +0 -9
- package/lib/entity/invoicing/product/productReducer.js +0 -50
- package/lib/entity/invoicing/product/productSelector.d.ts +0 -4
- package/lib/entity/invoicing/product/productSelector.js +0 -17
- package/lib/entity/invoicing/product/productState.js +0 -2
- package/lib/esm/entity/invoicing/plan/planPayload.js +0 -47
- package/lib/esm/entity/invoicing/product/productReducer.js +0 -43
- package/lib/esm/entity/invoicing/product/productSelector.js +0 -10
- package/lib/esm/entity/invoicing/product/productState.js +0 -1
- /package/lib/entity/invoicing/{plan/planState.js → invoicingCatalog/invoicingCatalogState.js} +0 -0
- /package/lib/esm/entity/invoicing/{plan/planState.js → invoicingCatalog/invoicingCatalogState.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) => "agent" | "user";
|
|
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) => "agent" | "user" | 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) => "draft" | "paid" | "pending_approval" | "scheduled";
|
|
112
112
|
export type BillStageCodeType = ReturnType<typeof toBillStageCodeType>;
|
|
113
|
-
declare const toBillPaymentStatusCodeType: (v: string) => "failed" | "
|
|
113
|
+
declare const toBillPaymentStatusCodeType: (v: string) => "failed" | "posted" | "cancelled" | "paid" | "returned" | "processing" | "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) => "canceled" | "paid" | "authorized" | "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" | "canceled" | "rejected" | "returned" | "clearing" | "sent" | undefined;
|
|
32
32
|
export type DepositTransactionStatusCode = ReturnType<typeof toDepositTransactionStatusCode>;
|
|
33
33
|
export {};
|
|
@@ -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 { InvoicingCatalogItem, InvoicingCatalogPricePoint, InvoicingCatalogTier } from './invoicingCatalogState';
|
|
4
|
+
export interface InvoicingCatalogTierPayload {
|
|
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 InvoicingCatalogPricePointPayload {
|
|
28
28
|
id: string;
|
|
29
29
|
accounting_detail?: InvoicingAccountingDetailPayload;
|
|
30
30
|
applicable_items?: string[];
|
|
@@ -69,7 +69,7 @@ export interface InvoicingProductPayload {
|
|
|
69
69
|
show_description_in_quotes?: boolean;
|
|
70
70
|
status?: string;
|
|
71
71
|
subscription_count?: number;
|
|
72
|
-
tiers?:
|
|
72
|
+
tiers?: InvoicingCatalogTierPayload[];
|
|
73
73
|
trial_end_action?: string;
|
|
74
74
|
trial_period?: number;
|
|
75
75
|
trial_period_unit?: string;
|
|
@@ -79,5 +79,43 @@ export interface InvoicingProductPayload {
|
|
|
79
79
|
usage_accumulation_reset_frequency?: string;
|
|
80
80
|
usage_calculation?: string;
|
|
81
81
|
}
|
|
82
|
-
export declare const
|
|
83
|
-
export declare const
|
|
82
|
+
export declare const mapInvoicingCatalogTierPayloadToState: (payload: InvoicingCatalogTierPayload, currencyCode: string, currencySymbol: string) => InvoicingCatalogTier;
|
|
83
|
+
export declare const mapInvoicingCatalogPricePointPayloadToState: (payload: InvoicingCatalogPricePointPayload) => InvoicingCatalogPricePoint;
|
|
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;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mapInvoicingCatalogItemPayloadToState = exports.mapInvoicingCatalogPricePointPayloadToState = exports.mapInvoicingCatalogTierPayloadToState = 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 mapInvoicingCatalogTierPayloadToState = (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.mapInvoicingCatalogTierPayloadToState = mapInvoicingCatalogTierPayloadToState;
|
|
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 mapInvoicingCatalogPricePointPayloadToState = (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 mapInvoicingProductPayloadToState = (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.mapInvoicingCatalogTierPayloadToState)(tier, currencyCode, currencySymbol)),
|
|
84
84
|
trialEndAction: payload.trial_end_action,
|
|
85
85
|
trialPeriod: payload.trial_period,
|
|
86
86
|
trialPeriodUnit: payload.trial_period_unit,
|
|
@@ -91,4 +91,48 @@ const mapInvoicingProductPayloadToState = (payload) => {
|
|
|
91
91
|
usageCalculation: payload.usage_calculation,
|
|
92
92
|
};
|
|
93
93
|
};
|
|
94
|
-
exports.
|
|
94
|
+
exports.mapInvoicingCatalogPricePointPayloadToState = mapInvoicingCatalogPricePointPayloadToState;
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UpdateType } from '../../../commonStateTypes/common';
|
|
2
|
+
import { InvoicingCatalogItemPayload, InvoicingCatalogPricePointPayload } from './invoicingCatalogPayload';
|
|
3
|
+
import { InvoicingCatalogPricePoint, InvoicingCatalogState } from './invoicingCatalogState';
|
|
4
|
+
export declare const initialState: InvoicingCatalogState;
|
|
5
|
+
export declare const updateInvoicingCatalogItems: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InvoicingCatalogItemPayload[], updateType?: UpdateType | undefined], InvoicingCatalogItemPayload[], "invoicingCatalog/updateInvoicingCatalogItems", never, {
|
|
6
|
+
updateType: UpdateType;
|
|
7
|
+
}>, mergeInvoicingCatalogPricePoint: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[itemId: string, subFamilyPayload: InvoicingCatalogPricePointPayload], {
|
|
8
|
+
itemId: string;
|
|
9
|
+
subFamily: InvoicingCatalogPricePoint;
|
|
10
|
+
}, "invoicingCatalog/mergeInvoicingCatalogPricePoint", never, never>, removeInvoicingCatalogItem: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingCatalog/removeInvoicingCatalogItem">;
|
|
11
|
+
declare const _default: import("redux").Reducer<InvoicingCatalogState>;
|
|
12
|
+
export default _default;
|
package/lib/entity/invoicing/{plan/planReducer.js → invoicingCatalog/invoicingCatalogReducer.js}
RENAMED
|
@@ -4,48 +4,47 @@ 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.removeInvoicingCatalogItem = exports.mergeInvoicingCatalogPricePoint = exports.updateInvoicingCatalogItems = 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
|
-
|
|
15
|
-
name: 'invoicingPlan',
|
|
11
|
+
const invoicingCatalogPayload_1 = require("./invoicingCatalogPayload");
|
|
12
|
+
exports.initialState = { itemByID: {} };
|
|
13
|
+
const invoicingCatalog = (0, toolkit_1.createSlice)({
|
|
14
|
+
name: 'invoicingCatalog',
|
|
16
15
|
initialState: exports.initialState,
|
|
17
16
|
reducers: {
|
|
18
|
-
|
|
17
|
+
updateInvoicingCatalogItems: {
|
|
19
18
|
reducer(draft, action) {
|
|
20
|
-
doUpdateInvoicingPlans(draft.
|
|
19
|
+
doUpdateInvoicingPlans(draft.itemByID, action.payload, action.meta.updateType);
|
|
21
20
|
},
|
|
22
21
|
prepare(payload, updateType = 'replace') {
|
|
23
22
|
return { payload, meta: { updateType } };
|
|
24
23
|
},
|
|
25
24
|
},
|
|
26
|
-
|
|
27
|
-
delete draft.
|
|
25
|
+
removeInvoicingCatalogItem(draft, action) {
|
|
26
|
+
delete draft.itemByID[action.payload];
|
|
28
27
|
},
|
|
29
|
-
|
|
28
|
+
mergeInvoicingCatalogPricePoint: {
|
|
30
29
|
reducer(draft, action) {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
30
|
+
const item = draft.itemByID[action.payload.itemId];
|
|
31
|
+
if (item == null) {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
|
-
const existing =
|
|
34
|
+
const existing = item.subFamilies ?? [];
|
|
36
35
|
const index = existing.findIndex((subFamily) => subFamily.id === action.payload.subFamily.id);
|
|
37
|
-
|
|
36
|
+
item.subFamilies =
|
|
38
37
|
index >= 0
|
|
39
38
|
? existing.map((subFamily, subFamilyIndex) => subFamilyIndex === index
|
|
40
39
|
? { ...subFamily, ...action.payload.subFamily }
|
|
41
40
|
: subFamily)
|
|
42
41
|
: [...existing, action.payload.subFamily];
|
|
43
42
|
},
|
|
44
|
-
prepare(
|
|
43
|
+
prepare(itemId, subFamilyPayload) {
|
|
45
44
|
return {
|
|
46
45
|
payload: {
|
|
47
|
-
|
|
48
|
-
subFamily: (0,
|
|
46
|
+
itemId,
|
|
47
|
+
subFamily: (0, invoicingCatalogPayload_1.mapInvoicingCatalogPricePointPayloadToState)(subFamilyPayload),
|
|
49
48
|
},
|
|
50
49
|
};
|
|
51
50
|
},
|
|
@@ -57,14 +56,14 @@ const plan = (0, toolkit_1.createSlice)({
|
|
|
57
56
|
});
|
|
58
57
|
},
|
|
59
58
|
});
|
|
60
|
-
_a =
|
|
61
|
-
exports.default =
|
|
59
|
+
_a = invoicingCatalog.actions, exports.updateInvoicingCatalogItems = _a.updateInvoicingCatalogItems, exports.mergeInvoicingCatalogPricePoint = _a.mergeInvoicingCatalogPricePoint, exports.removeInvoicingCatalogItem = _a.removeInvoicingCatalogItem;
|
|
60
|
+
exports.default = invoicingCatalog.reducer;
|
|
62
61
|
/**
|
|
63
62
|
* Helper functions.
|
|
64
63
|
*/
|
|
65
64
|
function doUpdateInvoicingPlans(draft, payload, updateType) {
|
|
66
65
|
payload.forEach((planPayload) => {
|
|
67
|
-
const latestPlan = (0,
|
|
66
|
+
const latestPlan = (0, invoicingCatalogPayload_1.mapInvoicingCatalogItemPayloadToState)(planPayload);
|
|
68
67
|
if (latestPlan.id in draft && updateType === 'merge') {
|
|
69
68
|
(0, assignWith_1.default)(draft[latestPlan.id], latestPlan, (objValue, srcValue) => srcValue == null ? objValue : srcValue);
|
|
70
69
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
2
|
import { ID } from '../../../commonStateTypes/common';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function getInvoicingPlanById(planState: InvoicingPlanState, id: ID): InvoicingPlan | undefined;
|
|
3
|
+
import { InvoicingCatalogItem, InvoicingCatalogPricePoint, InvoicingCatalogState } from './invoicingCatalogState';
|
|
4
|
+
export declare function getInvoicingCatalogItemsByIds(catalogState: InvoicingCatalogState, ids: ID[]): InvoicingCatalogItem[];
|
|
5
|
+
export declare function getInvoicingCatalogItemById(catalogState: InvoicingCatalogState, id: ID): InvoicingCatalogItem | undefined;
|
|
7
6
|
/**
|
|
8
7
|
* The amount to show for one price point: what the service computed for a
|
|
9
8
|
* single unit. `price` is only a fallback for responses predating
|
|
@@ -11,7 +10,7 @@ export declare function getInvoicingPlanById(planState: InvoicingPlanState, id:
|
|
|
11
10
|
* and stairstep model, whose configured price is legitimately zero because the
|
|
12
11
|
* money lives in its tiers.
|
|
13
12
|
*/
|
|
14
|
-
export declare const invoicingPricePointDisplayAmount: (pricePoint:
|
|
13
|
+
export declare const invoicingPricePointDisplayAmount: (pricePoint: InvoicingCatalogPricePoint) => Amount | undefined;
|
|
15
14
|
/**
|
|
16
15
|
* The lowest amount a catalog item can be bought at: the smallest single-unit
|
|
17
16
|
* price across its active price points.
|
|
@@ -21,4 +20,4 @@ export declare const invoicingPricePointDisplayAmount: (pricePoint: InvoicingPro
|
|
|
21
20
|
* points are priced in different currencies, where the smallest number is not
|
|
22
21
|
* the lowest price. A zero is a real price and wins on its merits.
|
|
23
22
|
*/
|
|
24
|
-
export declare const
|
|
23
|
+
export declare const getLowestInvoicingCatalogPricePointAmount: (item: InvoicingCatalogItem | undefined) => Amount | undefined;
|
package/lib/entity/invoicing/{plan/planSelector.js → invoicingCatalog/invoicingCatalogSelector.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.getLowestInvoicingCatalogPricePointAmount = exports.invoicingPricePointDisplayAmount = void 0;
|
|
7
|
+
exports.getInvoicingCatalogItemsByIds = getInvoicingCatalogItemsByIds;
|
|
8
|
+
exports.getInvoicingCatalogItemById = getInvoicingCatalogItemById;
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
.map((id) =>
|
|
10
|
+
function getInvoicingCatalogItemsByIds(catalogState, ids) {
|
|
11
|
+
const items = ids
|
|
12
|
+
.map((id) => getInvoicingCatalogItemById(catalogState, id))
|
|
13
13
|
.filter((value) => value != null);
|
|
14
|
-
return
|
|
14
|
+
return items;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return (0, get_1.default)(
|
|
16
|
+
function getInvoicingCatalogItemById(catalogState, id) {
|
|
17
|
+
return (0, get_1.default)(catalogState.itemByID, 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 getLowestInvoicingCatalogPricePointAmount = (item) => {
|
|
43
|
+
const amounts = (item?.subFamilies ?? [])
|
|
44
44
|
.filter(isActiveInvoicingPricePoint)
|
|
45
45
|
.map(exports.invoicingPricePointDisplayAmount)
|
|
46
46
|
.filter((amount) => amount != null);
|
|
@@ -56,4 +56,4 @@ const getLowestInvoicingPlanPricePointAmount = (plan) => {
|
|
|
56
56
|
// to visit last.
|
|
57
57
|
return amounts.reduce((lowest, amount) => amount.amount < lowest.amount ? amount : lowest);
|
|
58
58
|
};
|
|
59
|
-
exports.
|
|
59
|
+
exports.getLowestInvoicingCatalogPricePointAmount = getLowestInvoicingCatalogPricePointAmount;
|
|
@@ -1,7 +1,46 @@
|
|
|
1
1
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
2
|
import { ID } from '../../../commonStateTypes/common';
|
|
3
3
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
4
|
-
export interface
|
|
4
|
+
export interface InvoicingCatalogItem {
|
|
5
|
+
id: ID;
|
|
6
|
+
applicableItems?: ID[];
|
|
7
|
+
archivedAt?: ZeniDate;
|
|
8
|
+
billingCycles?: number;
|
|
9
|
+
createdAt?: ZeniDate;
|
|
10
|
+
currencyCode?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
enabledForCheckout?: boolean;
|
|
13
|
+
enabledInPortal?: boolean;
|
|
14
|
+
externalId?: string;
|
|
15
|
+
externalName?: string;
|
|
16
|
+
giftClaimRedirectUrl?: string;
|
|
17
|
+
includedInMrr?: boolean;
|
|
18
|
+
isGiftable?: boolean;
|
|
19
|
+
isShippable?: boolean;
|
|
20
|
+
itemApplicability?: string;
|
|
21
|
+
itemFamilyID?: ID;
|
|
22
|
+
itemType?: string;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
metered?: boolean;
|
|
25
|
+
name?: string;
|
|
26
|
+
period?: number;
|
|
27
|
+
periodUnit?: string;
|
|
28
|
+
price?: Amount;
|
|
29
|
+
productCode?: string;
|
|
30
|
+
status?: string;
|
|
31
|
+
subFamilies?: InvoicingCatalogPricePoint[];
|
|
32
|
+
tiers?: InvoicingCatalogTier[];
|
|
33
|
+
trialPeriod?: number;
|
|
34
|
+
trialPeriodUnit?: string;
|
|
35
|
+
type?: string;
|
|
36
|
+
unit?: string;
|
|
37
|
+
updatedAt?: ZeniDate;
|
|
38
|
+
usageCalculation?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface InvoicingCatalogState {
|
|
41
|
+
itemByID: Record<ID, InvoicingCatalogItem>;
|
|
42
|
+
}
|
|
43
|
+
export interface InvoicingCatalogTier {
|
|
5
44
|
price: Amount;
|
|
6
45
|
startingUnit: number;
|
|
7
46
|
endingUnit?: number;
|
|
@@ -21,7 +60,7 @@ export interface InvoicingAccountingDetail {
|
|
|
21
60
|
* so this union is the single place they are named on the client.
|
|
22
61
|
*/
|
|
23
62
|
export type InvoicingCatalogPricingModel = 'flat_fee' | 'per_unit' | 'tiered' | 'volume' | 'stairstep';
|
|
24
|
-
export interface
|
|
63
|
+
export interface InvoicingCatalogPricePoint {
|
|
25
64
|
id: ID;
|
|
26
65
|
accountingDetail?: InvoicingAccountingDetail;
|
|
27
66
|
applicableItems?: ID[];
|
|
@@ -69,7 +108,7 @@ export interface InvoicingProduct {
|
|
|
69
108
|
showDescriptionInQuotes?: boolean;
|
|
70
109
|
status?: string;
|
|
71
110
|
subscriptionCount?: number;
|
|
72
|
-
tiers?:
|
|
111
|
+
tiers?: InvoicingCatalogTier[];
|
|
73
112
|
trialEndAction?: string;
|
|
74
113
|
trialPeriod?: number;
|
|
75
114
|
trialPeriodUnit?: string;
|
|
@@ -79,6 +118,3 @@ export interface InvoicingProduct {
|
|
|
79
118
|
usageAccumulationResetFrequency?: string;
|
|
80
119
|
usageCalculation?: string;
|
|
81
120
|
}
|
|
82
|
-
export interface InvoicingProductState {
|
|
83
|
-
productByID: Record<ID, InvoicingProduct>;
|
|
84
|
-
}
|
|
@@ -187,6 +187,7 @@ export interface JEOneTimeAccrualPayload {
|
|
|
187
187
|
reversal_policy?: string | null;
|
|
188
188
|
reversal_posting_date?: string | null;
|
|
189
189
|
reversal_transaction_id?: ID | null;
|
|
190
|
+
reversal_transaction_integration_id?: ID | null;
|
|
190
191
|
reversal_trigger?: string | null;
|
|
191
192
|
reversed_by_user?: UserPayload | null;
|
|
192
193
|
transaction_id?: ID | null;
|
|
@@ -550,6 +550,7 @@ function toJEOneTimeAccrual(payload) {
|
|
|
550
550
|
transactionId: payload.transaction_id ?? undefined,
|
|
551
551
|
transactionIntegrationId: payload.transaction_integration_id ?? undefined,
|
|
552
552
|
reversalTransactionId: payload.reversal_transaction_id ?? undefined,
|
|
553
|
+
reversalTransactionIntegrationId: payload.reversal_transaction_integration_id ?? undefined,
|
|
553
554
|
createdBy: toJEOneTimeAccrualCreator(payload.created_by_user),
|
|
554
555
|
reversedBy: toJEOneTimeAccrualCreator(payload.reversed_by_user),
|
|
555
556
|
};
|
|
@@ -269,6 +269,7 @@ export interface JEOneTimeAccrualState {
|
|
|
269
269
|
profileSnapshot?: JEOneTimeAccrualProfileSnapshot;
|
|
270
270
|
reversalPostingDate?: ZeniDate;
|
|
271
271
|
reversalTransactionId?: ID;
|
|
272
|
+
reversalTransactionIntegrationId?: ID;
|
|
272
273
|
reversalTrigger?: OneTimeAccrualReversalTriggerType;
|
|
273
274
|
reversedBy?: JEOneTimeAccrualCreator;
|
|
274
275
|
transactionId?: ID;
|
|
@@ -13,19 +13,19 @@ export type ScheduleTypes = ReturnType<typeof toScheduleTypesType>;
|
|
|
13
13
|
export declare const toScheduleTypesTypeStrict: (v?: string) => "prepaid_expenses" | "fixed_assets" | "accrued_expenses" | "deferred_revenue" | undefined;
|
|
14
14
|
export declare const toScheduleJournalEntryStatusCodeType: (v: string) => "unknown" | "pending" | "posted" | "canceled" | "recorded";
|
|
15
15
|
export type ScheduleJournalEntryStatusCodeType = ReturnType<typeof toScheduleJournalEntryStatusCodeType>;
|
|
16
|
-
export declare const toScheduleStatusCodeType: (v: string) => "completed" | "
|
|
16
|
+
export declare const toScheduleStatusCodeType: (v: string) => "completed" | "new" | "ongoing" | "marked_as_completed" | "draft";
|
|
17
17
|
export type ScheduleStatusCodeType = ReturnType<typeof toScheduleStatusCodeType>;
|
|
18
|
-
export declare const toOneTimeAccrualStatusCodeType: (v: string) => "
|
|
18
|
+
export declare const toOneTimeAccrualStatusCodeType: (v: string) => "posted" | "draft" | "posting" | "posting_blocked" | "reversing" | "reversed" | "reverted";
|
|
19
19
|
export type OneTimeAccrualStatusCodeType = ReturnType<typeof toOneTimeAccrualStatusCodeType>;
|
|
20
20
|
export declare const toOneTimeAccrualOriginType: (v: string) => "agent" | "human";
|
|
21
21
|
export type OneTimeAccrualOriginType = ReturnType<typeof toOneTimeAccrualOriginType>;
|
|
22
|
-
export declare const toOneTimeAccrualAutomationTierType: (v: string) => "
|
|
22
|
+
export declare const toOneTimeAccrualAutomationTierType: (v: string) => "draft" | "manual" | "auto";
|
|
23
23
|
export type OneTimeAccrualAutomationTierType = ReturnType<typeof toOneTimeAccrualAutomationTierType>;
|
|
24
24
|
export declare const toOneTimeAccrualReversalPolicyType: (v: string) => "on_bill_match" | "scheduled_date";
|
|
25
25
|
export type OneTimeAccrualReversalPolicyType = ReturnType<typeof toOneTimeAccrualReversalPolicyType>;
|
|
26
26
|
export declare const toOneTimeAccrualReversalTriggerType: (v?: string) => "scheduled_date" | "bill_match" | "manual_reverse" | undefined;
|
|
27
27
|
export type OneTimeAccrualReversalTriggerType = ReturnType<typeof toOneTimeAccrualReversalTriggerType>;
|
|
28
|
-
export declare const toOneTimeAccrualIgnoreReasonType: (v: string) => "
|
|
28
|
+
export declare const toOneTimeAccrualIgnoreReasonType: (v: string) => "no_activity" | "paused" | "too_small" | "need_invoice" | "other_ignore";
|
|
29
29
|
export type OneTimeAccrualIgnoreReasonType = ReturnType<typeof toOneTimeAccrualIgnoreReasonType>;
|
|
30
30
|
export declare const ALL_ONE_TIME_ACCRUAL_IGNORE_REASONS: readonly OneTimeAccrualIgnoreReasonType[];
|
|
31
31
|
export declare const toJEScheduleIgnoreReasonType: (v: string) => "other_ignore" | "not_needed" | "wrong_account" | "duplicate" | "already_handled";
|
|
@@ -3,7 +3,7 @@ import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelpe
|
|
|
3
3
|
import { date } from '../../../zeniDayJS';
|
|
4
4
|
import { firstSelectableInvoicingId } from '../invoicingCommonPayload';
|
|
5
5
|
// ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
|
|
6
|
-
export const
|
|
6
|
+
export const mapInvoicingCatalogTierPayloadToState = (payload, currencyCode, currencySymbol) => ({
|
|
7
7
|
price: toAmount(payload.price, currencyCode, currencySymbol),
|
|
8
8
|
startingUnit: payload.starting_unit,
|
|
9
9
|
endingUnit: payload.ending_unit,
|
|
@@ -29,7 +29,7 @@ const mapInvoicingAccountingDetailPayloadToState = (payload) => ({
|
|
|
29
29
|
]),
|
|
30
30
|
sku: payload.sku,
|
|
31
31
|
});
|
|
32
|
-
export const
|
|
32
|
+
export const mapInvoicingCatalogPricePointPayloadToState = (payload) => {
|
|
33
33
|
const currencyCode = payload.currency_code ?? defaultCustomerCurrency.currencyCode;
|
|
34
34
|
const currencySymbol = payload.currency_symbol ?? defaultCustomerCurrency.currencySymbol;
|
|
35
35
|
return {
|
|
@@ -76,7 +76,7 @@ export const mapInvoicingProductPayloadToState = (payload) => {
|
|
|
76
76
|
showDescriptionInQuotes: payload.show_description_in_quotes,
|
|
77
77
|
status: payload.status,
|
|
78
78
|
subscriptionCount: payload.subscription_count ?? 0,
|
|
79
|
-
tiers: payload.tiers?.map((tier) =>
|
|
79
|
+
tiers: payload.tiers?.map((tier) => mapInvoicingCatalogTierPayloadToState(tier, currencyCode, currencySymbol)),
|
|
80
80
|
trialEndAction: payload.trial_end_action,
|
|
81
81
|
trialPeriod: payload.trial_period,
|
|
82
82
|
trialPeriodUnit: payload.trial_period_unit,
|
|
@@ -87,3 +87,46 @@ export const mapInvoicingProductPayloadToState = (payload) => {
|
|
|
87
87
|
usageCalculation: payload.usage_calculation,
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
|
+
// ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
|
|
91
|
+
export const mapInvoicingCatalogItemPayloadToState = (payload) => {
|
|
92
|
+
const currencyCode = payload.currency_code ?? defaultCustomerCurrency.currencyCode;
|
|
93
|
+
const currencySymbol = payload.currency_symbol ?? defaultCustomerCurrency.currencySymbol;
|
|
94
|
+
return {
|
|
95
|
+
id: payload.id,
|
|
96
|
+
applicableItems: payload.applicable_items,
|
|
97
|
+
archivedAt: payload.archived_at != null ? date(payload.archived_at) : undefined,
|
|
98
|
+
billingCycles: payload.billing_cycles,
|
|
99
|
+
createdAt: payload.created_at != null ? date(payload.created_at) : undefined,
|
|
100
|
+
currencyCode: payload.currency_code,
|
|
101
|
+
description: payload.description,
|
|
102
|
+
enabledForCheckout: payload.enabled_for_checkout,
|
|
103
|
+
enabledInPortal: payload.enabled_in_portal,
|
|
104
|
+
externalId: payload.external_id,
|
|
105
|
+
externalName: payload.external_name,
|
|
106
|
+
giftClaimRedirectUrl: payload.gift_claim_redirect_url,
|
|
107
|
+
includedInMrr: payload.included_in_mrr,
|
|
108
|
+
isGiftable: payload.is_giftable,
|
|
109
|
+
isShippable: payload.is_shippable,
|
|
110
|
+
itemApplicability: payload.item_applicability,
|
|
111
|
+
itemFamilyID: payload.item_family_id,
|
|
112
|
+
itemType: payload.item_type,
|
|
113
|
+
metadata: payload.metadata,
|
|
114
|
+
metered: payload.metered,
|
|
115
|
+
name: payload.name,
|
|
116
|
+
period: payload.period,
|
|
117
|
+
periodUnit: payload.period_unit,
|
|
118
|
+
productCode: payload.product_code,
|
|
119
|
+
price: payload.price != null
|
|
120
|
+
? toAmount(payload.price, currencyCode, currencySymbol)
|
|
121
|
+
: undefined,
|
|
122
|
+
subFamilies: payload.sub_families?.map(mapInvoicingCatalogPricePointPayloadToState),
|
|
123
|
+
status: payload.status,
|
|
124
|
+
tiers: payload.tiers?.map((tier) => mapInvoicingCatalogTierPayloadToState(tier, currencyCode, currencySymbol)),
|
|
125
|
+
trialPeriod: payload.trial_period,
|
|
126
|
+
trialPeriodUnit: payload.trial_period_unit,
|
|
127
|
+
type: payload.type,
|
|
128
|
+
unit: payload.unit,
|
|
129
|
+
updatedAt: payload.updated_at != null ? date(payload.updated_at) : undefined,
|
|
130
|
+
usageCalculation: payload.usage_calculation,
|
|
131
|
+
};
|
|
132
|
+
};
|