@zeniai/client-epic-state 4.9.16 → 4.9.17

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 (22) hide show
  1. package/lib/entity/account/accountPayload.d.ts +1 -1
  2. package/lib/entity/reimbursement/reimbursementPayload.js +1 -1
  3. package/lib/entity/reimbursement/reimbursementState.d.ts +1 -1
  4. package/lib/index.d.ts +2 -2
  5. package/lib/view/referralView/epics/fetchRewardsPlanEpic.js +1 -7
  6. package/lib/view/referralView/epics/resendReferralInviteEpic.js +1 -7
  7. package/lib/view/referralView/epics/sendReferralInviteEpic.js +1 -7
  8. package/lib/view/referralView/referralPayload.d.ts +1 -0
  9. package/lib/view/referralView/referralReducer.js +4 -0
  10. package/lib/view/referralView/referralSelector.js +1 -0
  11. package/lib/view/referralView/referralState.d.ts +1 -0
  12. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigPayload.d.ts +0 -1
  13. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigPayload.js +0 -1
  14. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigState.d.ts +0 -1
  15. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +7 -7
  16. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewReducer.js +44 -22
  17. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.d.ts +2 -2
  18. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.js +16 -17
  19. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewState.d.ts +3 -3
  20. package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchRemiAndInitializeLocalStoreEpic.js +1 -1
  21. package/lib/view/spendManagement/reimbursement/editRemiView/epics/parseReceiptsToRemiEpic.js +2 -2
  22. package/package.json +1 -1
@@ -44,7 +44,7 @@ export interface AccountMetadataPayload extends AccountBasePayload {
44
44
  parent_account_id: string | null;
45
45
  is_sub_account: boolean | null;
46
46
  }
47
- export declare const toAccountPayload: (acc?: AccountBase | undefined) => AccountBasePayload;
47
+ export declare const toAccountPayload: (acc: AccountBase) => AccountBasePayload;
48
48
  export declare const toRecommendedAccountBasePayload: (acc: RecommendedAccountBase) => RecommendedAccountBasePayload;
