@zeniai/client-epic-state 5.2.32-betaAK4 → 5.2.32-betaAK6

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 (132) hide show
  1. package/lib/epic.d.ts +6 -4
  2. package/lib/epic.js +30 -17
  3. package/lib/esm/epic.js +17 -4
  4. package/lib/esm/index.js +2 -1
  5. package/lib/esm/view/invoicing/couponView/fetchInvoicingCouponCountsEpic.js +29 -0
  6. package/lib/esm/view/invoicing/couponView/fetchInvoicingCouponListEpic.js +41 -0
  7. package/lib/esm/view/invoicing/couponView/fetchInvoicingCouponListPageEpic.js +22 -0
  8. package/lib/esm/view/invoicing/customerPaymentMethod/createInvoicingSetupIntentEpic.js +17 -0
  9. package/lib/esm/view/invoicing/customerPaymentMethod/fetchInvoicingPlaidLinkTokenEpic.js +15 -0
  10. package/lib/esm/view/invoicing/customerPaymentMethod/saveInvoicingPaymentMethodEpic.js +21 -0
  11. package/lib/esm/view/invoicing/customerPaymentMethod/sendInvoicingPaymentLinkEpic.js +26 -0
  12. package/lib/esm/view/invoicing/dataImportView/fetchInvoicingDataImportStatusEpic.js +14 -0
  13. package/lib/esm/view/invoicing/dataImportView/fetchInvoicingMigrationDiagnosticsEpic.js +44 -0
  14. package/lib/esm/view/invoicing/dataImportView/fetchInvoicingMigrationSessionEpic.js +14 -0
  15. package/lib/esm/view/invoicing/dataImportView/fetchInvoicingMigrationSessionsEpic.js +14 -0
  16. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +8 -0
  17. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +48 -1
  18. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +52 -9
  19. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/fetchInvoicingPaymentLinkEmailPreviewEpic.js +31 -0
  20. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/fetchInvoicingPaymentLinkEmailPreviewPageEpic.js +23 -0
  21. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +4 -4
  22. package/lib/esm/view/invoicing/invoiceDetail/voidInvoiceHelper.js +32 -0
  23. package/lib/esm/view/invoicing/settingsView/initializeInvoicingBrandingAddressEpic.js +27 -0
  24. package/lib/esm/view/invoicing/settingsView/{invoicingBrandingFormEpics.js → submitInvoicingBrandingFormEpic.js} +3 -19
  25. package/lib/index.d.ts +5 -3
  26. package/lib/index.js +10 -5
  27. package/lib/view/invoicing/couponView/{couponViewEpics.d.ts → fetchInvoicingCouponCountsEpic.d.ts} +4 -2
  28. package/lib/view/invoicing/couponView/fetchInvoicingCouponCountsEpic.js +33 -0
  29. package/lib/view/invoicing/couponView/fetchInvoicingCouponListEpic.d.ts +8 -0
  30. package/lib/view/invoicing/couponView/fetchInvoicingCouponListEpic.js +45 -0
  31. package/lib/view/invoicing/couponView/fetchInvoicingCouponListPageEpic.d.ts +7 -0
  32. package/lib/view/invoicing/couponView/fetchInvoicingCouponListPageEpic.js +26 -0
  33. package/lib/view/invoicing/customerPaymentMethod/createInvoicingSetupIntentEpic.d.ts +8 -0
  34. package/lib/view/invoicing/customerPaymentMethod/createInvoicingSetupIntentEpic.js +21 -0
  35. package/lib/view/invoicing/customerPaymentMethod/customerPaymentMethodReducer.d.ts +4 -0
  36. package/lib/view/invoicing/customerPaymentMethod/{customerPaymentMethodEpic.d.ts → fetchInvoicingPlaidLinkTokenEpic.d.ts} +0 -3
  37. package/lib/view/invoicing/customerPaymentMethod/fetchInvoicingPlaidLinkTokenEpic.js +19 -0
  38. package/lib/view/invoicing/customerPaymentMethod/saveInvoicingPaymentMethodEpic.d.ts +8 -0
  39. package/lib/view/invoicing/customerPaymentMethod/saveInvoicingPaymentMethodEpic.js +25 -0
  40. package/lib/view/invoicing/customerPaymentMethod/sendInvoicingPaymentLinkEpic.d.ts +8 -0
  41. package/lib/view/invoicing/customerPaymentMethod/sendInvoicingPaymentLinkEpic.js +30 -0
  42. package/lib/view/invoicing/dataImportView/fetchInvoicingDataImportStatusEpic.d.ts +7 -0
  43. package/lib/view/invoicing/dataImportView/fetchInvoicingDataImportStatusEpic.js +18 -0
  44. package/lib/view/invoicing/dataImportView/{dataImportViewEpics.d.ts → fetchInvoicingMigrationDiagnosticsEpic.d.ts} +0 -3
  45. package/lib/view/invoicing/dataImportView/fetchInvoicingMigrationDiagnosticsEpic.js +48 -0
  46. package/lib/view/invoicing/dataImportView/fetchInvoicingMigrationSessionEpic.d.ts +7 -0
  47. package/lib/view/invoicing/dataImportView/fetchInvoicingMigrationSessionEpic.js +18 -0
  48. package/lib/view/invoicing/dataImportView/fetchInvoicingMigrationSessionsEpic.d.ts +7 -0
  49. package/lib/view/invoicing/dataImportView/fetchInvoicingMigrationSessionsEpic.js +18 -0
  50. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +1 -0
  51. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +1 -1
  52. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.d.ts +1 -0
  53. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.d.ts +27 -0
  54. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +10 -1
  55. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +16 -1
  56. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +49 -2
  57. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +45 -1
  58. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +54 -10
  59. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +9 -0
  60. package/lib/view/invoicing/editInvoicingCustomerDetailView/fetchInvoicingPaymentLinkEmailPreviewEpic.d.ts +12 -0
  61. package/lib/view/invoicing/editInvoicingCustomerDetailView/fetchInvoicingPaymentLinkEmailPreviewEpic.js +35 -0
  62. package/lib/view/invoicing/editInvoicingCustomerDetailView/fetchInvoicingPaymentLinkEmailPreviewPageEpic.d.ts +10 -0
  63. package/lib/view/invoicing/editInvoicingCustomerDetailView/fetchInvoicingPaymentLinkEmailPreviewPageEpic.js +27 -0
  64. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.d.ts +55 -0
  65. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +1 -1
  66. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +4 -4
  67. package/lib/view/invoicing/invoiceDetail/invoiceDetailPayload.d.ts +53 -0
  68. package/lib/view/invoicing/invoiceDetail/invoiceDetailReducer.d.ts +1 -1
  69. package/lib/view/invoicing/invoiceDetail/voidInvoiceHelper.d.ts +11 -0
  70. package/lib/view/invoicing/invoiceDetail/voidInvoiceHelper.js +38 -0
  71. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +1 -1
  72. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +1 -1
  73. package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewPayload.d.ts +25 -0
  74. package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningCaseDetailViewReducer.d.ts +1 -1
  75. package/lib/view/invoicing/invoicingTransactionDetailView/invoicingTransactionDetailViewPayload.d.ts +8 -0
  76. package/lib/view/invoicing/invoicingTransactionDetailView/invoicingTransactionDetailViewReducer.d.ts +1 -1
  77. package/lib/view/invoicing/settingsView/{invoicingBrandingFormEpics.d.ts → initializeInvoicingBrandingAddressEpic.d.ts} +1 -8
  78. package/lib/view/invoicing/settingsView/initializeInvoicingBrandingAddressEpic.js +31 -0
  79. package/lib/view/invoicing/settingsView/submitInvoicingBrandingFormEpic.d.ts +20 -0
  80. package/lib/view/invoicing/settingsView/{invoicingBrandingFormEpics.js → submitInvoicingBrandingFormEpic.js} +1 -18
  81. package/package.json +1 -1
  82. package/lib/esm/view/invoicing/couponView/couponViewEpics.js +0 -76
  83. package/lib/esm/view/invoicing/customerPaymentMethod/customerPaymentMethodEpic.js +0 -63
  84. package/lib/esm/view/invoicing/dataImportView/dataImportViewEpics.js +0 -74
  85. package/lib/esm/view/invoicing/dataImportView/invoicingDataImportActionPayload.js +0 -1
  86. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemDetailPayload.js +0 -1
  87. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/invoicingCouponDetailPayload.js +0 -1
  88. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerDetailPayload.js +0 -1
  89. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerRecordSelector.js +0 -32
  90. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/promotionalCreditPayload.js +0 -1
  91. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionActionPayload.js +0 -1
  92. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionActionRequestPayload.js +0 -2
  93. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionDetailPayload.js +0 -1
  94. package/lib/esm/view/invoicing/invoiceDetail/invoicingInvoiceActionPayload.js +0 -1
  95. package/lib/esm/view/invoicing/invoiceDetail/invoicingInvoiceActionRequestPayload.js +0 -2
  96. package/lib/esm/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningActionPayload.js +0 -1
  97. package/lib/esm/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningActionRequestPayload.js +0 -2
  98. package/lib/esm/view/invoicing/invoicingTransactionDetailView/invoicingPaymentActionPayload.js +0 -1
  99. package/lib/esm/view/invoicing/invoicingTransactionDetailView/invoicingPaymentActionRequestPayload.js +0 -2
  100. package/lib/view/invoicing/couponView/couponViewEpics.js +0 -82
  101. package/lib/view/invoicing/customerPaymentMethod/customerPaymentMethodEpic.js +0 -70
  102. package/lib/view/invoicing/dataImportView/dataImportViewEpics.js +0 -81
  103. package/lib/view/invoicing/dataImportView/invoicingDataImportActionPayload.d.ts +0 -3
  104. package/lib/view/invoicing/dataImportView/invoicingDataImportActionPayload.js +0 -2
  105. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemDetailPayload.d.ts +0 -3
  106. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemDetailPayload.js +0 -2
  107. package/lib/view/invoicing/editInvoicingCouponDetailView/invoicingCouponDetailPayload.d.ts +0 -3
  108. package/lib/view/invoicing/editInvoicingCouponDetailView/invoicingCouponDetailPayload.js +0 -2
  109. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerDetailPayload.d.ts +0 -3
  110. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerDetailPayload.js +0 -2
  111. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerRecordSelector.d.ts +0 -37
  112. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerRecordSelector.js +0 -36
  113. package/lib/view/invoicing/editInvoicingCustomerDetailView/promotionalCreditPayload.d.ts +0 -3
  114. package/lib/view/invoicing/editInvoicingCustomerDetailView/promotionalCreditPayload.js +0 -2
  115. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionActionPayload.d.ts +0 -3
  116. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionActionPayload.js +0 -2
  117. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionActionRequestPayload.d.ts +0 -53
  118. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionActionRequestPayload.js +0 -3
  119. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionDetailPayload.d.ts +0 -3
  120. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionDetailPayload.js +0 -2
  121. package/lib/view/invoicing/invoiceDetail/invoicingInvoiceActionPayload.d.ts +0 -3
  122. package/lib/view/invoicing/invoiceDetail/invoicingInvoiceActionPayload.js +0 -2
  123. package/lib/view/invoicing/invoiceDetail/invoicingInvoiceActionRequestPayload.d.ts +0 -52
  124. package/lib/view/invoicing/invoiceDetail/invoicingInvoiceActionRequestPayload.js +0 -3
  125. package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningActionPayload.d.ts +0 -3
  126. package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningActionPayload.js +0 -2
  127. package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningActionRequestPayload.d.ts +0 -24
  128. package/lib/view/invoicing/invoicingDunningCaseDetailView/invoicingDunningActionRequestPayload.js +0 -3
  129. package/lib/view/invoicing/invoicingTransactionDetailView/invoicingPaymentActionPayload.d.ts +0 -3
  130. package/lib/view/invoicing/invoicingTransactionDetailView/invoicingPaymentActionPayload.js +0 -2
  131. package/lib/view/invoicing/invoicingTransactionDetailView/invoicingPaymentActionRequestPayload.d.ts +0 -7
  132. package/lib/view/invoicing/invoicingTransactionDetailView/invoicingPaymentActionRequestPayload.js +0 -3
