@zeniai/client-epic-state 4.9.81 → 4.9.83

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.
@@ -1,4 +1,5 @@
1
1
  import { ZeniDate } from '../zeniDayJS';
2
+ export declare const standardFormat = "MM/DD/YYYY";
2
3
  export declare const startDate = "2000-01-01";
3
4
  export declare const endDate = "2070-12-31";
4
5
  export declare const PAYMENT_BUSINESS_DAYS = 4;
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isHoliday = exports.getYearsList = exports.filterDays = exports.isHolidayToday = exports.getPreviousNthWorkingDay = exports.getNextNthWorkingDay = exports.holidaysFormatted = exports.holidays = exports.PAYMENT_BUSINESS_DAYS = exports.endDate = exports.startDate = void 0;
6
+ exports.isHoliday = exports.getYearsList = exports.filterDays = exports.isHolidayToday = exports.getPreviousNthWorkingDay = exports.getNextNthWorkingDay = exports.holidaysFormatted = exports.holidays = exports.PAYMENT_BUSINESS_DAYS = exports.endDate = exports.startDate = exports.standardFormat = void 0;
7
7
  const date_holidays_1 = __importDefault(require("date-holidays"));
8
8
  const zeniDayJS_1 = require("../zeniDayJS");
9
- const standardFormat = 'MM/DD/YYYY';
9
+ exports.standardFormat = 'MM/DD/YYYY';
10
10
  exports.startDate = '2000-01-01';
11
11
  exports.endDate = '2070-12-31';
12
12
  exports.PAYMENT_BUSINESS_DAYS = 4;
@@ -15,16 +15,16 @@ exports.holidays = dateHolidays
15
15
  .getHolidays(new Date().getFullYear())
16
16
  .filter((holiday) => holiday.type === 'public' || holiday.type === 'bank')
17
17
  .map((holiday) => (0, zeniDayJS_1.date)(holiday.date).toDate()); // https://www.linkedin.com/pulse/fix-invalid-date-safari-ie-hatem-ahmad/
18
- exports.holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(standardFormat));
18
+ exports.holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(exports.standardFormat));
19
19
  const getNextNthWorkingDay = (date, filterDaysIndex, numberOfWorkingDays) => {
20
20
  const currentDate = new Date(date.toDateString());
21
- const holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(standardFormat));
21
+ const holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(exports.standardFormat));
22
22
  Array(numberOfWorkingDays)
23
23
  .fill(0)
24
24
  .forEach(() => {
25
25
  currentDate.setDate(currentDate.getDate() + 1);
26
26
  while (filterDaysIndex.includes(currentDate.getDay()) ||
27
- holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(standardFormat)) != -1) {
27
+ holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(exports.standardFormat)) != -1) {
28
28
  currentDate.setDate(currentDate.getDate() + 1);
29
29
  }
30
30
  });
@@ -33,32 +33,32 @@ const getNextNthWorkingDay = (date, filterDaysIndex, numberOfWorkingDays) => {
33
33
  exports.getNextNthWorkingDay = getNextNthWorkingDay;
34
34
  const getPreviousNthWorkingDay = (date, filterDaysIndex, numberOfWorkingDays) => {
35
35
  const currentDate = new Date(date.toDateString());
36
- const holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(standardFormat));
36
+ const holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(exports.standardFormat));
37
37
  Array(numberOfWorkingDays)
38
38
  .fill(0)
39
39
  .forEach(() => {
40
40
  while (filterDaysIndex.includes(currentDate.getDay()) ||
41
- holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(standardFormat)) != -1) {
41
+ holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(exports.standardFormat)) != -1) {
42
42
  currentDate.setDate(currentDate.getDate() - 1);
43
43
  }
44
44
  currentDate.setDate(currentDate.getDate() - 1);
45
45
  });
46
46
  while (filterDaysIndex.includes(currentDate.getDay()) ||
47
- holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(standardFormat)) != -1) {
47
+ holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(exports.standardFormat)) != -1) {
48
48
  currentDate.setDate(currentDate.getDate() - 1);
49
49
  }
50
50
  return currentDate;
