@zeniai/client-epic-state 5.2.13 → 5.2.14-betaRD0

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 (126) hide show
  1. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
  2. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  3. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +78 -1
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.js +183 -4
  5. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
  6. package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  7. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
  8. package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
  9. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +123 -1
  10. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
  11. package/lib/entity/jeSchedules/jeSchedulesTypes.js +96 -1
  12. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  13. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  14. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
  15. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  16. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
  17. package/lib/epic.d.ts +9 -1
  18. package/lib/epic.js +16 -0
  19. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
  20. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +183 -5
  21. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  22. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
  23. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +86 -0
  24. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  25. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  26. package/lib/esm/epic.js +16 -0
  27. package/lib/esm/index.js +17 -11
  28. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  29. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  30. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
  31. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
  32. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  33. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +104 -0
  34. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
  35. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +138 -0
  36. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
  37. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +180 -0
  38. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +111 -0
  39. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +28 -0
  40. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
  41. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
  42. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +319 -29
  43. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
  44. package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  45. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
  46. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +327 -22
  47. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
  48. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +24 -7
  49. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +1 -1
  50. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +8 -1
  51. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +42 -8
  52. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogSubFamilyEpics.js +8 -2
  53. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +19 -10
  54. package/lib/esm/view/invoicing/invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewSelector.js +2 -0
  55. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +0 -1
  56. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +15 -36
  57. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  58. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  59. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  60. package/lib/index.d.ts +24 -18
  61. package/lib/index.js +93 -48
  62. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  63. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  64. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
  65. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
  66. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +21 -0
  67. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
  68. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  69. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +9 -0
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +108 -0
  71. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
  72. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
  73. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +9 -0
  74. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +142 -0
  75. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
  76. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
  77. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +13 -0
  78. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +187 -0
  79. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
  80. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +115 -0
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +32 -0
  83. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
  84. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
  85. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  86. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +86 -3
  87. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
  88. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +93 -12
  89. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +321 -29
  90. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  91. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  92. package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
  93. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
  94. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
  95. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +41 -7
  96. package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  97. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
  98. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
  99. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
  100. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +335 -21
  101. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  102. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
  103. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  104. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  105. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +13 -21
  106. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +24 -7
  107. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +7 -0
  108. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +4 -3
  109. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.d.ts +18 -9
  110. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +9 -2
  111. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +15 -5
  112. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +43 -8
  113. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +24 -0
  114. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogSubFamilyEpics.d.ts +1 -1
  115. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogSubFamilyEpics.js +8 -2
  116. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +18 -9
  117. package/lib/view/invoicing/invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewSelector.d.ts +6 -0
  118. package/lib/view/invoicing/invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewSelector.js +2 -0
  119. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +0 -1
  120. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +13 -13
  121. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +17 -38
  122. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  123. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  124. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
  125. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  126. package/package.json +1 -1
@@ -3,7 +3,9 @@ import orderBy from 'lodash/orderBy';
3
3
  import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