@@ -1,13 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInvoicingCustomerFormView = void 0;
3
+ exports.getInvoicingCustomerFormView = exports.getInvoicingCustomerRecord = void 0;
4
4
  const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
5
5
  const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
6
6
  const addressViewSelector_1 = require("../../addressView/addressViewSelector");
7
- const customerPaymentMethodSelector_1 = require("../customerPaymentMethod/customerPaymentMethodSelector");
8
- const invoicingCustomerRecordSelector_1 = require("./invoicingCustomerRecordSelector");
9
7
  const invoicingConfigViewSelector_1 = require("../invoicingConfigView/invoicingConfigViewSelector");
10
8
  const invoicingCustomerFormConfig_1 = require("./invoicingCustomerFormConfig");
9
+ const invoiceSelector_1 = require("../../../entity/invoicing/invoice/invoiceSelector");
10
+ const invoicingCustomerSelector_2 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
11
+ const customerPaymentMethodSelector_1 = require("../customerPaymentMethod/customerPaymentMethodSelector");
12
+ const invoicingSettingsHelpers_1 = require("../settingsView/invoicingSettingsHelpers");
13
+ const settingsViewSelector_1 = require("../settingsView/settingsViewSelector");
14
+ /**
15
+ * `invoicingCustomerID` is absent in create mode, where there is no record to
16
+ * resolve — the view still renders, off an empty record.
17
+ */
18
+ const getInvoicingCustomerRecord = (state, invoicingCustomerID) => {
19
+ const { invoicingCustomerState } = state;
20
+ const invoicingCustomerDetail = invoicingCustomerID == null
21
+ ? undefined
22
+ : state.editInvoicingCustomerDetailViewState.recordStateById[invoicingCustomerID];
23
+ const settings = (0, settingsViewSelector_1.getInvoicingSettings)(state);
24
+ const invoicingCustomer = invoicingCustomerID == null
25
+ ? undefined
26
+ : (0, invoicingCustomerSelector_1.getInvoicingCustomerById)(invoicingCustomerState, invoicingCustomerID);
27
+ return {
28
+ fieldHelp: (0, invoicingConfigViewSelector_1.invoicingFieldHelpForGroup)(state, 'customer'),
29
+ invoicingCustomer,
30
+ invoices: (0, invoiceSelector_1.getInvoicesByIds)(state.invoicingInvoiceState, state.invoicingInvoiceListState.invoiceByTab[state.invoicingInvoiceListState.activeTab]?.invoiceIds ?? []),
31
+ paymentMethods: (0, invoicingCustomerSelector_2.invoicingCustomerPaymentMethods)(invoicingCustomer),
32
+ setupIntent: (0, customerPaymentMethodSelector_1.getInvoicingSetupIntent)(state),
33
+ setupIntentFetchState: (0, customerPaymentMethodSelector_1.getInvoicingSetupIntentFetchState)(state),
34
+ plaidLinkToken: (0, customerPaymentMethodSelector_1.getInvoicingPlaidLinkToken)(state),
35
+ paymentMethodSaveState: (0, customerPaymentMethodSelector_1.getInvoicingPaymentMethodSaveState)(state),
36
+ sendLinkState: (0, customerPaymentMethodSelector_1.getInvoicingPaymentLinkSendState)(state),
37
+ sentPaymentLinkEmail: (0, customerPaymentMethodSelector_1.getInvoicingSentPaymentLinkEmail)(state),
38
+ sentPaymentLinkMagicUrl: (0, customerPaymentMethodSelector_1.getInvoicingSentPaymentLinkMagicUrl)(state),
39
+ brandingAccentColor: settings?.accent_color,
40
+ brandingCompanyName: settings?.company_name,
41
+ brandingEmail: settings?.email,
42
+ brandingLogoUrl: settings?.logo_url,
43
+ stripeConnected: (0, invoicingSettingsHelpers_1.isStripeConnectedFromSettings)(settings),
44
+ fetchState: invoicingCustomerDetail?.fetchState ?? 'Not-Started',
45
+ error: invoicingCustomerDetail?.error,
46
+ };
47
+ };
48
+ exports.getInvoicingCustomerRecord = getInvoicingCustomerRecord;
11
49
  /**
12
50
  * Bundled view for the customer create/edit form. Exposes the draft `localData`
13
51
  * (seeded from the existing customer entity in edit mode until the user edits),
@@ -36,21 +74,27 @@ const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
36
74
  const billingAddressLabel = newAddress?.addressToCreate != null
37
75
  ? (0, addressViewSelector_1.getFormattedAddress)(newAddress.addressToCreate)
38
76
  : undefined;
39
- const { customerTypeOptions, netTermDayOptions, taxabilityOptions } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
40
77
  const configState = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
41
- const recordState = state.editInvoicingCustomerDetailViewState
42
- .recordStateById[invoicingCustomerID ?? ''] ?? {
43
- error: undefined,
44
- fetchState: invoicingCustomerID != null ? 'Not-Started' : 'Completed',
45
- };
78
+ const { customerTypeOptions, netTermDayOptions, taxabilityOptions } = configState;
79
+ // In create mode there is nothing to load, so the record state reads as
80
+ // settled rather than pending.
81
+ const recordState = invoicingCustomerID == null
82
+ ? { error: undefined, fetchState: 'Completed' }
83
+ : (state.editInvoicingCustomerDetailViewState.recordStateById[invoicingCustomerID] ?? { error: undefined, fetchState: 'Not-Started' });
84
+ const { emailPreview, emailPreviewCustomerId, emailPreviewFetchState } = state.editInvoicingCustomerDetailViewState;
46
85
  return {
86
+ // A preview cached for another customer is not this screen's.
87
+ emailPreview: emailPreviewCustomerId === invoicingCustomerID ? emailPreview : undefined,
88
+ emailPreviewFetchState: emailPreviewCustomerId === invoicingCustomerID
89
+ ? emailPreviewFetchState
90
+ : { error: undefined, fetchState: 'Not-Started' },
47
91
  pageFetchState: (0, reduceFetchState_1.reduceAllFetchState)([
48
92
  recordState,
49
93
  { error: configState.error, fetchState: configState.fetchState },
50
94
  ]),
51
95
  plaidTokenFetchState: (0, customerPaymentMethodSelector_1.getInvoicingPlaidLinkTokenFetchState)(state),
52
96
  promotionalCreditSubmitState: state.editInvoicingCustomerDetailViewState.promotionalCreditSubmitState,
53
- record: (0, invoicingCustomerRecordSelector_1.getInvoicingCustomerRecord)(state, invoicingCustomerID ?? ''),
97
+ record: (0, exports.getInvoicingCustomerRecord)(state, invoicingCustomerID),
54
98
  fieldHelp: (0, invoicingConfigViewSelector_1.invoicingFieldHelpForGroup)(state, 'customer'),
55
99
  customerTypeOptions,
56
100
  localData,
@@ -1,3 +1,4 @@
1
+ import { InvoicingPaymentLinkEmailPreviewData } from './editInvoicingCustomerDetailViewPayload';
1
2
  import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
2
3
  /**
3
4
  * Draft form state for the create/edit customer form. Held in CES so the form
@@ -23,6 +24,12 @@ export interface InvoicingCustomerFormLocalData {
23
24
  }
24
25
  export interface EditInvoicingCustomerDetailViewState extends FetchedState {
25
26
  editDraftById: Record<ID, InvoicingCustomerFormLocalData>;
27
+ /**
28
+ * The payment-link email rendered by the backend, cached per customer so
29
+ * reopening the composer costs nothing. `emailPreviewCustomerId` is the cache
30
+ * key — a different customer invalidates it.
31
+ */
32
+ emailPreviewFetchState: FetchStateAndError;
26
33
  newCustomerDraft: InvoicingCustomerFormLocalData;