51
51
  };
52
52
  exports.getPreviousNthWorkingDay = getPreviousNthWorkingDay;
53
53
  const isHolidayToday = (filterDaysIndex) => {
54
- const holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(standardFormat));
54
+ const holidaysFormatted = exports.holidays.map((holiday) => (0, zeniDayJS_1.date)(holiday.toDateString()).format(exports.standardFormat));
55
55
  const currentDate = new Date();
56
56
  return (filterDaysIndex.includes(currentDate.getDay()) ||
57
- holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(standardFormat)) != -1);
57
+ holidaysFormatted.indexOf((0, zeniDayJS_1.date)(currentDate.toDateString()).format(exports.standardFormat)) != -1);
58
58
  };
59
59
  exports.isHolidayToday = isHolidayToday;
60
60
  const filterDays = (date, filterDaysIndex) => {
61
- const formattedDate = (0, zeniDayJS_1.date)(date.toDateString()).format(standardFormat);
61
+ const formattedDate = (0, zeniDayJS_1.date)(date.toDateString()).format(exports.standardFormat);
62
62
  return (filterDaysIndex.includes(date.getDay()) === false &&
63
63
  exports.holidaysFormatted.includes(formattedDate) === false);
64
64
  };
@@ -81,6 +81,7 @@ const getHolidaysListPerYear = (year) => {
81
81
  const holidaysPerYear = {
82
82
  [(0, zeniDayJS_1.dateNow)().year()]: getHolidaysListPerYear((0, zeniDayJS_1.dateNow)().year()),
83
83
  };
84
+ //isHoliday requires date parameter to be simple date Dayjs format, not datetime Dayjs
84
85
  const isHoliday = (date) => {
85
86
  const currentYear = date.year();
86
87
  let holidays = [];
@@ -4,11 +4,11 @@ import { RootState } from '../../../../reducer';
4
4
  import { fetchUserDetails, resetVendorDetailLocalData, saveVendor, saveVendorSuccessOrFailure, updateVendorDetailLocalData } from '../vendorViewReducer';
5
5
  import { updateVendors } from '../../../../entity/vendor/vendorReducer';
6
6
  import { updateAddresses } from '../../../../entity/address/addressReducer';
7
- import { convertAmountToHomeCurrency, saveBillUpdatesToLocalStore, updateRecommendedVendorId } from '../../../spendManagement/billPay/editBillView/editBillViewReducer';
7
+ import { convertAmountToHomeCurrency, saveBillUpdatesToLocalStore } from '../../../spendManagement/billPay/editBillView/editBillViewReducer';
8
8
  import { fetchPreviousBills } from '../../../spendManagement/billPay/previousBills/previousBillsReducer';
9
9
  import { updateContacts } from '../../../../entity/billPay/contact/contactReducer';
10
10
  import { updateBankAccounts } from '../../../../entity/bankAccount/bankAccountReducer';
11
11
  import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
12
12
  import { updatePaymentInstruments } from '../../../../entity/paymentInstrument/paymentInstrumentReducer';
13
- export declare type ActionType = ReturnType<typeof saveVendor> | ReturnType<typeof updateVendors> | ReturnType<typeof updateContacts> | ReturnType<typeof updateBankAccounts> | ReturnType<typeof updateRecommendedVendorId> | ReturnType<typeof saveBillUpdatesToLocalStore> | ReturnType<typeof fetchPreviousBills> | ReturnType<typeof openSnackbar> | ReturnType<typeof saveVendorSuccessOrFailure> | ReturnType<typeof resetVendorDetailLocalData> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateVendorDetailLocalData> | ReturnType<typeof fetchUserDetails> | ReturnType<typeof updatePaymentInstruments> | ReturnType<typeof convertAmountToHomeCurrency>;
13
+ export declare type ActionType = ReturnType<typeof saveVendor> | ReturnType<typeof updateVendors> | ReturnType<typeof updateContacts> | ReturnType<typeof updateBankAccounts> | ReturnType<typeof saveBillUpdatesToLocalStore> | ReturnType<typeof fetchPreviousBills> | ReturnType<typeof openSnackbar> | ReturnType<typeof saveVendorSuccessOrFailure> | ReturnType<typeof resetVendorDetailLocalData> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateVendorDetailLocalData> | ReturnType<typeof fetchUserDetails> | ReturnType<typeof updatePaymentInstruments> | ReturnType<typeof convertAmountToHomeCurrency>;
14
14
  export declare const saveVendorEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -148,7 +148,7 @@ const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operator
148
148
  isRecurring: false,
149
149
  },
150
150
  billId: action.payload.billId,
151
- }), (0, editBillViewReducer_1.updateRecommendedVendorId)());
151
+ }));
152
152
  if ((updatedVendor === null || updatedVendor === void 0 ? void 0 : updatedVendor.qboId) != null) {
153
153
  actions.push((0, previousBillsReducer_1.fetchPreviousBills)(updatedVendor.qboId, false));
154
154
  }
