@zeniai/client-epic-state 4.8.48 → 4.8.49

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.
@@ -22,6 +22,7 @@ export interface BillPayReviewSelectorView extends SelectorView {
22
22
  isCollectToAccountInfoFromVendorContact: boolean;
23
23
  billPayConfigList: BillPayConfig[];
24
24
  isRecurring: boolean;
25
+ isInvoiceDateAutoUpdated: boolean;
25
26
  recurringBillInstance?: number;
26
27
  recurringConfig?: RecurringBillConfigLocalData;
27
28
  }
@@ -36,7 +36,7 @@ const getDuplicateBills = (state, billId) => {
36
36
  };
37
37
  exports.getDuplicateBills = getDuplicateBills;
38
38
  const getReviewPageBillDetail = (state, billId) => {
39
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
39
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
40
40
  const { accountListState, accountState, setupViewState, billTransactionState, classListState, editBillDetailViewState, paymentAccountState, vendorState, contactState, billPayConfigState, recurringBillState, depositAccountState, depositAccountListState, } = state;
41
41
  const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(billId !== null && billId !== void 0 ? billId : '');
42
42
  const sourceBillDetail = billId != null
@@ -163,6 +163,7 @@ const getReviewPageBillDetail = (state, billId) => {
163
163
  isRecurring,
164
164
  recurringBillInstance,
165
165
  recurringConfig,
166
+ isInvoiceDateAutoUpdated: (_s = whatForSection.isInvoiceDateAutoUpdated) !== null && _s !== void 0 ? _s : false,
166
167
  };
167
168
  };
168
169
  exports.getReviewPageBillDetail = getReviewPageBillDetail;
@@ -136,4 +136,6 @@ export declare const getRecurringBillLocalData: (recurringBillState: RecurringBi
136
136
  recurringBillInstancesLocalData: RecurringBillInstance[];
137
137
  recurringConfigLocalData?: RecurringBillConfigLocalData | undefined;
138
138
  };
139
+ export declare const getInvoiceDate: (invoiceDate: ZeniDate, bookCloseDate?: import("dayjs").Dayjs | undefined) => import("dayjs").Dayjs;
140
+ export declare const getDueDate: (dueDate: ZeniDate, invoiceDate?: import("dayjs").Dayjs | undefined, bookCloseDate?: import("dayjs").Dayjs | undefined) => import("dayjs").Dayjs;
139
141
  export declare const getWithdrawFrom: (paymentAccountState: PaymentAccountState, depositAccountState: DepositAccountState, fromAccountId: ID, fromAccountType: string) => TransferMoneyParty | undefined;
@@ -3,13 +3,14 @@ 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.getWithdrawFrom = exports.getRecurringBillLocalData = exports.getCurrentPaymentToOption = exports.toPaymentToOption = exports.getActualPaymentTypeBasedOnAccType = exports.getPaymentSection = exports.getWhatForSection = exports.getPaymentMethodType = exports.getBillPayConfigList = exports.getEditBillDetail = void 0;
6
+ exports.getWithdrawFrom = exports.getDueDate = exports.getInvoiceDate = exports.getRecurringBillLocalData = exports.getCurrentPaymentToOption = exports.toPaymentToOption = exports.getActualPaymentTypeBasedOnAccType = exports.getPaymentSection = exports.getWhatForSection = exports.getPaymentMethodType = exports.getBillPayConfigList = exports.getEditBillDetail = void 0;
7
7
  const get_1 = __importDefault(require("lodash/get"));
8
8
  const has_1 = __importDefault(require("lodash/has"));
9
9
  const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
10
10
  const bankAccountSelector_1 = require("../../../../entity/bankAccount/bankAccountSelector");
11
11
  const paymentAccountSelector_1 = require("../../../../entity/paymentAccount/paymentAccountSelector");
12
12
  const vendorSelector_1 = require("../../../../entity/vendor/vendorSelector");
13
+ const zeniDayJS_1 = require("../../../../zeniDayJS");
13
14
  const accountListSelector_1 = require("../../../accountList/accountListSelector");
14
15
  const classListSelector_1 = require("../../../classList/classListSelector");
15
16
  const billDetailViewState_1 = require("../billDetailView/billDetailViewState");
@@ -131,6 +132,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
131
132
  invoiceDate: transaction === null || transaction === void 0 ? void 0 : transaction.date,
132
133
  billDueDate: transaction === null || transaction === void 0 ? void 0 : transaction.dueDate,
133
134
  memo: transaction === null || transaction === void 0 ? void 0 : transaction.memo,
135
+ isInvoiceDateAutoUpdated: false,
134
136
  };