4
4
  import { LAST_SCHEDULE_DAY_OF_MONTH, toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
5
5
  import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
6
- import { getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
6
+ import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
7
+ import { getJEAccruedScheduleByJEScheduleKey, getJEOneTimeAccrualByKey, getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
8
+ import { ALL_SCHEDULES_TYPES, } from '../../../entity/jeSchedules/jeSchedulesTypes';
7
9
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
8
10
  import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
9
11
  import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
@@ -11,8 +13,143 @@ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleD
11
13
  import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
12
14
  import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
13
15
  import { getAllSteps } from './getAllStepsHelper';
16
+ import { ALL_JE_PAGE_TABS, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
14
17
  import { getJEAccountSettingsView } from './jeAccountSettingsViewSelector';
18
+ import { getNewScheduleView } from './jeNewScheduleViewSelector';
19
+ // Matches the AI-automation user addresses webc's schedule list row already
20
+ // checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
21
+ // strings.ts aiBotEmail/botEmail) to determine whether a schedule was
22
+ // created by the AI accountant vs. a human.
23
+ const AI_BOT_EMAIL = 'ai@zeni.ai';
24
+ const BOT_EMAIL = 'bot@zeni.ai';
25
+ // A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
26
+ // accrued expense, so it counts and filters under that type on the page's type tabs.
27
+ const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
28
+ // Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it;
29
+ // everything else is already on the books or in a transient claim.
30
+ const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
31
+ 'draft',
32
+ ];
33
+ /**
34
+ * `posting_blocked` is written by the posting Cron when a JE fails to post. It is an internal
35
+ * failure state with no human action attached, so it is dropped here rather than hidden at render
36
+ * time — filtering in the view would leave the group counts and KPI totals counting rows nobody
37
+ * can see. The expense-automation endpoint applies no status filter on the close-period path, so
38
+ * these rows do arrive.
39
+ */
40
+ export function isRenderableOneTimeAccrual(accrual) {
41
+ return (accrual.accrualStatus !== 'posting_blocked' &&
42
+ // Terminal states the user has already decided. The GET list excludes both server-side, so
43
+ // these only appear in the window between an ignore/revert response being written back and the
44
+ // background refresh landing -- during which an ignored row would otherwise sit in Pending
45
+ // Review offering a Post button. Dropped here rather than at render time so group counts and
46
+ // KPI totals do not count rows nobody can see.
47
+ accrual.accrualStatus !== 'reverted' &&
48
+ !accrual.isIgnored);
49
+ }
50
+ export function getJEScheduleRowType(schedule) {
51
+ return isOneTimeAccrualRow(schedule)
52
+ ? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
53
+ : schedule.jeScheduleType;
54
+ }
55
+ export function isPendingReviewRow(schedule) {
56
+ return isOneTimeAccrualRow(schedule)
57
+ ? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
58
+ : schedule.status.code === 'draft';
59
+ }
60
+ // Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
61
+ // posted, so this only has to agree with that rather than re-derive it.
62
+ export function isExistingTabRow(schedule) {
63
+ return isOneTimeAccrualRow(schedule)
64
+ ? schedule.accrualStatus === 'posted'
65
+ : schedule.status.code === 'ongoing';
66
+ }
67
+ // Exported (rather than kept as a closure inside the selector) so it can be
68
+ // unit-tested directly — confidenceScore is a separate, more narrowly
69
+ // populated field that can be null on a schedule the bot user created,
70
+ // which previously caused these schedules to display as "AI Accountant" in
71
+ // the list but count under "Manual" in the KPI summary.
72
+ export const isAiAccountantSchedule = (schedule) => {
73
+ // A one-time accrual records who made it as `origin`, which is authoritative — no email
74
+ // sniffing needed, and the JE bot is often absent from the user entity entirely.
75
+ if (isOneTimeAccrualRow(schedule)) {
76
+ return schedule.origin === 'agent';
77
+ }
78
+ return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
79
+ schedule.createdByUser?.email === BOT_EMAIL);
80
+ };
81
+ // Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
82
+ // memo in its place — so anything reading baseTransaction has to branch on this first.
83
+ //
84
+ // Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
85
+ // cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
86
+ // arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
87
+ // misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
88
+ export function isAccruedScheduleRow(schedule) {
89
+ return 'jeAccruedScheduleKey' in schedule;
90
+ }
91
+ // Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
92
+ // exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
93
+ // not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
94
+ // render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
95
+ // which it has.
96
+ export function isOneTimeAccrualRow(schedule) {
97
+ return 'jeOneTimeAccrualKey' in schedule;
98
+ }
99
+ /** The row's own Amount, so callers can read its currency and not just its value. */
100
+ function getScheduleAmountObject(schedule) {
101
+ if (isOneTimeAccrualRow(schedule)) {
102
+ return schedule.estimatedAmount;
103
+ }
104
+ if (isAccruedScheduleRow(schedule)) {
105
+ return schedule.recurringAmount;
106
+ }
107
+ return schedule.baseTransaction.amount;
108
+ }
109
+ function getScheduleAmount(schedule) {
110
+ if (isOneTimeAccrualRow(schedule)) {
111
+ return schedule.estimatedAmount.amount;
112
+ }
113
+ if (isAccruedScheduleRow(schedule)) {
114
+ return schedule.recurringAmount.amount;
115
+ }
116
+ return schedule.baseTransaction.amount.amount;
117
+ }
118
+ // A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
119
+ // rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
120
+ // accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
121
+ // deliberately fall through to undefined, which sorts them together at one end.
122
+ function getOneTimeAccrualSortValue(accrual, sortKey) {
123
+ switch (sortKey) {
124
+ case 'vendor':
125
+ return accrual.vendorName.toLowerCase();
126
+ case 'category':
127
+ return accrual.jeDebitAccountName?.toLowerCase();
128
+ case 'class':
129
+ return accrual.jeDebitAccountingClassName?.toLowerCase();
130
+ case 'depCategory':
131
+ return accrual.jeCreditAccountName?.toLowerCase();
132
+ case 'type':
133
+ return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
134
+ case 'totalAmount':
135
+ return accrual.estimatedAmount.amount;
136
+ case 'transactionDate':
137
+ return accrual.postingDate?.valueOf();
138
+ case 'memo':
139
+ return accrual.memo.toLowerCase();
140
+ case 'startMonth':
141
+ return accrual.serviceMonth;
142
+ default:
143
+ return undefined;
144
+ }
145
+ }
15
146
  function getJEScheduleSortAccessor(sortKey) {
147
+ const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
148
+ return (schedule) => isOneTimeAccrualRow(schedule)
149
+ ? getOneTimeAccrualSortValue(schedule, sortKey)
150
+ : scheduleAccessor(schedule);
151
+ }
152
+ function getScheduleRowSortAccessor(sortKey) {
16
153
  switch (sortKey) {
17
154
  case 'vendor':
18
155
  return (s) => s.vendor.name?.toLowerCase();
@@ -23,7 +160,9 @@ function getJEScheduleSortAccessor(sortKey) {
23
160
  case 'depCategory':
24
161
  return (s) => s.jeCredit.account?.accountName?.toLowerCase();
25
162
  case 'scheduleCategory':
26
- return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
163
+ return (s) => isAccruedScheduleRow(s)
164
+ ? undefined
165
+ : s.baseTransaction.account?.accountName?.toLowerCase();
27
166
  case 'startMonth':
28
167
  return (s) => s.startDate?.valueOf();
29
168
  case 'type':
@@ -51,11 +190,13 @@ function getJEScheduleSortAccessor(sortKey) {
51
190
  return s.balanceAsOfToday?.amount ?? null;
52
191
  };
53
192
  case 'totalAmount':
54
- return (s) => s.baseTransaction.amount.amount;
193
+ return (s) => getScheduleAmount(s);
55
194
  case 'transactionDate':
56
- return (s) => s.baseTransaction.date.valueOf();
195
+ return (s) => s.createTime?.valueOf();
57
196
  case 'memo':
58
- return (s) => s.baseTransaction.memo?.toLowerCase();
197
+ return (s) => isAccruedScheduleRow(s)
198
+ ? s.memo.toLowerCase()
199
+ : s.baseTransaction.memo?.toLowerCase();
59
200
  default:
60
201
  return (s) => s.startDate?.valueOf();
61
202
  }
@@ -67,9 +208,15 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
67
208
  export function getExpenseAutomationJESchedulesView(state) {
68
209
  const jeScheduledTransaction = [];
69
210
  const failedJeScheduledTransaction = [];
211
+ const accruedSchedules = [];
212
+ const oneTimeAccruals = [];
70
213
  const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
71
- const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, } = expenseAutomationJESchedulesViewState;
214
+ const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
72
215
  const accountSettingsView = getJEAccountSettingsView(state);
216
+ const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
217
+ newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
218
+ ? getNewScheduleView(state, newSchedule.selectedDetailScheduleType)
219
+ : undefined;
73
220
  const currentTenant = getCurrentTenant(state);
74
221
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
75
222
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
@@ -97,27 +244,48 @@ export function getExpenseAutomationJESchedulesView(state) {
97
244
  const filteredDepAccountListNestedAccountHierarchy = filterNestedAccountHierarchyById(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
98
245
  const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
99
246
  const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
100
- const jeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
101
- ? jeScheduleTransactionKeysByPeriod[monthYearPeriodId]
102
- : null;
103
- const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
104
- ? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
247
+ const selectedPeriodTabKey = monthYearPeriodId != null
248
+ ? getJESchedulePeriodTabKey(uiState.selectedPageTab, monthYearPeriodId)
105
249
  : null;
106
- const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedPeriod ?? [];
107
- const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedPeriod ?? [];
250
+ const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
251
+ ? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
252
+ : undefined;
253
+ const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
254
+ ? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
255
+ : undefined;
256
+ // Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
257
+ // empty". Without it the page cannot tell a first visit from a real empty state, and renders an
258
+ // empty table where it should render a skeleton.
259
+ const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
260
+ const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
261
+ const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
262
+ const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
263
+ ? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
264
+ : undefined) ?? [];
265
+ const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
266
+ ? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
267
+ : undefined) ?? [];
268
+ jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
269
+ const accrual = getJEOneTimeAccrualByKey(jeOneTimeAccrualKey, state.jeSchedulesState);
270
+ if (accrual != null && isRenderableOneTimeAccrual(accrual)) {
271
+ oneTimeAccruals.push(accrual);
272
+ }
273
+ });
108
274
  jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
109
275
  const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
110
276
  jeScheduledTransaction.push(jeScheduleDetails);
111
277
  });