49
49
  export declare const toRecommendedAccountBasePayloadForAmountRange: (acc: RecommendedAccountBase | undefined, amountRange: {
50
50
  min: number;
@@ -106,7 +106,7 @@ exports.toReimbursementLineBase = toReimbursementLineBase;
106
106
  const toReimbursementLineBasePayload = (line) => {
107
107
  var _a, _b;
108
108
  return ({
109
- file_id: (_a = line.fileId) !== null && _a !== void 0 ? _a : null,
109
+ file_id: (_a = line.fileId) !== null && _a !== void 0 ? _a : '',
110
110
  home_currency_conversions: {
111
111
  amount: line.type === 'mileage'
112
112
  ? line.amount
@@ -35,7 +35,7 @@ export interface Reimbursement {
35
35
  }
36
36
  export declare type ReimbursementLine = MilageReimbursementLine | OutofPocketReimbursementLine;
37
37
  export interface ReimbursementLineBase extends Amount {
38
- fileId?: ID;
38
+ fileId: ID;
39
39
  homeCurrencyConversions: Amount;
40
40
  description: string;
41
41
  lineDetail: LineDetail;
package/lib/index.d.ts CHANGED
@@ -439,8 +439,8 @@ import { deleteRemi, fetchRemiDetail, cancelAndDeleteRemi, approveOrRejectRemi,
439
439
  export { deleteRemi, fetchRemiDetail, cancelAndDeleteRemi, approveOrRejectRemi, clearRemiDetailView, fetchDuplicateReimbursement, clearDuplicateReimbursementDetail, removeDuplicateReimbursementByLineId, };
440
440
  import { ReceiptsProcessingPayload } from './view/spendManagement/reimbursement/editRemiView/editRemiViewPayload';
441
441
  export { ReceiptsProcessingPayload };
442
- import { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, getEditRemiDetail, ReimbursementLineWithAttachmentAndRecommendation } from './view/spendManagement/reimbursement/editRemiView/editRemiViewSelector';
443
- export { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, getEditRemiDetail, ReimbursementLineWithAttachmentAndRecommendation, };
442
+ import { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, getEditRemiDetail } from './view/spendManagement/reimbursement/editRemiView/editRemiViewSelector';
443
+ export { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, getEditRemiDetail, };
444
444
  import { RemiDetailLocalData, AutoFields, OutofPocketReimbursementLineWithRecommendation, ReimbursementLineWithRecommendation } from './view/spendManagement/reimbursement/editRemiView/editRemiViewState';
445
445
  export { RemiDetailLocalData, AutoFields, OutofPocketReimbursementLineWithRecommendation, ReimbursementLineWithRecommendation, };
446
446
  import { Merchant } from './entity/merchant/merchant';
@@ -10,17 +10,11 @@ const fetchRewardsPlanEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
10
10
  const state = state$.value;
11
11
  const fetchState = state.referralViewState.rewardsPlanFetchState.fetchState;
12
12
  if (cacheOverride === true || fetchState === 'Not-Started') {
13
- const { userId, sessionId } = zeniAPI;
14
- const headers = {
15
- 'zeni-user-id': userId,
16
- 'zeni-tenant-id': '',
17
- 'zeni-session-id': sessionId,
18
- };
19
13
  const payload = {
20
14
  is_primary_refer_reward_plan: true,
21
15
  };
22
16
  return zeniAPI
23
- .getJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-refer-reward-plan?query=${encodeURIComponent(JSON.stringify(payload))}`, headers)
17
+ .getJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-refer-reward-plan?query=${encodeURIComponent(JSON.stringify(payload))}`)
24
18
  .pipe((0, operators_1.mergeMap)((response) => {
25
19
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
26
20
  const actions = [
@@ -7,14 +7,8 @@ const responsePayload_1 = require("../../../responsePayload");
7
7
  const referralReducer_1 = require("../referralReducer");
8
8
  const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
9
9
  const resendReferralInviteEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(referralReducer_1.resendReferralInvite.match), (0, operators_1.switchMap)((action) => {
10
- const { userId, sessionId } = zeniAPI;
11
- const headers = {
12
- 'zeni-user-id': userId,
13
- 'zeni-tenant-id': '',
14
- 'zeni-session-id': sessionId,
15
- };
16
10
  return zeniAPI
17
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referals`, { reinvite_to: action.payload.emailId }, headers)
11
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referals`, { reinvite_to: action.payload.emailId })
18
12
  .pipe((0, operators_1.mergeMap)((response) => {
19
13
  if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
20
14
  const actions = [
@@ -10,14 +10,8 @@ const sendReferralInviteEpic = (actions$, state$, zeniAPI) => actions$.pipe((0,
10
10
  const referralFormLocalData = referralViewState.referralFormLocalData;
11
11
  const referRewardsPlanId = referralViewState.rewardsPlan.referRewardPlanId;
12
12
  const invitePayload = Object.assign({}, toInvitePayloadFromLocalData(referralFormLocalData, referRewardsPlanId));
13
- const { userId, sessionId } = zeniAPI;
14
- const headers = {
15
- 'zeni-user-id': userId,
16
- 'zeni-tenant-id': '',
17
- 'zeni-session-id': sessionId,
18
- };
19
13
  return zeniAPI
20
- .postAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referals`, invitePayload, headers)
14
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referals`, invitePayload)
21
15
  .pipe((0, operators_1.mergeMap)((response) => {
22
16
  if ((0, responsePayload_1.isSuccessStatus)(response)) {
23
17
  const actions = [(0, referralReducer_1.sendReferralInviteSuccess)()];
@@ -17,6 +17,7 @@ export interface FetchRewardsPayload {
17
17
  referees: InviteePayload[];
18
18
  }
19
19
  export interface FetchRewardsPlanPayload {
20
+ company_legal_name: string | null;
20
21
  create_time: string | null;
21
22
  is_deleted: boolean | null;
22
23
  is_primary: boolean | null;
@@ -51,6 +51,7 @@ exports.initialState = {
51
51
  },
52
52
  referRewardPlanId: 'dummy',
53
53
  referalUniqueLink: (0, zeniUrl_1.toZeniUrl)(''),
54
+ companyLegalName: '',
54
55
  },
55
56
  showConfirmationPopup: false,
56
57
  };
@@ -150,11 +151,14 @@ const referral = (0, toolkit_1.createSlice)({
150
151
  },
151
152
  },
152
153
  updateRewardsPlan(draft, action) {
154
+ var _a;
153
155
  draft.rewardsPlanFetchState.fetchState = 'Completed';
154
156
  draft.rewardsPlanFetchState.error = undefined;
155
157
  draft.rewardsPlan.amount = (0, amount_1.toAmount)(action.payload.referral_plan_amount.amount, action.payload.referral_plan_amount.currency_code, action.payload.referral_plan_amount.currency_symbol);
156
158
  draft.rewardsPlan.referRewardPlanId = action.payload.refer_reward_plan_id;
157
159
  draft.rewardsPlan.referalUniqueLink = (0, zeniUrl_1.toZeniUrl)(action.payload.static_referal_link);
160
+ draft.rewardsPlan.companyLegalName =
161
+ (_a = action.payload.company_legal_name) !== null && _a !== void 0 ? _a : '';
158
162
  },
159
163
  updateRewardsPlanFailure(draft, action) {
160
164
  draft.rewardsPlanFetchState.fetchState = 'Error';
@@ -81,6 +81,7 @@ const getInviteFormView = (state) => {
81
81
  saveStatus: referralViewState.sendInviteState,
82
82
  amount: referralViewState.rewardsPlan.amount,
83
83
  referalUniqueLink: referralViewState.rewardsPlan.referalUniqueLink,
84
+ companyLegalName: referralViewState.rewardsPlan.companyLegalName,
84
85
  fetchState: referralViewState.rewardsPlanFetchState.fetchState,
85
86
  error: referralViewState.rewardsPlanFetchState.error,
86
87
  showConfirmationPopup: referralViewState.showConfirmationPopup,
@@ -38,6 +38,7 @@ export interface RewardsPlanData {
38
38
  amount: Amount;
39
39
  referRewardPlanId: ID;
40
40
  referalUniqueLink: ZeniUrl;
41
+ companyLegalName: string;
41
42
  }
42
43
  export interface InviteCompanyLocalData {
43
44
  companyName: string;
@@ -15,7 +15,6 @@ export interface RePaymentInfoPayload {
15
15
  current_statement_period_end_date: string;
16
16
  current_statement_period_start_date: string;
17
17
  next_repayment_due_date: string;
18
- card_limit_reset_date: string;
19
18
  }
20
19
  export declare type ChargeCardConfigResponse = ZeniAPIResponse<ChargeCardConfigPayload>;
21
20
  export declare const toCreditTerm: (payload: CreditTermsPayload) => CreditTerm;
@@ -14,6 +14,5 @@ const toRePaymentInfo = (payload) => ({
14
14
  endDate: (0, zeniDayJS_1.date)(payload.current_statement_period_end_date),
15
15
  },
16
16
  rePaymentDueDate: (0, zeniDayJS_1.date)(payload.next_repayment_due_date),
17
- cardLimitResetDate: (0, zeniDayJS_1.date)(payload.card_limit_reset_date),
18
17
  });
19
18
  exports.toRePaymentInfo = toRePaymentInfo;
@@ -15,7 +15,6 @@ export interface CreditTerm {
15
15
  export interface RePaymentInfo {
16
16
  statementPeriod: TimeframeTick;
17
17
  rePaymentDueDate: ZeniDate;
18
- cardLimitResetDate: ZeniDate;
19
18
  }
20
19
  export interface ConfigPeriod {
21
20
  value: number;
@@ -15,7 +15,9 @@ const userRoleSelector_1 = require("../../../../entity/userRole/userRoleSelector
15
15
  const userListViewSelector_1 = require("../../../userListView/userListViewSelector");
16
16
  const getChargeCardListView = (state, includeCreditAccount) => {
17
17
  const { addressState, chargeCardListState, chargeCardState, classState, userState, userRoleState, chargeCardConfigState, classListState, } = state;
18
- const searchText = chargeCardListState.searchText.toLowerCase();
18
+ const searchText = chargeCardListState.searchText
19
+ .trim()
20
+ .toLowerCase();
19
21
  const cards = (0, chargeCardSelector_1.getChargeCardsByIds)(chargeCardState, chargeCardListState.cardIds)
20
22
  .map((chargeCard) => {
21
23
  const cardHolderUser = (0, userSelector_1.getUserByUserId)(userState, chargeCard.cardHolderUserId);
@@ -29,13 +31,11 @@ const getChargeCardListView = (state, includeCreditAccount) => {
29
31
  return Object.assign(Object.assign({}, chargeCard), { cardHolderUser, cardHolderRoles: (0, userRoleSelector_1.getUserRoleByUserId)(userRoleState, chargeCard.cardHolderUserId), department, address: (0, addressSelector_1.getAddressByAddressId)(addressState, chargeCard.addressId) });
30
32
  })
31
33
  .filter((cardWithUser) => {
32
- var _a, _b, _c, _d, _e;
33
- const derivedCardHolderName = `${(_a = cardWithUser.cardHolderUser) === null || _a === void 0 ? void 0 : _a.firstName} ${(_b = cardWithUser.cardHolderUser) === null || _b === void 0 ? void 0 : _b.lastName}`;
34
+ var _a, _b, _c;
34
35
  return (cardWithUser.cardName.toLowerCase().includes(searchText) === true ||
35
- ((_c = cardWithUser.cardHolderUser) === null || _c === void 0 ? void 0 : _c.firstName.toLowerCase().includes(searchText)) === true ||
36
- derivedCardHolderName.includes(searchText) === true ||
37
- ((_d = cardWithUser.cardHolderUser) === null || _d === void 0 ? void 0 : _d.lastName.toLowerCase().includes(searchText)) === true ||
38
- ((_e = cardWithUser.department) === null || _e === void 0 ? void 0 : _e.className.toLowerCase().includes(searchText)) === true);
36
+ ((_a = cardWithUser.cardHolderUser) === null || _a === void 0 ? void 0 : _a.firstName.toLowerCase().includes(searchText)) === true ||
37
+ ((_b = cardWithUser.cardHolderUser) === null || _b === void 0 ? void 0 : _b.lastName.toLowerCase().includes(searchText)) === true ||
38
+ ((_c = cardWithUser.department) === null || _c === void 0 ? void 0 : _c.className.toLowerCase().includes(searchText)) === true);
39
39
  });
40
40
  const sortKey = chargeCardListState.uiState.sortKey;
41
41
  const sortOrder = (0, sortOrderPayload_1.getSortOrder)(chargeCardListState.uiState.sortOrder);
@@ -69,9 +69,10 @@ const editRemiView = (0, toolkit_1.createSlice)({
69
69
  },
70
70
  fetchRemiAndInitializeLocalStore: {
71
71
  reducer(draft, action) {
72
- var _a;
73
72
  const { reimbursementId } = action.payload;
74
- const oldData = (_a = draft.editRemiStateById[reimbursementId]) !== null && _a !== void 0 ? _a : editRemiViewState_1.initialRemiDetail;
73
+ const oldData = draft.editRemiStateById[reimbursementId] != null
74
+ ? draft.editRemiStateById[reimbursementId]
75
+ : editRemiViewState_1.initialRemiDetail;
75
76
  draft.editRemiStateById[reimbursementId] = Object.assign(Object.assign({}, oldData), { fetchStatus: {
76
77
  fetchState: 'In-Progress',
77
78
  error: undefined,
@@ -137,12 +138,13 @@ const editRemiView = (0, toolkit_1.createSlice)({
137
138
  saveRemiUpdatesToLocalStore(draft, action) {
138
139
  if (action.payload.reimbursementId != null) {
139
140
  const reimbursementId = action.payload.reimbursementId;
140
- draft.editRemiStateById[reimbursementId].remiDetailLocalData = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData), action.payload.remiDetailLocalData);
141
+ draft.editRemiStateById[reimbursementId].remiDetailLocalData =
142
+ Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData, action.payload.remiDetailLocalData);
141
143
  draft.editRemiStateById[reimbursementId].reimbursementId =
142
144
  reimbursementId;
143
145
  }
144
146
  else {
145
- draft.newRemiState.remiDetailLocalData = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData), action.payload.remiDetailLocalData);
147
+ draft.newRemiState.remiDetailLocalData = Object.assign({}, draft.newRemiState.remiDetailLocalData, action.payload.remiDetailLocalData);
146
148
  }
147
149
  },
148
150
  updatesPaymentToInLocalStore(draft, action) {
@@ -151,14 +153,17 @@ const editRemiView = (0, toolkit_1.createSlice)({
151
153
  if (shouldOverWriteCurrentBankAccountId ||
152
154
  draft.editRemiStateById[reimbursementId].remiDetailLocalData
153
155
  .paymentTo == null) {
154
- draft.editRemiStateById[reimbursementId].remiDetailLocalData = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData), { paymentTo: bankAccountId });
156
+ draft.editRemiStateById[reimbursementId].remiDetailLocalData =
157
+ Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData, { paymentTo: bankAccountId });
155
158
  }
156
159
  draft.editRemiStateById[reimbursementId].reimbursementId =
157
160
  reimbursementId;
158
161
  }
159
- else if (shouldOverWriteCurrentBankAccountId ||
160
- draft.newRemiState.remiDetailLocalData.paymentTo == null) {
161
- draft.newRemiState.remiDetailLocalData = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData), { paymentTo: bankAccountId });
162
+ else {
163
+ if (shouldOverWriteCurrentBankAccountId ||
164
+ draft.newRemiState.remiDetailLocalData.paymentTo == null) {
165
+ draft.newRemiState.remiDetailLocalData = Object.assign({}, draft.newRemiState.remiDetailLocalData, { paymentTo: bankAccountId });
166
+ }
162
167
  }
163
168
  },
164
169
  discardRemiUpdatesInLocalStore(draft, action) {
@@ -279,10 +284,11 @@ const editRemiView = (0, toolkit_1.createSlice)({
279
284
  updateAddRemiAutoFields(draft, action) {
280
285
  const { reimbursementId, addRemiAutoFields } = action.payload;
281
286
  if (reimbursementId != null) {
282
- draft.editRemiStateById[reimbursementId].addRemiAutoFieldsByLineId = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].addRemiAutoFieldsByLineId), addRemiAutoFields);
287
+ draft.editRemiStateById[reimbursementId].addRemiAutoFieldsByLineId =
288
+ Object.assign({}, draft.editRemiStateById[reimbursementId].addRemiAutoFieldsByLineId, addRemiAutoFields);
283
289
  }
284
290
  else {
285
- draft.newRemiState.addRemiAutoFieldsByLineId = Object.assign(Object.assign({}, draft.newRemiState.addRemiAutoFieldsByLineId), addRemiAutoFields);
291
+ draft.newRemiState.addRemiAutoFieldsByLineId = Object.assign({}, draft.newRemiState.addRemiAutoFieldsByLineId, addRemiAutoFields);
286
292
  }
287
293
  },
288
294
  updateHomeCurrencyConversion(draft, action) {
@@ -362,12 +368,19 @@ const doUpdateRecommendationForEntity = (draft, lineId, recommendations, shouldA
362
368
  const { recommendedAccount } = (0, initializeRemiToLocalStoreEpic_1.getRecommendedCategoryClass)(recommendations, lineAccount, lineClass);
363
369
  // autofill the account with recommendedAccount and set isCategoryFirstTimeAutofilled as true
364
370
  if (shouldAutofill) {
365
- draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId] = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
366
- .updatesByLineId[lineId]), { recommendations,
367
- recommendedAccount, isCategoryUpdateSelected: false, isCategoryFirstTimeAutofilled: true });
371
+ draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId] = Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
372
+ .updatesByLineId[lineId], {
373
+ recommendations,
374
+ recommendedAccount,
375
+ isCategoryUpdateSelected: false,
376
+ isCategoryFirstTimeAutofilled: true,
377
+ });
368
378
  //autofilling account with recommendedAccount
369
- draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId].lineDetail = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
370
- .updatesByLineId[lineId].lineDetail), { account: recommendedAccount });
379
+ draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId].lineDetail =
380
+ Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
381
+ .updatesByLineId[lineId].lineDetail, {
382
+ account: recommendedAccount,
383
+ });
371
384
  //add account to addRemiAutoFieldsByLineId, since account was autofilled
372
385
  if (!((_c = draft.editRemiStateById[reimbursementId].addRemiAutoFieldsByLineId[lineId]) === null || _c === void 0 ? void 0 : _c.includes('account')) &&
373
386
  (recommendedAccount === null || recommendedAccount === void 0 ? void 0 : recommendedAccount.accountId) != null) {
@@ -382,8 +395,11 @@ const doUpdateRecommendationForEntity = (draft, lineId, recommendations, shouldA
382
395
  }
383
396
  // show retain checkbox only in pending approval
384
397
  if (reimbursementStageCode === 'pending_approval') {
385
- draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId] = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
386
- .updatesByLineId[lineId]), { retainedAccount: recommendedAccount != null ? lineAccount : undefined, isRetainedCategorySelected: false });
398
+ draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId] = Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
399
+ .updatesByLineId[lineId], {
400
+ retainedAccount: recommendedAccount != null ? lineAccount : undefined,
401
+ isRetainedCategorySelected: false, //retain checkbox is selected
402
+ });
387
403
  }
388
404
  }
389
405
  }
@@ -396,11 +412,17 @@ const doUpdateRecommendationForEntity = (draft, lineId, recommendations, shouldA
396
412
  const { recommendedAccount } = (0, initializeRemiToLocalStoreEpic_1.getRecommendedCategoryClass)(recommendations, lineAccount, lineClass);
397
413
  // autofill the account with recommendedAccount and set isCategoryFirstTimeAutofilled as true
398
414
  if (shouldAutofill) {
399
- draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId] = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]), { recommendations,
400
- recommendedAccount, isCategoryUpdateSelected: false, isCategoryFirstTimeAutofilled: true });
401
- draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].lineDetail = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
402
- .lineDetail), { account: recommendedAccount });
403
- //add account to addRemiAutoFieldsByLineId, since account was autofilled
415
+ draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId] =
416
+ Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId], {
417
+ recommendations,
418
+ recommendedAccount,
419
+ isCategoryUpdateSelected: false,
420
+ isCategoryFirstTimeAutofilled: true,
421
+ });
422
+ draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].lineDetail = Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
423
+ .lineDetail, {
424
+ account: recommendedAccount,
425
+ }); //add account to addRemiAutoFieldsByLineId, since account was autofilled
404
426
  if (!((_f = draft.newRemiState.addRemiAutoFieldsByLineId[lineId]) === null || _f === void 0 ? void 0 : _f.includes('account')) &&
405
427
  (recommendedAccount === null || recommendedAccount === void 0 ? void 0 : recommendedAccount.accountId) != null) {
406
428
  if (draft.newRemiState.addRemiAutoFieldsByLineId[lineId] != null) {
@@ -24,7 +24,7 @@ export interface EditRemiDetailSelectorView extends BankAccountSelectorView, Sel
24
24
  remiId: ID | undefined;
25
25
  whatForSection: WhatForSection;
26
26
  achSameDayMaxDays: number;
27
- lineDetailSection: Record<ID, ReimbursementLineWithAttachmentAndRecommendation>;
27
+ lineDetailSection: Record<ID, Partial<ReimbursementLineWithAttachmentAndRecommendation>>;
28
28
  currencyConversionStatus: Record<ID, FetchStateAndError>;
29
29
  paymentTo?: string;
30
30
  accountList: AccountListSelectorView;
@@ -56,7 +56,7 @@ export interface EditRemiDetailSelectorView extends BankAccountSelectorView, Sel
56
56
  }
57
57
  export interface EditRemiInitialDetails {
58
58
  whatForSection?: WhatForSection;
59
- lineDetailSection: Record<ID, ReimbursementLineWithAttachment>;
59
+ lineDetailSection: Record<ID, Partial<ReimbursementLineWithAttachment>>;
60
60
  paymentTo?: ID;
61
61
  }
62
62
  export declare type ReimbursementLineWithAttachment = ReimbursementLine & {
@@ -77,7 +77,9 @@ const getEditRemiDetail = (state, reimbursementId) => {
77
77
  };
78
78
  const updatesByLineId = {};
79
79
  (_e = reimbursement === null || reimbursement === void 0 ? void 0 : reimbursement.lines) === null || _e === void 0 ? void 0 : _e.forEach((line) => {
80
- updatesByLineId[line.lineId] = Object.assign(Object.assign({}, line), { file: reimbursement.attachments.find((attachment) => attachment.fileId === line.fileId) });
80
+ updatesByLineId[line.lineId] = Object.assign({}, line, {
81
+ file: reimbursement.attachments.find((attachment) => attachment.fileId === line.fileId),
82
+ });
81
83
  });
82
84
  editRemiInitialDetails = {
83
85
  whatForSection: initialWhatForSection,
@@ -118,30 +120,27 @@ const getEditRemiDetail = (state, reimbursementId) => {
118
120
  const lineDetailSectionUpdatesByLineId = (_k = (_j = sourceRemiDetail === null || sourceRemiDetail === void 0 ? void 0 : sourceRemiDetail.remiDetailLocalData) === null || _j === void 0 ? void 0 : _j.updatesByLineId) !== null && _k !== void 0 ? _k : {};
119
121
  const currencyConversionStatus = (_m = (_l = sourceRemiDetail === null || sourceRemiDetail === void 0 ? void 0 : sourceRemiDetail.remiDetailLocalData) === null || _l === void 0 ? void 0 : _l.currencyConversionStateByLineId) !== null && _m !== void 0 ? _m : {};
120
122
  Object.keys(lineDetailSectionUpdatesByLineId).forEach((lineId) => {
121
- var _a, _b, _c, _d, _e, _f;
123
+ var _a, _b, _c;
124
+ lineDetailSection[lineId] = Object.assign({}, lineDetailSectionUpdatesByLineId[lineId], {
125
+ file: (_a = sourceRemiDetail.remiDetailLocalData.files) === null || _a === void 0 ? void 0 : _a.find((attachment) => attachment.fileId ===
126
+ lineDetailSectionUpdatesByLineId[lineId].fileId),
127
+ });
122
128
  if (lineDetailSectionUpdatesByLineId[lineId].type === 'out_of_pocket') {
123
- const merchantId = (_a = lineDetailSectionUpdatesByLineId[lineId].merchant) === null || _a === void 0 ? void 0 : _a.id;
124
- const merchantName = (_b = lineDetailSectionUpdatesByLineId[lineId].merchant) === null || _b === void 0 ? void 0 : _b.name;
129
+ const merchantId = (_b = lineDetailSectionUpdatesByLineId[lineId].merchant) === null || _b === void 0 ? void 0 : _b.id;
130
+ const merchantName = (_c = lineDetailSectionUpdatesByLineId[lineId].merchant) === null || _c === void 0 ? void 0 : _c.name;
125
131
  if (Boolean(merchantId) === true) {
126
132
  const { fetchState } = (0, recommendationSelector_1.getRecommendationsForEntity)(state, merchantId, 'merchant');
127
- lineDetailSection[lineId] = Object.assign(Object.assign({}, lineDetailSectionUpdatesByLineId[lineId]), { file: (_c = sourceRemiDetail.remiDetailLocalData.files) === null || _c === void 0 ? void 0 : _c.find((attachment) => attachment.fileId ===
128
- lineDetailSectionUpdatesByLineId[lineId].fileId), recommendationFetchState: fetchState });
133
+ lineDetailSection[lineId] = Object.assign({}, lineDetailSection[lineId], {
134
+ recommendationFetchState: fetchState,
135
+ });
129
136
  }
130
137
  else if (Boolean(merchantName) === true) {
131
138
  const { fetchState } = (0, recommendationSelector_1.getRecommendationsForEntity)(state, merchantName, 'merchant');
132
- lineDetailSection[lineId] = Object.assign(Object.assign({}, lineDetailSectionUpdatesByLineId[lineId]), { file: (_d = sourceRemiDetail.remiDetailLocalData.files) === null || _d === void 0 ? void 0 : _d.find((attachment) => attachment.fileId ===
133
- lineDetailSectionUpdatesByLineId[lineId].fileId), recommendationFetchState: fetchState });
134
- }
135
- //merchant is not detected
136
- else {
137
- lineDetailSection[lineId] = Object.assign(Object.assign({}, lineDetailSectionUpdatesByLineId[lineId]), { file: (_e = sourceRemiDetail.remiDetailLocalData.files) === null || _e === void 0 ? void 0 : _e.find((attachment) => attachment.fileId ===
138
- lineDetailSectionUpdatesByLineId[lineId].fileId), recommendationFetchState: 'Not-Started' });
139
+ lineDetailSection[lineId] = Object.assign({}, lineDetailSection[lineId], {
140
+ recommendationFetchState: fetchState,
141
+ });
139
142
  }
140
143
  }
141
- else {
142
- lineDetailSection[lineId] = Object.assign(Object.assign({}, lineDetailSectionUpdatesByLineId[lineId]), { file: (_f = sourceRemiDetail.remiDetailLocalData.files) === null || _f === void 0 ? void 0 : _f.find((attachment) => attachment.fileId ===
143
- lineDetailSectionUpdatesByLineId[lineId].fileId), recommendationFetchState: 'Not-Started' });
144
- }
145
144
  });
146
145
  const paymentTo = (_o = sourceRemiDetail === null || sourceRemiDetail === void 0 ? void 0 : sourceRemiDetail.remiDetailLocalData) === null || _o === void 0 ? void 0 : _o.paymentTo;
147
146
  const paymentToBankAccountDetail = paymentTo != null
@@ -14,7 +14,7 @@ export interface EditRemiDetail {
14
14
  remiDetailLocalData: RemiDetailLocalData;
15
15
  }
16
16
  export declare const initialRemiDetail: EditRemiDetail;
17
- export interface OutofPocketReimbursementLineWithRecommendation extends Partial<OutofPocketReimbursementLine> {
17
+ export interface OutofPocketReimbursementLineWithRecommendation extends OutofPocketReimbursementLine {
18
18
  recommendations: Recommendation[];
19
19
  recommendedAccount?: RecommendedAccountBase;
20
20
  isCategoryUpdateSelected: boolean;
@@ -22,14 +22,14 @@ export interface OutofPocketReimbursementLineWithRecommendation extends Partial<
22
22
  retainedAccount?: AccountBase;
23
23
  isRetainedCategorySelected: boolean;
24
24
  }
25
- export declare type ReimbursementLineWithRecommendation = Partial<MilageReimbursementLine> | OutofPocketReimbursementLineWithRecommendation;
25
+ export declare type ReimbursementLineWithRecommendation = MilageReimbursementLine | OutofPocketReimbursementLineWithRecommendation;
26
26
  export interface EditRemiDetailViewState {
27
27
  newRemiState: EditRemiDetail;
28
28
  editRemiStateById: Record<ID, EditRemiDetail>;
29
29
  }
30
30
  export interface RemiDetailLocalData {
31
31
  whatForSection?: WhatForSection;
32
- updatesByLineId: Record<ID, ReimbursementLineWithRecommendation>;
32
+ updatesByLineId: Record<ID, Partial<ReimbursementLineWithRecommendation>>;
33
33
  currencyConversionStateByLineId: Record<ID, FetchStateAndError>;
34
34
  totalAmount?: Amount;
35
35
  files?: Attachment[];
@@ -15,7 +15,7 @@ state$) => actions$.pipe((0, operators_1.filter)(editRemiViewReducer_1.fetchRemi
15
15
  const { reimbursementId, cacheOverride, isShowDeletedReimbursementEnabled, } = action.payload;
16
16
  const state = state$.value;
17
17
  const remiDetailActions = [];
18
- if (cacheOverride) {
18
+ if (cacheOverride == true) {
19
19
  remiDetailActions.push((0, remiDetailViewReducer_1.fetchRemiDetail)(reimbursementId, true, isShowDeletedReimbursementEnabled));
20
20
  remiDetailActions.push(
21
21
  //https://stackoverflow.com/questions/42276419/invoking-epics-from-within-other-epics
@@ -20,7 +20,7 @@ const parseReceiptsToRemiEpic = (actions$, state$) => actions$.pipe((0, operator
20
20
  : state.editRemiDetailViewState.newRemiState;
21
21
  const loggedInUserDepartmentId = (_a = (0, tenantSelector_1.getCurrentTenant)(state).accountingClassIDs) === null || _a === void 0 ? void 0 : _a[0];
22
22
  const newUpdatesByLineId = Object.assign({}, remiState.remiDetailLocalData.updatesByLineId);
23
- if (shouldOverwrite === false) {
23
+ if (shouldOverwrite == false) {
24
24
  let currentLineId = lineId;
25
25
  receiptsProcessingPayload.receipts.forEach((receipt) => {
26
26
  var _a;
@@ -58,7 +58,7 @@ const parseReceiptsToRemiEpic = (actions$, state$) => actions$.pipe((0, operator
58
58
  if (parsedMerchantName != null && parsedMerchantName.length > 0) {
59
59
  finalMerchant = merchants.filter((merchant) => merchant.name.toLowerCase() === parsedMerchantName.toLowerCase())[0];
60
60
  }
61
- newUpdatesByLineId[currentLineId] = Object.assign(Object.assign({}, toUpdateLine(state.accountState, state.classState, receipt, currentLineId, finalMerchant, loggedInUserDepartmentId)), { recommendations: [], isCategoryUpdateSelected: false, isCategoryFirstTimeAutofilled: false, isRetainedCategorySelected: false });
61
+ newUpdatesByLineId[currentLineId] = toUpdateLine(state.accountState, state.classState, receipt, currentLineId, finalMerchant, loggedInUserDepartmentId);
62
62
  if (receipt.currency_code !== 'USD') {
63
63
  currencyConversionActions.push((0, editRemiViewReducer_1.fetchCurrencyConversionValue)('USD', currentLineId.toString(), reimbursementId));
64
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.9.16",
3
+ "version": "4.9.17",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",