135
137
  const updatesByLineId = {};
136
138
  if (accountList.fetchState === 'Completed') {
@@ -408,7 +410,7 @@ const getPaymentMethodType = (billPayConfigState, accType, paymentMethod, intern
408
410
  };
409
411
  exports.getPaymentMethodType = getPaymentMethodType;
410
412
  function getWhatForSection(updatedWhatForSection) {
411
- var _a, _b, _c, _d, _e;
413
+ var _a, _b, _c, _d, _e, _f;
412
414
  return {
413
415
  invoiceNumber: (updatedWhatForSection === null || updatedWhatForSection === void 0 ? void 0 : updatedWhatForSection.invoiceNumber) != null &&
414
416
  ((_a = updatedWhatForSection.invoiceNumber) === null || _a === void 0 ? void 0 : _a.length) > 0
@@ -421,6 +423,7 @@ function getWhatForSection(updatedWhatForSection) {
421
423
  ? updatedWhatForSection.memo
422
424
  : '',
423
425
  currencyCode: (_e = updatedWhatForSection === null || updatedWhatForSection === void 0 ? void 0 : updatedWhatForSection.currencyCode) !== null && _e !== void 0 ? _e : 'USD',
426
+ isInvoiceDateAutoUpdated: (_f = updatedWhatForSection === null || updatedWhatForSection === void 0 ? void 0 : updatedWhatForSection.isInvoiceDateAutoUpdated) !== null && _f !== void 0 ? _f : false,
424
427
  };
425
428
  }
426
429
  exports.getWhatForSection = getWhatForSection;
@@ -554,6 +557,26 @@ const getRecurringBillLocalData = (recurringBillState, transaction) => {
554
557
  return { recurringConfigLocalData, recurringBillInstancesLocalData };
555
558
  };
556
559
  exports.getRecurringBillLocalData = getRecurringBillLocalData;
560
+ const getInvoiceDate = (invoiceDate, bookCloseDate) => {
561
+ if (bookCloseDate != null && invoiceDate.isBefore(bookCloseDate)) {
562
+ return (0, zeniDayJS_1.dateNow)().startOf('month');
563
+ }
564
+ else {
565
+ return invoiceDate;
566
+ }
567
+ };
568
+ exports.getInvoiceDate = getInvoiceDate;
569
+ const getDueDate = (dueDate, invoiceDate, bookCloseDate) => {
570
+ if (bookCloseDate != null &&
571
+ invoiceDate != null &&
572
+ invoiceDate.isBefore(bookCloseDate)) {
573
+ return (0, zeniDayJS_1.dateNow)().startOf('month');
574
+ }
575
+ else {
576
+ return dueDate;
577
+ }
578
+ };
579
+ exports.getDueDate = getDueDate;
557
580
  const getWithdrawFrom = (paymentAccountState, depositAccountState, fromAccountId, fromAccountType) => {
558
581
  const withdrawFromAsDepositAcc = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, fromAccountId);
559
582
  const withdrawFromAsPaymentAcc = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, fromAccountId);
@@ -70,6 +70,7 @@ export interface WhatForSection {
70
70
  billDueDate?: ZeniDate;
71
71
  memo?: string;
72
72
  currencyCode?: string;
73
+ isInvoiceDateAutoUpdated?: boolean;
73
74
  }
74
75
  export interface PaymentDetailsSection {
75
76
  internationalTransferFeeBearerPaymentMethod?: InternationalTransferFeeBearerPaymentMethod;
@@ -23,6 +23,7 @@ exports.initialBillDetail = {
23
23
  invoiceDate: undefined,
24
24
  billDueDate: undefined,
25
25
  memo: '',
26
+ isInvoiceDateAutoUpdated: false,
26
27
  },
27
28
  updatesByLineId: {},
28
29
  paymentDetailsSection: {
@@ -128,23 +128,29 @@ const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
128
128
  }
129
129
  }
130
130
  }
131
+ const { tenantState, companyState } = state;
132
+ const { currentTenantId } = tenantState;
133
+ const companyId = currentTenantId != null
134
+ ? (_f = (_e = tenantState.tenantsById) === null || _e === void 0 ? void 0 : _e[currentTenantId]) === null || _f === void 0 ? void 0 : _f.companyId
135
+ : undefined;
136
+ const currentCompany = (0, companySelector_1.getCompanyByCompanyId)(companyState, companyId !== null && companyId !== void 0 ? companyId : '');
137
+ const bookCloseDate = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.company.companyInfo.bookCloseDate;
131
138
  const whatForSection = {
132
139
  invoiceNumber: transaction.documentId,
133
- invoiceDate: transaction.date,
134
- billDueDate: transaction.dueDate,
140
+ billDueDate: transaction.dueDate != null && transaction.date != null
141
+ ? (0, editBillViewSelector_1.getDueDate)(transaction.dueDate, transaction.date, bookCloseDate)
142
+ : transaction.dueDate,
143
+ invoiceDate: (0, editBillViewSelector_1.getInvoiceDate)(transaction.date, bookCloseDate),
135
144
  memo: transaction.memo,
136
145
  currencyCode: transaction.amount.currencyCode,
146
+ isInvoiceDateAutoUpdated: transaction.date != null
147
+ ? transaction.date.isBefore(bookCloseDate)
148
+ : false,
137
149
  };