278
+ jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
279
+ const accruedScheduleDetails = getJEAccruedScheduleByJEScheduleKey(jeAccruedScheduleKey, state);
280
+ if (accruedScheduleDetails != null) {
281
+ accruedSchedules.push(accruedScheduleDetails);
282
+ }
283
+ });
112
284
  failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
113
285
  const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
114
286
  failedJeScheduledTransaction.push(jeScheduleDetails);
115
287
  });
116
- const { sortKey, sortOrder } = uiState;
117
- const draftSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'), sortKey, sortOrder);
118
- const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
119
- const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
120
- schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
288
+ const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
121
289
  const unsortedResolveSchedules = [];
122
290
  failedJeScheduledTransaction.forEach((schedule) => {
123
291
  schedule.scheduledJournalEntry.forEach((journalEntry) => {
@@ -129,10 +297,103 @@ export function getExpenseAutomationJESchedulesView(state) {
129
297
  });
130
298
  const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
131
299
  const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
300
+ const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
301
+ getJEScheduleRowType(schedule) === selectedJETypeFilter;
302
+ const isCreatedStatus = (schedule) => {
303
+ // An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
304
+ // transient posting claim.
305
+ if (isOneTimeAccrualRow(schedule)) {
306
+ return !isPendingReviewRow(schedule);
307
+ }
308
+ return (schedule.status.code === 'ongoing' ||
309
+ schedule.status.code === 'completed' ||
310
+ schedule.status.code === 'marked_as_completed');
311
+ };
312
+ const allScheduleRows = [
313
+ ...jeScheduledTransaction,
314
+ ...accruedSchedules,
315
+ ...oneTimeAccruals,
316
+ ];
132
317
  const pendingReviewSchedules = sortJEScheduledTransactions([
133
- ...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
318
+ ...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
134
319
  ...validResolveForPending,
135
320
  ], sortKey, sortOrder);
321
+ const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
322
+ // KPI summary — derived from unfiltered schedules so counts are always accurate
323
+ const allSchedules = allScheduleRows;
324
+ const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
325
+ const pendingReviewTotal = sumAmount(pendingReviewSchedules);
326
+ const createdTotal = sumAmount(createdSchedules);
327
+ /**
328
+ * The currency the tiles render in. Taken from the schedules themselves rather than assumed:
329
+ * every row on a tab shares a tenant currency, so the first one that states it is the answer.
330
+ */
331
+ const sumToAmount = (schedules) => {
332
+ const first = schedules[0];
333
+ const currency = first != null ? getScheduleAmountObject(first) : allScheduleAmountFallback;
334
+ return {
335
+ ...currency,
336
+ amount: sumAmount(schedules),
337
+ };
338
+ };
339
+ // An empty bucket still has to render a currency; borrow it from any row on the page.
340
+ const allScheduleAmountFallback = allScheduleRows.length > 0
341
+ ? getScheduleAmountObject(allScheduleRows[0])
342
+ : { amount: 0, currencyCode: '', currencySymbol: '' };
343
+ const aiAccountantSchedules = allSchedules.filter(isAiAccountantSchedule);
344
+ const manualSchedules = allSchedules.filter((schedule) => !isAiAccountantSchedule(schedule));
345
+ const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
346
+ const kpiSummary = {
347
+ aiAccountant: {
348
+ count: aiAccountantSchedules.length,
349
+ amount: sumToAmount(aiAccountantSchedules),
350
+ },
351
+ manual: {
352
+ count: manualSchedules.length,
353
+ amount: sumToAmount(manualSchedules),
354
+ },
355
+ needsReview: {
356
+ count: pendingUnfiltered.length,
357
+ amount: sumToAmount(pendingUnfiltered),
358
+ },
359
+ total: {
360
+ count: allSchedules.length,
361
+ amount: sumToAmount(allSchedules),
362
+ },
363
+ };
364
+ // Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
365
+ // reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
366
+ const scheduleCountsByTab = {};
367
+ ALL_JE_PAGE_TABS.forEach((pageTab) => {
368
+ const periodTabKey = monthYearPeriodId != null
369
+ ? getJESchedulePeriodTabKey(pageTab, monthYearPeriodId)
370
+ : null;
371
+ const transactionKeys = periodTabKey != null
372
+ ? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
373
+ : undefined;
374
+ if (transactionKeys == null) {
375
+ return;
376
+ }
377
+ const accruedKeys = (periodTabKey != null
378
+ ? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
379
+ : undefined) ?? [];
380
+ const oneTimeAccrualKeys = (periodTabKey != null
381
+ ? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
382
+ : undefined) ?? [];
383
+ const rowsForTab = [
384
+ ...transactionKeys.map((transactionKey) => getJEScheduledTransactionByJEScheduleTransactionKey(transactionKey, state)),
385
+ ...accruedKeys
386
+ .map((accruedKey) => getJEAccruedScheduleByJEScheduleKey(accruedKey, state))
387
+ .filter((accruedRow) => accruedRow != null),
388
+ ...oneTimeAccrualKeys
389
+ .map((accrualKey) => getJEOneTimeAccrualByKey(accrualKey, state.jeSchedulesState))
390
+ .filter((accrualRow) => accrualRow != null && isRenderableOneTimeAccrual(accrualRow)),
391
+ ];
392
+ scheduleCountsByTab[pageTab] =
393
+ pageTab === 'existing_schedules'
394
+ ? rowsForTab.filter((row) => isExistingTabRow(row)).length
395
+ : rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
396
+ });
136
397
  const allSteps = monthYearPeriodId != null
137
398
  ? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
138
399
  : [];
@@ -145,6 +406,20 @@ export function getExpenseAutomationJESchedulesView(state) {
145
406
  { fetchState, error },
146
407
  monthEndFetchState,
147
408
  ]);
409
+ const countByType = (schedules) => {
410
+ const counts = ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
411
+ schedules.forEach((schedule) => {
412
+ const scheduleType = getJEScheduleRowType(schedule);
413
+ if (scheduleType != null) {
414
+ counts[scheduleType] += 1;
415
+ }
416
+ });
417
+ return counts;
418
+ };
419
+ const jeScheduleTypeCounts = {
420
+ active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
421
+ ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
422
+ };
148
423
  return {
149
424
  uncategorizedAccounts,
150
425
  allDepreciationAccountList: filteredDepAccounts,
@@ -153,14 +428,21 @@ export function getExpenseAutomationJESchedulesView(state) {
153
428
  allAccountList: filteredAccounts,
154
429
  accountListNestedAccountHierarchy,
155
430
  allClassList: allClasses,
156
- completedSchedules,
157
- draftSchedules,
158
- ongoingSchedules,
431
+ createdSchedules,
432
+ createdTotal,
433
+ hasLoadedForSelectedTab,
434
+ jeScheduleTypeCounts,
435
+ scheduleCountsByTab,
436
+ kpiSummary,
159
437
  pendingReviewSchedules,
438
+ pendingReviewTotal,
160
439
  resolveSchedules: resolveSchedules,
161
440
  accountSettingsView,
441
+ newScheduleView,
162
442
  postStatusById: postStatusById,
163
443
  ignoreStatusById: ignoreStatusById,
444
+ revertStatusById: revertStatusById,
445
+ oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
164
446
  fetchState: reducedFetchStatus.fetchState,
165
447
  jeScheduleLocalDataById: jeScheduleLocalDataById,
166
448
  uiState: uiState,
@@ -169,3 +451,26 @@ export function getExpenseAutomationJESchedulesView(state) {
169
451
  completionStatus,
170
452
  };
171
453
  }
454
+ /**
455
+ * One accrual plus the status of its promote / ignore request, for the detail screen.
456
+ *
457
+ * `accrual` is undefined on a cold load — a refresh or a shared link, where the list has never run
458
+ * — so the screen dispatches `fetchOneTimeAccrual` and waits on `detailFetchState`. The two states
459
+ * are separate on purpose: `actionFetchState` drives the row spinner and the post-revert navigation,
460
+ * and a page load must not look like an action that just finished.
461
+ */
462
+ export function getExpenseAutomationJEOneTimeAccrualDetailView(state, accrualId) {
463
+ return {
464
+ accrual: getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState),
465
+ actionFetchState: state.expenseAutomationJESchedulesViewState
466
+ .oneTimeAccrualActionStatusById[accrualId] ?? {
467
+ fetchState: 'Not-Started',
468
+ error: undefined,
469
+ },
470
+ detailFetchState: state.expenseAutomationJESchedulesViewState
471
+ .oneTimeAccrualFetchStatusById[accrualId] ?? {
472
+ fetchState: 'Not-Started',
473
+ error: undefined,
474
+ },
475
+ };
476
+ }
@@ -16,9 +16,8 @@ const JE_SCHEDULE_SORT_KEYS = [
16
16
  'memo',
17
17
  ];
18
18
  export const toJEScheduleSortKey = (v) => stringToUnion(v, JE_SCHEDULE_SORT_KEYS);
19
- const JE_SCHEDULE_MAIN_TABS = [
20
- 'pending_review',
21
- 'ongoing',
22
- 'completed',
23
- ];
24
- export const toJEScheduleMainTab = (v) => stringToUnion(v, JE_SCHEDULE_MAIN_TABS);
19
+ const JE_PAGE_TABS = ['schedules', 'existing_schedules'];
20
+ export const toJEPageTab = (v) => stringToUnion(v, JE_PAGE_TABS);
21
+ export const ALL_JE_PAGE_TABS = JE_PAGE_TABS;
22
+ export const getJESchedulePeriodTabKey = (selectedPageTab, monthYearPeriodId) => `${selectedPageTab}_${monthYearPeriodId}`;
23
+ export const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
@@ -1,3 +1,4 @@
1
+ import { buildAccountingDetail, } from './editInvoicingCatalogItemDetailViewPayload';
1
2
  import { invoicingProductToCatalogItemFormSubFamily, isTieredCatalogPricingModel, } from './invoicingCatalogItemFormConfig';
2
3
  const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
3
4
  const trimOrNull = (value) => value.trim() !== '' ? value.trim() : null;
@@ -35,7 +36,7 @@ const tierToPayload = (tier) => ({
35
36
  pricing_type: tier.pricingType,
36
37
  starting_unit: Number(tier.startingUnit) || 1,
37
38
  });
38
- const subFamilyToProductUpdate = (subFamily, itemType) => {
39
+ const subFamilyToProductUpdate = (subFamily, itemType, lookup) => {
39
40
  const tiered = isTieredCatalogPricingModel(subFamily.pricingModel);
40
41
  const data = {
41
42
  billing_cycles: hasValue(subFamily.billingCycles)
@@ -62,9 +63,12 @@ const subFamilyToProductUpdate = (subFamily, itemType) => {
62
63
  if (itemType === 'addon') {
63
64
  data.proration_type = subFamily.prorationType;
64
65
  }
66
+ // `null` rather than omitted when empty: an absent key on an update reads as
67
+ // "leave it alone", so a cleared account or class could never be saved.
68
+ data.accounting_detail = buildAccountingDetail(subFamily, lookup) ?? null;
65
69
  return { data, id: subFamily.id };
66
70
  };
67
- export const catalogDetailEditValuesToSavePayload = (values, itemType = 'plan', originalSubFamilies) => {
71
+ export const catalogDetailEditValuesToSavePayload = (values, lookup, itemType = 'plan', originalSubFamilies) => {
68
72
  const planData = {
69
73
  applicable_items: values.itemApplicability === 'restricted' ? values.applicableItems : [],
70
74
  enabled_for_checkout: values.enabledForCheckout,
@@ -96,12 +100,12 @@ export const catalogDetailEditValuesToSavePayload = (values, itemType = 'plan',
96
100
  planData.unit = unit;
97
101
  }
98
102
  const productUpdates = values.subFamilies.flatMap((subFamily) => {
99
- const update = subFamilyToProductUpdate(subFamily, itemType);
103
+ const update = subFamilyToProductUpdate(subFamily, itemType, lookup);
100
104
  const original = originalSubFamilies?.find((product) => product.id === subFamily.id);
101
105
  if (original == null) {
102
106
  return [update];
103
107
  }
104
- const originalUpdate = subFamilyToProductUpdate(subFamilyToEditValues(original), itemType);
108
+ const originalUpdate = subFamilyToProductUpdate(subFamilyToEditValues(original), itemType, lookup);
105
109
  const changedData = Object.fromEntries(Object.entries(update.data).filter(([key, value]) => JSON.stringify(value) !== JSON.stringify(originalUpdate.data[key])));
106
110
  return Object.keys(changedData).length > 0
107
111
  ? [{ data: changedData, id: update.id }]
@@ -113,21 +117,28 @@ export const catalogDetailEditValuesToSavePayload = (values, itemType = 'plan',
113
117
  };
114
118
  };
115
119
  /** Build POST /catalog/products body for Create sub-family. */
116
- export const createSubFamilyFormToPayload = (itemId, itemType, values) => {
120
+ export const createSubFamilyFormToPayload = (itemId, itemType, values, lookup) => {
117
121
  const name = values.name.trim();
118
122
  const priceCode = trimOrUndefined(values.priceCode) ?? toProductCode(name);
119
123
  const tiered = isTieredCatalogPricingModel(values.pricingModel);
120
124
  const payload = {
121
125
  currency_code: 'USD',
122
126
  free_quantity: Number(values.freeQuantity) || 0,
123
- is_taxable: true,
127
+ is_taxable: values.isTaxable,
124
128
  item_id: itemId,
125
129
  name,
126
130
  price: tiered ? 0 : (values.priceDollars?.amount ?? 0),
127
131
  price_code: priceCode,
128
132
  pricing_model: values.pricingModel || 'flat_fee',
129
- show_description_in_invoices: true,
133
+ show_description_in_invoices: values.showDescriptionInInvoices,
134
+ show_description_in_quotes: values.showDescriptionInQuotes,
130
135
  };
136
+ // The same accounting body the item payload sends, so a price point created
137
+ // from the dialog carries the account and class the form would have given it.
138
+ const accountingDetail = buildAccountingDetail(values, lookup);
139
+ if (accountingDetail != null) {
140
+ payload.accounting_detail = accountingDetail;
141
+ }
131
142
  if (tiered) {
132
143
  payload.tiers = (values.tiers ?? []).map(tierToPayload);
133
144
  }
@@ -157,10 +168,13 @@ export const createSubFamilyFormToPayload = (itemId, itemType, values) => {
157
168
  return payload;
158
169
  };
159
170
  export const productToCreateSubFamilyFormValues = (product) => ({
171
+ accountingCategory: product?.accountingDetail?.accountingCategory1 ?? '',
172
+ accountingCode: product?.accountingDetail?.accountingCode ?? '',
160
173
  billingCycles: product?.billingCycles != null ? String(product.billingCycles) : '',
161
174
  description: product?.description ?? '',
162
175
  freeQuantity: product?.freeQuantity != null ? String(product.freeQuantity) : '0',
163
176
  invoiceNotes: product?.invoiceNotes ?? '',
177
+ isTaxable: product?.isTaxable ?? true,
164
178
  name: product?.name != null ? `${product.name} (copy)` : '',
165
179
  period: product?.period != null ? String(product.period) : '1',
166
180
  periodUnit: product?.periodUnit ?? 'month',
@@ -168,6 +182,9 @@ export const productToCreateSubFamilyFormValues = (product) => ({
168
182
  priceDollars: product?.price,
169
183
  pricingModel: product?.pricingModel ?? 'flat_fee',
170
184
  prorationType: product?.prorationType ?? 'site_default',
185
+ showDescriptionInInvoices: product?.showDescriptionInInvoices ?? true,
186
+ showDescriptionInQuotes: product?.showDescriptionInQuotes ?? false,
187
+ sku: product?.accountingDetail?.sku ?? '',
171
188
  trialEndAction: product?.trialEndAction ?? 'site_default',
172
189
  trialPeriod: product?.trialPeriod != null ? String(product.trialPeriod) : '',
173
190
  trialPeriodUnit: product?.trialPeriodUnit ?? 'day',
@@ -9,7 +9,7 @@ const toProductCode = (value) => value
9
9
  .toLowerCase()
10
10
  .replace(/[^a-z0-9]+/g, '-')
11
11
  .replace(/^-|-$/g, '');
12
- const buildAccountingDetail = (subFamily, lookup) => {
12
+ export const buildAccountingDetail = (subFamily, lookup) => {
13
13
  const detail = {};
14
14
  if (subFamily.sku.trim() !== '') {
15
15
  detail.sku = subFamily.sku.trim();
@@ -4,6 +4,7 @@ import { initialInvoicingCatalogItemFormLocalData } from './invoicingCatalogItem
4
4
  export const initialState = {
5
5
  fetchState: 'Not-Started',
6
6
  error: undefined,
7
+ detailEditDraftById: {},
7
8
  editDraftById: {},
8
9
  newItemDraft: { ...initialInvoicingCatalogItemFormLocalData },
9
10
  savedItemId: undefined,
@@ -25,6 +26,10 @@ const editInvoicingCatalogItemDetailView = createSlice({
25
26
  draft.newItemDraft = localData;
26
27
  }
27
28
  },
29
+ updateInvoicingCatalogItemDetailEditDraft(draft, action) {
30
+ const { id, localData } = action.payload;
31
+ draft.detailEditDraftById[id] = localData;
32
+ },
28
33
  submitInvoicingCatalogItemForm: {
29
34
  reducer(draft) {
30
35
  draft.fetchState = 'In-Progress';
@@ -66,6 +71,7 @@ const editInvoicingCatalogItemDetailView = createSlice({
66
71
  draft.error = undefined;
67
72
  draft.savedItemId = action.payload.itemId;
68
73
  draft.savedKind = action.payload.kind;
74
+ delete draft.detailEditDraftById[action.payload.itemId];
69
75
  },
70
76
  submitInvoicingCatalogItemFormFailure(draft, action) {
71
77
  draft.fetchState = 'Error';
@@ -76,6 +82,7 @@ const editInvoicingCatalogItemDetailView = createSlice({
76
82
  draft.error = undefined;
77
83
  draft.savedItemId = undefined;
78
84
  draft.savedKind = undefined;
85
+ draft.detailEditDraftById = {};
79
86
  draft.editDraftById = {};
80
87
  draft.newItemDraft = { ...initialInvoicingCatalogItemFormLocalData };
81
88
  },
@@ -86,5 +93,5 @@ const editInvoicingCatalogItemDetailView = createSlice({
86
93
  });
87
94
  },
88
95
  });
89
- export const { updateInvoicingCatalogItemFormDraft, submitInvoicingCatalogItemForm, saveInvoicingCatalogItem, createInvoicingCatalogSubFamily, archiveInvoicingCatalogSubFamily, submitInvoicingCatalogItemFormSuccess, submitInvoicingCatalogItemFormFailure, resetEditInvoicingCatalogItemDetailView, } = editInvoicingCatalogItemDetailView.actions;
96
+ export const { updateInvoicingCatalogItemDetailEditDraft, updateInvoicingCatalogItemFormDraft, submitInvoicingCatalogItemForm, saveInvoicingCatalogItem, createInvoicingCatalogSubFamily, archiveInvoicingCatalogSubFamily, submitInvoicingCatalogItemFormSuccess, submitInvoicingCatalogItemFormFailure, resetEditInvoicingCatalogItemDetailView, } = editInvoicingCatalogItemDetailView.actions;
90
97
  export default editInvoicingCatalogItemDetailView.reducer;