@zeniai/client-epic-state 4.9.71 → 4.9.73

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.
@@ -85,7 +85,7 @@ export declare const toBillTransaction: (payload: BillTransactionPayload) => Bil
85
85
  export declare const toBillPayInfo: (payload: BillPayInfoPayload) => BillPayInfo;
86
86
  export declare const toBillStage: (payload: BillStagePayload) => BillStage;
87
87
  export declare const toBillPaymentMethod: (payload: BillPaymentMethodPayload) => BillPaymentMethod;
88
- export declare const toBillAccount: (payload: BillAccountPayload) => BillAccount;
88
+ export declare const toBillAccount: (payload: BillAccountPayload, billPaymentMethod: BillPaymentMethod) => BillAccount;
89
89
  export declare const toFromBillAccount: (payload: BillAccountPayload) => FromBillAccount;
90
90
  export declare const toBillPaymentStatus: (payload: BillPaymentStatusPayload) => BillPaymentStatus;
91
91
  export declare const toBillStatus: (payload: BillStatusPayload) => BillStatus;
@@ -29,7 +29,7 @@ const toBillPayInfo = (payload) => {
29
29
  : undefined,
30
30
  billPaymentMethodType: (0, exports.toBillPaymentMethod)(payload.bill_payment_method_type),
31
31
  fromAccount: (0, exports.toFromBillAccount)(payload.from_account),
32
- toAccount: (0, exports.toBillAccount)(payload.to_account),
32
+ toAccount: (0, exports.toBillAccount)(payload.to_account, (0, exports.toBillPaymentMethod)(payload.bill_payment_method_type)),
33
33
  isCancelled: payload.is_cancelled,
34
34
  billStatus: (0, exports.toBillStatus)(payload.bill_status),
35
35
  actualDepositDate: payload.actual_deposit_date != null
@@ -63,11 +63,14 @@ const toBillPaymentMethod = (payload) => {
63
63
  });
64
64
  };
65
65
  exports.toBillPaymentMethod = toBillPaymentMethod;