138
150
  const updatesByLineId = {};
139
- (_e = transaction.lines) === null || _e === void 0 ? void 0 : _e.forEach((line) => {
151
+ (_g = transaction.lines) === null || _g === void 0 ? void 0 : _g.forEach((line) => {
140
152
  updatesByLineId[line.id] = Object.assign(Object.assign({}, line), (0, exports.getLineRecommendationsLocalData)(line.id, line, recommendations, accountList, classList, vendor));
141
153
  });
142
- const { tenantState, companyState } = state;
143
- const { currentTenantId } = tenantState;
144
- const companyId = currentTenantId != null
145
- ? (_g = (_f = tenantState.tenantsById) === null || _f === void 0 ? void 0 : _f[currentTenantId]) === null || _g === void 0 ? void 0 : _g.companyId
146
- : undefined;
147
- const currentCompany = (0, companySelector_1.getCompanyByCompanyId)(companyState, companyId !== null && companyId !== void 0 ? companyId : '');
148
154
  const payNowCutOffTime = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach;
149
155
  const isPayNowEnabled = payNowCutOffTime != null
150
156
  ? (0, zeniDayJS_1.dateNow)().isSameOrBefore(payNowCutOffTime)
@@ -188,6 +188,15 @@ const toBillDetailLocalData = (state, showVendorGptRecommendationText, billPaylo
188
188
  ? (0, zeniDayJS_1.dateNow)().isSameOrBefore(payNowCutOffTime)
189
189
  : false;
190
190
  const fromAccountType = (0, billPayConfigPayload_1.getAccountTypeSubConfigCodeKey)((0, billPayConfigState_1.toAccType)((_m = (_l = billPayload.bill_pay_info) === null || _l === void 0 ? void 0 : _l.from_account.account_type) !== null && _m !== void 0 ? _m : ''));
191
+ const bookCloseDate = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.company.companyInfo.bookCloseDate;
192
+ const invoiceDate = Boolean(billPayload.transaction_date) === true
193
+ ? (0, editBillViewSelector_1.getInvoiceDate)((0, zeniDayJS_1.date)(billPayload.transaction_date), bookCloseDate)
194
+ : undefined;
195
+ const dueDate = Boolean(billPayload.due_date) === true
196
+ ? Boolean(billPayload.transaction_date) === true
197
+ ? (0, editBillViewSelector_1.getDueDate)((0, zeniDayJS_1.date)(billPayload.due_date), (0, zeniDayJS_1.date)(billPayload.transaction_date), bookCloseDate)
198
+ : (0, zeniDayJS_1.date)(billPayload.due_date)
199
+ : undefined;
191
200
  return {
192
201
  recommendedVendorId,
193
202
  showVendorGptRecommendationText,
@@ -195,14 +204,12 @@ const toBillDetailLocalData = (state, showVendorGptRecommendationText, billPaylo
195
204
  vendor: vendor,
196
205
  whatForSection: {
197
206
  invoiceNumber: billPayload.invoice_number,
198
- billDueDate: billPayload.due_date != null && billPayload.due_date.length > 0
199
- ? (0, zeniDayJS_1.date)(billPayload.due_date)
200
- : undefined,
207
+ billDueDate: dueDate,
201
208
  memo: billPayload.transaction_memo,
202
- invoiceDate: billPayload.transaction_date != null &&
203
- billPayload.transaction_date.length > 0
204
- ? (0, zeniDayJS_1.date)(billPayload.transaction_date)
205
- : undefined,
209
+ invoiceDate: invoiceDate,
210
+ isInvoiceDateAutoUpdated: Boolean(billPayload.transaction_date) === true
211
+ ? (0, zeniDayJS_1.date)(billPayload.transaction_date).isBefore(bookCloseDate)
212
+ : false,
206
213
  currencyCode: billPayload.currency_code,
207
214
  },
208
215
  updatesByLineId: linesById,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.8.48",
3
+ "version": "4.8.49",
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",