27
34
  /**
28
35
  * Adding promotional credits to this customer — a write against the customer,
@@ -31,5 +38,7 @@ export interface EditInvoicingCustomerDetailViewState extends FetchedState {
31
38
  promotionalCreditSubmitState: FetchStateAndError;
32
39
  /** Detail-load state per customer id. */
33
40
  recordStateById: Record<ID, FetchStateAndError>;
41
+ emailPreview?: InvoicingPaymentLinkEmailPreviewData;
42
+ emailPreviewCustomerId?: ID;
34
43
  savedCustomerId?: ID;
35
44
  }
@@ -0,0 +1,12 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../rootStateTypes';
4
+ import { ZeniAPI } from '../../../zeniAPI';
5
+ import { fetchInvoicingPaymentLinkEmailPreview, updateInvoicingPaymentLinkEmailPreview, updateInvoicingPaymentLinkEmailPreviewFailure } from './editInvoicingCustomerDetailViewReducer';
6
+ export type ActionType = ReturnType<typeof fetchInvoicingPaymentLinkEmailPreview> | ReturnType<typeof updateInvoicingPaymentLinkEmailPreview> | ReturnType<typeof updateInvoicingPaymentLinkEmailPreviewFailure>;
7
+ /**
8
+ * Renders the payment-link email once, server-side, with sentinel tokens where
9
+ * the subject and body go. The composer splices the draft into those tokens as
10
+ * the user types, so editing costs no further requests.
11
+ */
12
+ export declare const fetchInvoicingPaymentLinkEmailPreviewEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchInvoicingPaymentLinkEmailPreviewEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../responsePayload");
7
+ const editInvoicingCustomerDetailViewReducer_1 = require("./editInvoicingCustomerDetailViewReducer");
8
+ const editInvoicingCustomerDetailViewPayload_1 = require("./editInvoicingCustomerDetailViewPayload");
9
+ /**
10
+ * Renders the payment-link email once, server-side, with sentinel tokens where
11
+ * the subject and body go. The composer splices the draft into those tokens as
12
+ * the user types, so editing costs no further requests.
13
+ */
14
+ const fetchInvoicingPaymentLinkEmailPreviewEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(editInvoicingCustomerDetailViewReducer_1.fetchInvoicingPaymentLinkEmailPreview.match), (0, operators_1.switchMap)((action) => {
15
+ const { customerId } = action.payload;
16
+ const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(customerId)}/payment-link/email-preview`;
17
+ return zeniAPI
18
+ .postAndGetJSON(apiUrl, {})
19
+ .pipe((0, operators_1.map)((response) => {
20
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
21
+ return (0, editInvoicingCustomerDetailViewReducer_1.updateInvoicingPaymentLinkEmailPreview)({
22
+ customerId,
23
+ preview: (0, editInvoicingCustomerDetailViewPayload_1.toInvoicingPaymentLinkEmailPreview)(response.data),
24
+ });
25
+ }
26
+ return (0, editInvoicingCustomerDetailViewReducer_1.updateInvoicingPaymentLinkEmailPreviewFailure)({
27
+ customerId,
28
+ status: response.status,
29
+ });
30
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, editInvoicingCustomerDetailViewReducer_1.updateInvoicingPaymentLinkEmailPreviewFailure)({
31
+ customerId,
32
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Payment link email preview REST API call errored out: ${error instanceof Error ? error.message : String(error)}`),
33
+ }))));
34
+ }));
35
+ exports.fetchInvoicingPaymentLinkEmailPreviewEpic = fetchInvoicingPaymentLinkEmailPreviewEpic;
@@ -0,0 +1,10 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../rootStateTypes';
4
+ import { fetchInvoicingPaymentLinkEmailPreview, fetchInvoicingPaymentLinkEmailPreviewPage } from './editInvoicingCustomerDetailViewReducer';
5
+ export type ActionType = ReturnType<typeof fetchInvoicingPaymentLinkEmailPreview> | ReturnType<typeof fetchInvoicingPaymentLinkEmailPreviewPage>;
6
+ /**
7
+ * Opening the composer asks for the preview at most once per customer: a
8
+ * cached one is reused, and switching customer invalidates it.
9
+ */
10
+ export declare const fetchInvoicingPaymentLinkEmailPreviewPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchInvoicingPaymentLinkEmailPreviewPageEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const editInvoicingCustomerDetailViewReducer_1 = require("./editInvoicingCustomerDetailViewReducer");
7
+ /**
8
+ * Fetch unless this customer's preview is already loaded or in flight — or
9
+ * always when the caller forces a refresh via `cacheOverride` (Retry).
10
+ */
11
+ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
12
+ (fetchStateAndError.fetchState !== 'Completed' &&
13
+ fetchStateAndError.fetchState !== 'In-Progress');
14
+ /**
15
+ * Opening the composer asks for the preview at most once per customer: a
16
+ * cached one is reused, and switching customer invalidates it.
17
+ */
18
+ const fetchInvoicingPaymentLinkEmailPreviewPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editInvoicingCustomerDetailViewReducer_1.fetchInvoicingPaymentLinkEmailPreviewPage.match), (0, operators_1.mergeMap)((action) => {
19
+ const { cacheOverride, customerId } = action.payload;
20
+ const { emailPreviewCustomerId, emailPreviewFetchState } = state$.value.editInvoicingCustomerDetailViewState;
21
+ const cachedForThisCustomer = emailPreviewCustomerId === customerId;
22
+ return !cachedForThisCustomer ||
23
+ shouldFetch(emailPreviewFetchState, cacheOverride)
24
+ ? (0, rxjs_1.of)((0, editInvoicingCustomerDetailViewReducer_1.fetchInvoicingPaymentLinkEmailPreview)({ customerId }))
25
+ : rxjs_1.EMPTY;
26
+ }));
27
+ exports.fetchInvoicingPaymentLinkEmailPreviewPageEpic = fetchInvoicingPaymentLinkEmailPreviewPageEpic;
@@ -19,3 +19,58 @@ export type SaveInvoicingSubscriptionResponse = ZeniAPIResponse<InvoicingSubscri
19
19
  * — a daily plan, for instance — fail with a 422.
