@zeniai/client-epic-state 5.1.30-betaAK0 → 5.1.30-betaAK1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/lib/entity/invoicing/invoice/invoicePayload.d.ts +3 -3
  2. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +2 -2
  3. package/lib/entity/invoicing/invoicingCommonState.d.ts +45 -0
  4. package/lib/entity/invoicing/{customer/customerPayload.d.ts → invoicingCustomer/invoicingCustomerPayload.d.ts} +7 -5
  5. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.js +72 -0
  6. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerReducer.d.ts +9 -0
  7. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerReducer.js +47 -0
  8. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerSelector.d.ts +4 -0
  9. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerSelector.js +17 -0
  10. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerState.d.ts +50 -0
  11. package/lib/entity/invoicing/{subscription/subscriptionPayload.d.ts → invoicingSubscription/invoicingSubscriptionPayload.d.ts} +14 -9
  12. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload.js +105 -0
  13. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer.d.ts +9 -0
  14. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer.js +49 -0
  15. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector.d.ts +5 -0
  16. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector.js +17 -0
  17. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionState.d.ts +75 -0
  18. package/lib/entity/tenant/clearAllEpic.d.ts +7 -5
  19. package/lib/entity/tenant/clearAllEpic.js +16 -12
  20. package/lib/epic.d.ts +5 -3
  21. package/lib/epic.js +9 -3
  22. package/lib/esm/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.js +68 -0
  23. package/lib/esm/entity/invoicing/invoicingCustomer/invoicingCustomerReducer.js +40 -0
  24. package/lib/esm/entity/invoicing/invoicingCustomer/invoicingCustomerSelector.js +10 -0
  25. package/lib/esm/entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload.js +98 -0
  26. package/lib/esm/entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer.js +42 -0
  27. package/lib/esm/entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector.js +10 -0
  28. package/lib/esm/entity/tenant/clearAllEpic.js +10 -6
  29. package/lib/esm/epic.js +9 -3
  30. package/lib/esm/index.js +11 -7
  31. package/lib/esm/reducer.js +14 -8
  32. package/lib/esm/view/invoicing/customerPaymentMethod/customerPaymentMethodEpic.js +1 -1
  33. package/lib/esm/view/invoicing/customerWrite/customerWriteEpic.js +1 -1
  34. package/lib/esm/view/invoicing/invoicingApiHelper.js +0 -24
  35. package/lib/esm/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewEpics.js +19 -0
  36. package/lib/esm/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewReducer.js +31 -0
  37. package/lib/esm/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +10 -0
  38. package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerCountsEpic.js +20 -0
  39. package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +40 -0
  40. package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListPageEpic.js +27 -0
  41. package/lib/esm/view/invoicing/{customerView/customerViewReducer.js → invoicingCustomerListView/invoicingCustomerListViewReducer.js} +20 -21
  42. package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +9 -0
  43. package/lib/esm/view/invoicing/invoicingOverview/epics/fetchInvoicingOverviewEpic.js +7 -3
  44. package/lib/esm/view/invoicing/invoicingOverview/invoicingOverviewSelector.js +29 -3
  45. package/lib/esm/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewEpics.js +19 -0
  46. package/lib/esm/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewReducer.js +31 -0
  47. package/lib/esm/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewSelector.js +10 -0
  48. package/lib/esm/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewState.js +1 -0
  49. package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionCountsEpic.js +23 -0
  50. package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +49 -0
  51. package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListPageEpic.js +27 -0
  52. package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewPayload.js +1 -0
  53. package/lib/esm/view/invoicing/{subscriptionView/subscriptionViewReducer.js → invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js} +20 -21
  54. package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +9 -0
  55. package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.js +1 -0
  56. package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +1 -1
  57. package/lib/esm/view/invoicing/subscriptionWrite/subscriptionWriteEpic.js +1 -1
  58. package/lib/index.d.ts +21 -13
  59. package/lib/index.js +45 -46
  60. package/lib/reducer.d.ts +14 -8
  61. package/lib/reducer.js +24 -18
  62. package/lib/view/invoicing/customerPaymentMethod/customerPaymentMethodEpic.d.ts +1 -1
  63. package/lib/view/invoicing/customerPaymentMethod/customerPaymentMethodEpic.js +2 -2
  64. package/lib/view/invoicing/customerWrite/customerWriteEpic.d.ts +1 -1
  65. package/lib/view/invoicing/customerWrite/customerWriteEpic.js +2 -2
  66. package/lib/view/invoicing/customerWrite/customerWritePayload.d.ts +2 -2
  67. package/lib/view/invoicing/invoicingApiHelper.d.ts +0 -7
  68. package/lib/view/invoicing/invoicingApiHelper.js +1 -26
  69. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewEpics.d.ts +8 -0
  70. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewEpics.js +23 -0
  71. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewPayload.d.ts +3 -0
  72. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewReducer.d.ts +11 -0
  73. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewReducer.js +35 -0
  74. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.d.ts +6 -0
  75. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +16 -0
  76. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewState.d.ts +4 -0
  77. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerCountsEpic.d.ts +7 -0
  78. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerCountsEpic.js +24 -0
  79. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.d.ts +8 -0
  80. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +44 -0
  81. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListPageEpic.d.ts +16 -0
  82. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListPageEpic.js +31 -0
  83. package/lib/view/invoicing/{customerView/customerViewPayload.d.ts → invoicingCustomerListView/invoicingCustomerListViewPayload.d.ts} +2 -3
  84. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +31 -0
  85. package/lib/view/invoicing/{customerView/customerViewReducer.js → invoicingCustomerListView/invoicingCustomerListViewReducer.js} +21 -22
  86. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.d.ts +12 -0
  87. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +13 -0
  88. package/lib/view/invoicing/{customerView/customerViewState.d.ts → invoicingCustomerListView/invoicingCustomerListViewState.d.ts} +1 -3
  89. package/lib/view/invoicing/invoicingOverview/epics/fetchInvoicingOverviewEpic.d.ts +1 -1
  90. package/lib/view/invoicing/invoicingOverview/epics/fetchInvoicingOverviewEpic.js +8 -4
  91. package/lib/view/invoicing/invoicingOverview/invoicingOverviewSelector.d.ts +12 -3
  92. package/lib/view/invoicing/invoicingOverview/invoicingOverviewSelector.js +30 -3
  93. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewEpics.d.ts +8 -0
  94. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewEpics.js +23 -0
  95. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewPayload.d.ts +3 -0
  96. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewReducer.d.ts +11 -0
  97. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewReducer.js +35 -0
  98. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewSelector.d.ts +6 -0
  99. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewSelector.js +16 -0
  100. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewState.d.ts +4 -0
  101. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewState.js +2 -0
  102. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionCountsEpic.d.ts +7 -0
  103. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionCountsEpic.js +27 -0
  104. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.d.ts +8 -0
  105. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +53 -0
  106. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListPageEpic.d.ts +16 -0
  107. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListPageEpic.js +31 -0
  108. package/lib/view/invoicing/{subscriptionView/subscriptionViewPayload.d.ts → invoicingSubscriptionListView/invoicingSubscriptionListViewPayload.d.ts} +2 -3
  109. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewPayload.js +2 -0
  110. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +31 -0
  111. package/lib/view/invoicing/{subscriptionView/subscriptionViewReducer.js → invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.js} +21 -22
  112. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.d.ts +12 -0
  113. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +13 -0
  114. package/lib/view/invoicing/{subscriptionView/subscriptionViewState.d.ts → invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts} +1 -3
  115. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.js +2 -0
  116. package/lib/view/invoicing/settingsView/settingsViewPayload.d.ts +2 -2
  117. package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +2 -2
  118. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +2 -2
  119. package/lib/view/invoicing/settingsView/settingsViewState.d.ts +2 -2
  120. package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.d.ts +1 -1
  121. package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +2 -2
  122. package/lib/view/invoicing/subscriptionAction/subscriptionActionPayload.d.ts +2 -2
  123. package/lib/view/invoicing/subscriptionWrite/subscriptionWriteEpic.d.ts +1 -1
  124. package/lib/view/invoicing/subscriptionWrite/subscriptionWriteEpic.js +2 -2
  125. package/lib/view/invoicing/subscriptionWrite/subscriptionWritePayload.d.ts +2 -2
  126. package/package.json +1 -1
  127. package/lib/entity/invoicing/customer/customerReducer.d.ts +0 -10
  128. package/lib/entity/invoicing/customer/customerReducer.js +0 -33
  129. package/lib/entity/invoicing/customer/customerState.d.ts +0 -5
  130. package/lib/entity/invoicing/subscription/subscriptionReducer.d.ts +0 -10
  131. package/lib/entity/invoicing/subscription/subscriptionReducer.js +0 -35
  132. package/lib/entity/invoicing/subscription/subscriptionState.d.ts +0 -5
  133. package/lib/esm/entity/invoicing/customer/customerReducer.js +0 -29
  134. package/lib/esm/entity/invoicing/subscription/subscriptionReducer.js +0 -31
  135. package/lib/esm/view/invoicing/customerView/customerViewEpics.js +0 -69
  136. package/lib/esm/view/invoicing/customerView/customerViewSelector.js +0 -17
  137. package/lib/esm/view/invoicing/subscriptionView/subscriptionViewEpics.js +0 -81
  138. package/lib/esm/view/invoicing/subscriptionView/subscriptionViewSelector.js +0 -19
  139. package/lib/view/invoicing/customerView/customerViewEpics.d.ts +0 -10
  140. package/lib/view/invoicing/customerView/customerViewEpics.js +0 -75
  141. package/lib/view/invoicing/customerView/customerViewReducer.d.ts +0 -27
  142. package/lib/view/invoicing/customerView/customerViewSelector.d.ts +0 -14
  143. package/lib/view/invoicing/customerView/customerViewSelector.js +0 -29
  144. package/lib/view/invoicing/subscriptionView/subscriptionViewEpics.d.ts +0 -10
  145. package/lib/view/invoicing/subscriptionView/subscriptionViewEpics.js +0 -87
  146. package/lib/view/invoicing/subscriptionView/subscriptionViewReducer.d.ts +0 -27
  147. package/lib/view/invoicing/subscriptionView/subscriptionViewSelector.d.ts +0 -14
  148. package/lib/view/invoicing/subscriptionView/subscriptionViewSelector.js +0 -31
  149. /package/lib/entity/invoicing/{customer/customerPayload.js → invoicingCommonState.js} +0 -0
  150. /package/lib/entity/invoicing/{customer/customerState.js → invoicingCustomer/invoicingCustomerState.js} +0 -0
  151. /package/lib/entity/invoicing/{subscription/subscriptionPayload.js → invoicingSubscription/invoicingSubscriptionState.js} +0 -0
  152. /package/lib/esm/entity/invoicing/{customer/customerPayload.js → invoicingCommonState.js} +0 -0
  153. /package/lib/esm/entity/invoicing/{customer/customerState.js → invoicingCustomer/invoicingCustomerState.js} +0 -0
  154. /package/lib/esm/entity/invoicing/{subscription/subscriptionPayload.js → invoicingSubscription/invoicingSubscriptionState.js} +0 -0
  155. /package/lib/esm/{entity/invoicing/subscription/subscriptionState.js → view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewPayload.js} +0 -0
  156. /package/lib/esm/view/invoicing/{customerView/customerViewPayload.js → invoicingCustomerDetailView/invoicingCustomerDetailViewState.js} +0 -0
  157. /package/lib/esm/view/invoicing/{customerView/customerViewState.js → invoicingCustomerListView/invoicingCustomerListViewPayload.js} +0 -0
  158. /package/lib/esm/view/invoicing/{subscriptionView/subscriptionViewPayload.js → invoicingCustomerListView/invoicingCustomerListViewState.js} +0 -0
  159. /package/lib/esm/view/invoicing/{subscriptionView/subscriptionViewState.js → invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewPayload.js} +0 -0
  160. /package/lib/{entity/invoicing/subscription/subscriptionState.js → view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewPayload.js} +0 -0
  161. /package/lib/view/invoicing/{customerView/customerViewPayload.js → invoicingCustomerDetailView/invoicingCustomerDetailViewState.js} +0 -0
  162. /package/lib/view/invoicing/{customerView/customerViewState.js → invoicingCustomerListView/invoicingCustomerListViewPayload.js} +0 -0
  163. /package/lib/view/invoicing/{subscriptionView/subscriptionViewPayload.js → invoicingCustomerListView/invoicingCustomerListViewState.js} +0 -0
  164. /package/lib/view/invoicing/{subscriptionView/subscriptionViewState.js → invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewPayload.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { InvoicingBillingAddress, InvoicingPriceType } from '../invoicingCommonPayload';
1
+ import { InvoicingBillingAddressPayload, InvoicingPriceType } from '../invoicingCommonPayload';
2
2
  export type InvoicingInvoiceStatus = 'paid' | 'partially_paid' | 'posted' | 'payment_due' | 'not_paid' | 'voided' | 'pending' | 'draft';
3
3
  export interface InvoicingLineItem {
4
4
  amount: number;
@@ -54,7 +54,7 @@ export interface InvoicingInvoice {
54
54
  amount_due?: number;
55
55
  amount_paid?: number;
56
56
  amount_to_collect?: number;
57
- billing_address?: InvoicingBillingAddress;
57
+ billing_address?: InvoicingBillingAddressPayload;
58
58
  created_at?: string;
59
59
  credits_applied?: number;
60
60
  currency_code?: string;
@@ -77,7 +77,7 @@ export interface InvoicingInvoice {
77
77
  price_type?: InvoicingPriceType;
78
78
  recurring?: boolean;
79
79
  round_off_amount?: number;
80
- shipping_address?: InvoicingBillingAddress;
80
+ shipping_address?: InvoicingBillingAddressPayload;
81
81
  sub_total?: number;
82
82
  subscription_id?: string;
83
83
  subscription_name?: string;
@@ -1,4 +1,4 @@
1
- export interface InvoicingBillingAddress {
1
+ export interface InvoicingBillingAddressPayload {
2
2
  city?: string;
3
3
  company?: string;
4
4
  country?: string;
@@ -22,7 +22,7 @@ export interface InvoicingPaginatedList<T> {
22
22
  items: T[];
23
23
  next_cursor: string | null;
24
24
  }
25
- export interface InvoicingSettings {
25
+ export interface InvoicingSettingsPayload {
26
26
  accent_color?: string;
27
27
  address?: string;
28
28
  address_enabled?: boolean;
@@ -0,0 +1,45 @@
1
+ import { ID } from "../../commonStateTypes/common";
2
+ import { ZeniUrl } from '../../zeniUrl';
3
+ export interface InvoicingBillingAddress {
4
+ city?: string;
5
+ company?: string;
6
+ country?: string;
7
+ email?: string;
8
+ firstName?: string;
9
+ lastName?: string;
10
+ line1?: string;
11
+ line2?: string;
12
+ phone?: string;
13
+ stateCode?: string;
14
+ validation_status?: 'not_validated' | 'valid' | 'partially_valid' | 'invalid';
15
+ zip?: string;
16
+ }
17
+ export interface InvoicingSettings {
18
+ addressEnabled: boolean;
19
+ autoCollection: 'on' | 'off';
20
+ chargebeeConnected: boolean;
21
+ chargebeeSite: string;
22
+ companyName: string;
23
+ dateFormat: string;
24
+ defaultMemo: string;
25
+ phoneEnabled: boolean;
26
+ showServicePeriods: boolean;
27
+ showTaxId: boolean;
28
+ taxEnabled: boolean;
29
+ accentColor?: string;
30
+ address?: InvoicingBillingAddress;
31
+ dunningMaxAttempts?: number;
32
+ dunningRetryInterval?: number;
33
+ email?: string;
34
+ id?: ID;
35
+ invoicePrefix?: string;
36
+ logoUrl?: ZeniUrl;
37
+ netTermDays?: number;
38
+ paymentTerms?: string;
39
+ phone?: string;
40
+ stripeConnectedAccountId?: ID;
41
+ stripePublishableKey?: ID;
42
+ taxId?: ID;
43
+ taxRate?: number;
44
+ timezone?: string;
45
+ }
@@ -1,11 +1,12 @@
1
- import { InvoicingBillingAddress, InvoicingListCounts } from '../invoicingCommonPayload';
2
- import { InvoicingSubscription } from '../subscription/subscriptionPayload';
3
- export interface InvoicingCustomer {
1
+ import { InvoicingBillingAddressPayload, InvoicingListCounts } from '../invoicingCommonPayload';
2
+ import { InvoicingSubscriptionPayload } from '../invoicingSubscription/invoicingSubscriptionPayload';
3
+ import { InvoicingCustomer } from './invoicingCustomerState';
4
+ export interface InvoicingCustomerPayload {
4
5
  id: string;
5
6
  allow_direct_debit?: boolean;
6
7
  arr?: number;
7
8
  auto_collection?: 'on' | 'off';
8
- billing_address?: InvoicingBillingAddress;
9
+ billing_address?: InvoicingBillingAddressPayload;
9
10
  card_status?: 'no_card' | 'valid' | 'expiring' | 'expired';
10
11
  company?: string;
11
12
  consolidated_invoicing?: boolean;
@@ -35,7 +36,7 @@ export interface InvoicingCustomer {
35
36
  refundable_credits?: number;
36
37
  status?: string;
37
38
  stripe_customer_id?: string;
38
- subscriptions?: InvoicingSubscription[];
39
+ subscriptions?: InvoicingSubscriptionPayload[];
39
40
  taxability?: 'taxable' | 'exempt';
40
41
  total_receivable?: number;
41
42
  unbilled_charges?: number;
@@ -50,3 +51,4 @@ export interface InvoicingCustomerCounts extends InvoicingListCounts {
50
51
  total: number;
51
52
  trial: number;
52
53
  }
54
+ export declare const mapInvoicingCustomerPayloadToState: (payload: InvoicingCustomerPayload) => InvoicingCustomer;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapInvoicingCustomerPayloadToState = void 0;
4
+ const amount_1 = require("../../../commonStateTypes/amount");
5
+ const zeniDayJS_1 = require("../../../zeniDayJS");
6
+ const invoicingSubscriptionPayload_1 = require("../invoicingSubscription/invoicingSubscriptionPayload");
7
+ // ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
8
+ const DEFAULT_CURRENCY_CODE = 'USD';
9
+ const DEFAULT_CURRENCY_SYMBOL = '$';
10
+ const mapInvoicingCustomerPayloadToState = (payload) => {
11
+ const currencyCode = payload.preferred_currency_code ?? DEFAULT_CURRENCY_CODE;
12
+ const currencySymbol = DEFAULT_CURRENCY_SYMBOL;
13
+ return {
14
+ id: payload.id,
15
+ allowDirectDebit: payload.allow_direct_debit,
16
+ arr: payload.arr != null
17
+ ? (0, amount_1.toAmount)(payload.arr, currencyCode, currencySymbol)
18
+ : undefined,
19
+ autoCollection: payload.auto_collection,
20
+ billingAddress: payload.billing_address,
21
+ cardStatus: payload.card_status,
22
+ company: payload.company,
23
+ consolidatedInvoicing: payload.consolidated_invoicing,
24
+ createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
25
+ customerType: payload.customer_type,
26
+ defaultPaymentMethodID: payload.default_payment_method_id,
27
+ email: payload.email,
28
+ excessPayments: payload.excess_payments != null
29
+ ? (0, amount_1.toAmount)(payload.excess_payments, currencyCode, currencySymbol)
30
+ : undefined,
31
+ firstName: payload.first_name,
32
+ fraudFlag: payload.fraud_flag,
33
+ initials: payload.initials,
34
+ invoiceNotes: payload.invoice_notes,
35
+ isAtRisk: payload.is_at_risk,
36
+ lastName: payload.last_name,
37
+ lifetimeValue: payload.lifetime_value != null
38
+ ? (0, amount_1.toAmount)(payload.lifetime_value, currencyCode, currencySymbol)
39
+ : undefined,
40
+ locale: payload.locale,
41
+ mrr: payload.mrr != null
42
+ ? (0, amount_1.toAmount)(payload.mrr, currencyCode, currencySymbol)
43
+ : undefined,
44
+ netTermDays: payload.net_term_days,
45
+ paymentMethod: payload.payment_method,
46
+ paymentMethodLast4: payload.payment_method_last4,
47
+ paymentMethodType: payload.payment_method_type,
48
+ phone: payload.phone,
49
+ plan: payload.plan,
50
+ planName: payload.plan_name,
51
+ preferredCurrencyCode: payload.preferred_currency_code,
52
+ promotionalCredits: payload.promotional_credits != null
53
+ ? (0, amount_1.toAmount)(payload.promotional_credits, currencyCode, currencySymbol)
54
+ : undefined,
55
+ refundableCredits: payload.refundable_credits != null
56
+ ? (0, amount_1.toAmount)(payload.refundable_credits, currencyCode, currencySymbol)
57
+ : undefined,
58
+ status: payload.status,
59
+ stripeCustomerID: payload.stripe_customer_id,
60
+ subscriptions: payload.subscriptions?.map(invoicingSubscriptionPayload_1.mapInvoicingSubscriptionPayloadToState),
61
+ taxability: payload.taxability,
62
+ totalReceivable: payload.total_receivable != null
63
+ ? (0, amount_1.toAmount)(payload.total_receivable, currencyCode, currencySymbol)
64
+ : undefined,
65
+ unbilledCharges: payload.unbilled_charges != null
66
+ ? (0, amount_1.toAmount)(payload.unbilled_charges, currencyCode, currencySymbol)
67
+ : undefined,
68
+ updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
69
+ vatNumber: payload.vat_number,
70
+ };
71
+ };
72
+ exports.mapInvoicingCustomerPayloadToState = mapInvoicingCustomerPayloadToState;
@@ -0,0 +1,9 @@
1
+ import { UpdateType } from '../../../commonStateTypes/common';
2
+ import { InvoicingCustomerPayload } from './invoicingCustomerPayload';
3
+ import { InvoicingCustomerState } from './invoicingCustomerState';
4
+ export declare const initialState: InvoicingCustomerState;
5
+ export declare const updateInvoicingCustomers: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InvoicingCustomerPayload[], updateType?: UpdateType | undefined], InvoicingCustomerPayload[], "invoicingCustomer/updateInvoicingCustomers", never, {
6
+ updateType: UpdateType;
7
+ }>, removeInvoicingCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingCustomer/removeInvoicingCustomer">, clearAllInvoicingCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCustomer/clearAllInvoicingCustomers">;
8
+ declare const _default: import("redux").Reducer<InvoicingCustomerState>;
9
+ export default _default;
@@ -0,0 +1,47 @@
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.clearAllInvoicingCustomers = exports.removeInvoicingCustomer = exports.updateInvoicingCustomers = exports.initialState = void 0;
8
+ const toolkit_1 = require("@reduxjs/toolkit");
9
+ const assignWith_1 = __importDefault(require("lodash/assignWith"));
10
+ const invoicingCustomerPayload_1 = require("./invoicingCustomerPayload");
11
+ exports.initialState = { customerByID: {} };
12
+ const customer = (0, toolkit_1.createSlice)({
13
+ name: 'invoicingCustomer',
14
+ initialState: exports.initialState,
15
+ reducers: {
16
+ updateInvoicingCustomers: {
17
+ reducer(draft, action) {
18
+ doUpdateInvoicingCustomers(draft.customerByID, action.payload, action.meta.updateType);
19
+ },
20
+ prepare(payload, updateType = 'replace') {
21
+ return { payload, meta: { updateType } };
22
+ },
23
+ },
24
+ removeInvoicingCustomer(draft, action) {
25
+ delete draft.customerByID[action.payload];
26
+ },
27
+ clearAllInvoicingCustomers(draft) {
28
+ Object.assign(draft, exports.initialState);
29
+ },
30
+ },
31
+ });
32
+ _a = customer.actions, exports.updateInvoicingCustomers = _a.updateInvoicingCustomers, exports.removeInvoicingCustomer = _a.removeInvoicingCustomer, exports.clearAllInvoicingCustomers = _a.clearAllInvoicingCustomers;
33
+ exports.default = customer.reducer;
34
+ /**
35
+ * Helper functions.
36
+ */
37
+ function doUpdateInvoicingCustomers(draft, payload, updateType) {
38
+ payload.forEach((customerPayload) => {
39
+ const latestCustomer = (0, invoicingCustomerPayload_1.mapInvoicingCustomerPayloadToState)(customerPayload);
40
+ if (latestCustomer.id in draft && updateType === 'merge') {
41
+ (0, assignWith_1.default)(draft[latestCustomer.id], latestCustomer, (objValue, srcValue) => (srcValue == null ? objValue : srcValue));
42
+ }
43
+ else {
44
+ draft[latestCustomer.id] = latestCustomer;
45
+ }
46
+ });
47
+ }
@@ -0,0 +1,4 @@
1
+ import { ID } from '../../../commonStateTypes/common';
2
+ import { InvoicingCustomer, InvoicingCustomerState } from './invoicingCustomerState';
3
+ export declare function getInvoicingCustomersByIds(invoicingCustomerState: InvoicingCustomerState, ids: ID[]): InvoicingCustomer[];
4
+ export declare function getInvoicingCustomerById(invoicingCustomerState: InvoicingCustomerState, id: ID): InvoicingCustomer | 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.getInvoicingCustomersByIds = getInvoicingCustomersByIds;
7
+ exports.getInvoicingCustomerById = getInvoicingCustomerById;
8
+ const get_1 = __importDefault(require("lodash/get"));
9
+ function getInvoicingCustomersByIds(invoicingCustomerState, ids) {
10
+ const invoicingCustomers = ids
11
+ .map((id) => getInvoicingCustomerById(invoicingCustomerState, id))
12
+ .filter((value) => value != null);
13
+ return invoicingCustomers;
14
+ }
15
+ function getInvoicingCustomerById(invoicingCustomerState, id) {
16
+ return (0, get_1.default)(invoicingCustomerState.customerByID, id);
17
+ }
@@ -0,0 +1,50 @@
1
+ import { Amount } from '../../../commonStateTypes/amount';
2
+ import { ID } from '../../../commonStateTypes/common';
3
+ import { ZeniDate } from '../../../zeniDayJS';
4
+ import { InvoicingBillingAddressPayload } from '../invoicingCommonPayload';
5
+ import { InvoicingSubscription } from '../invoicingSubscription/invoicingSubscriptionState';
6
+ export interface InvoicingCustomer {
7
+ id: ID;
8
+ allowDirectDebit?: boolean;
9
+ arr?: Amount;
10
+ autoCollection?: 'on' | 'off';
11
+ billingAddress?: InvoicingBillingAddressPayload;
12
+ cardStatus?: 'no_card' | 'valid' | 'expiring' | 'expired';
13
+ company?: string;
14
+ consolidatedInvoicing?: boolean;
15
+ createdAt?: ZeniDate;
16
+ customerType?: 'residential' | 'business';
17
+ defaultPaymentMethodID?: ID;
18
+ email?: string;
19
+ excessPayments?: Amount;
20
+ firstName?: string;
21
+ fraudFlag?: 'safe' | 'suspicious' | 'fraudulent';
22
+ initials?: string;
23
+ invoiceNotes?: string;
24
+ isAtRisk?: boolean;
25
+ lastName?: string;
26
+ lifetimeValue?: Amount;
27
+ locale?: string;
28
+ mrr?: Amount;
29
+ netTermDays?: number;
30
+ paymentMethod?: string;
31
+ paymentMethodLast4?: string;
32
+ paymentMethodType?: 'ach' | 'card' | 'none';
33
+ phone?: string;
34
+ plan?: string;
35
+ planName?: string;
36
+ preferredCurrencyCode?: string;
37
+ promotionalCredits?: Amount;
38
+ refundableCredits?: Amount;
39
+ status?: string;
40
+ stripeCustomerID?: ID;
41
+ subscriptions?: InvoicingSubscription[];
42
+ taxability?: 'taxable' | 'exempt';
43
+ totalReceivable?: Amount;
44
+ unbilledCharges?: Amount;
45
+ updatedAt?: ZeniDate;
46
+ vatNumber?: string;
47
+ }
48
+ export interface InvoicingCustomerState {
49
+ customerByID: Record<ID, InvoicingCustomer>;
50
+ }
@@ -1,7 +1,8 @@
1
- import { InvoicingBillingAddress } from '../invoicingCommonPayload';
1
+ import { InvoicingBillingAddressPayload } from '../invoicingCommonPayload';
2
+ import { InvoicingContractTerm, InvoicingSubscription, InvoicingSubscriptionCoupon, InvoicingSubscriptionItem } from './invoicingSubscriptionState';
2
3
  export type InvoicingSubscriptionStatus = 'active' | 'in_trial' | 'future' | 'non_renewing' | 'paused' | 'cancelled';
3
4
  export type InvoicingBillingPeriodUnit = 'day' | 'week' | 'month' | 'year';
4
- export interface InvoicingSubscriptionItem {
5
+ export interface InvoicingSubscriptionItemPayload {
5
6
  amount?: number;
6
7
  billing_cycles?: number;
7
8
  catalog_item_id?: string;
@@ -11,13 +12,13 @@ export interface InvoicingSubscriptionItem {
11
12
  quantity?: number;
12
13
  unit_price?: number;
13
14
  }
14
- export interface InvoicingSubscriptionCoupon {
15
+ export interface InvoicingSubscriptionCouponPayload {
15
16
  coupon_id: string;
16
17
  applied_count?: number;
17
18
  apply_till?: string;
18
19
  coupon_code?: string;
19
20
  }
20
- export interface InvoicingContractTerm {
21
+ export interface InvoicingContractTermPayload {
21
22
  id: string;
22
23
  action_at_term_end?: string;
23
24
  auto_renew?: boolean;
@@ -28,7 +29,7 @@ export interface InvoicingContractTerm {
28
29
  status?: string;
29
30
  total_contract_value?: number;
30
31
  }
31
- export interface InvoicingSubscription {
32
+ export interface InvoicingSubscriptionPayload {
32
33
  customer_id: string;
33
34
  id: string;
34
35
  status: InvoicingSubscriptionStatus;
@@ -40,8 +41,8 @@ export interface InvoicingSubscription {
40
41
  cancel_reason?: string;
41
42
  cancelled_at?: string;
42
43
  catalog_item_id?: string;
43
- contract_term?: InvoicingContractTerm;
44
- coupons?: InvoicingSubscriptionCoupon[];
44
+ contract_term?: InvoicingContractTermPayload;
45
+ coupons?: InvoicingSubscriptionCouponPayload[];
45
46
  created_at?: string;
46
47
  currency_code?: string;
47
48
  current_term_end?: string;
@@ -60,11 +61,15 @@ export interface InvoicingSubscription {
60
61
  remaining_billing_cycles?: number;
61
62
  resume_date?: string;
62
63
  setup_fee?: number;
63
- shipping_address?: InvoicingBillingAddress;
64
+ shipping_address?: InvoicingBillingAddressPayload;
64
65
  started_at?: string;
65
- subscription_items?: InvoicingSubscriptionItem[];
66
+ subscription_items?: InvoicingSubscriptionItemPayload[];
66
67
  total_dues?: number;
67
68
  trial_end?: string;
68
69
  trial_start?: string;
69
70
  updated_at?: string;
70
71
  }
72
+ export declare const mapInvoicingSubscriptionItemPayloadToState: (payload: InvoicingSubscriptionItemPayload, currencyCode: string, currencySymbol: string) => InvoicingSubscriptionItem;
73
+ export declare const mapInvoicingSubscriptionCouponPayloadToState: (payload: InvoicingSubscriptionCouponPayload) => InvoicingSubscriptionCoupon;
74
+ export declare const mapInvoicingContractTermPayloadToState: (payload: InvoicingContractTermPayload, currencyCode: string, currencySymbol: string) => InvoicingContractTerm;
75
+ export declare const mapInvoicingSubscriptionPayloadToState: (payload: InvoicingSubscriptionPayload) => InvoicingSubscription;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapInvoicingSubscriptionPayloadToState = exports.mapInvoicingContractTermPayloadToState = exports.mapInvoicingSubscriptionCouponPayloadToState = exports.mapInvoicingSubscriptionItemPayloadToState = 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 mapInvoicingSubscriptionItemPayloadToState = (payload, currencyCode, currencySymbol) => ({
10
+ amount: payload.amount != null
11
+ ? (0, amount_1.toAmount)(payload.amount, currencyCode, currencySymbol)
12
+ : undefined,
13
+ billingCycles: payload.billing_cycles,
14
+ catalogItemID: payload.catalog_item_id,
15
+ itemName: payload.item_name,
16
+ itemPriceID: payload.item_price_id,
17
+ itemType: payload.item_type,
18
+ quantity: payload.quantity,
19
+ unitPrice: payload.unit_price != null
20
+ ? (0, amount_1.toAmount)(payload.unit_price, currencyCode, currencySymbol)
21
+ : undefined,
22
+ });
23
+ exports.mapInvoicingSubscriptionItemPayloadToState = mapInvoicingSubscriptionItemPayloadToState;
24
+ const mapInvoicingSubscriptionCouponPayloadToState = (payload) => ({
25
+ couponID: payload.coupon_id,
26
+ appliedCount: payload.applied_count,
27
+ applyTill: payload.apply_till != null ? (0, zeniDayJS_1.date)(payload.apply_till) : undefined,
28
+ couponCode: payload.coupon_code,
29
+ });
30
+ exports.mapInvoicingSubscriptionCouponPayloadToState = mapInvoicingSubscriptionCouponPayloadToState;
31
+ const mapInvoicingContractTermPayloadToState = (payload, currencyCode, currencySymbol) => ({
32
+ id: payload.id,
33
+ actionAtTermEnd: payload.action_at_term_end,
34
+ autoRenew: payload.auto_renew,
35
+ billingCycle: payload.billing_cycle,
36
+ cancellationNoticeDays: payload.cancellation_notice_days,
37
+ contractEnd: payload.contract_end != null ? (0, zeniDayJS_1.date)(payload.contract_end) : undefined,
38
+ contractStart: payload.contract_start != null ? (0, zeniDayJS_1.date)(payload.contract_start) : undefined,
39
+ status: payload.status,
40
+ totalContractValue: payload.total_contract_value != null
41
+ ? (0, amount_1.toAmount)(payload.total_contract_value, currencyCode, currencySymbol)
42
+ : undefined,
43
+ });
44
+ exports.mapInvoicingContractTermPayloadToState = mapInvoicingContractTermPayloadToState;
45
+ const mapInvoicingSubscriptionPayloadToState = (payload) => {
46
+ const currencyCode = payload.currency_code ?? DEFAULT_CURRENCY_CODE;
47
+ const currencySymbol = DEFAULT_CURRENCY_SYMBOL;
48
+ return {
49
+ customerID: payload.customer_id,
50
+ id: payload.id,
51
+ status: payload.status,
52
+ activatedAt: payload.activated_at != null ? (0, zeniDayJS_1.date)(payload.activated_at) : undefined,
53
+ autoCollection: payload.auto_collection,
54
+ autoCollectionCount: payload.auto_collection_count,
55
+ billingPeriod: payload.billing_period,
56
+ billingPeriodUnit: payload.billing_period_unit,
57
+ cancelReason: payload.cancel_reason,
58
+ cancelledAt: payload.cancelled_at != null ? (0, zeniDayJS_1.date)(payload.cancelled_at) : undefined,
59
+ catalogItemID: payload.catalog_item_id,
60
+ contractTerm: payload.contract_term != null
61
+ ? (0, exports.mapInvoicingContractTermPayloadToState)(payload.contract_term, currencyCode, currencySymbol)
62
+ : undefined,
63
+ coupons: payload.coupons?.map(exports.mapInvoicingSubscriptionCouponPayloadToState),
64
+ createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
65
+ currencyCode: payload.currency_code,
66
+ currentTermEnd: payload.current_term_end != null
67
+ ? (0, zeniDayJS_1.date)(payload.current_term_end)
68
+ : undefined,
69
+ currentTermStart: payload.current_term_start != null
70
+ ? (0, zeniDayJS_1.date)(payload.current_term_start)
71
+ : undefined,
72
+ customerName: payload.customer_name,
73
+ dueInvoicesCount: payload.due_invoices_count,
74
+ dueSince: payload.due_since != null ? (0, zeniDayJS_1.date)(payload.due_since) : undefined,
75
+ hasScheduledChanges: payload.has_scheduled_changes,
76
+ mrr: payload.mrr != null
77
+ ? (0, amount_1.toAmount)(payload.mrr, currencyCode, currencySymbol)
78
+ : undefined,
79
+ nextBillingAt: payload.next_billing_at != null
80
+ ? (0, zeniDayJS_1.date)(payload.next_billing_at)
81
+ : undefined,
82
+ pauseDate: payload.pause_date != null ? (0, zeniDayJS_1.date)(payload.pause_date) : undefined,
83
+ planAmount: payload.plan_amount != null
84
+ ? (0, amount_1.toAmount)(payload.plan_amount, currencyCode, currencySymbol)
85
+ : undefined,
86
+ planID: payload.plan_id,
87
+ planName: payload.plan_name,
88
+ poNumber: payload.po_number,
89
+ remainingBillingCycles: payload.remaining_billing_cycles,
90
+ resumeDate: payload.resume_date != null ? (0, zeniDayJS_1.date)(payload.resume_date) : undefined,
91
+ setupFee: payload.setup_fee != null
92
+ ? (0, amount_1.toAmount)(payload.setup_fee, currencyCode, currencySymbol)
93
+ : undefined,
94
+ shippingAddress: payload.shipping_address,
95
+ startedAt: payload.started_at != null ? (0, zeniDayJS_1.date)(payload.started_at) : undefined,
96
+ subscriptionItems: payload.subscription_items?.map((item) => (0, exports.mapInvoicingSubscriptionItemPayloadToState)(item, currencyCode, currencySymbol)),
97
+ totalDues: payload.total_dues != null
98
+ ? (0, amount_1.toAmount)(payload.total_dues, currencyCode, currencySymbol)
99
+ : undefined,
100
+ trialEnd: payload.trial_end != null ? (0, zeniDayJS_1.date)(payload.trial_end) : undefined,
101
+ trialStart: payload.trial_start != null ? (0, zeniDayJS_1.date)(payload.trial_start) : undefined,
102
+ updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
103
+ };
104
+ };
105
+ exports.mapInvoicingSubscriptionPayloadToState = mapInvoicingSubscriptionPayloadToState;
@@ -0,0 +1,9 @@
1
+ import { UpdateType } from '../../../commonStateTypes/common';
2
+ import { InvoicingSubscriptionPayload } from './invoicingSubscriptionPayload';
3
+ import { InvoicingSubscriptionState } from './invoicingSubscriptionState';
4
+ export declare const initialState: InvoicingSubscriptionState;
5
+ export declare const updateInvoicingSubscriptions: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InvoicingSubscriptionPayload[], updateType?: UpdateType | undefined], InvoicingSubscriptionPayload[], "invoicingSubscription/updateInvoicingSubscriptions", never, {
6
+ updateType: UpdateType;
7
+ }>, removeInvoicingSubscription: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "invoicingSubscription/removeInvoicingSubscription">, clearAllInvoicingSubscriptions: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSubscription/clearAllInvoicingSubscriptions">;
8
+ declare const _default: import("redux").Reducer<InvoicingSubscriptionState>;
9
+ export default _default;
@@ -0,0 +1,49 @@
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.clearAllInvoicingSubscriptions = exports.removeInvoicingSubscription = exports.updateInvoicingSubscriptions = exports.initialState = void 0;
8
+ const toolkit_1 = require("@reduxjs/toolkit");
9
+ const assignWith_1 = __importDefault(require("lodash/assignWith"));
10
+ const invoicingSubscriptionPayload_1 = require("./invoicingSubscriptionPayload");
11
+ exports.initialState = {
12
+ invoicingSubscriptionByID: {},
13
+ };
14
+ const invoicingSubscription = (0, toolkit_1.createSlice)({
15
+ name: 'invoicingSubscription',
16
+ initialState: exports.initialState,
17
+ reducers: {
18
+ updateInvoicingSubscriptions: {
19
+ reducer(draft, action) {
20
+ doUpdateInvoicingSubscriptions(draft.invoicingSubscriptionByID, action.payload, action.meta.updateType);
21
+ },
22
+ prepare(payload, updateType = 'replace') {
23
+ return { payload, meta: { updateType } };
24
+ },
25
+ },
26
+ removeInvoicingSubscription(draft, action) {
27
+ delete draft.invoicingSubscriptionByID[action.payload];
28
+ },
29
+ clearAllInvoicingSubscriptions(draft) {
30
+ Object.assign(draft, exports.initialState);
31
+ },
32
+ },
33
+ });
34
+ _a = invoicingSubscription.actions, exports.updateInvoicingSubscriptions = _a.updateInvoicingSubscriptions, exports.removeInvoicingSubscription = _a.removeInvoicingSubscription, exports.clearAllInvoicingSubscriptions = _a.clearAllInvoicingSubscriptions;
35
+ exports.default = invoicingSubscription.reducer;
36
+ /**
37
+ * Helper functions.
38
+ */
39
+ function doUpdateInvoicingSubscriptions(draft, payload, updateType) {
40
+ payload.forEach((subscriptionPayload) => {
41
+ const latestSubscription = (0, invoicingSubscriptionPayload_1.mapInvoicingSubscriptionPayloadToState)(subscriptionPayload);
42
+ if (latestSubscription.id in draft && updateType === 'merge') {
43
+ (0, assignWith_1.default)(draft[latestSubscription.id], latestSubscription, (objValue, srcValue) => (srcValue == null ? objValue : srcValue));
44
+ }
45
+ else {
46
+ draft[latestSubscription.id] = latestSubscription;
47
+ }
48
+ });
49
+ }
@@ -0,0 +1,5 @@
1
+ import { ID } from '../../../commonStateTypes/common';
2
+ import { InvoicingSubscription } from './invoicingSubscriptionState';
3
+ import { InvoicingSubscriptionState } from './invoicingSubscriptionState';
4
+ export declare function getInvoicingSubscriptionsByIds(invoicingSubscriptionState: InvoicingSubscriptionState, ids: ID[]): InvoicingSubscription[];
5
+ export declare function getInvoicingSubscriptionById(invoicingSubscriptionState: InvoicingSubscriptionState, id: ID): InvoicingSubscription | 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.getInvoicingSubscriptionsByIds = getInvoicingSubscriptionsByIds;
7
+ exports.getInvoicingSubscriptionById = getInvoicingSubscriptionById;
8
+ const get_1 = __importDefault(require("lodash/get"));
9
+ function getInvoicingSubscriptionsByIds(invoicingSubscriptionState, ids) {
10
+ const invoicingSubscriptions = ids
11
+ .map((id) => getInvoicingSubscriptionById(invoicingSubscriptionState, id))
12
+ .filter((value) => value != null);
13
+ return invoicingSubscriptions;
14
+ }
15
+ function getInvoicingSubscriptionById(invoicingSubscriptionState, id) {
16
+ return (0, get_1.default)(invoicingSubscriptionState.invoicingSubscriptionByID, id);
17
+ }
@@ -0,0 +1,75 @@
1
+ import { Amount } from '../../../commonStateTypes/amount';
2
+ import { ID } from '../../../commonStateTypes/common';
3
+ import { ZeniDate } from '../../../zeniDayJS';
4
+ import { InvoicingBillingAddressPayload } from '../invoicingCommonPayload';
5
+ import { InvoicingBillingPeriodUnit, InvoicingSubscriptionStatus } from './invoicingSubscriptionPayload';
6
+ export interface InvoicingSubscriptionItem {
7
+ amount?: Amount;
8
+ billingCycles?: number;
9
+ catalogItemID?: ID;
10
+ itemName?: string;
11
+ itemPriceID?: ID;
12
+ itemType?: string;
13
+ quantity?: number;
14
+ unitPrice?: Amount;
15
+ }
16
+ export interface InvoicingSubscriptionCoupon {
17
+ couponID: ID;
18
+ appliedCount?: number;
19
+ applyTill?: ZeniDate;
20
+ couponCode?: string;
21
+ }
22
+ export interface InvoicingContractTerm {
23
+ id: ID;
24
+ actionAtTermEnd?: string;
25
+ autoRenew?: boolean;
26
+ billingCycle?: number;
27
+ cancellationNoticeDays?: number;
28
+ contractEnd?: ZeniDate;
29
+ contractStart?: ZeniDate;
30
+ status?: string;
31
+ totalContractValue?: Amount;
32
+ }
33
+ export interface InvoicingSubscription {
34
+ customerID: ID;
35
+ id: ID;
36
+ status: InvoicingSubscriptionStatus;
37
+ activatedAt?: ZeniDate;
38
+ autoCollection?: 'on' | 'off';
39
+ autoCollectionCount?: number;
40
+ billingPeriod?: number;
41
+ billingPeriodUnit?: InvoicingBillingPeriodUnit;
42
+ cancelledAt?: ZeniDate;
43
+ cancelReason?: string;
44
+ catalogItemID?: ID;
45
+ contractTerm?: InvoicingContractTerm;
46
+ coupons?: InvoicingSubscriptionCoupon[];
47
+ createdAt?: ZeniDate;
48
+ currencyCode?: string;
49
+ currentTermEnd?: ZeniDate;
50
+ currentTermStart?: ZeniDate;
51
+ customerName?: string;
52
+ dueInvoicesCount?: number;
53
+ dueSince?: ZeniDate;
54
+ hasScheduledChanges?: boolean;
55
+ mrr?: Amount;
56
+ nextBillingAt?: ZeniDate;
57
+ pauseDate?: ZeniDate;
58
+ planAmount?: Amount;
59
+ planID?: ID;
60
+ planName?: string;
61
+ poNumber?: string;
62
+ remainingBillingCycles?: number;
63
+ resumeDate?: ZeniDate;
64
+ setupFee?: Amount;
65
+ shippingAddress?: InvoicingBillingAddressPayload;
66
+ startedAt?: ZeniDate;
67
+ subscriptionItems?: InvoicingSubscriptionItem[];
68
+ totalDues?: Amount;
69
+ trialEnd?: ZeniDate;
70
+ trialStart?: ZeniDate;
71
+ updatedAt?: ZeniDate;
72
+ }
73
+ export interface InvoicingSubscriptionState {
74
+ invoicingSubscriptionByID: Record<ID, InvoicingSubscription>;
75
+ }