@@ -72,11 +72,14 @@ const waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic = (actions$, state$) =
72
72
  state.editBillDetailViewState.editBillStateById[billDetailKey];
73
73
  }
74
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);
75
+ if (vendor.vendorCurrencyCode != null &&
76
+ !(0, currencyHelper_1.isUsdCurrency)(vendor.vendorCurrencyCode)) {
77
+ fetchActions.push((0, editBillViewReducer_1.convertAmountToHomeCurrency)(true, {
78
+ amount: (_b = (_a = billInLocalStore.billDetailLocalData.totalAmount) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0,
79
+ currencyCode: (_c = vendor.vendorCurrencyCode) !== null && _c !== void 0 ? _c : 'USD',
80
+ currencySymbol: (_d = vendor.vendorCurrencySymbol) !== null && _d !== void 0 ? _d : '$',
81
+ }, 'USD', action.payload.billId));
82
+ }
80
83
  fetchActions.push((0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({
81
84
  billDetailLocalData: prepareBillLocalData(state, billInLocalStore, vendor),
82
85
  billId: action.payload.billId,
@@ -2,12 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapReviewTransferMoneyPayloadToReviewTransferMoney = void 0;
4
4
  const amount_1 = require("../../../../commonStateTypes/amount");
5
+ const workingDayHelper_1 = require("../../../../commonStateTypes/workingDayHelper");
5
6
  const zeniDayJS_1 = require("../../../../zeniDayJS");
6
7
  const mapReviewTransferMoneyPayloadToReviewTransferMoney = (payload) => ({
7
8
  isShowDailyAchLimitWarning: payload.is_show_daily_ach_limit_warning,
8
9
  dailyAchDebitLimit: payload.daily_ach_debit_limit != null
9
10
  ? (0, amount_1.toAmount)(payload.daily_ach_debit_limit.amount, payload.daily_ach_debit_limit.currency_code, payload.daily_ach_debit_limit.currency_symbol)
10
11
  : (0, amount_1.toAmount)(0, 'USD', '$'),
11
- transferSchedules: payload.transfer_schedules.map((transfer_schedule) => (Object.assign(Object.assign({}, (0, amount_1.toAmount)(transfer_schedule.amount, transfer_schedule.currency_code, transfer_schedule.currency_symbol)), { scheduleTime: (0, zeniDayJS_1.dateInLocal)(transfer_schedule.schedule_time) }))),
12
+ transferSchedules: payload.transfer_schedules.map((transfer_schedule) => (Object.assign(Object.assign({}, (0, amount_1.toAmount)(transfer_schedule.amount, transfer_schedule.currency_code, transfer_schedule.currency_symbol)), { scheduleTime: (0, zeniDayJS_1.date)(
13
+ //this is required as isHoliday function in src/commonStateTypes/workingDayHelper.ts require date to be simple date Dayjs format, not datetime Dayjs
14
+ (0, zeniDayJS_1.date)(transfer_schedule.schedule_time).format(workingDayHelper_1.standardFormat)) }))),
12
15
  });
13
16
  exports.mapReviewTransferMoneyPayloadToReviewTransferMoney = mapReviewTransferMoneyPayloadToReviewTransferMoney;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.9.81",
3
+ "version": "4.9.83",
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",