20
20
  */
21
21
  export declare const localDataToSaveInvoicingSubscriptionPayload: (localData: InvoicingSubscriptionFormLocalData, shippingAddress?: AddressUpdatableInfo) => Record<string, unknown>;
22
+ export type RunInvoicingSubscriptionActionResponse = ZeniAPIResponse<InvoicingSubscriptionPayload>;
23
+ /** Snake_case request bodies for subscription action endpoints. */
24
+ export type ApplyCouponBody = {
25
+ coupon_code: string;
26
+ };
27
+ export type RemoveCouponBody = {
28
+ coupon_code: string;
29
+ };
30
+ export type SubscriptionChargeItemBody = {
31
+ item_price_code: string;
32
+ description?: string;
33
+ quantity?: number;
34
+ unit_price?: number;
35
+ };
36
+ export type AddChargesBody = {
37
+ charges: SubscriptionChargeItemBody[];
38
+ };
39
+ export type PauseSubscriptionBody = {
40
+ pause_reason?: string;
41
+ resume_date?: string;
42
+ };
43
+ /**
44
+ * What the cancel dialog collects. Form values, not the request body: the screen
45
+ * turns these into {@link CancelSubscriptionBody}.
46
+ */
47
+ export type InvoicingCancelSubscriptionValues = {
48
+ cancelReasonCode: string;
49
+ cancelReason?: string;
50
+ };
51
+ export type CancelSubscriptionBody = {
52
+ cancel_reason?: string;
53
+ cancel_reason_code?: string;
54
+ end_of_term?: boolean;
55
+ };
56
+ export type ChangeTermEndBody = {
57
+ term_ends_at: string;
58
+ invoice_immediately?: boolean;
59
+ prorate?: boolean;
60
+ };
61
+ export type ChangePlanBody = {
62
+ item_price_code: string;
63
+ billing_period?: number;
64
+ billing_period_unit?: 'month' | 'year' | 'week' | 'day';
65
+ change_option?: 'immediately' | 'end_of_term';
66
+ invoice_immediately?: boolean;
67
+ prorate?: boolean;
68
+ };
69
+ export type ScheduleChargeBody = {
70
+ amount: number;
71
+ charge_date: string;
72
+ description: string;
73
+ payment_method?: string;
74
+ };
75
+ export type InvoicingSubscriptionActionBody = ApplyCouponBody | RemoveCouponBody | AddChargesBody | PauseSubscriptionBody | CancelSubscriptionBody | ChangePlanBody | ChangeTermEndBody | ScheduleChargeBody | Record<string, never>;
76
+ export type InvoicingSubscriptionDetailResponse = ZeniAPIResponse<InvoicingSubscriptionPayload>;
@@ -20,7 +20,7 @@ export interface SyncInvoicingSubscriptionCouponsPayload {
20
20
  previousCouponCode: string;
21
21
  subscriptionId: string;
22
22
  }