66
- const toBillAccount = (payload) => ({
67
- billAccountId: payload.account_id != null
68
- ? payload.account_id
69
- : payload.payment_instrument_id != null
66
+ const toBillAccount = (payload, billPaymentMethod) => ({
67
+ billAccountId: billPaymentMethod.code === 'wire' &&
68
+ billPaymentMethod.subCode === 'international'
69
+ ? payload.payment_instrument_id != null
70
70
  ? payload.payment_instrument_id
71
+ : undefined
72
+ : payload.account_id != null
73
+ ? payload.account_id
71
74
  : undefined,
72
75
  billAccountType: payload.account_type != null
73
76
  ? (0, billTransactionState_1.toBillAccountType)(payload.account_type)
@@ -76,15 +76,8 @@ const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operator
76
76
  const vendorCurrencyCode = updatedVendor.vendorCurrencyCode;
77
77
  const vendorCurrencySymbol = updatedVendor.vendorCurrencySymbol;
78
78
  Object.keys(updatedLines).forEach((lineId) => {
79
- var _a, _b;
80
79
  const line = lines[lineId];
81
- updatedLines[lineId] = Object.assign(Object.assign({}, line), { account: Boolean((_a = line.account) === null || _a === void 0 ? void 0 : _a.accountId) === false &&
82
- vendorCategory != null
83
- ? vendorCategory
84
- : line.account, class: Boolean((_b = line.class) === null || _b === void 0 ? void 0 : _b.classId) === false &&
85
- vendorClass != null
86
- ? vendorClass
87
- : line.class });
80
+ updatedLines[lineId] = Object.assign(Object.assign({}, line), { account: vendorCategory, class: vendorClass });
88
81
  });
89
82
  //when it's a new bill and it doesn't have any line item, we want to default the account and class to vendor's account and class
90
83
  if (Object.keys(updatedLines).length === 0) {
@@ -1,10 +1,10 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { updateBankAccounts } from '../../../../../entity/bankAccount/bankAccountReducer';
3
3
  import { RootState } from '../../../../../reducer';
4
- import { fetchVendorAndUpdateBillLocalData, saveBillUpdatesToLocalStore, waitForVendorByIdThenSaveBillUpdatetoLocalStore } from '../editBillViewReducer';
4
+ import { convertAmountToHomeCurrency, fetchVendorAndUpdateBillLocalData, saveBillUpdatesToLocalStore, waitForVendorByIdThenSaveBillUpdatetoLocalStore } from '../editBillViewReducer';
5
5
  import { updateVendorsList, updateVendorListFailure } from '../../../../vendorList/vendorListReducer';
6
6
  import { fetchVendor, indicateReadyToInitializeBillLocalStore } from '../../../../commonVendorView/vendorView/vendorViewReducer';
7
7
  import { fetchPreviousBills } from '../../previousBills/previousBillsReducer';
8
- export declare type ActionType = ReturnType<typeof waitForVendorByIdThenSaveBillUpdatetoLocalStore> | ReturnType<typeof fetchVendor> | ReturnType<typeof updateVendorListFailure> | ReturnType<typeof saveBillUpdatesToLocalStore> | ReturnType<typeof fetchVendorAndUpdateBillLocalData> | ReturnType<typeof updateBankAccounts> | ReturnType<typeof updateVendorsList> | ReturnType<typeof indicateReadyToInitializeBillLocalStore> | ReturnType<typeof fetchPreviousBills>;
8
+ export declare type ActionType = ReturnType<typeof waitForVendorByIdThenSaveBillUpdatetoLocalStore> | ReturnType<typeof fetchVendor> | ReturnType<typeof updateVendorListFailure> | ReturnType<typeof saveBillUpdatesToLocalStore> | ReturnType<typeof fetchVendorAndUpdateBillLocalData> | ReturnType<typeof updateBankAccounts> | ReturnType<typeof updateVendorsList> | ReturnType<typeof indicateReadyToInitializeBillLocalStore> | ReturnType<typeof fetchPreviousBills> | ReturnType<typeof convertAmountToHomeCurrency>;
9
9
  export declare const fetchVendorAndUpdateBillLocalDataEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => import("rxjs").Observable<ActionType>;
10
10
  export declare const waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => import("rxjs").Observable<ActionType>;
@@ -14,7 +14,9 @@ const classSelector_1 = require("../../../../../entity/class/classSelector");
14
14
  const editBillViewState_1 = require("../../../../spendManagement/billPay/editBillView/editBillViewState");
15
15
  const vendorViewReducer_1 = require("../../../../commonVendorView/vendorView/vendorViewReducer");
16
16
  const previousBillsReducer_1 = require("../../previousBills/previousBillsReducer");
17
+ const currencyHelper_1 = require("../../../../../commonStateTypes/currencyHelper");
17
18
  const fetchVendorAndUpdateBillLocalDataEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.fetchVendorAndUpdateBillLocalData.match), (0, operators_1.mergeMap)((action) => {
19
+ var _a, _b, _c, _d;
18
20
  const fetchActions = [];
19
21
  const { vendorId } = action.payload;
20
22
  const state = state$.value;
@@ -27,6 +29,14 @@ const fetchVendorAndUpdateBillLocalDataEpic = (actions$, state$) => actions$.pip
27
29
  if (vendorId != null) {
28
30
  const vendor = (0, vendorSelector_1.getVendorByVendorId)(state.vendorState, vendorId);
29
31
  if (vendor != null) {
32
+ if (vendor.vendorCurrencyCode != null &&
33
+ !(0, currencyHelper_1.isUsdCurrency)(vendor.vendorCurrencyCode)) {
34
+ fetchActions.push((0, editBillViewReducer_1.convertAmountToHomeCurrency)(true, {
35
+ amount: (_b = (_a = billInLocalStore.billDetailLocalData.totalAmount) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0,
36
+ currencyCode: (_c = vendor.vendorCurrencyCode) !== null && _c !== void 0 ? _c : 'USD',
37
+ currencySymbol: (_d = vendor.vendorCurrencySymbol) !== null && _d !== void 0 ? _d : '$',
38
+ }, 'USD', action.payload.billId));
39
+ }
30
40
  fetchActions.push((0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({
31
41
  billDetailLocalData: prepareBillLocalData(state, billInLocalStore, vendor),
32
42
  billId: action.payload.billId,
@@ -51,6 +61,7 @@ const waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic = (actions$, state$) =
51
61
  const { vendorId } = action.payload;
52
62
  return actions$.pipe((0, operators_1.filter)((value) => vendorViewReducer_1.indicateReadyToInitializeBillLocalStore.match(value)), (0, operators_1.take)(1), // don't listen forever! IMPORTANT!
53
63
  (0, operators_1.mergeMap)(() => {
64
+ var _a, _b, _c, _d;
54
65
  const state = state$.value;
55
66
  const fetchActions = [];
56
67
  const vendor = (0, vendorSelector_1.getVendorByVendorId)(state.vendorState, vendorId);
@@ -61,6 +72,11 @@ const waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic = (actions$, state$) =
61
72
  state.editBillDetailViewState.editBillStateById[billDetailKey];
62
73
  }
63
74
  if (vendor != null) {
75
+ (0, editBillViewReducer_1.convertAmountToHomeCurrency)(true, {
76
+ amount: (_b = (_a = billInLocalStore.billDetailLocalData.totalAmount) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0,
77
+ currencyCode: (_c = vendor.vendorCurrencyCode) !== null && _c !== void 0 ? _c : 'USD',
78
+ currencySymbol: (_d = vendor.vendorCurrencySymbol) !== null && _d !== void 0 ? _d : '$',
79
+ }, 'USD', action.payload.billId);
64
80
  fetchActions.push((0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({
65
81
  billDetailLocalData: prepareBillLocalData(state, billInLocalStore, vendor),
66
82
  billId: action.payload.billId,
@@ -98,13 +114,8 @@ function prepareBillLocalData(state, billInLocalStore, vendor) {
98
114
  ? (0, zeniDayJS_1.dateNow)().isSameOrBefore(payNowCutOffTime)
99
115
  : false;
100
116
  Object.keys(updatedLines).forEach((lineId) => {
101
- var _a, _b;
102
117
  const line = lines[lineId];
103
- updatedLines[lineId] = Object.assign(Object.assign({}, line), { account: Boolean((_a = line.account) === null || _a === void 0 ? void 0 : _a.accountId) === false && vendorCategory != null
104
- ? vendorCategory
105
- : line.account, class: Boolean((_b = line.class) === null || _b === void 0 ? void 0 : _b.classId) === false && vendorClass != null
106
- ? vendorClass
107
- : line.class });
118
+ updatedLines[lineId] = Object.assign(Object.assign(Object.assign({}, line), { account: vendorCategory, class: vendorClass }), editBillViewState_1.defaultRecommendationStateObj);
108
119
  });
109
120
  //when it's a new bill and it doesn't have any line item, we want to default the account and class to vendor's account and class
110
121
  if (Object.keys(updatedLines).length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.9.71",
3
+ "version": "4.9.73",
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",