@zeniai/client-epic-state 5.1.34-betaAK1 → 5.1.34-betaAK3
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/coupon/couponConstants.d.ts +11 -0
- package/lib/entity/invoicing/coupon/couponConstants.js +29 -0
- package/lib/entity/invoicing/coupon/couponPayload.d.ts +9 -4
- package/lib/entity/invoicing/coupon/couponPayload.js +46 -0
- package/lib/entity/invoicing/coupon/couponReducer.d.ts +4 -5
- package/lib/entity/invoicing/coupon/couponReducer.js +23 -9
- package/lib/entity/invoicing/coupon/couponSelector.d.ts +5 -0
- package/lib/entity/invoicing/coupon/couponSelector.js +9 -0
- package/lib/entity/invoicing/coupon/couponState.d.ts +35 -1
- package/lib/entity/invoicing/invoice/invoicePayload.d.ts +15 -12
- package/lib/entity/invoicing/invoice/invoicePayload.js +118 -0
- package/lib/entity/invoicing/invoice/invoiceReducer.d.ts +4 -5
- package/lib/entity/invoicing/invoice/invoiceReducer.js +23 -10
- package/lib/entity/invoicing/invoice/invoiceSelector.d.ts +1 -1
- package/lib/entity/invoicing/invoice/invoiceState.d.ts +95 -1
- package/lib/entity/invoicing/invoicingCommonPayload.d.ts +9 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +4 -3
- package/lib/entity/tenant/clearAllEpic.js +5 -3
- package/lib/epic.d.ts +4 -2
- package/lib/epic.js +4 -2
- package/lib/esm/entity/invoicing/coupon/couponConstants.js +26 -0
- package/lib/esm/entity/invoicing/coupon/couponPayload.js +43 -1
- package/lib/esm/entity/invoicing/coupon/couponReducer.js +20 -9
- package/lib/esm/entity/invoicing/coupon/couponSelector.js +4 -0
- package/lib/esm/entity/invoicing/invoice/invoicePayload.js +115 -1
- package/lib/esm/entity/invoicing/invoice/invoiceReducer.js +20 -10
- package/lib/esm/entity/tenant/clearAllEpic.js +6 -4
- package/lib/esm/epic.js +5 -3
- package/lib/esm/index.js +12 -9
- package/lib/esm/reducer.js +6 -3
- package/lib/esm/view/invoicing/couponView/couponViewEpics.js +31 -17
- package/lib/esm/view/invoicing/couponView/couponViewReducer.js +16 -17
- package/lib/esm/view/invoicing/couponView/couponViewSelector.js +21 -6
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +22 -0
- package/lib/esm/view/invoicing/{couponWrite/couponWriteReducer.js → editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js} +5 -5
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +29 -0
- package/lib/esm/view/invoicing/{couponWrite/couponWriteEpic.js → editInvoicingCouponDetailView/saveInvoicingCouponEpic.js} +1 -1
- package/lib/esm/view/invoicing/invoiceDetail/fetchInvoiceDetailEpic.js +6 -3
- package/lib/esm/view/invoicing/invoiceDetail/invoiceDetailReducer.js +21 -17
- package/lib/esm/view/invoicing/invoiceDetail/invoiceDetailSelector.js +13 -7
- package/lib/esm/view/invoicing/invoiceList/fetchInvoiceKPIsEpic.js +2 -1
- package/lib/esm/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +30 -0
- package/lib/esm/view/invoicing/invoiceList/invoiceListReducer.js +16 -1
- package/lib/esm/view/invoicing/invoiceList/invoiceListSelector.js +21 -0
- package/lib/esm/view/invoicing/invoicingCouponDetailView/fetchInvoicingCouponDetailEpic.js +22 -0
- package/lib/esm/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewPayload.js +1 -0
- package/lib/esm/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewReducer.js +38 -0
- package/lib/esm/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewSelector.js +11 -0
- package/lib/esm/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewState.js +1 -0
- package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +15 -8
- package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +16 -8
- package/lib/esm/view/transactionDetail/epics/updateTransactionDetailEpic.js +4 -2
- package/lib/index.d.ts +24 -13
- package/lib/index.js +25 -17
- package/lib/reducer.d.ts +6 -3
- package/lib/reducer.js +6 -3
- package/lib/view/invoicing/couponView/couponViewEpics.d.ts +8 -3
- package/lib/view/invoicing/couponView/couponViewEpics.js +30 -16
- package/lib/view/invoicing/couponView/couponViewPayload.d.ts +3 -4
- package/lib/view/invoicing/couponView/couponViewReducer.d.ts +11 -7
- package/lib/view/invoicing/couponView/couponViewReducer.js +17 -18
- package/lib/view/invoicing/couponView/couponViewSelector.d.ts +18 -4
- package/lib/view/invoicing/couponView/couponViewSelector.js +22 -10
- package/lib/view/invoicing/couponView/couponViewState.d.ts +1 -3
- package/lib/view/invoicing/createInvoice/createInvoicePayload.d.ts +2 -2
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +19 -0
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +24 -1
- package/lib/view/invoicing/{couponWrite/couponWritePayload.d.ts → editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.d.ts} +2 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.d.ts +14 -0
- package/lib/view/invoicing/{couponWrite/couponWriteReducer.js → editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js} +6 -6
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +28 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +34 -0
- package/lib/view/invoicing/{couponWrite/couponWriteState.d.ts → editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts} +1 -1
- package/lib/view/invoicing/{couponWrite/couponWriteEpic.d.ts → editInvoicingCouponDetailView/saveInvoicingCouponEpic.d.ts} +1 -1
- package/lib/view/invoicing/{couponWrite/couponWriteEpic.js → editInvoicingCouponDetailView/saveInvoicingCouponEpic.js} +5 -5
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +1 -1
- package/lib/view/invoicing/invoiceAction/invoiceActionPayload.d.ts +2 -2
- package/lib/view/invoicing/invoiceDetail/fetchInvoiceDetailEpic.js +6 -3
- package/lib/view/invoicing/invoiceDetail/invoiceDetailPayload.d.ts +2 -2
- package/lib/view/invoicing/invoiceDetail/invoiceDetailReducer.d.ts +8 -3
- package/lib/view/invoicing/invoiceDetail/invoiceDetailReducer.js +23 -18
- package/lib/view/invoicing/invoiceDetail/invoiceDetailSelector.d.ts +14 -4
- package/lib/view/invoicing/invoiceDetail/invoiceDetailSelector.js +17 -9
- package/lib/view/invoicing/invoiceDetail/invoiceDetailState.d.ts +5 -2
- package/lib/view/invoicing/invoiceList/fetchInvoiceKPIsEpic.js +2 -1
- package/lib/view/invoicing/invoiceList/fetchInvoiceListPageEpic.d.ts +11 -0
- package/lib/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +34 -0
- package/lib/view/invoicing/invoiceList/invoiceListPayload.d.ts +3 -3
- package/lib/view/invoicing/invoiceList/invoiceListReducer.d.ts +12 -3
- package/lib/view/invoicing/invoiceList/invoiceListReducer.js +17 -2
- package/lib/view/invoicing/invoiceList/invoiceListSelector.d.ts +18 -1
- package/lib/view/invoicing/invoiceList/invoiceListSelector.js +22 -1
- package/lib/view/invoicing/invoiceList/invoiceListState.d.ts +1 -1
- package/lib/view/invoicing/invoicingCouponDetailView/fetchInvoicingCouponDetailEpic.d.ts +8 -0
- package/lib/view/invoicing/invoicingCouponDetailView/fetchInvoicingCouponDetailEpic.js +26 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewPayload.d.ts +3 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewPayload.js +2 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewReducer.d.ts +16 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewReducer.js +43 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewSelector.d.ts +12 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewSelector.js +18 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewState.d.ts +7 -0
- package/lib/view/invoicing/invoicingCouponDetailView/invoicingCouponDetailViewState.js +2 -0
- package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.d.ts +1 -1
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.d.ts +6 -0
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +15 -9
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.d.ts +7 -0
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +16 -9
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +4 -2
- package/package.json +1 -1
- package/lib/esm/view/invoicing/couponWrite/couponWriteSelector.js +0 -5
- package/lib/view/invoicing/couponWrite/couponWriteReducer.d.ts +0 -14
- package/lib/view/invoicing/couponWrite/couponWriteSelector.d.ts +0 -4
- package/lib/view/invoicing/couponWrite/couponWriteSelector.js +0 -10
- /package/lib/esm/view/invoicing/{couponWrite/couponWritePayload.js → editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js} +0 -0
- /package/lib/esm/view/invoicing/{couponWrite/couponWriteState.js → editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js} +0 -0
- /package/lib/view/invoicing/{couponWrite/couponWritePayload.js → editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js} +0 -0
- /package/lib/view/invoicing/{couponWrite/couponWriteState.js → editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InvoicingFormOption } from '../invoicingCommonPayload';
|
|
2
|
+
import { InvoicingCouponApplyOn, InvoicingCouponDurationType, InvoicingCouponPeriodUnit, InvoicingDiscountType } from './couponPayload';
|
|
3
|
+
/**
|
|
4
|
+
* Coupon form select options. Single source of truth (CES-owned) for the value
|
|
5
|
+
* sets that back the coupon's string-union domain fields; surfaced to the form
|
|
6
|
+
* via `getInvoicingCouponFormView` so web-components need not hardcode them.
|
|
7
|
+
*/
|
|
8
|
+
export declare const INVOICING_DISCOUNT_TYPE_OPTIONS: readonly InvoicingFormOption<InvoicingDiscountType>[];
|
|
9
|
+
export declare const INVOICING_COUPON_DURATION_TYPE_OPTIONS: readonly InvoicingFormOption<InvoicingCouponDurationType>[];
|
|
10
|
+
export declare const INVOICING_COUPON_PERIOD_UNIT_OPTIONS: readonly InvoicingFormOption<InvoicingCouponPeriodUnit>[];
|
|
11
|
+
export declare const INVOICING_COUPON_APPLY_ON_OPTIONS: readonly InvoicingFormOption<InvoicingCouponApplyOn>[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INVOICING_COUPON_APPLY_ON_OPTIONS = exports.INVOICING_COUPON_PERIOD_UNIT_OPTIONS = exports.INVOICING_COUPON_DURATION_TYPE_OPTIONS = exports.INVOICING_DISCOUNT_TYPE_OPTIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Coupon form select options. Single source of truth (CES-owned) for the value
|
|
6
|
+
* sets that back the coupon's string-union domain fields; surfaced to the form
|
|
7
|
+
* via `getInvoicingCouponFormView` so web-components need not hardcode them.
|
|
8
|
+
*/
|
|
9
|
+
exports.INVOICING_DISCOUNT_TYPE_OPTIONS = [
|
|
10
|
+
{ label: 'Percentage', value: 'percentage' },
|
|
11
|
+
{ label: 'Fixed amount', value: 'fixed_amount' },
|
|
12
|
+
{ label: 'Offer quantity', value: 'offer_quantity' },
|
|
13
|
+
];
|
|
14
|
+
exports.INVOICING_COUPON_DURATION_TYPE_OPTIONS = [
|
|
15
|
+
{ label: 'One time', value: 'one_time' },
|
|
16
|
+
{ label: 'Forever', value: 'forever' },
|
|
17
|
+
{ label: 'Limited period', value: 'limited_period' },
|
|
18
|
+
];
|
|
19
|
+
exports.INVOICING_COUPON_PERIOD_UNIT_OPTIONS = [
|
|
20
|
+
{ label: 'Day', value: 'day' },
|
|
21
|
+
{ label: 'Week', value: 'week' },
|
|
22
|
+
{ label: 'Month', value: 'month' },
|
|
23
|
+
{ label: 'Year', value: 'year' },
|
|
24
|
+
];
|
|
25
|
+
exports.INVOICING_COUPON_APPLY_ON_OPTIONS = [
|
|
26
|
+
{ label: 'Invoice amount', value: 'invoice_amount' },
|
|
27
|
+
{ label: 'Each specified item', value: 'each_specified_item' },
|
|
28
|
+
{ label: 'Specified items total', value: 'specified_items_total' },
|
|
29
|
+
];
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { InvoicingCoupon, InvoicingDiscountKPIs } from './couponState';
|
|
1
2
|
export type InvoicingDiscountType = 'percentage' | 'fixed_amount' | 'offer_quantity';
|
|
2
3
|
export type InvoicingCouponDurationType = 'one_time' | 'forever' | 'limited_period';
|
|
3
4
|
export type InvoicingCouponStatus = 'active' | 'expired' | 'archived';
|
|
4
|
-
export
|
|
5
|
+
export type InvoicingCouponApplyOn = 'invoice_amount' | 'each_specified_item' | 'specified_items_total';
|
|
6
|
+
export type InvoicingCouponPeriodUnit = 'day' | 'week' | 'month' | 'year';
|
|
7
|
+
export interface InvoicingCouponPayload {
|
|
5
8
|
id: string;
|
|
6
|
-
apply_on?:
|
|
9
|
+
apply_on?: InvoicingCouponApplyOn;
|
|
7
10
|
coupon_code?: string;
|
|
8
11
|
created_at?: string;
|
|
9
12
|
currency_code?: string;
|
|
@@ -18,7 +21,7 @@ export interface InvoicingCoupon {
|
|
|
18
21
|
max_redemptions?: number;
|
|
19
22
|
name?: string;
|
|
20
23
|
period?: number;
|
|
21
|
-
period_unit?:
|
|
24
|
+
period_unit?: InvoicingCouponPeriodUnit;
|
|
22
25
|
redemptions?: number;
|
|
23
26
|
restricted_products?: string[];
|
|
24
27
|
rev_rec_treatment?: string;
|
|
@@ -42,9 +45,11 @@ export interface InvoicingCouponSet {
|
|
|
42
45
|
redeemed_count?: number;
|
|
43
46
|
total_count?: number;
|
|
44
47
|
}
|
|
45
|
-
export interface
|
|
48
|
+
export interface InvoicingDiscountKPIsPayload {
|
|
46
49
|
total_active: number;
|
|
47
50
|
total_discounted_amount: number;
|
|
48
51
|
total_expired: number;
|
|
49
52
|
total_redemptions: number;
|
|
50
53
|
}
|
|
54
|
+
export declare const mapInvoicingCouponPayloadToState: (payload: InvoicingCouponPayload) => InvoicingCoupon;
|
|
55
|
+
export declare const mapInvoicingDiscountKPIsPayloadToState: (payload: InvoicingDiscountKPIsPayload) => InvoicingDiscountKPIs;
|
|
@@ -1,2 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapInvoicingDiscountKPIsPayloadToState = exports.mapInvoicingCouponPayloadToState = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
|
+
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
6
|
+
// ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
|
|
7
|
+
const DEFAULT_CURRENCY_CODE = 'USD';
|
|
8
|
+
const DEFAULT_CURRENCY_SYMBOL = '$';
|
|
9
|
+
const mapInvoicingCouponPayloadToState = (payload) => {
|
|
10
|
+
const currencyCode = payload.currency_code ?? DEFAULT_CURRENCY_CODE;
|
|
11
|
+
const currencySymbol = DEFAULT_CURRENCY_SYMBOL;
|
|
12
|
+
return {
|
|
13
|
+
id: payload.id,
|
|
14
|
+
applyOn: payload.apply_on,
|
|
15
|
+
couponCode: payload.coupon_code,
|
|
16
|
+
createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
|
|
17
|
+
currencyCode: payload.currency_code,
|
|
18
|
+
discountAmount: payload.discount_amount != null
|
|
19
|
+
? (0, amount_1.toAmount)(payload.discount_amount, currencyCode, currencySymbol)
|
|
20
|
+
: undefined,
|
|
21
|
+
discountPercentage: payload.discount_percentage,
|
|
22
|
+
discountQuantity: payload.discount_quantity,
|
|
23
|
+
discountType: payload.discount_type,
|
|
24
|
+
durationType: payload.duration_type,
|
|
25
|
+
invoiceName: payload.invoice_name,
|
|
26
|
+
invoiceNotes: payload.invoice_notes,
|
|
27
|
+
itemConstraints: payload.item_constraints,
|
|
28
|
+
maxRedemptions: payload.max_redemptions,
|
|
29
|
+
name: payload.name,
|
|
30
|
+
period: payload.period,
|
|
31
|
+
periodUnit: payload.period_unit,
|
|
32
|
+
redemptions: payload.redemptions,
|
|
33
|
+
restrictedProducts: payload.restricted_products,
|
|
34
|
+
revRecTreatment: payload.rev_rec_treatment,
|
|
35
|
+
status: payload.status,
|
|
36
|
+
updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
|
|
37
|
+
validFrom: payload.valid_from != null ? (0, zeniDayJS_1.date)(payload.valid_from) : undefined,
|
|
38
|
+
validTill: payload.valid_till != null ? (0, zeniDayJS_1.date)(payload.valid_till) : undefined,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.mapInvoicingCouponPayloadToState = mapInvoicingCouponPayloadToState;
|
|
42
|
+
const mapInvoicingDiscountKPIsPayloadToState = (payload) => ({
|
|
43
|
+
totalActive: payload.total_active,
|
|
44
|
+
totalDiscountedAmount: (0, amount_1.toAmount)(payload.total_discounted_amount, DEFAULT_CURRENCY_CODE, DEFAULT_CURRENCY_SYMBOL),
|
|
45
|
+
totalExpired: payload.total_expired,
|
|
46
|
+
totalRedemptions: payload.total_redemptions,
|
|
47
|
+
});
|
|
48
|
+
exports.mapInvoicingDiscountKPIsPayloadToState = mapInvoicingDiscountKPIsPayloadToState;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { UpdateType } from '../../../commonStateTypes/common';
|
|
2
|
-
import {
|
|
2
|
+
import { InvoicingCouponPayload } from './couponPayload';
|
|
3
3
|
import { InvoicingCouponState } from './couponState';
|
|
4
4
|
export declare const initialState: InvoicingCouponState;
|
|
5
|
-
export declare const updateInvoicingCoupons: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, "invoicingCoupon/updateInvoicingCoupons", never, never>, removeInvoicingCoupon: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingCoupon/removeInvoicingCoupon">, clearAllInvoicingCoupons: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCoupon/clearAllInvoicingCoupons">;
|
|
5
|
+
export declare const updateInvoicingCoupons: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InvoicingCouponPayload[], updateType?: UpdateType | undefined], InvoicingCouponPayload[], "invoicingCoupon/updateInvoicingCoupons", never, {
|
|
6
|
+
updateType: UpdateType;
|
|
7
|
+
}>, removeInvoicingCoupon: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingCoupon/removeInvoicingCoupon">, clearAllInvoicingCoupons: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCoupon/clearAllInvoicingCoupons">;
|
|
9
8
|
declare const _default: import("redux").Reducer<InvoicingCouponState>;
|
|
10
9
|
export default _default;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
var _a;
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.clearAllInvoicingCoupons = exports.removeInvoicingCoupon = exports.updateInvoicingCoupons = exports.initialState = void 0;
|
|
5
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
+
const assignWith_1 = __importDefault(require("lodash/assignWith"));
|
|
10
|
+
const couponPayload_1 = require("./couponPayload");
|
|
6
11
|
exports.initialState = { couponByID: {} };
|
|
7
12
|
const coupon = (0, toolkit_1.createSlice)({
|
|
8
13
|
name: 'invoicingCoupon',
|
|
@@ -10,24 +15,33 @@ const coupon = (0, toolkit_1.createSlice)({
|
|
|
10
15
|
reducers: {
|
|
11
16
|
updateInvoicingCoupons: {
|
|
12
17
|
reducer(draft, action) {
|
|
13
|
-
|
|
14
|
-
draft.couponByID = {};
|
|
15
|
-
}
|
|
16
|
-
action.payload.items.forEach((item) => {
|
|
17
|
-
draft.couponByID[item.id] = item;
|
|
18
|
-
});
|
|
18
|
+
doUpdateInvoicingCoupons(draft.couponByID, action.payload, action.meta.updateType);
|
|
19
19
|
},
|
|
20
|
-
prepare(
|
|
21
|
-
return { payload: {
|
|
20
|
+
prepare(payload, updateType = 'replace') {
|
|
21
|
+
return { payload, meta: { updateType } };
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
removeInvoicingCoupon(draft, action) {
|
|
25
25
|
delete draft.couponByID[action.payload];
|
|
26
26
|
},
|
|
27
27
|
clearAllInvoicingCoupons(draft) {
|
|
28
|
-
draft.
|
|
28
|
+
Object.assign(draft, exports.initialState);
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
32
|
_a = coupon.actions, exports.updateInvoicingCoupons = _a.updateInvoicingCoupons, exports.removeInvoicingCoupon = _a.removeInvoicingCoupon, exports.clearAllInvoicingCoupons = _a.clearAllInvoicingCoupons;
|
|
33
33
|
exports.default = coupon.reducer;
|
|
34
|
+
/**
|
|
35
|
+
* Helper functions.
|
|
36
|
+
*/
|
|
37
|
+
function doUpdateInvoicingCoupons(draft, payload, updateType) {
|
|
38
|
+
payload.forEach((couponPayload) => {
|
|
39
|
+
const latestCoupon = (0, couponPayload_1.mapInvoicingCouponPayloadToState)(couponPayload);
|
|
40
|
+
if (latestCoupon.id in draft && updateType === 'merge') {
|
|
41
|
+
(0, assignWith_1.default)(draft[latestCoupon.id], latestCoupon, (objValue, srcValue) => (srcValue == null ? objValue : srcValue));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
draft[latestCoupon.id] = latestCoupon;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ID } from '../../../commonStateTypes/common';
|
|
2
|
+
import { RootState } from '../../../reducer';
|
|
3
|
+
import { InvoicingCoupon } from './couponState';
|
|
4
|
+
export declare const getInvoicingCouponById: (state: RootState, id: ID) => InvoicingCoupon | undefined;
|
|
5
|
+
export declare const getInvoicingCouponsByIds: (state: RootState, ids: ID[]) => InvoicingCoupon[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInvoicingCouponsByIds = exports.getInvoicingCouponById = void 0;
|
|
4
|
+
const getInvoicingCouponById = (state, id) => state.invoicingCouponState.couponByID[id];
|
|
5
|
+
exports.getInvoicingCouponById = getInvoicingCouponById;
|
|
6
|
+
const getInvoicingCouponsByIds = (state, ids) => ids
|
|
7
|
+
.map((id) => state.invoicingCouponState.couponByID[id])
|
|
8
|
+
.filter((coupon) => coupon != null);
|
|
9
|
+
exports.getInvoicingCouponsByIds = getInvoicingCouponsByIds;
|
|
@@ -1,5 +1,39 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import {
|
|
3
|
+
import { ZeniDate } from '../../../zeniDayJS';
|
|
4
|
+
import { InvoicingCouponApplyOn, InvoicingCouponDurationType, InvoicingCouponPeriodUnit, InvoicingCouponStatus, InvoicingDiscountType } from './couponPayload';
|
|
5
|
+
export interface InvoicingCoupon {
|
|
6
|
+
id: ID;
|
|
7
|
+
applyOn?: InvoicingCouponApplyOn;
|
|
8
|
+
couponCode?: string;
|
|
9
|
+
createdAt?: ZeniDate;
|
|
10
|
+
currencyCode?: string;
|
|
11
|
+
discountAmount?: Amount;
|
|
12
|
+
discountPercentage?: number;
|
|
13
|
+
discountQuantity?: number;
|
|
14
|
+
discountType?: InvoicingDiscountType;
|
|
15
|
+
durationType?: InvoicingCouponDurationType;
|
|
16
|
+
invoiceName?: string;
|
|
17
|
+
invoiceNotes?: string;
|
|
18
|
+
itemConstraints?: Record<string, unknown>[];
|
|
19
|
+
maxRedemptions?: number;
|
|
20
|
+
name?: string;
|
|
21
|
+
period?: number;
|
|
22
|
+
periodUnit?: InvoicingCouponPeriodUnit;
|
|
23
|
+
redemptions?: number;
|
|
24
|
+
restrictedProducts?: ID[];
|
|
25
|
+
revRecTreatment?: string;
|
|
26
|
+
status?: InvoicingCouponStatus;
|
|
27
|
+
updatedAt?: ZeniDate;
|
|
28
|
+
validFrom?: ZeniDate;
|
|
29
|
+
validTill?: ZeniDate;
|
|
30
|
+
}
|
|
31
|
+
export interface InvoicingDiscountKPIs {
|
|
32
|
+
totalActive: number;
|
|
33
|
+
totalDiscountedAmount: Amount;
|
|
34
|
+
totalExpired: number;
|
|
35
|
+
totalRedemptions: number;
|
|
36
|
+
}
|
|
3
37
|
export interface InvoicingCouponState {
|
|
4
38
|
couponByID: Record<ID, InvoicingCoupon>;
|
|
5
39
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InvoicingBillingAddressPayload, InvoicingPriceType } from '../invoicingCommonPayload';
|
|
2
|
+
import { InvoicingInvoice, InvoicingInvoiceKPIs } from './invoiceState';
|
|
2
3
|
export type InvoicingInvoiceStatus = 'paid' | 'partially_paid' | 'posted' | 'payment_due' | 'not_paid' | 'voided' | 'pending' | 'draft';
|
|
3
|
-
export interface
|
|
4
|
+
export interface InvoicingLineItemPayload {
|
|
4
5
|
amount: number;
|
|
5
6
|
description: string;
|
|
6
7
|
quantity: number;
|
|
@@ -19,7 +20,7 @@ export interface InvoicingLineItem {
|
|
|
19
20
|
tax_rate?: number;
|
|
20
21
|
usage_percentage?: number;
|
|
21
22
|
}
|
|
22
|
-
export interface
|
|
23
|
+
export interface InvoicingLinkedPaymentPayload {
|
|
23
24
|
applied_amount: number;
|
|
24
25
|
txn_id: string;
|
|
25
26
|
applied_at?: string;
|
|
@@ -27,23 +28,23 @@ export interface InvoicingLinkedPayment {
|
|
|
27
28
|
txn_date?: string;
|
|
28
29
|
txn_status?: string;
|
|
29
30
|
}
|
|
30
|
-
export interface
|
|
31
|
+
export interface InvoicingIssuedCreditNotePayload {
|
|
31
32
|
cn_id: string;
|
|
32
33
|
cn_status: string;
|
|
33
34
|
cn_total: number;
|
|
34
35
|
}
|
|
35
|
-
export interface
|
|
36
|
+
export interface InvoicingDunningAttemptPayload {
|
|
36
37
|
attempt: number;
|
|
37
38
|
created_at?: string;
|
|
38
39
|
dunning_type?: string;
|
|
39
40
|
transaction_id?: string;
|
|
40
41
|
}
|
|
41
|
-
export interface
|
|
42
|
+
export interface InvoicingInvoiceNotePayload {
|
|
42
43
|
note: string;
|
|
43
44
|
entity_id?: string;
|
|
44
45
|
entity_type?: string;
|
|
45
46
|
}
|
|
46
|
-
export interface
|
|
47
|
+
export interface InvoicingInvoicePayload {
|
|
47
48
|
customer_id: string;
|
|
48
49
|
date: string;
|
|
49
50
|
id: string;
|
|
@@ -61,17 +62,17 @@ export interface InvoicingInvoice {
|
|
|
61
62
|
customer_email?: string;
|
|
62
63
|
customer_name?: string;
|
|
63
64
|
due_date?: string;
|
|
64
|
-
dunning_attempts?:
|
|
65
|
+
dunning_attempts?: InvoicingDunningAttemptPayload[];
|
|
65
66
|
dunning_status?: string;
|
|
66
67
|
first_invoice?: boolean;
|
|
67
68
|
generated_at?: string;
|
|
68
69
|
has_advance_charges?: boolean;
|
|
69
|
-
issued_credit_notes?:
|
|
70
|
-
line_items?:
|
|
71
|
-
linked_payments?:
|
|
70
|
+
issued_credit_notes?: InvoicingIssuedCreditNotePayload[];
|
|
71
|
+
line_items?: InvoicingLineItemPayload[];
|
|
72
|
+
linked_payments?: InvoicingLinkedPaymentPayload[];
|
|
72
73
|
net_term_days?: number;
|
|
73
74
|
next_retry_at?: string;
|
|
74
|
-
notes?:
|
|
75
|
+
notes?: InvoicingInvoiceNotePayload[];
|
|
75
76
|
paid_at?: string;
|
|
76
77
|
po_number?: string;
|
|
77
78
|
price_type?: InvoicingPriceType;
|
|
@@ -85,9 +86,11 @@ export interface InvoicingInvoice {
|
|
|
85
86
|
updated_at?: string;
|
|
86
87
|
write_off_amount?: number;
|
|
87
88
|
}
|
|
88
|
-
export interface
|
|
89
|
+
export interface InvoicingInvoiceKPIsPayload {
|
|
89
90
|
due_total: number;
|
|
90
91
|
paid_total: number;
|
|
91
92
|
pending_total: number;
|
|
92
93
|
total_invoiced: number;
|
|
93
94
|
}
|
|
95
|
+
export declare const mapInvoicingInvoicePayloadToState: (payload: InvoicingInvoicePayload) => InvoicingInvoice;
|
|
96
|
+
export declare const mapInvoicingInvoiceKPIsPayloadToState: (payload: InvoicingInvoiceKPIsPayload) => InvoicingInvoiceKPIs;
|
|
@@ -1,2 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapInvoicingInvoiceKPIsPayloadToState = exports.mapInvoicingInvoicePayloadToState = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
|
+
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
6
|
+
// ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
|
|
7
|
+
const DEFAULT_CURRENCY_CODE = 'USD';
|
|
8
|
+
const DEFAULT_CURRENCY_SYMBOL = '$';
|
|
9
|
+
const mapLineItem = (payload, currencyCode, currencySymbol) => ({
|
|
10
|
+
amount: (0, amount_1.toAmount)(payload.amount, currencyCode, currencySymbol),
|
|
11
|
+
description: payload.description,
|
|
12
|
+
quantity: payload.quantity,
|
|
13
|
+
unitAmount: (0, amount_1.toAmount)(payload.unit_amount, currencyCode, currencySymbol),
|
|
14
|
+
dateFrom: payload.date_from != null ? (0, zeniDayJS_1.date)(payload.date_from) : undefined,
|
|
15
|
+
dateTo: payload.date_to != null ? (0, zeniDayJS_1.date)(payload.date_to) : undefined,
|
|
16
|
+
discountAmount: payload.discount_amount != null
|
|
17
|
+
? (0, amount_1.toAmount)(payload.discount_amount, currencyCode, currencySymbol)
|
|
18
|
+
: undefined,
|
|
19
|
+
entityDescription: payload.entity_description,
|
|
20
|
+
entityType: payload.entity_type,
|
|
21
|
+
id: payload.id,
|
|
22
|
+
isTaxed: payload.is_taxed,
|
|
23
|
+
itemLevelDiscountAmount: payload.item_level_discount_amount != null
|
|
24
|
+
? (0, amount_1.toAmount)(payload.item_level_discount_amount, currencyCode, currencySymbol)
|
|
25
|
+
: undefined,
|
|
26
|
+
subscriptionID: payload.subscription_id,
|
|
27
|
+
taxAmount: payload.tax_amount != null
|
|
28
|
+
? (0, amount_1.toAmount)(payload.tax_amount, currencyCode, currencySymbol)
|
|
29
|
+
: undefined,
|
|
30
|
+
taxExemptReason: payload.tax_exempt_reason,
|
|
31
|
+
taxRate: payload.tax_rate,
|
|
32
|
+
usagePercentage: payload.usage_percentage,
|
|
33
|
+
});
|
|
34
|
+
const mapLinkedPayment = (payload, currencyCode, currencySymbol) => ({
|
|
35
|
+
appliedAmount: (0, amount_1.toAmount)(payload.applied_amount, currencyCode, currencySymbol),
|
|
36
|
+
txnID: payload.txn_id,
|
|
37
|
+
appliedAt: payload.applied_at != null ? (0, zeniDayJS_1.date)(payload.applied_at) : undefined,
|
|
38
|
+
txnAmount: payload.txn_amount != null
|
|
39
|
+
? (0, amount_1.toAmount)(payload.txn_amount, currencyCode, currencySymbol)
|
|
40
|
+
: undefined,
|
|
41
|
+
txnDate: payload.txn_date != null ? (0, zeniDayJS_1.date)(payload.txn_date) : undefined,
|
|
42
|
+
txnStatus: payload.txn_status,
|
|
43
|
+
});
|
|
44
|
+
const mapIssuedCreditNote = (payload, currencyCode, currencySymbol) => ({
|
|
45
|
+
cnID: payload.cn_id,
|
|
46
|
+
cnStatus: payload.cn_status,
|
|
47
|
+
cnTotal: (0, amount_1.toAmount)(payload.cn_total, currencyCode, currencySymbol),
|
|
48
|
+
});
|
|
49
|
+
const mapDunningAttempt = (payload) => ({
|
|
50
|
+
attempt: payload.attempt,
|
|
51
|
+
createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
|
|
52
|
+
dunningType: payload.dunning_type,
|
|
53
|
+
transactionID: payload.transaction_id,
|
|
54
|
+
});
|
|
55
|
+
const mapInvoiceNote = (payload) => ({
|
|
56
|
+
note: payload.note,
|
|
57
|
+
entityID: payload.entity_id,
|
|
58
|
+
entityType: payload.entity_type,
|
|
59
|
+
});
|
|
60
|
+
const mapInvoicingInvoicePayloadToState = (payload) => {
|
|
61
|
+
const currencyCode = payload.currency_code ?? DEFAULT_CURRENCY_CODE;
|
|
62
|
+
const currencySymbol = DEFAULT_CURRENCY_SYMBOL;
|
|
63
|
+
const toAmt = (value) => (0, amount_1.toAmount)(value, currencyCode, currencySymbol);
|
|
64
|
+
return {
|
|
65
|
+
customerID: payload.customer_id,
|
|
66
|
+
date: (0, zeniDayJS_1.date)(payload.date),
|
|
67
|
+
id: payload.id,
|
|
68
|
+
status: payload.status,
|
|
69
|
+
total: toAmt(payload.total),
|
|
70
|
+
adjustmentCreditNotes: payload.adjustment_credit_notes,
|
|
71
|
+
amountAdjusted: payload.amount_adjusted != null ? toAmt(payload.amount_adjusted) : undefined,
|
|
72
|
+
amountDue: payload.amount_due != null ? toAmt(payload.amount_due) : undefined,
|
|
73
|
+
amountPaid: payload.amount_paid != null ? toAmt(payload.amount_paid) : undefined,
|
|
74
|
+
amountToCollect: payload.amount_to_collect != null
|
|
75
|
+
? toAmt(payload.amount_to_collect)
|
|
76
|
+
: undefined,
|
|
77
|
+
billingAddress: payload.billing_address,
|
|
78
|
+
createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
|
|
79
|
+
creditsApplied: payload.credits_applied != null ? toAmt(payload.credits_applied) : undefined,
|
|
80
|
+
currencyCode: payload.currency_code,
|
|
81
|
+
customerEmail: payload.customer_email,
|
|
82
|
+
customerName: payload.customer_name,
|
|
83
|
+
dueDate: payload.due_date != null ? (0, zeniDayJS_1.date)(payload.due_date) : undefined,
|
|
84
|
+
dunningAttempts: payload.dunning_attempts?.map(mapDunningAttempt),
|
|
85
|
+
dunningStatus: payload.dunning_status,
|
|
86
|
+
firstInvoice: payload.first_invoice,
|
|
87
|
+
generatedAt: payload.generated_at != null ? (0, zeniDayJS_1.date)(payload.generated_at) : undefined,
|
|
88
|
+
hasAdvanceCharges: payload.has_advance_charges,
|
|
89
|
+
issuedCreditNotes: payload.issued_credit_notes?.map((note) => mapIssuedCreditNote(note, currencyCode, currencySymbol)),
|
|
90
|
+
lineItems: payload.line_items?.map((item) => mapLineItem(item, currencyCode, currencySymbol)),
|
|
91
|
+
linkedPayments: payload.linked_payments?.map((payment) => mapLinkedPayment(payment, currencyCode, currencySymbol)),
|
|
92
|
+
netTermDays: payload.net_term_days,
|
|
93
|
+
nextRetryAt: payload.next_retry_at != null ? (0, zeniDayJS_1.date)(payload.next_retry_at) : undefined,
|
|
94
|
+
notes: payload.notes?.map(mapInvoiceNote),
|
|
95
|
+
paidAt: payload.paid_at != null ? (0, zeniDayJS_1.date)(payload.paid_at) : undefined,
|
|
96
|
+
poNumber: payload.po_number,
|
|
97
|
+
priceType: payload.price_type,
|
|
98
|
+
recurring: payload.recurring,
|
|
99
|
+
roundOffAmount: payload.round_off_amount != null
|
|
100
|
+
? toAmt(payload.round_off_amount)
|
|
101
|
+
: undefined,
|
|
102
|
+
shippingAddress: payload.shipping_address,
|
|
103
|
+
subscriptionID: payload.subscription_id,
|
|
104
|
+
subscriptionName: payload.subscription_name,
|
|
105
|
+
subTotal: payload.sub_total != null ? toAmt(payload.sub_total) : undefined,
|
|
106
|
+
tax: payload.tax != null ? toAmt(payload.tax) : undefined,
|
|
107
|
+
updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
|
|
108
|
+
writeOffAmount: payload.write_off_amount != null
|
|
109
|
+
? toAmt(payload.write_off_amount)
|
|
110
|
+
: undefined,
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
exports.mapInvoicingInvoicePayloadToState = mapInvoicingInvoicePayloadToState;
|
|
114
|
+
const mapInvoicingInvoiceKPIsPayloadToState = (payload) => ({
|
|
115
|
+
dueTotal: (0, amount_1.toAmount)(payload.due_total, DEFAULT_CURRENCY_CODE, DEFAULT_CURRENCY_SYMBOL),
|
|
116
|
+
paidTotal: (0, amount_1.toAmount)(payload.paid_total, DEFAULT_CURRENCY_CODE, DEFAULT_CURRENCY_SYMBOL),
|
|
117
|
+
pendingTotal: (0, amount_1.toAmount)(payload.pending_total, DEFAULT_CURRENCY_CODE, DEFAULT_CURRENCY_SYMBOL),
|
|
118
|
+
totalInvoiced: (0, amount_1.toAmount)(payload.total_invoiced, DEFAULT_CURRENCY_CODE, DEFAULT_CURRENCY_SYMBOL),
|
|
119
|
+
});
|
|
120
|
+
exports.mapInvoicingInvoiceKPIsPayloadToState = mapInvoicingInvoiceKPIsPayloadToState;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { UpdateType } from '../../../commonStateTypes/common';
|
|
2
|
-
import {
|
|
2
|
+
import { InvoicingInvoicePayload } from './invoicePayload';
|
|
3
3
|
import { InvoiceState } from './invoiceState';
|
|
4
4
|
export declare const initialState: InvoiceState;
|
|
5
|
-
export declare const updateInvoices: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, "invoicingInvoice/updateInvoices", never, never>, removeInvoice: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingInvoice/removeInvoice">, clearAllInvoices: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoice/clearAllInvoices">;
|
|
5
|
+
export declare const updateInvoices: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InvoicingInvoicePayload[], updateType?: UpdateType | undefined], InvoicingInvoicePayload[], "invoicingInvoice/updateInvoices", never, {
|
|
6
|
+
updateType: UpdateType;
|
|
7
|
+
}>, removeInvoice: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingInvoice/removeInvoice">, clearAllInvoices: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingInvoice/clearAllInvoices">;
|
|
9
8
|
declare const _default: import("redux").Reducer<InvoiceState>;
|
|
10
9
|
export default _default;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
var _a;
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.clearAllInvoices = exports.removeInvoice = exports.updateInvoices = exports.initialState = void 0;
|
|
5
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
+
const assignWith_1 = __importDefault(require("lodash/assignWith"));
|
|
10
|
+
const invoicePayload_1 = require("./invoicePayload");
|
|
6
11
|
exports.initialState = {
|
|
7
12
|
invoiceByID: {},
|
|
8
13
|
};
|
|
@@ -12,25 +17,33 @@ const invoice = (0, toolkit_1.createSlice)({
|
|
|
12
17
|
reducers: {
|
|
13
18
|
updateInvoices: {
|
|
14
19
|
reducer(draft, action) {
|
|
15
|
-
|
|
16
|
-
if (updateType === 'replace') {
|
|
17
|
-
draft.invoiceByID = {};
|
|
18
|
-
}
|
|
19
|
-
invoices.forEach((invoice) => {
|
|
20
|
-
draft.invoiceByID[invoice.id] = invoice;
|
|
21
|
-
});
|
|
20
|
+
doUpdateInvoices(draft.invoiceByID, action.payload, action.meta.updateType);
|
|
22
21
|
},
|
|
23
|
-
prepare(
|
|
24
|
-
return { payload: {
|
|
22
|
+
prepare(payload, updateType = 'replace') {
|
|
23
|
+
return { payload, meta: { updateType } };
|
|
25
24
|
},
|
|
26
25
|
},
|
|
27
26
|
removeInvoice(draft, action) {
|
|
28
27
|
delete draft.invoiceByID[action.payload];
|
|
29
28
|
},
|
|
30
29
|
clearAllInvoices(draft) {
|
|
31
|
-
draft.
|
|
30
|
+
Object.assign(draft, exports.initialState);
|
|
32
31
|
},
|
|
33
32
|
},
|
|
34
33
|
});
|
|
35
34
|
_a = invoice.actions, exports.updateInvoices = _a.updateInvoices, exports.removeInvoice = _a.removeInvoice, exports.clearAllInvoices = _a.clearAllInvoices;
|
|
36
35
|
exports.default = invoice.reducer;
|
|
36
|
+
/**
|
|
37
|
+
* Helper functions.
|
|
38
|
+
*/
|
|
39
|
+
function doUpdateInvoices(draft, payload, updateType) {
|
|
40
|
+
payload.forEach((invoicePayload) => {
|
|
41
|
+
const latestInvoice = (0, invoicePayload_1.mapInvoicingInvoicePayloadToState)(invoicePayload);
|
|
42
|
+
if (latestInvoice.id in draft && updateType === 'merge') {
|
|
43
|
+
(0, assignWith_1.default)(draft[latestInvoice.id], latestInvoice, (objValue, srcValue) => (srcValue == null ? objValue : srcValue));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
draft[latestInvoice.id] = latestInvoice;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ID } from '../../../commonStateTypes/common';
|
|
2
2
|
import { RootState } from '../../../reducer';
|
|
3
|
-
import { InvoicingInvoice } from './
|
|
3
|
+
import { InvoicingInvoice } from './invoiceState';
|
|
4
4
|
export declare const getInvoiceById: (state: RootState, invoiceId: ID) => InvoicingInvoice | undefined;
|
|
5
5
|
export declare const getInvoicesByIds: (state: RootState, invoiceIds: ID[]) => InvoicingInvoice[];
|
|
@@ -1,5 +1,99 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import {
|
|
3
|
+
import { ZeniDate } from '../../../zeniDayJS';
|
|
4
|
+
import { InvoicingBillingAddressPayload, InvoicingPriceType } from '../invoicingCommonPayload';
|
|
5
|
+
import { InvoicingInvoiceStatus } from './invoicePayload';
|
|
6
|
+
export interface InvoicingLineItem {
|
|
7
|
+
amount: Amount;
|
|
8
|
+
description: string;
|
|
9
|
+
quantity: number;
|
|
10
|
+
unitAmount: Amount;
|
|
11
|
+
dateFrom?: ZeniDate;
|
|
12
|
+
dateTo?: ZeniDate;
|
|
13
|
+
discountAmount?: Amount;
|
|
14
|
+
entityDescription?: string;
|
|
15
|
+
entityType?: string;
|
|
16
|
+
id?: ID;
|
|
17
|
+
isTaxed?: boolean;
|
|
18
|
+
itemLevelDiscountAmount?: Amount;
|
|
19
|
+
subscriptionID?: ID;
|
|
20
|
+
taxAmount?: Amount;
|
|
21
|
+
taxExemptReason?: string;
|
|
22
|
+
taxRate?: number;
|
|
23
|
+
usagePercentage?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface InvoicingLinkedPayment {
|
|
26
|
+
appliedAmount: Amount;
|
|
27
|
+
txnID: ID;
|
|
28
|
+
appliedAt?: ZeniDate;
|
|
29
|
+
txnAmount?: Amount;
|
|
30
|
+
txnDate?: ZeniDate;
|
|
31
|
+
txnStatus?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface InvoicingIssuedCreditNote {
|
|
34
|
+
cnID: ID;
|
|
35
|
+
cnStatus: string;
|
|
36
|
+
cnTotal: Amount;
|
|
37
|
+
}
|
|
38
|
+
export interface InvoicingDunningAttempt {
|
|
39
|
+
attempt: number;
|
|
40
|
+
createdAt?: ZeniDate;
|
|
41
|
+
dunningType?: string;
|
|
42
|
+
transactionID?: ID;
|
|
43
|
+
}
|
|
44
|
+
export interface InvoicingInvoiceNote {
|
|
45
|
+
note: string;
|
|
46
|
+
entityID?: ID;
|
|
47
|
+
entityType?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface InvoicingInvoice {
|
|
50
|
+
customerID: ID;
|
|
51
|
+
date: ZeniDate;
|
|
52
|
+
id: ID;
|
|
53
|
+
status: InvoicingInvoiceStatus;
|
|
54
|
+
total: Amount;
|
|
55
|
+
adjustmentCreditNotes?: ID[];
|
|
56
|
+
amountAdjusted?: Amount;
|
|
57
|
+
amountDue?: Amount;
|
|
58
|
+
amountPaid?: Amount;
|
|
59
|
+
amountToCollect?: Amount;
|
|
60
|
+
billingAddress?: InvoicingBillingAddressPayload;
|
|
61
|
+
createdAt?: ZeniDate;
|
|
62
|
+
creditsApplied?: Amount;
|
|
63
|
+
currencyCode?: string;
|
|
64
|
+
customerEmail?: string;
|
|
65
|
+
customerName?: string;
|
|
66
|
+
dueDate?: ZeniDate;
|
|
67
|
+
dunningAttempts?: InvoicingDunningAttempt[];
|
|
68
|
+
dunningStatus?: string;
|
|
69
|
+
firstInvoice?: boolean;
|
|
70
|
+
generatedAt?: ZeniDate;
|
|
71
|
+
hasAdvanceCharges?: boolean;
|
|
72
|
+
issuedCreditNotes?: InvoicingIssuedCreditNote[];
|
|
73
|
+
lineItems?: InvoicingLineItem[];
|
|
74
|
+
linkedPayments?: InvoicingLinkedPayment[];
|
|
75
|
+
netTermDays?: number;
|
|
76
|
+
nextRetryAt?: ZeniDate;
|
|
77
|
+
notes?: InvoicingInvoiceNote[];
|
|
78
|
+
paidAt?: ZeniDate;
|
|
79
|
+
poNumber?: string;
|
|
80
|
+
priceType?: InvoicingPriceType;
|
|
81
|
+
recurring?: boolean;
|
|
82
|
+
roundOffAmount?: Amount;
|
|
83
|
+
shippingAddress?: InvoicingBillingAddressPayload;
|
|
84
|
+
subscriptionID?: ID;
|
|
85
|
+
subscriptionName?: string;
|
|
86
|
+
subTotal?: Amount;
|
|
87
|
+
tax?: Amount;
|
|
88
|
+
updatedAt?: ZeniDate;
|
|
89
|
+
writeOffAmount?: Amount;
|
|
90
|
+
}
|
|
91
|
+
export interface InvoicingInvoiceKPIs {
|
|
92
|
+
dueTotal: Amount;
|
|
93
|
+
paidTotal: Amount;
|
|
94
|
+
pendingTotal: Amount;
|
|
95
|
+
totalInvoiced: Amount;
|
|
96
|
+
}
|
|
3
97
|
export interface InvoiceState {
|
|
4
98
|
invoiceByID: Record<ID, InvoicingInvoice>;
|
|
5
99
|
}
|