@zeniai/client-epic-state 4.9.65 → 4.9.67

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.
@@ -4,22 +4,25 @@ import { BillPayInfo, BillStage, BillTransaction, BillAccount, BillPaymentMethod
4
4
  export interface BillTransactionPayload extends VendorTransactionPayload {
5
5
  bill_pay_info: BillPayInfoPayload;
6
6
  entity_approval_id: ID;
7
+ total_fee: number;
8
+ is_deleted: boolean;
9
+ deletion_info: DeletionInfoPayload;
10
+ update_time: string;
11
+ is_recurring: boolean;
12
+ recurring_bill_config_id: string | null;
13
+ recurring_bill_instance: number | null;
14
+ home_currency_amount: number;
15
+ home_currency_code: string;
16
+ home_currency_symbol: string;
7
17
  class_id?: ID | null;
8
18
  class_name?: string | null;
9
19
  qbo_class_id?: ID | null;
10
20
  transaction_reference_id?: ID | null;
11
- update_time: string;
12
21
  invoice_number?: string;
13
22
  created_by_user_id?: ID | null;
14
- total_fee: number;
15
- is_deleted: boolean;
16
- deletion_info: DeletionInfoPayload;
17
23
  last_updated_by_user_id?: string;
18
24
  candidate_vendor_name?: string;
19
25
  tax?: number;
20
- is_recurring: boolean;
21
- recurring_bill_config_id: string | null;
22
- recurring_bill_instance: number | null;
23
26
  discount?: number;
24
27
  }
25
28
  export interface BillPayInfoPayload {
@@ -9,7 +9,7 @@ const billTransactionState_1 = require("./billTransactionState");
9
9
  const billPayConfigPayload_1 = require("../../../view/spendManagement/billPay/billPayConfig/billPayConfigPayload");
10
10
  const toBillTransaction = (payload) => {
11
11
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
12
- return (Object.assign(Object.assign({}, (0, vendorTransactionPayload_1.toVendorTransaction)(payload)), { billPayInfo: (0, exports.toBillPayInfo)(payload.bill_pay_info), classId: (_a = payload.class_id) !== null && _a !== void 0 ? _a : '', className: (_b = payload.class_name) !== null && _b !== void 0 ? _b : '', qboClassId: (_c = payload.qbo_class_id) !== null && _c !== void 0 ? _c : '', transactionReferenceId: (_d = payload.transaction_reference_id) !== null && _d !== void 0 ? _d : '', entityApprovalId: payload.entity_approval_id, updateTime: (0, zeniDayJS_1.date)(payload.update_time), createdBy: (_e = payload.created_by_user_id) !== null && _e !== void 0 ? _e : '', candidateVendorName: (_f = payload.candidate_vendor_name) !== null && _f !== void 0 ? _f : '', bookCloseDate: payload.book_close_date != null ? (0, zeniDayJS_1.date)(payload.book_close_date) : undefined, lastUpdatedByUserId: (_g = payload.last_updated_by_user_id) !== null && _g !== void 0 ? _g : '', paymentProcessingTotalFee: (0, amount_1.toAmount)((_h = payload.total_fee) !== null && _h !== void 0 ? _h : 0, payload.currency_code, payload.currency_symbol), isDeleted: payload.is_deleted, deletionInfo: (0, exports.toDeletionInfo)(payload.deletion_info), isRecurring: payload.is_recurring, recurringBillConfigId: (_j = payload.recurring_bill_config_id) !== null && _j !== void 0 ? _j : undefined, recurringBillInstance: (_k = payload.recurring_bill_instance) !== null && _k !== void 0 ? _k : undefined }));
12
+ return (Object.assign(Object.assign({}, (0, vendorTransactionPayload_1.toVendorTransaction)(payload)), { billPayInfo: (0, exports.toBillPayInfo)(payload.bill_pay_info), classId: (_a = payload.class_id) !== null && _a !== void 0 ? _a : '', className: (_b = payload.class_name) !== null && _b !== void 0 ? _b : '', qboClassId: (_c = payload.qbo_class_id) !== null && _c !== void 0 ? _c : '', transactionReferenceId: (_d = payload.transaction_reference_id) !== null && _d !== void 0 ? _d : '', entityApprovalId: payload.entity_approval_id, updateTime: (0, zeniDayJS_1.date)(payload.update_time), createdBy: (_e = payload.created_by_user_id) !== null && _e !== void 0 ? _e : '', candidateVendorName: (_f = payload.candidate_vendor_name) !== null && _f !== void 0 ? _f : '', bookCloseDate: payload.book_close_date != null ? (0, zeniDayJS_1.date)(payload.book_close_date) : undefined, lastUpdatedByUserId: (_g = payload.last_updated_by_user_id) !== null && _g !== void 0 ? _g : '', paymentProcessingTotalFee: (0, amount_1.toAmount)((_h = payload.total_fee) !== null && _h !== void 0 ? _h : 0, payload.currency_code, payload.currency_symbol), isDeleted: payload.is_deleted, deletionInfo: (0, exports.toDeletionInfo)(payload.deletion_info), isRecurring: payload.is_recurring, recurringBillConfigId: (_j = payload.recurring_bill_config_id) !== null && _j !== void 0 ? _j : undefined, recurringBillInstance: (_k = payload.recurring_bill_instance) !== null && _k !== void 0 ? _k : undefined, totalAmountInUSD: (0, amount_1.toAmount)(payload.home_currency_amount, payload.home_currency_code, payload.home_currency_symbol) }));
13
13
  };
14
14
  exports.toBillTransaction = toBillTransaction;
15
15
  const toBillPayInfo = (payload) => {
@@ -12,7 +12,6 @@ export interface BillTransaction extends VendorTransaction {
12
12
  transactionReferenceId: ID;
13
13
  entityApprovalId: ID;
14
14
  updateTime: ZeniDate;
15
- bookCloseDate?: ZeniDate;
16
15
  createdBy: ID;
17
16
  paymentProcessingTotalFee: Amount;
18
17
  candidateVendorName: string;
@@ -20,8 +19,10 @@ export interface BillTransaction extends VendorTransaction {
20
19
  isDeleted: boolean;
21
20
  deletionInfo: DeletionInfo;
22
21
  isRecurring: boolean;
22
+ totalAmountInUSD: Amount;
23
23
  recurringBillConfigId?: ID;
24
24
  recurringBillInstance?: number;
25
+ bookCloseDate?: ZeniDate;
25
26
  }
26
27
  export interface BillPayInfo {
27
28
  stage: BillStage;
@@ -375,7 +375,7 @@ const getBillListOnSort = (sortKey, sortOrder, currentTab, transactions) => {
375
375
  }
376
376
  break;
377
377
  case 'amount':
378
- if (Boolean(transaction.amount) === true) {
378
+ if (Boolean(transaction.totalAmountInUSD) === true) {
379
379
  transactionsWithSortKeyValue.push(transaction);
380
380
  }
381
381
  else
@@ -413,7 +413,7 @@ const getBillListOnSort = (sortKey, sortOrder, currentTab, transactions) => {
413
413
  case 'status':
414
414
  return getStatusPerTab(transaction);
415
415
  case 'amount':
416
- return (_b = transaction.amount.amount) !== null && _b !== void 0 ? _b : 0;
416
+ return (_b = transaction.totalAmountInUSD.amount) !== null && _b !== void 0 ? _b : 0;
417
417
  case 'paymentMethod':
418
418
  return transaction.billPayInfo.billPaymentMethodType.name;
419
419
  }
@@ -1,6 +1,6 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
- import { parseInvoiceToBill, saveBillUpdatesToLocalStore, updateAddBillAutoFields, updateBillUploadFetchState, updateShowAutofill } from '../editBillViewReducer';
3
+ import { convertAmountToHomeCurrency, parseInvoiceToBill, saveBillUpdatesToLocalStore, updateAddBillAutoFields, updateBillUploadFetchState, updateShowAutofill } from '../editBillViewReducer';
4
4
  import { RootState } from '../../../../../reducer';
5
5
  import { fetchClassList } from '../../../../classList/classListReducer';
6
6
  import { BillTransactionPayload } from '../../../../../entity/billPay/billTransaction/billTransactionPayload';
@@ -8,7 +8,7 @@ import { AddBillAutoFields, BillDetailLocalData } from '../editBillViewState';
8
8
  import { Vendor } from '../../../../../entity/vendor/vendorState';
9
9
  import { fetchPreviousBills } from '../../previousBills/previousBillsReducer';
10
10
  import { fetchDuplicateBill } from '../../billPayReview/billPayReviewReducer';
11
- export declare type ActionType = ReturnType<typeof parseInvoiceToBill> | ReturnType<typeof saveBillUpdatesToLocalStore> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchPreviousBills> | ReturnType<typeof fetchDuplicateBill> | ReturnType<typeof updateShowAutofill> | ReturnType<typeof updateAddBillAutoFields> | ReturnType<typeof updateBillUploadFetchState>;
11
+ export declare type ActionType = ReturnType<typeof parseInvoiceToBill> | ReturnType<typeof saveBillUpdatesToLocalStore> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchPreviousBills> | ReturnType<typeof fetchDuplicateBill> | ReturnType<typeof updateShowAutofill> | ReturnType<typeof updateAddBillAutoFields> | ReturnType<typeof updateBillUploadFetchState> | ReturnType<typeof convertAmountToHomeCurrency>;
12
12
  export declare const parseInvoiceToBillEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
13
13
  export declare const toBillDetailLocalData: (state: RootState, showVendorGptRecommendationText: boolean, billPayload: Partial<BillTransactionPayload>, vendor: Vendor | undefined, recommendedVendorId?: string | undefined) => BillDetailLocalData;
14
14
  export declare const getAutoFieldsData: (finalBill: BillDetailLocalData, isVendorWithNewCurrency: boolean, tentativeVendorName?: string | undefined, currencyInInvoice?: string | undefined, vendorCurrency?: string | undefined) => AddBillAutoFields;
@@ -29,7 +29,7 @@ const billTransactionState_1 = require("../../../../../entity/billPay/billTransa
29
29
  const workingDayHelper_1 = require("../../../../../commonStateTypes/workingDayHelper");
30
30
  const companySelector_1 = require("../../../../../entity/company/companySelector");
31
31
  const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.parseInvoiceToBill.match), (0, operators_1.mergeMap)((action) => {
32
- var _a, _b, _c, _d, _e, _f;
32
+ var _a, _b, _c, _d, _e, _f, _g, _h;
33
33
  const { invoiceProcessingPayload, isVendorRecommendationFeatureEnabled } = action.payload;
34
34
  const state = state$.value;
35
35
  const showSkipAutofill = state.editBillDetailViewState.newBillState.showSkipAutofill;
@@ -102,10 +102,28 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
102
102
  const finalBill = Object.assign(Object.assign({}, (0, exports.toBillDetailLocalData)(state, showVendorGptRecommendationText, invoiceProcessingPayload.bills[0], finalVendor, recommendedVendorId)), { file: file });
103
103
  const addBillAutoFields = (0, exports.getAutoFieldsData)(finalBill, isVendorWithNewCurrency, vendorNameFromInvoice, currencyInInvoice, vendorCurrency);
104
104
  if (finalVendor != null) {
105
- return (0, rxjs_1.of)((0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({ billDetailLocalData: finalBill }), (0, previousBillsReducer_1.fetchPreviousBills)(finalVendor.qboId, false), (0, billPayReviewReducer_1.fetchDuplicateBill)(finalVendor.name, finalVendor.id, (_e = (_d = finalBill.totalAmount) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : 0, (_f = finalBill.whatForSection) === null || _f === void 0 ? void 0 : _f.invoiceNumber), (0, editBillViewReducer_1.updateShowAutofill)(false), (0, editBillViewReducer_1.updateAddBillAutoFields)(addBillAutoFields), (0, editBillViewReducer_1.updateBillUploadFetchState)({
106
- fetchState: 'Completed',
107
- error: undefined,
108
- }));
105
+ let actions = [];
106
+ if (finalVendor.vendorCurrencyCode != null &&
107
+ finalVendor.vendorCurrencyCode !== 'USD') {
108
+ actions.push((0, editBillViewReducer_1.convertAmountToHomeCurrency)(true, {
109
+ amount: (_e = (_d = finalBill.totalAmount) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : 0,
110
+ currencyCode: finalVendor.vendorCurrencyCode,
111
+ currencySymbol: finalVendor.vendorCurrencySymbol,
112
+ }, 'USD'));
113
+ }
114
+ actions = [
115
+ ...actions,
116
+ (0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({ billDetailLocalData: finalBill }),
117
+ (0, previousBillsReducer_1.fetchPreviousBills)(finalVendor.qboId, false),
118
+ (0, billPayReviewReducer_1.fetchDuplicateBill)(finalVendor.name, finalVendor.id, (_g = (_f = finalBill.totalAmount) === null || _f === void 0 ? void 0 : _f.amount) !== null && _g !== void 0 ? _g : 0, (_h = finalBill.whatForSection) === null || _h === void 0 ? void 0 : _h.invoiceNumber),
119
+ (0, editBillViewReducer_1.updateShowAutofill)(false),
120
+ (0, editBillViewReducer_1.updateAddBillAutoFields)(addBillAutoFields),
121
+ (0, editBillViewReducer_1.updateBillUploadFetchState)({
122
+ fetchState: 'Completed',
123
+ error: undefined,
124
+ }),
125
+ ];
126
+ return (0, rxjs_1.from)(actions);
109
127
  }
110
128
  else {
111
129
  const actions = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.9.65",
3
+ "version": "4.9.67",
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",