23
- import { InvoicingSubscriptionActionBody } from './invoicingSubscriptionActionRequestPayload';
23
+ import { InvoicingSubscriptionActionBody } from './editInvoicingSubscriptionDetailViewPayload';
24
24
  export interface RunInvoicingSubscriptionActionPayload {
25
25
  action: string;
26
26
  id: ID;
@@ -64,10 +64,10 @@ const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID) => {
64
64
  recordState,
65
65
  { error: configState.error, fetchState: configState.fetchState },
66
66
  ]),
67
- cancelReasonCodeOptions: (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state).subscriptionCancelReasonCodeOptions,
68
- subscriptionCommercialEditAllowedFromStatuses: (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state).subscriptionCommercialEditAllowedFromStatuses,
69
- subscriptionLifecycleActionOptions: (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state).subscriptionLifecycleActionOptions,
70
- subscriptionMetadataEditAllowedFromStatuses: (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state).subscriptionMetadataEditAllowedFromStatuses,
67
+ cancelReasonCodeOptions: configState.subscriptionCancelReasonCodeOptions,
68
+ subscriptionCommercialEditAllowedFromStatuses: configState.subscriptionCommercialEditAllowedFromStatuses,
69
+ subscriptionLifecycleActionOptions: configState.subscriptionLifecycleActionOptions,
70
+ subscriptionMetadataEditAllowedFromStatuses: configState.subscriptionMetadataEditAllowedFromStatuses,
71
71
  recordState,
72
72
  fieldHelp: (0, invoicingConfigViewSelector_1.invoicingFieldHelpForGroup)(state, 'subscription'),
73
73
  coupons: (0, couponViewSelector_1.getInvoicingCouponListItems)(state),
@@ -1,3 +1,56 @@
1
1
  import { InvoicingInvoicePayload } from '../../../entity/invoicing/invoice/invoicePayload';
2
2
  import { ZeniAPIResponse } from '../../../responsePayload';
3
3
  export type InvoiceDetailResponse = ZeniAPIResponse<InvoicingInvoicePayload>;
