@zeniai/client-epic-state 5.1.98 → 5.2.0

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 (150) hide show
  1. package/lib/commonStateTypes/accountView/nestedAccountID.d.ts +0 -3
  2. package/lib/commonStateTypes/accountView/nestedAccountID.js +1 -4
  3. package/lib/commonStateTypes/coaBalance/coaBalance.d.ts +0 -5
  4. package/lib/commonStateTypes/timePeriod.d.ts +0 -2
  5. package/lib/commonStateTypes/timePeriod.js +1 -6
  6. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +12 -0
  7. package/lib/entity/invoicing/invoicingCommonPayload.js +18 -0
  8. package/lib/entity/invoicing/invoicingTransaction/invoicingTransactionPayload.d.ts +1 -1
  9. package/lib/entity/toastNotification/epic/pushToastNotificationEpic.d.ts +0 -1
  10. package/lib/entity/toastNotification/epic/pushToastNotificationEpic.js +0 -1
  11. package/lib/entity/transaction/toSupportedTransaction.d.ts +1 -1
  12. package/lib/entity/transaction/toSupportedTransaction.js +0 -1
  13. package/lib/esm/commonStateTypes/accountView/nestedAccountID.js +0 -3
  14. package/lib/esm/commonStateTypes/timePeriod.js +0 -4
  15. package/lib/esm/entity/invoicing/invoicingCommonPayload.js +16 -0
  16. package/lib/esm/entity/toastNotification/epic/pushToastNotificationEpic.js +0 -1
  17. package/lib/esm/entity/transaction/toSupportedTransaction.js +1 -1
  18. package/lib/esm/index.js +12 -11
  19. package/lib/esm/view/invoicing/auditView/auditViewSelector.js +4 -0
  20. package/lib/esm/view/invoicing/couponView/couponViewSelector.js +18 -8
  21. package/lib/esm/view/invoicing/couponView/couponViewState.js +0 -9
  22. package/lib/esm/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +1 -0
  23. package/lib/esm/view/invoicing/createCreditNote/createCreditNotePayload.js +4 -1
  24. package/lib/esm/view/invoicing/createCreditNote/createCreditNoteSelector.js +4 -2
  25. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +7 -6
  26. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +3 -19
  27. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +10 -5
  28. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +6 -4
  29. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig.js +0 -17
  30. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +5 -0
  31. package/lib/esm/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +2 -1
  32. package/lib/esm/view/invoicing/invoiceList/invoiceListReducer.js +18 -17
  33. package/lib/esm/view/invoicing/invoiceList/invoiceListSelector.js +12 -4
  34. package/lib/esm/view/invoicing/invoiceList/invoiceListState.js +13 -9
  35. package/lib/esm/view/invoicing/invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewSelector.js +5 -1
  36. package/lib/esm/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.js +2 -1
  37. package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +26 -0
  38. package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +9 -0
  39. package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +9 -3
  40. package/lib/esm/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewState.js +0 -9
  41. package/lib/esm/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailPageEpic.js +2 -2
  42. package/lib/esm/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +1 -1
  43. package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +9 -3
  44. package/lib/esm/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.js +0 -9
  45. package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +8 -3
  46. package/lib/esm/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.js +1 -9
  47. package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +11 -3
  48. package/lib/esm/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.js +0 -9
  49. package/lib/esm/view/invoicing/invoicingTabHelper.js +27 -0
  50. package/lib/esm/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListPageEpic.js +2 -1
  51. package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.js +5 -5
  52. package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.js +12 -4
  53. package/lib/esm/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.js +11 -9
  54. package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteFormConfig.js +1 -8
  55. package/lib/esm/view/invoicing/issueCreditNote/issueCreditNotePayload.js +5 -1
  56. package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +5 -2
  57. package/lib/esm/view/invoicing/recordPayment/recordPaymentFormConfig.js +0 -26
  58. package/lib/esm/view/invoicing/recordPayment/recordPaymentSelector.js +26 -6
  59. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +7 -1
  60. package/lib/esm/view/profitAndLossProjectView/profitAndLossProjectViewReducer.js +2 -1
  61. package/lib/index.d.ts +13 -12
  62. package/lib/index.js +9 -24
  63. package/lib/view/invoicing/auditView/auditViewSelector.d.ts +4 -0
  64. package/lib/view/invoicing/auditView/auditViewSelector.js +4 -0
  65. package/lib/view/invoicing/couponView/couponViewSelector.d.ts +5 -1
  66. package/lib/view/invoicing/couponView/couponViewSelector.js +17 -7
  67. package/lib/view/invoicing/couponView/couponViewState.d.ts +0 -7
  68. package/lib/view/invoicing/couponView/couponViewState.js +1 -10
  69. package/lib/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +1 -0
  70. package/lib/view/invoicing/createCreditNote/createCreditNotePayload.js +4 -1
  71. package/lib/view/invoicing/createCreditNote/createCreditNoteSelector.d.ts +3 -1
  72. package/lib/view/invoicing/createCreditNote/createCreditNoteSelector.js +4 -2
  73. package/lib/view/invoicing/createCreditNote/createCreditNoteState.d.ts +6 -0
  74. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +5 -5
  75. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +6 -5
  76. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.d.ts +3 -6
  77. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +4 -20
  78. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +9 -7
  79. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +10 -5
  80. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +4 -3
  81. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +5 -3
  82. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig.d.ts +0 -8
  83. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig.js +1 -18
  84. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +5 -0
  85. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +5 -0
  86. package/lib/view/invoicing/invoiceList/fetchInvoiceListPageEpic.js +2 -1
  87. package/lib/view/invoicing/invoiceList/invoiceListReducer.js +17 -16
  88. package/lib/view/invoicing/invoiceList/invoiceListSelector.d.ts +3 -1
  89. package/lib/view/invoicing/invoiceList/invoiceListSelector.js +11 -3
  90. package/lib/view/invoicing/invoiceList/invoiceListState.d.ts +13 -9
  91. package/lib/view/invoicing/invoiceList/invoiceListState.js +15 -10
  92. package/lib/view/invoicing/invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewSelector.d.ts +9 -1
  93. package/lib/view/invoicing/invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewSelector.js +5 -1
  94. package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.d.ts +3 -1
  95. package/lib/view/invoicing/invoicingCatalogListView/invoicingCatalogListViewSelector.js +2 -1
  96. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +13 -0
  97. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
  98. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +26 -0
  99. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +19 -1
  100. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +11 -1
  101. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +13 -0
  102. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.d.ts +8 -1
  103. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewSelector.js +8 -2
  104. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewState.d.ts +0 -7
  105. package/lib/view/invoicing/invoicingCreditNoteListView/invoicingCreditNoteListViewState.js +1 -10
  106. package/lib/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailPageEpic.js +2 -2
  107. package/lib/view/invoicing/invoicingCustomerDetailView/invoicingCustomerDetailViewSelector.js +1 -1
  108. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.d.ts +3 -1
  109. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewSelector.js +8 -2
  110. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +0 -7
  111. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.js +1 -10
  112. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewReducer.d.ts +1 -1
  113. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.d.ts +3 -1
  114. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewSelector.js +7 -2
  115. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.d.ts +2 -9
  116. package/lib/view/invoicing/invoicingDunningCaseListView/invoicingDunningCaseListViewState.js +2 -10
  117. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.d.ts +7 -1
  118. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewSelector.js +10 -2
  119. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +0 -7
  120. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.js +1 -10
  121. package/lib/view/invoicing/invoicingTabHelper.d.ts +27 -0
  122. package/lib/view/invoicing/invoicingTabHelper.js +30 -0
  123. package/lib/view/invoicing/invoicingTransactionListView/epics/fetchInvoicingTransactionListPageEpic.js +2 -1
  124. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.d.ts +1 -1
  125. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewReducer.js +4 -4
  126. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.d.ts +8 -0
  127. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewSelector.js +11 -3
  128. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.d.ts +10 -10
  129. package/lib/view/invoicing/invoicingTransactionListView/invoicingTransactionListViewState.js +13 -10
  130. package/lib/view/invoicing/issueCreditNote/issueCreditNoteFormConfig.d.ts +0 -2
  131. package/lib/view/invoicing/issueCreditNote/issueCreditNoteFormConfig.js +2 -9
  132. package/lib/view/invoicing/issueCreditNote/issueCreditNotePayload.d.ts +2 -2
  133. package/lib/view/invoicing/issueCreditNote/issueCreditNotePayload.js +5 -1
  134. package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.d.ts +3 -1
  135. package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +4 -1
  136. package/lib/view/invoicing/issueCreditNote/issueCreditNoteState.d.ts +6 -0
  137. package/lib/view/invoicing/recordPayment/recordPaymentFormConfig.d.ts +0 -6
  138. package/lib/view/invoicing/recordPayment/recordPaymentFormConfig.js +1 -27
  139. package/lib/view/invoicing/recordPayment/recordPaymentSelector.d.ts +3 -2
  140. package/lib/view/invoicing/recordPayment/recordPaymentSelector.js +26 -6
  141. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +11 -1
  142. package/lib/view/invoicing/settingsView/settingsViewSelector.js +7 -1
  143. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewReducer.js +2 -1
  144. package/package.json +4 -10
  145. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
  146. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  147. package/lib/entity/invoicing/coupon/couponConstants.d.ts +0 -11
  148. package/lib/entity/invoicing/coupon/couponConstants.js +0 -29
  149. package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  150. package/lib/esm/entity/invoicing/coupon/couponConstants.js +0 -26
@@ -1,7 +1,7 @@
1
1
  import { FetchStateAndError } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { InvoicingCoupon } from '../../../entity/invoicing/coupon/couponState';
4
- import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPayload';
4
+ import { InvoicingDiscountLifecycleActionOption, InvoicingListCounts, InvoicingNamedOption } from '../../../entity/invoicing/invoicingCommonPayload';
5
5
  import { RootState } from '../../../reducer';
6
6
  import { InvoicingListSort } from '../invoicingApiHelper';
7
7
  import { InvoicingCouponColumnConfig, InvoicingCouponFilters, InvoicingCouponTabId } from './couponViewState';
@@ -17,8 +17,12 @@ export interface InvoicingCouponListView extends SelectorView {
17
17
  count: InvoicingListCounts;
18
18
  countsFetchState: FetchStateAndError;
19
19
  coupons: InvoicingCoupon[];
20
+ /** Config-owned; folded in so the screen reads one selector. */
21
+ discountLifecycleActionOptions: InvoicingDiscountLifecycleActionOption[];
20
22
  filters: InvoicingCouponFilters;
21
23
  nextCursor: string | null;
24
+ /** Config status/type list; the page labels tabs and badges from it. */
25
+ statusOptions: InvoicingNamedOption[];
22
26
  tabIds: InvoicingCouponTabId[];
23
27
  sort?: InvoicingListSort;
24
28
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvoicingCouponListView = exports.getInvoicingCouponCounts = exports.getInvoicingCouponListFilters = exports.getInvoicingCouponListHasMore = exports.getInvoicingCouponListNextCursor = exports.getInvoicingCouponListFetchState = exports.getInvoicingCouponListItems = void 0;
4
4
  const toolkit_1 = require("@reduxjs/toolkit");
5
+ const invoicingTabHelper_1 = require("../invoicingTabHelper");
5
6
  const couponViewState_1 = require("./couponViewState");
6
7
  const getInvoicingCouponListItems = (state) => state.invoicingCouponViewState.ids
7
8
  .map((id) => state.invoicingCouponState.couponByID[id])
@@ -26,19 +27,22 @@ exports.getInvoicingCouponCounts = getInvoicingCouponCounts;
26
27
  * array (and the wrapping view object) keep referential identity until the
27
28
  * coupon entity slice or the list-view slice actually change.
28
29
  */
29
- exports.getInvoicingCouponListView = (0, toolkit_1.createSelector)((state) => state.invoicingCouponState, (state) => state.invoicingCouponViewState, (couponState, listViewState) => {
30
+ exports.getInvoicingCouponListView = (0, toolkit_1.createSelector)((state) => state.invoicingCouponState, (state) => state.invoicingCouponViewState, (state) => state.invoicingConfigViewState.discountStatusOptions, (state) => state.invoicingConfigViewState.discountLifecycleActionOptions, (couponState, listViewState, statusOptions, discountLifecycleActionOptions) => {
30
31
  const { activeTab } = listViewState;
31
32
  const allCoupons = listViewState.ids
32
33
  .map((id) => couponState.couponByID[id])
33
34
  .filter((item) => item != null);
34
35
  // The list API ignores `status`, so it returns every status; filter to the
35
- // active tab client-side. 'all' shows everything, 'active' shows only active
36
- // coupons, and 'inactive' shows every non-active status (undefined included).
36
+ // active tab client-side. 'all' shows everything and 'inactive' is the
37
+ // FE-derived composite of every non-active status (undefined included);
38
+ // every other tab is a real backend status and matches exactly — without
39
+ // that, config-supplied tabs like `expired` and `archived` would each show
40
+ // the whole non-active set.
37
41
  const coupons = activeTab === 'all'
38
42
  ? allCoupons
39
- : allCoupons.filter((coupon) => activeTab === 'active'
40
- ? coupon.status === 'active'
41
- : coupon.status !== 'active');
43
+ : activeTab === 'inactive'
44
+ ? allCoupons.filter((coupon) => coupon.status !== 'active')
45
+ : allCoupons.filter((coupon) => coupon.status === activeTab);
42
46
  return {
43
47
  activeTab,
44
48
  columns: couponViewState_1.INVOICING_COUPON_COLUMNS,
@@ -47,7 +51,13 @@ exports.getInvoicingCouponListView = (0, toolkit_1.createSelector)((state) => st
47
51
  countsFetchState: listViewState.countsFetchState,
48
52
  filters: listViewState.filters,
49
53
  nextCursor: listViewState.nextCursor,
50
- tabIds: couponViewState_1.INVOICING_COUPON_TABS,
54
+ discountLifecycleActionOptions,
55
+ statusOptions,
56
+ tabIds: (0, invoicingTabHelper_1.invoicingTabIdsFromConfig)({
57
+ allTabIds: couponViewState_1.ALL_INVOICING_COUPON_TAB_IDS,
58
+ localTabIds: ['inactive'],
59
+ statusOptions,
60
+ }),
51
61
  fetchState: listViewState.fetchState,
52
62
  error: listViewState.error,
53
63
  sort: listViewState.sort,
@@ -22,13 +22,6 @@ export declare const INVOICING_COUPON_COLUMNS: InvoicingCouponColumnConfig[];
22
22
  export declare const ALL_INVOICING_COUPON_TAB_IDS: readonly ["all", "active", "inactive"];
23
23
  export declare const toInvoicingCouponTabId: (v: string) => "active" | "inactive" | "all";
24
24
  export type InvoicingCouponTabId = ReturnType<typeof toInvoicingCouponTabId>;
25
- /**
26
- * Ordered filter-tab id set owned by CES so the coupon/discount-list tabs live
27
- * next to the model rather than being hardcoded in web-components. Tab labels
28
- * and the per-tab count lookup stay in the view layer; this only carries the id
29
- * set and display order.
30
- */
31
- export declare const INVOICING_COUPON_TABS: InvoicingCouponTabId[];
32
25
  export interface InvoicingCouponViewState extends FetchedState {
33
26
  /** Selected status tab (CES-owned so it persists across page revisits). */
34
27
  activeTab: InvoicingCouponTabId;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INVOICING_COUPON_TABS = exports.toInvoicingCouponTabId = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.INVOICING_COUPON_COLUMNS = exports.toInvoicingCouponSortKey = exports.ALL_INVOICING_COUPON_SORT_KEYS = void 0;
3
+ exports.toInvoicingCouponTabId = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.INVOICING_COUPON_COLUMNS = exports.toInvoicingCouponSortKey = exports.ALL_INVOICING_COUPON_SORT_KEYS = void 0;
4
4
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
5
5
  exports.ALL_INVOICING_COUPON_SORT_KEYS = [
6
6
  'coupon_id',
@@ -33,12 +33,3 @@ exports.ALL_INVOICING_COUPON_TAB_IDS = [
33
33
  ];
34
34
  const toInvoicingCouponTabId = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_INVOICING_COUPON_TAB_IDS);
35
35
  exports.toInvoicingCouponTabId = toInvoicingCouponTabId;
36
- /**
37
- * Ordered filter-tab id set owned by CES so the coupon/discount-list tabs live
38
- * next to the model rather than being hardcoded in web-components. Tab labels
39
- * and the per-tab count lookup stay in the view layer; this only carries the id
40
- * set and display order.
41
- */
42
- exports.INVOICING_COUPON_TABS = [
43
- ...exports.ALL_INVOICING_COUPON_TAB_IDS,
44
- ];
@@ -11,5 +11,6 @@ const initialCreateCreditNoteFormLocalData = () => ({
11
11
  ],
12
12
  reasonCode: '',
13
13
  referenceInvoiceId: '',
14
+ type: '',
14
15
  });
15
16
  exports.initialCreateCreditNoteFormLocalData = initialCreateCreditNoteFormLocalData;
@@ -18,10 +18,13 @@ const localDataToCreateCreditNotePayload = (localData) => {
18
18
  lineItem.unit_amount > 0);
19
19
  const reasonCode = localData.reasonCode.trim();
20
20
  const referenceInvoiceId = localData.referenceInvoiceId.trim();
21
+ // Optional-chained: a draft persisted before this field existed has no
22
+ // `type`, and the draft survives navigation.
23
+ const type = localData.type?.trim() ?? '';
21
24
  return {
22
25
  customer_id: localData.customerId,
23
26
  line_items: lineItems,
24
- type: 'adjustment',
27
+ ...(type !== '' ? { type } : {}),
25
28
  ...(reasonCode !== '' ? { reason_code: reasonCode } : {}),
26
29
  ...(referenceInvoiceId !== ''
27
30
  ? { reference_invoice_id: referenceInvoiceId }
@@ -1,5 +1,6 @@
1
1
  import { ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
+ import { InvoicingNamedOption } from '../../../entity/invoicing/invoicingCommonPayload';
3
4
  import { RootState } from '../../../reducer';
4
5
  import { CreateCreditNoteFormLocalData } from './createCreditNoteState';
5
6
  export interface InvoicingCreateCreditNoteView extends SelectorView {
@@ -8,6 +9,7 @@ export interface InvoicingCreateCreditNoteView extends SelectorView {
8
9
  export declare const getCreateCreditNoteView: (state: RootState) => InvoicingCreateCreditNoteView;
9
10
  export interface CreateCreditNoteFormView extends SelectorView {
10
11
  localData: CreateCreditNoteFormLocalData;
11
- reasonCodeValues: string[];
12
+ reasonCodeOptions: InvoicingNamedOption[];
13
+ typeOptions: InvoicingNamedOption[];
12
14
  }
13
15
  export declare const getCreateCreditNoteFormView: (state: RootState) => CreateCreditNoteFormView;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCreateCreditNoteFormView = exports.getCreateCreditNoteView = void 0;
4
- const issueCreditNoteFormConfig_1 = require("../issueCreditNote/issueCreditNoteFormConfig");
4
+ const invoicingConfigViewSelector_1 = require("../invoicingConfigView/invoicingConfigViewSelector");
5
5
  const getCreateCreditNoteView = (state) => {
6
6
  const { createdCreditNoteId, error, fetchState } = state.invoicingCreateCreditNoteState;
7
7
  return {
@@ -14,9 +14,11 @@ const getCreateCreditNoteView = (state) => {
14
14
  exports.getCreateCreditNoteView = getCreateCreditNoteView;
15
15
  const getCreateCreditNoteFormView = (state) => {
16
16
  const { draft, error, fetchState } = state.invoicingCreateCreditNoteState;
17
+ const { creditNoteReasonCodeOptions, creditNoteTypeOptions } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
17
18
  return {
18
19
  localData: draft,
19
- reasonCodeValues: [...issueCreditNoteFormConfig_1.INVOICING_CREDIT_NOTE_REASON_CODES],
20
+ reasonCodeOptions: creditNoteReasonCodeOptions,
21
+ typeOptions: creditNoteTypeOptions,
20
22
  error,
21
23
  fetchState,
22
24
  version: 1.0,
@@ -11,6 +11,12 @@ export interface CreateCreditNoteFormLocalData {
11
11
  lineItems: CreateCreditNoteLineItemDraft[];
12
12
  reasonCode: string;
13
13
  referenceInvoiceId: string;
14
+ /**
15
+ * Credit-note type code from `credit_note_type_options`. Empty until the user
16
+ * picks one; the payload then omits it and lets the backend default, rather
17
+ * than the client asserting `adjustment` for every credit note as it used to.
18
+ */
19
+ type: string;
14
20
  }
15
21
  export interface CreateCreditNoteState extends FetchedState {
16
22
  draft: CreateCreditNoteFormLocalData;
@@ -1,6 +1,6 @@
1
1
  import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
- import { InvoicingNamedOptionsByKey } from '../../../entity/invoicing/invoicingCommonPayload';
3
+ import { InvoicingNamedOption, InvoicingNamedOptionsByKey } from '../../../entity/invoicing/invoicingCommonPayload';
4
4
  import { InvoicingPlan } from '../../../entity/invoicing/plan/planState';
5
5
  import { RootState } from '../../../reducer';
6
6
  import { InvoicingCatalogItemKind } from '../invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewState';
@@ -32,13 +32,13 @@ export interface InvoicingCatalogItemFormView extends SelectorView {
32
32
  applicableItemOptions: ApplicableCatalogItemOption[];
33
33
  localData: InvoicingCatalogItemFormLocalData;
34
34
  mode: 'create' | 'edit';
35
- periodUnitValues: readonly string[];
35
+ periodUnitOptions: InvoicingNamedOption[];
36
36
  pricingModelValues: readonly string[];
37
37
  prorationValues: readonly string[];
38
38
  tierTypeValues: readonly string[];
39
- trialEndActionValues: readonly string[];
40
- trialUnitValues: readonly string[];
41
- typeValues: readonly string[];
39
+ trialEndActionOptions: InvoicingNamedOption[];
40
+ trialUnitOptions: InvoicingNamedOption[];
41
+ typeOptions: InvoicingNamedOption[];
42
42
  /**
43
43
  * Backend tier-type choices per pricing model. Folded in here rather than left
44
44
  * for the screen to pull off `getInvoicingConfigView` itself, so the form wires
@@ -54,19 +54,20 @@ const getInvoicingCatalogItemFormView = (state, id) => {
54
54
  const applicableItemOptions = id != null
55
55
  ? allApplicableItemOptions.filter((option) => option.id !== id)
56
56
  : allApplicableItemOptions;
57
+ const { billingPeriodUnitOptions, catalogItemTypeOptions, catalogTierTypeOptionsByPricingModel, catalogTrialEndActionOptions, catalogTrialUnitOptions, } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
57
58
  return {
58
59
  applicabilityValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_APPLICABILITY_VALUES,
59
60
  applicableItemOptions,
60
61
  localData,
61
62
  mode: id != null ? 'edit' : 'create',
62
- periodUnitValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_PERIOD_UNIT_VALUES,
63
+ periodUnitOptions: billingPeriodUnitOptions,
63
64
  pricingModelValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_PRICING_MODEL_VALUES,
64
65
  prorationValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_PRORATION_VALUES,
65
66
  tierTypeValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_TIER_TYPE_VALUES,
66
- trialEndActionValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_TRIAL_END_ACTION_VALUES,
67
- trialUnitValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_TRIAL_UNIT_VALUES,
68
- typeValues: invoicingCatalogItemFormConfig_1.INVOICING_CATALOG_TYPE_VALUES,
69
- catalogTierTypeOptionsByPricingModel: (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state).catalogTierTypeOptionsByPricingModel,
67
+ trialEndActionOptions: catalogTrialEndActionOptions,
68
+ trialUnitOptions: catalogTrialUnitOptions,
69
+ typeOptions: catalogItemTypeOptions,
70
+ catalogTierTypeOptionsByPricingModel,
70
71
  kind,
71
72
  plan,
72
73
  savedItemId,
@@ -2,15 +2,12 @@ import { InvoicingPlan } from '../../../entity/invoicing/plan/planState';
2
2
  import { InvoicingProduct } from '../../../entity/invoicing/product/productState';
3
3
  import { InvoicingCatalogItemFormLocalData, InvoicingCatalogItemFormSubFamily, InvoicingCatalogItemFormTier } from './editInvoicingCatalogItemDetailViewState';
4
4
  /**
5
- * Canonical value sets for the catalog item form. CES owns the values;
6
- * web-components maps each value to a localized label.
5
+ * Value sets the catalog item form still owns locally: the backend has no enum
6
+ * for pricing model, tier type, proration or applicability yet, so these stay
7
+ * here until it does. Everything else on this form comes from `/1.0/config`.
7
8
  */
8
- export declare const INVOICING_CATALOG_TYPE_VALUES: readonly ["plan", "addon", "charge"];
9
- export declare const INVOICING_CATALOG_PERIOD_UNIT_VALUES: readonly ["day", "week", "month", "year"];
10
9
  export declare const INVOICING_CATALOG_PRICING_MODEL_VALUES: readonly ["flat_fee", "per_unit", "tiered", "volume", "stairstep"];
11
10
  export declare const INVOICING_CATALOG_TIER_TYPE_VALUES: readonly ["per_unit", "flat_fee", "package"];
12
- export declare const INVOICING_CATALOG_TRIAL_UNIT_VALUES: readonly ["day", "month"];
13
- export declare const INVOICING_CATALOG_TRIAL_END_ACTION_VALUES: readonly ["site_default", "activate_subscription", "cancel_subscription"];
14
11
  export declare const INVOICING_CATALOG_PRORATION_VALUES: readonly ["site_default", "partial_term", "full_term"];
15
12
  export declare const INVOICING_CATALOG_APPLICABILITY_VALUES: readonly ["all", "restricted"];
16
13
  export declare const isTieredCatalogPricingModel: (model: string) => boolean;
@@ -1,21 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.entityToInvoicingCatalogItemFormLocalData = exports.initialInvoicingCatalogItemFormLocalData = exports.invoicingProductToCatalogItemFormSubFamily = exports.blankInvoicingCatalogSubFamily = exports.blankInvoicingCatalogTier = exports.isTieredCatalogPricingModel = exports.INVOICING_CATALOG_APPLICABILITY_VALUES = exports.INVOICING_CATALOG_PRORATION_VALUES = exports.INVOICING_CATALOG_TRIAL_END_ACTION_VALUES = exports.INVOICING_CATALOG_TRIAL_UNIT_VALUES = exports.INVOICING_CATALOG_TIER_TYPE_VALUES = exports.INVOICING_CATALOG_PRICING_MODEL_VALUES = exports.INVOICING_CATALOG_PERIOD_UNIT_VALUES = exports.INVOICING_CATALOG_TYPE_VALUES = void 0;
3
+ exports.entityToInvoicingCatalogItemFormLocalData = exports.initialInvoicingCatalogItemFormLocalData = exports.invoicingProductToCatalogItemFormSubFamily = exports.blankInvoicingCatalogSubFamily = exports.blankInvoicingCatalogTier = exports.isTieredCatalogPricingModel = exports.INVOICING_CATALOG_APPLICABILITY_VALUES = exports.INVOICING_CATALOG_PRORATION_VALUES = exports.INVOICING_CATALOG_TIER_TYPE_VALUES = exports.INVOICING_CATALOG_PRICING_MODEL_VALUES = void 0;
4
4
  /**
5
- * Canonical value sets for the catalog item form. CES owns the values;
6
- * web-components maps each value to a localized label.
5
+ * Value sets the catalog item form still owns locally: the backend has no enum
6
+ * for pricing model, tier type, proration or applicability yet, so these stay
7
+ * here until it does. Everything else on this form comes from `/1.0/config`.
7
8
  */
8
- exports.INVOICING_CATALOG_TYPE_VALUES = [
9
- 'plan',
10
- 'addon',
11
- 'charge',
12
- ];
13
- exports.INVOICING_CATALOG_PERIOD_UNIT_VALUES = [
14
- 'day',
15
- 'week',
16
- 'month',
17
- 'year',
18
- ];
19
9
  exports.INVOICING_CATALOG_PRICING_MODEL_VALUES = [
20
10
  'flat_fee',
21
11
  'per_unit',
@@ -28,12 +18,6 @@ exports.INVOICING_CATALOG_TIER_TYPE_VALUES = [
28
18
  'flat_fee',
29
19
  'package',
30
20
  ];
31
- exports.INVOICING_CATALOG_TRIAL_UNIT_VALUES = ['day', 'month'];
32
- exports.INVOICING_CATALOG_TRIAL_END_ACTION_VALUES = [
33
- 'site_default',
34
- 'activate_subscription',
35
- 'cancel_subscription',
36
- ];
37
21
  exports.INVOICING_CATALOG_PRORATION_VALUES = [
38
22
  'site_default',
39
23
  'partial_term',
@@ -1,11 +1,13 @@
1
- import { ID } from '../../../commonStateTypes/common';
1
+ import { FetchState, ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
- import { InvoicingCouponApplyOn, InvoicingCouponDurationType, InvoicingCouponPeriodUnit, InvoicingDiscountType } from '../../../entity/invoicing/coupon/couponPayload';
4
3
  import { InvoicingCoupon } from '../../../entity/invoicing/coupon/couponState';
5
- import { InvoicingFormOption } from '../../../entity/invoicing/invoicingCommonPayload';
4
+ import { InvoicingDiscountLifecycleActionOption, InvoicingFormOption } from '../../../entity/invoicing/invoicingCommonPayload';
6
5
  import { RootState } from '../../../reducer';
7
6
  import { InvoicingCouponFormLocalData } from './editInvoicingCouponDetailViewState';
8
7
  export interface EditInvoicingCouponDetailView extends SelectorView {
8
+ /** Config-owned; folded in so the screen reads one selector. */
9
+ configFetchState: FetchState;
10
+ discountLifecycleActionOptions: InvoicingDiscountLifecycleActionOption[];
9
11
  coupon?: InvoicingCoupon;
10
12
  savedCouponId?: ID;
11
13
  }
@@ -16,12 +18,12 @@ export interface EditInvoicingCouponDetailView extends SelectorView {
16
18
  */
17
19
  export declare const getEditInvoicingCouponDetailViewState: (state: RootState, couponId?: ID) => EditInvoicingCouponDetailView;
18
20
  export interface InvoicingCouponFormView extends EditInvoicingCouponDetailView {
19
- applyOnOptions: readonly InvoicingFormOption<InvoicingCouponApplyOn>[];
20
- discountTypeOptions: readonly InvoicingFormOption<InvoicingDiscountType>[];
21
- durationTypeOptions: readonly InvoicingFormOption<InvoicingCouponDurationType>[];
21
+ applyOnOptions: InvoicingFormOption[];
22
+ discountTypeOptions: InvoicingFormOption[];
23
+ durationTypeOptions: InvoicingFormOption[];
22
24
  localData: InvoicingCouponFormLocalData;
23
25
  mode: 'create' | 'edit';
24
- periodUnitOptions: readonly InvoicingFormOption<InvoicingCouponPeriodUnit>[];
26
+ periodUnitOptions: InvoicingFormOption[];
25
27
  }
26
28
  /**
27
29
  * Bundled view for the discount form screen: the edit view (save state + the
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvoicingCouponFormView = exports.getEditInvoicingCouponDetailViewState = void 0;
4
- const couponConstants_1 = require("../../../entity/invoicing/coupon/couponConstants");
5
4
  const couponSelector_1 = require("../../../entity/invoicing/coupon/couponSelector");
5
+ const invoicingCommonPayload_1 = require("../../../entity/invoicing/invoicingCommonPayload");
6
+ const invoicingConfigViewSelector_1 = require("../invoicingConfigView/invoicingConfigViewSelector");
6
7
  const editInvoicingCouponDetailViewState_1 = require("./editInvoicingCouponDetailViewState");
7
8
  /**
8
9
  * Bundled view for the discount create/edit form: the save fetch state/error,
@@ -11,7 +12,10 @@ const editInvoicingCouponDetailViewState_1 = require("./editInvoicingCouponDetai
11
12
  */
12
13
  const getEditInvoicingCouponDetailViewState = (state, couponId) => {
13
14
  const { error, fetchState, savedCouponId } = state.editInvoicingCouponDetailViewState;
15
+ const { discountLifecycleActionOptions, fetchState: configFetchState } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
14
16
  return {
17
+ configFetchState,
18
+ discountLifecycleActionOptions,
15
19
  coupon: couponId != null
16
20
  ? (0, couponSelector_1.getInvoicingCouponById)(state.invoicingCouponState, couponId)
17
21
  : undefined,
@@ -35,14 +39,15 @@ const getInvoicingCouponFormView = (state, couponId) => {
35
39
  ? (editDraftById[couponId] ??
36
40
  (0, editInvoicingCouponDetailViewState_1.entityToInvoicingCouponFormLocalData)(base.coupon))
37
41
  : newCouponDraft;
42
+ const { billingPeriodUnitOptions, discountApplyOnOptions, discountDurationTypeOptions, discountTypeOptions, } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
38
43
  return {
39
44
  ...base,
40
- applyOnOptions: couponConstants_1.INVOICING_COUPON_APPLY_ON_OPTIONS,
41
- discountTypeOptions: couponConstants_1.INVOICING_DISCOUNT_TYPE_OPTIONS,
42
- durationTypeOptions: couponConstants_1.INVOICING_COUPON_DURATION_TYPE_OPTIONS,
45
+ applyOnOptions: discountApplyOnOptions.map(invoicingCommonPayload_1.toInvoicingFormOption),
46
+ discountTypeOptions: discountTypeOptions.map(invoicingCommonPayload_1.toInvoicingFormOption),
47
+ durationTypeOptions: discountDurationTypeOptions.map(invoicingCommonPayload_1.toInvoicingFormOption),
43
48
  localData,
44
49
  mode: couponId != null ? 'edit' : 'create',
45
- periodUnitOptions: couponConstants_1.INVOICING_COUPON_PERIOD_UNIT_OPTIONS,
50
+ periodUnitOptions: billingPeriodUnitOptions.map(invoicingCommonPayload_1.toInvoicingFormOption),
46
51
  };
47
52
  };
48
53
  exports.getInvoicingCouponFormView = getInvoicingCouponFormView;
@@ -1,13 +1,14 @@
1
1
  import { ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
+ import { InvoicingNamedOption } from '../../../entity/invoicing/invoicingCommonPayload';
3
4
  import { RootState } from '../../../reducer';
4
5
  import { InvoicingCustomerFormLocalData } from './editInvoicingCustomerDetailViewState';
5
6
  export interface InvoicingCustomerFormView extends SelectorView {
6
- customerTypeValues: string[];
7
+ customerTypeOptions: InvoicingNamedOption[];
7
8
  localData: InvoicingCustomerFormLocalData;
8
9
  mode: 'create' | 'edit';
9
- netTermDayValues: string[];
10
- taxabilityValues: string[];
10
+ netTermDayOptions: InvoicingNamedOption[];
11
+ taxabilityOptions: InvoicingNamedOption[];
11
12
  billingAddressId?: ID;
12
13
  billingAddressLabel?: string;
13
14
  savedCustomerId?: ID;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvoicingCustomerFormView = void 0;
4
4
  const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
5
5
  const addressViewSelector_1 = require("../../addressView/addressViewSelector");
6
+ const invoicingConfigViewSelector_1 = require("../invoicingConfigView/invoicingConfigViewSelector");
6
7
  const invoicingCustomerFormConfig_1 = require("./invoicingCustomerFormConfig");
7
8
  /**
8
9
  * Bundled view for the customer create/edit form. Exposes the draft `localData`
@@ -29,12 +30,13 @@ const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
29
30
  const billingAddressLabel = newAddress?.addressToCreate != null
30
31
  ? (0, addressViewSelector_1.getFormattedAddress)(newAddress.addressToCreate)
31
32
  : undefined;
33
+ const { customerTypeOptions, netTermDayOptions, taxabilityOptions } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
32
34
  return {
33
- customerTypeValues: [...invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_TYPE_VALUES],
35
+ customerTypeOptions,
34
36
  localData,
35
37
  mode,
36
- netTermDayValues: [...invoicingCustomerFormConfig_1.INVOICING_NET_TERM_DAY_VALUES],
37
- taxabilityValues: [...invoicingCustomerFormConfig_1.INVOICING_TAXABILITY_VALUES],
38
+ netTermDayOptions,
39
+ taxabilityOptions,
38
40
  billingAddressId,
39
41
  billingAddressLabel,
40
42
  savedCustomerId,
@@ -2,14 +2,6 @@ import { InvoicingCustomer } from '../../../entity/invoicing/invoicingCustomer/i
2
2
  import { InvoicingCustomerFormLocalData } from './editInvoicingCustomerDetailViewState';
3
3
  /** `AddressType` key used when the customer form opens the shared Address screen. */
4
4
  export declare const INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE: "invoicing_customer_billing_address";
5
- /**
6
- * Canonical option value sets for the customer form. CES owns the values;
7
- * web-components maps each value to a localized label (same split as the
8
- * invoicing list column/tab config).
9
- */
10
- export declare const INVOICING_CUSTOMER_TYPE_VALUES: readonly ["business", "residential"];
11
- export declare const INVOICING_TAXABILITY_VALUES: readonly ["taxable", "exempt"];
12
- export declare const INVOICING_NET_TERM_DAY_VALUES: readonly ["0", "15", "30", "45", "60"];
13
5
  export declare const initialInvoicingCustomerFormLocalData: InvoicingCustomerFormLocalData;
14
6
  /** Seed the form draft from an existing customer entity (edit mode). */
15
7
  export declare const entityToInvoicingCustomerFormLocalData: (customer?: InvoicingCustomer) => InvoicingCustomerFormLocalData;
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.entityToInvoicingCustomerFormLocalData = exports.initialInvoicingCustomerFormLocalData = exports.INVOICING_NET_TERM_DAY_VALUES = exports.INVOICING_TAXABILITY_VALUES = exports.INVOICING_CUSTOMER_TYPE_VALUES = exports.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = void 0;
3
+ exports.entityToInvoicingCustomerFormLocalData = exports.initialInvoicingCustomerFormLocalData = exports.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = void 0;
4
4
  /** `AddressType` key used when the customer form opens the shared Address screen. */
5
5
  exports.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = 'invoicing_customer_billing_address';
6
- /**
7
- * Canonical option value sets for the customer form. CES owns the values;
8
- * web-components maps each value to a localized label (same split as the
9
- * invoicing list column/tab config).
10
- */
11
- exports.INVOICING_CUSTOMER_TYPE_VALUES = [
12
- 'business',
13
- 'residential',
14
- ];
15
- exports.INVOICING_TAXABILITY_VALUES = ['taxable', 'exempt'];
16
- exports.INVOICING_NET_TERM_DAY_VALUES = [
17
- '0',
18
- '15',
19
- '30',
20
- '45',
21
- '60',
22
- ];
23
6
  exports.initialInvoicingCustomerFormLocalData = {
24
7
  autoCollection: true,
25
8
  company: '',
@@ -1,6 +1,7 @@
1
1
  import { ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { InvoicingCoupon } from '../../../entity/invoicing/coupon/couponState';
4
+ import { InvoicingSubscriptionLifecycleActionOption } from '../../../entity/invoicing/invoicingCommonPayload';
4
5
  import { InvoicingCustomer } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerState';
5
6
  import { InvoicingSubscription } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionState';
6
7
  import { InvoicingProduct } from '../../../entity/invoicing/product/productState';
@@ -13,6 +14,10 @@ import { InvoicingSubscriptionFormLocalData } from './editInvoicingSubscriptionD
13
14
  * prefill the form.
14
15
  */
15
16
  export interface EditInvoicingSubscriptionDetailView extends SelectorView {
17
+ /** Config-owned; folded in so the screen reads one selector. */
18
+ subscriptionCommercialEditAllowedFromStatuses: string[];
19
+ subscriptionLifecycleActionOptions: InvoicingSubscriptionLifecycleActionOption[];
20
+ subscriptionMetadataEditAllowedFromStatuses: string[];
16
21
  savedSubscriptionId?: ID;
17
22
  subscription?: InvoicingSubscription;
18
23
  }
@@ -5,11 +5,16 @@ const invoicingSubscriptionSelector_1 = require("../../../entity/invoicing/invoi
5
5
  const addressViewSelector_1 = require("../../addressView/addressViewSelector");
6
6
  const couponViewSelector_1 = require("../couponView/couponViewSelector");
7
7
  const invoicingCatalogListViewSelector_1 = require("../invoicingCatalogListView/invoicingCatalogListViewSelector");
8
+ const invoicingConfigViewSelector_1 = require("../invoicingConfigView/invoicingConfigViewSelector");
8
9
  const invoicingCustomerListViewSelector_1 = require("../invoicingCustomerListView/invoicingCustomerListViewSelector");
9
10
  const invoicingSubscriptionFormConfig_1 = require("./invoicingSubscriptionFormConfig");
10
11
  const getEditInvoicingSubscriptionDetailViewState = (state, invoicingSubscriptionID) => {
11
12
  const { error, fetchState, savedSubscriptionId } = state.editInvoicingSubscriptionDetailViewState;
13
+ const { subscriptionCommercialEditAllowedFromStatuses, subscriptionLifecycleActionOptions, subscriptionMetadataEditAllowedFromStatuses, } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
12
14
  return {
15
+ subscriptionCommercialEditAllowedFromStatuses,
16
+ subscriptionLifecycleActionOptions,
17
+ subscriptionMetadataEditAllowedFromStatuses,
13
18
  subscription: invoicingSubscriptionID != null
14
19
  ? (0, invoicingSubscriptionSelector_1.getInvoicingSubscriptionById)(state.invoicingSubscriptionState, invoicingSubscriptionID)
15
20
  : undefined,
@@ -4,6 +4,7 @@ exports.fetchInvoiceListPageEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const invoiceListReducer_1 = require("./invoiceListReducer");
7
+ const invoiceListState_1 = require("./invoiceListState");
7
8
  /**
8
9
  * Fetch unless the endpoint is already loaded or in flight — or always when the
9
10
  * caller forces a refresh via `cacheOverride` (e.g. on a filter/sort change).
@@ -19,7 +20,7 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
19
20
  const fetchInvoiceListPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(invoiceListReducer_1.fetchInvoiceListPage.match), (0, operators_1.mergeMap)((action) => {
20
21
  const { cacheOverride, filters, sort } = action.payload;
21
22
  const state = state$.value.invoicingInvoiceListState;
22
- const activeTabState = state.invoiceByTab[state.activeTab];
23
+ const activeTabState = state.invoiceByTab[state.activeTab] ?? (0, invoiceListState_1.makeInvoiceTabState)();
23
24
  const pageActions = [];
24
25
  if (shouldFetch({ fetchState: activeTabState.fetchState, error: activeTabState.error }, cacheOverride)) {
25
26
  pageActions.push((0, invoiceListReducer_1.fetchInvoiceList)({ filters, sort }));
@@ -20,13 +20,17 @@ const sameInvoiceListQuery = (a, b) => a.filters.customerId === b.filters.custom
20
20
  a.sort?.dir === b.sort?.dir;
21
21
  exports.sameInvoiceListQuery = sameInvoiceListQuery;
22
22
  /**
23
- * Narrow an invoice status to a status tab id when one exists. Statuses like
24
- * `draft` / `posted` / `pending` have no dedicated tab, so a newly created
25
- * invoice in one of those states only lands in the `all` tab.
23
+ * The status tab a newly created invoice belongs in always its own status.
24
+ *
25
+ * This used to gate on `ALL_INVOICING_INVOICE_TAB_IDS`, which left a status the
26
+ * config added but this build's union does not know getting its count
27
+ * incremented while the id landed only in `all`: the tab rendered with a
28
+ * non-zero count and an empty list until a refetch. Per-tab cache entries are
29
+ * created on demand now, so every status is a valid key and the add path agrees
30
+ * with the count path. A status with no rendered tab just caches an entry nobody
31
+ * reads.
26
32
  */
27
- const statusToTabId = (status) => invoiceListState_1.ALL_INVOICING_INVOICE_TAB_IDS.includes(status)
28
- ? status
29
- : undefined;
33
+ const statusToTabId = (status) => status;
30
34
  exports.initialState = {
31
35
  activeTab: 'all',
32
36
  invoiceByTab: (0, invoiceListState_1.makeInvoiceByTab)(),
@@ -42,7 +46,7 @@ const invoiceList = (0, toolkit_1.createSlice)({
42
46
  reducers: {
43
47
  fetchInvoiceList: {
44
48
  reducer(draft, action) {
45
- const tab = draft.invoiceByTab[draft.activeTab];
49
+ const tab = (0, invoiceListState_1.invoiceTabStateFor)(draft.invoiceByTab, draft.activeTab);
46
50
  if (!action.payload.keepExistingListItems) {
47
51
  tab.invoiceIds = [];
48
52
  tab.nextCursor = null;
@@ -85,7 +89,7 @@ const invoiceList = (0, toolkit_1.createSlice)({
85
89
  },
86
90
  },
87
91
  updateInvoiceList(draft, action) {
88
- const tab = draft.invoiceByTab[draft.activeTab];
92
+ const tab = (0, invoiceListState_1.invoiceTabStateFor)(draft.invoiceByTab, draft.activeTab);
89
93
  const newIds = action.payload.invoices.map((invoice) => invoice.id);
90
94
  tab.invoiceIds = action.payload.keepExistingListItems
91
95
  ? [...new Set([...tab.invoiceIds, ...newIds])]
@@ -95,7 +99,7 @@ const invoiceList = (0, toolkit_1.createSlice)({
95
99
  tab.error = undefined;
96
100
  },
97
101
  updateInvoiceListFailure(draft, action) {
98
- const tab = draft.invoiceByTab[draft.activeTab];
102
+ const tab = (0, invoiceListState_1.invoiceTabStateFor)(draft.invoiceByTab, draft.activeTab);
99
103
  tab.fetchState = 'Error';
100
104
  tab.error = action.payload;
101
105
  },
@@ -141,17 +145,14 @@ const invoiceList = (0, toolkit_1.createSlice)({
141
145
  // are left untouched and refetched lazily.
142
146
  addInvoiceToList(draft, action) {
143
147
  const { id, status } = action.payload;
144
- const allTab = draft.invoiceByTab['all'];
148
+ const allTab = (0, invoiceListState_1.invoiceTabStateFor)(draft.invoiceByTab, 'all');
145
149
  if (allTab.invoiceIds.includes(id)) {
146
150
  return;
147
151
  }
148
152
  allTab.invoiceIds = [id, ...allTab.invoiceIds];
149
- const statusTab = statusToTabId(status);
150
- if (statusTab != null) {
151
- const tab = draft.invoiceByTab[statusTab];
152
- if (!tab.invoiceIds.includes(id)) {
153
- tab.invoiceIds = [id, ...tab.invoiceIds];
154
- }
153
+ const statusTab = (0, invoiceListState_1.invoiceTabStateFor)(draft.invoiceByTab, statusToTabId(status));
154
+ if (!statusTab.invoiceIds.includes(id)) {
155
+ statusTab.invoiceIds = [id, ...statusTab.invoiceIds];
155
156
  }
156
157
  draft.counts.all += 1;
157
158
  draft.counts[status] = (draft.counts[status] ?? 0) + 1;
@@ -1,7 +1,7 @@
1
1
  import { FetchStateAndError } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { InvoicingInvoice, InvoicingInvoiceKPIs } from '../../../entity/invoicing/invoice/invoiceState';
4
- import { InvoicingListCounts } from '../../../entity/invoicing/invoicingCommonPayload';
4
+ import { InvoicingListCounts, InvoicingNamedOption } from '../../../entity/invoicing/invoicingCommonPayload';
5
5
  import { RootState } from '../../../reducer';
6
6
  import { InvoiceListFilters, InvoicingInvoiceTabId } from './invoiceListState';
7
7
  export interface InvoiceListView extends SelectorView {
@@ -12,6 +12,8 @@ export interface InvoiceListView extends SelectorView {
12
12
  invoices: InvoicingInvoice[];
13
13
  kpisFetchState: FetchStateAndError;
14
14
  nextCursor: string | null;
15
+ /** Config status list; the page labels tabs and row badges from it. */
16
+ statusOptions: InvoicingNamedOption[];
15
17
  tabIds: InvoicingInvoiceTabId[];
16
18
  kpis?: InvoicingInvoiceKPIs;
17
19
  }