4
+ export type InvoicingInvoiceActionResponse = ZeniAPIResponse<InvoicingInvoicePayload>;
5
+ /** Snake_case request bodies for invoice action endpoints. */
6
+ export type RecordPaymentBody = {
7
+ amount: number;
8
+ date?: string;
9
+ gateway?: string;
10
+ installment_id?: string;
11
+ payment_method?: string;
12
+ reference_number?: string;
13
+ };
14
+ export type WriteOffBody = {
15
+ amount: number;
16
+ reason?: string;
17
+ };
18
+ export type IssueCreditNoteLineItemBody = {
19
+ amount?: number;
20
+ description?: string;
21
+ entity_type?: string;
22
+ id?: string;
23
+ quantity?: number;
24
+ unit_amount?: number;
25
+ };
26
+ export type IssueCreditNoteBody = {
27
+ amount?: number;
28
+ line_items?: IssueCreditNoteLineItemBody[];
29
+ reason_code?: string;
30
+ type?: 'adjustment' | 'refundable' | 'store';
31
+ };
32
+ export type RemovePaymentBody = {
33
+ txn_id: string;
34
+ };
35
+ export type ApplyExcessBody = {
36
+ amount: number;
37
+ target_invoice_id: string;
38
+ };
39
+ export type PaymentInstallmentBody = {
40
+ amount: number;
41
+ due_date: string;
42
+ id?: string;
43
+ seq?: number;
44
+ };
45
+ export type PaymentScheduleBody = {
46
+ installments: PaymentInstallmentBody[];
47
+ interval_count?: number;
48
+ interval_unit?: 'month' | 'year' | 'week' | 'day';
49
+ type?: 'fixed' | 'flexible';
50
+ };
51
+ export type VoidInvoiceBody = {
52
+ create_adjustment_credit_note?: boolean;
53
+ credit_note_date?: string;
54
+ reason_code?: string;
55
+ };
56
+ export type InvoicingInvoiceActionBody = RecordPaymentBody | WriteOffBody | IssueCreditNoteBody | RemovePaymentBody | ApplyExcessBody | PaymentScheduleBody | VoidInvoiceBody | Record<string, never>;
@@ -1,7 +1,7 @@
1
1
  import { FetchState, ID } from '../../../commonStateTypes/common';
2
2
  import { ZeniAPIStatus } from '../../../responsePayload';
3
3
  import { InvoiceDetail, InvoiceDetailState } from './invoiceDetailState';
4
- import { InvoicingInvoiceActionBody } from './invoicingInvoiceActionRequestPayload';
4
+ import { InvoicingInvoiceActionBody } from './invoiceDetailPayload';
5
5
  export type InvoicingInvoiceActionKind = 'apply-excess' | 'collect' | 'issue-credit-note' | 'record-payment' | 'refund-excess' | 'regenerate' | 'remove-payment' | 'payment-schedule' | 'send' | 'send-reminder' | 'void' | 'write-off';
6
6
  export interface RunInvoicingInvoiceActionPayload {
7
7
  action: InvoicingInvoiceActionKind;
@@ -0,0 +1,11 @@
1
+ import { VoidInvoiceBody } from './invoiceDetailPayload';
2
+ /**
3
+ * Whether an invoice falls before the current month. Voiding one of those
4
+ * leaves a hole in a closed period, which is why the adjustment credit note is
5
+ * offered — and defaulted on — for them.
6
+ */
7
+ export declare const isBackdatedInvoiceDate: (invoiceDate: string, referenceDate?: Date) => boolean;
8
+ /** Whether the void dialog should pre-tick "create adjustment credit note". */
9
+ export declare const shouldDefaultAdjustmentCreditNote: (invoiceDate: string, referenceDate?: Date) => boolean;
10
+ /** The request body for the void action, given the user's credit-note choice. */
11
+ export declare const buildVoidInvoiceSubmitBody: (createAdjustmentCreditNote: boolean, referenceDate?: Date) => VoidInvoiceBody;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildVoidInvoiceSubmitBody = exports.shouldDefaultAdjustmentCreditNote = exports.isBackdatedInvoiceDate = void 0;
4
+ const pad2 = (value) => String(value).padStart(2, '0');
5
+ /** `YYYY-MM-DD` from a date's local calendar components. */
6
+ const toLocalIsoDate = (value) => `${value.getFullYear()}-${pad2(value.getMonth() + 1)}-${pad2(value.getDate())}`;
7
+ /**
8
+ * Whether an invoice falls before the current month. Voiding one of those
9
+ * leaves a hole in a closed period, which is why the adjustment credit note is
10
+ * offered — and defaulted on — for them.
11
+ */
12
+ const isBackdatedInvoiceDate = (invoiceDate, referenceDate = new Date()) => {
13
+ if (invoiceDate.trim() === '') {
14
+ return false;
15
+ }
16
+ const parsed = new Date(invoiceDate);
17
+ if (Number.isNaN(parsed.getTime())) {
18
+ return false;
19
+ }
20
+ const monthStart = new Date(referenceDate.getFullYear(), referenceDate.getMonth(), 1);
21
+ return parsed < monthStart;
22
+ };
23
+ exports.isBackdatedInvoiceDate = isBackdatedInvoiceDate;
24
+ /** Whether the void dialog should pre-tick "create adjustment credit note". */
25
+ const shouldDefaultAdjustmentCreditNote = (invoiceDate, referenceDate = new Date()) => (0, exports.isBackdatedInvoiceDate)(invoiceDate, referenceDate);
26
+ exports.shouldDefaultAdjustmentCreditNote = shouldDefaultAdjustmentCreditNote;
27
+ /** The request body for the void action, given the user's credit-note choice. */
28
+ const buildVoidInvoiceSubmitBody = (createAdjustmentCreditNote, referenceDate = new Date()) => {
29
+ if (!createAdjustmentCreditNote) {
30
+ return {};
31
+ }
32
+ return {
33
+ create_adjustment_credit_note: true,
34
+ credit_note_date: toLocalIsoDate(referenceDate),
35
+ reason_code: 'invoice_voided',
36
+ };
37
+ };
38
+ exports.buildVoidInvoiceSubmitBody = buildVoidInvoiceSubmitBody;
@@ -26,7 +26,7 @@ export declare const fetchInvoicingCustomerList: import("@reduxjs/toolkit").Acti
26
26
  ids: ID[];
27
27
  keepExistingListItems: boolean;
28
28
  nextCursor: string | null;
29
- }, "invoicingCustomerListView/updateInvoicingCustomerList">, updateInvoicingCustomerListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerListFailure">, fetchInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCustomerListView/fetchInvoicingCustomerCounts">, updateInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCustomerListView/updateInvoicingCustomerCounts">, updateInvoicingCustomerCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerCountsFailure">, updateInvoicingCustomerFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCustomerFilters, "invoicingCustomerListView/updateInvoicingCustomerFilters">, setInvoicingCustomerActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"active" | "all" | "trial" | "at_risk", "invoicingCustomerListView/setInvoicingCustomerActiveTab">, addInvoicingCustomerToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
29
+ }, "invoicingCustomerListView/updateInvoicingCustomerList">, updateInvoicingCustomerListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerListFailure">, fetchInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCustomerListView/fetchInvoicingCustomerCounts">, updateInvoicingCustomerCounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingListCounts, "invoicingCustomerListView/updateInvoicingCustomerCounts">, updateInvoicingCustomerCountsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCustomerListView/updateInvoicingCustomerCountsFailure">, updateInvoicingCustomerFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCustomerFilters, "invoicingCustomerListView/updateInvoicingCustomerFilters">, setInvoicingCustomerActiveTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"active" | "all" | "at_risk" | "trial", "invoicingCustomerListView/setInvoicingCustomerActiveTab">, addInvoicingCustomerToList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
30
30
  id: ID;
31
31
  status?: string;
32
32
  }, "invoicingCustomerListView/addInvoicingCustomerToList">;
@@ -20,7 +20,7 @@ export interface InvoicingCustomerColumnConfig {
20
20
  }
21
21
  export declare const INVOICING_CUSTOMER_COLUMNS: InvoicingCustomerColumnConfig[];
22
22
  export declare const ALL_INVOICING_CUSTOMER_TAB_IDS: readonly ["all", "active", "trial", "at_risk"];
23
- export declare const toInvoicingCustomerTabId: (v: string) => "active" | "all" | "trial" | "at_risk";
23
+ export declare const toInvoicingCustomerTabId: (v: string) => "active" | "all" | "at_risk" | "trial";
24
24
  export type InvoicingCustomerTabId = ReturnType<typeof toInvoicingCustomerTabId>;
25
25
  export interface InvoicingCustomerListViewState extends FetchedState {
26
26
  /** Selected status tab (CES-owned so it persists across page revisits). */
@@ -13,3 +13,28 @@ export interface InvoicingDunningEmailPreviewPayload {
13
13
  }
14
14
  export type InvoicingDunningEmailPreviewResponse = ZeniAPIResponse<InvoicingDunningEmailPreviewPayload>;
15
15
  export declare const toInvoicingDunningEmailPreview: (payload: InvoicingDunningEmailPreviewPayload) => InvoicingDunningEmailPreview;
16
+ export type InvoicingDunningActionResponse = ZeniAPIResponse<InvoicingDunningCasePayload>;
17
+ /** Snake_case request bodies for dunning action endpoints. */
18
+ export type DunningPauseBody = {
19
+ duration?: number;
20
+ reason?: string;
21
+ resume_date?: string;
22
+ };
23
+ export type DunningCollectBody = {
24
+ amount?: number;
25
+ payment_method?: string;
26
+ };
27
+ export type DunningEmailBody = {
28
+ body?: string;
29
+ cc?: string;
30
+ subject?: string;
31
+ to?: string;
32
+ };
33
+ export type DunningBulkEmailBody = {
34
+ body?: string;
35
+ case_ids?: string[];
36
+ cc?: string;
37
+ subject?: string;
38
+ to?: string;
39
+ };
40
+ export type InvoicingDunningActionBody = DunningPauseBody | DunningCollectBody | DunningEmailBody | DunningBulkEmailBody | Record<string, never>;
@@ -1,7 +1,7 @@
1
1
  import { ID } from '../../../commonStateTypes/common';
2
2
  import { ZeniAPIStatus } from '../../../responsePayload';
3
3
  import { InvoicingDunningCaseDetailViewState, InvoicingDunningEmailPreview, InvoicingDunningEmailPreviewState } from './invoicingDunningCaseDetailViewState';
4
- import { InvoicingDunningActionBody } from './invoicingDunningActionRequestPayload';
4
+ import { InvoicingDunningActionBody } from './invoicingDunningCaseDetailViewPayload';
5
5
  /** Run a lifecycle action on a dunning case. */
6
6
  export interface RunInvoicingDunningActionPayload {
7
7
  action: string;
@@ -1,3 +1,11 @@
1
1
  import { InvoicingTransactionPayload } from '../../../entity/invoicing/invoicingTransaction/invoicingTransactionPayload';
2
2
  import { ZeniAPIResponse } from '../../../responsePayload';
3
3
  export type InvoicingTransactionDetailResponse = ZeniAPIResponse<InvoicingTransactionPayload>;
4
+ export type InvoicingPaymentActionResponse = ZeniAPIResponse<InvoicingTransactionPayload>;
5
+ /** Snake_case request bodies for payment action endpoints. */
6
+ export type RefundPaymentBody = {
7
+ amount?: number;
8
+ reason?: string;
9
+ refund_method?: string;
10
+ };
11
+ export type InvoicingPaymentActionBody = RefundPaymentBody | Record<string, never>;
@@ -1,6 +1,6 @@
1
1
  import { ID } from '../../../commonStateTypes/common';
2
2
  import { ZeniAPIStatus } from '../../../responsePayload';
3
- import { InvoicingPaymentActionBody } from './invoicingPaymentActionRequestPayload';
3
+ import { InvoicingPaymentActionBody } from './invoicingTransactionDetailViewPayload';
4
4
  import { InvoicingTransactionDetailViewState } from './invoicingTransactionDetailViewState';
5
5
  /** Run a lifecycle action on a payment. */
6
6
  export interface RunInvoicingPaymentActionPayload {
@@ -2,9 +2,9 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
3
  import { updateAddresses } from '../../../entity/address/addressReducer';
4
4
  import { RootState } from '../../../rootStateTypes';
5
- import { ZeniAPI } from '../../../zeniAPI';
6
5
  import { newAddressInLocalStore, resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
7
6
  import { saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, submitInvoicingBrandingForm, updateInvoicingSettings } from './settingsViewReducer';
7
+ export type SeedActionType = ReturnType<typeof updateInvoicingSettings> | ReturnType<typeof newAddressInLocalStore>;
8
8
  export type SubmitActionType = ReturnType<typeof submitInvoicingBrandingForm> | ReturnType<typeof saveInvoicingSettingsSuccess> | ReturnType<typeof saveInvoicingSettingsFailure> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses>;
9
9
  /**
10
10
  * On `submitInvoicingBrandingForm`, PUT the settings body built from the branding
@@ -12,11 +12,4 @@ export type SubmitActionType = ReturnType<typeof submitInvoicingBrandingForm> |
12
12
  * address is sent as a structured object (same shape as the customer save flow);
13
13
  * state is updated from the response — mirroring `saveInvoicingCustomerEpic`.
14
14
  */
15
- export declare const submitInvoicingBrandingFormEpic: (actions$: ActionsObservable<SubmitActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<SubmitActionType>;
16
- export type SeedActionType = ReturnType<typeof updateInvoicingSettings> | ReturnType<typeof newAddressInLocalStore>;
17
- /**
18
- * Seed the shared Address screen with the existing business address when settings
19
- * load — looked up in the shared address store by `address_id`, same as the
20
- * customer billing-address flow. Skips when an in-progress draft already exists.
21
- */
22
15
  export declare const initializeInvoicingBrandingAddressEpic: (actions$: ActionsObservable<SeedActionType>, state$: StateObservable<RootState>) => Observable<SeedActionType>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeInvoicingBrandingAddressEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const addressSelector_1 = require("../../../entity/address/addressSelector");
7
+ const addressViewReducer_1 = require("../../addressView/addressViewReducer");
8
+ const invoicingBrandingFormConfig_1 = require("./invoicingBrandingFormConfig");
9
+ const settingsViewReducer_1 = require("./settingsViewReducer");
10
+ /**
11
+ * On `submitInvoicingBrandingForm`, PUT the settings body built from the branding
12
+ * draft + the business address captured via the shared Address screen. The
13
+ * address is sent as a structured object (same shape as the customer save flow);
14
+ * state is updated from the response — mirroring `saveInvoicingCustomerEpic`.
15
+ */
16
+ const initializeInvoicingBrandingAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.updateInvoicingSettings.match), (0, operators_1.mergeMap)((action) => {
17
+ const rootState = state$.value;
18
+ const existing = rootState.addressViewState.newAddressState?.[invoicingBrandingFormConfig_1.INVOICING_BUSINESS_ADDRESS_TYPE]?.addressToCreate;
19
+ const addressId = action.payload.address?.address_id;
20
+ if (existing != null || addressId == null) {
21
+ return rxjs_1.EMPTY;
22
+ }
23
+ const address = (0, addressSelector_1.getAddressByAddressId)(rootState.addressState, addressId);
24
+ return address != null
25
+ ? (0, rxjs_1.of)((0, addressViewReducer_1.newAddressInLocalStore)({
26
+ addressType: invoicingBrandingFormConfig_1.INVOICING_BUSINESS_ADDRESS_TYPE,
27
+ addressToCreate: address,
28
+ }))
29
+ : rxjs_1.EMPTY;
30
+ }));
31
+ exports.initializeInvoicingBrandingAddressEpic = initializeInvoicingBrandingAddressEpic;
@@ -0,0 +1,20 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { RootState } from '../../../rootStateTypes';
5
+ import { ZeniAPI } from '../../../zeniAPI';
6
+ import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
7
+ import { saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, submitInvoicingBrandingForm } from './settingsViewReducer';
8
+ export type SubmitActionType = ReturnType<typeof submitInvoicingBrandingForm> | ReturnType<typeof saveInvoicingSettingsSuccess> | ReturnType<typeof saveInvoicingSettingsFailure> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses>;
9
+ /**
10
+ * On `submitInvoicingBrandingForm`, PUT the settings body built from the branding
11
+ * draft + the business address captured via the shared Address screen. The
12
+ * address is sent as a structured object (same shape as the customer save flow);
13
+ * state is updated from the response — mirroring `saveInvoicingCustomerEpic`.
14
+ */
15
+ export declare const submitInvoicingBrandingFormEpic: (actions$: ActionsObservable<SubmitActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<SubmitActionType>;
16
+ /**
17
+ * Seed the shared Address screen with the existing business address when settings
18
+ * load — looked up in the shared address store by `address_id`, same as the
19
+ * customer billing-address flow. Skips when an in-progress draft already exists.
20
+ */
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initializeInvoicingBrandingAddressEpic = exports.submitInvoicingBrandingFormEpic = void 0;
3
+ exports.submitInvoicingBrandingFormEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const addressReducer_1 = require("../../../entity/address/addressReducer");
7
- const addressSelector_1 = require("../../../entity/address/addressSelector");
8
7
  const responsePayload_1 = require("../../../responsePayload");
9
8
  const addressViewReducer_1 = require("../../addressView/addressViewReducer");
10
9
  const invoicingBrandingFormConfig_1 = require("./invoicingBrandingFormConfig");
@@ -45,19 +44,3 @@ exports.submitInvoicingBrandingFormEpic = submitInvoicingBrandingFormEpic;
45
44
  * load — looked up in the shared address store by `address_id`, same as the
46
45
  * customer billing-address flow. Skips when an in-progress draft already exists.
47
46
  */
48
- const initializeInvoicingBrandingAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.updateInvoicingSettings.match), (0, operators_1.mergeMap)((action) => {
49
- const rootState = state$.value;
50
- const existing = rootState.addressViewState.newAddressState?.[invoicingBrandingFormConfig_1.INVOICING_BUSINESS_ADDRESS_TYPE]?.addressToCreate;
51
- const addressId = action.payload.address?.address_id;
52
- if (existing != null || addressId == null) {
53
- return rxjs_1.EMPTY;
54
- }
55
- const address = (0, addressSelector_1.getAddressByAddressId)(rootState.addressState, addressId);
56
- return address != null
57
- ? (0, rxjs_1.of)((0, addressViewReducer_1.newAddressInLocalStore)({
58
- addressType: invoicingBrandingFormConfig_1.INVOICING_BUSINESS_ADDRESS_TYPE,
59
- addressToCreate: address,
60
- }))
61
- : rxjs_1.EMPTY;
62
- }));
63
- exports.initializeInvoicingBrandingAddressEpic = initializeInvoicingBrandingAddressEpic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.32-betaAK4",
3
+ "version": "5.2.32-betaAK6",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",