@zeniai/client-epic-state 4.13.3 → 4.13.4

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.
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toFileTypeStrict = exports.ALL_FILE_TYPES = void 0;
4
4
  const stringToUnion_1 = require("./stringToUnion");
5
- exports.ALL_FILE_TYPES = ['pdf', 'excel', "csv"];
5
+ exports.ALL_FILE_TYPES = ['pdf', 'excel', 'csv'];
6
6
  const toFileTypeStrict = (v) => { var _a; return (0, stringToUnion_1.stringToUnionStrict)((_a = v === null || v === void 0 ? void 0 : v.toLocaleLowerCase()) !== null && _a !== void 0 ? _a : '', exports.ALL_FILE_TYPES); };
7
7
  exports.toFileTypeStrict = toFileTypeStrict;
@@ -22,11 +22,11 @@ export interface AbsoluteDay {
22
22
  year: number;
23
23
  }
24
24
  export interface MonthYearPeriod {
25
- month: number;
25
+ month: Month;
26
26
  year: number;
27
27
  }
28
- export declare type MonthYearPeriodId = `${number}_${number}`;
29
- export declare type MonthYearPeriodQuery = `${number}-${number}`;
28
+ export declare type MonthYearPeriodId = `${Month}_${number}`;
29
+ export declare type MonthYearPeriodQuery = `${Month}-${number}`;
30
30
  export declare const toMonthYearPeriodQuery: (selectedPeriod: MonthYearPeriod) => MonthYearPeriodQuery;
31
31
  export declare const toMonthYearPeriodId: (selectedPeriod: MonthYearPeriod) => MonthYearPeriodId;
32
32
  /**
@@ -27,13 +27,20 @@ const toMonthEndInsights = (monthEndStatisticsPayload) => {
27
27
  };
28
28
  };
29
29
  const toMonthYearPeriods = (historicMonthYearPayload) => {
30
- return historicMonthYearPayload.map((monthYearString) => {
30
+ const historicMonthYears = historicMonthYearPayload.map((monthYearString) => {
31
31
  const parsedDate = (0, zeniDayJS_1.date)(monthYearString, formatZeniDateFY_1.MM_YYYY_FORMAT);
32
32
  return {
33
- month: parsedDate.month() + 1,
33
+ month: (0, timePeriod_1.toMonth)(parsedDate.month() + 1),
34
34
  year: parsedDate.year(),
35
35
  };
36
36
  });
37
+ historicMonthYears.sort((a, b) => {
38
+ if (a.year !== b.year) {
39
+ return a.year - b.year; // Sort by year first
40
+ }
41
+ return a.month - b.month; // Then sort by month
42
+ });
43
+ return historicMonthYears;
37
44
  };
38
45
  const toMonthEndCloseChecksInfo = (payload, period) => ({
39
46
  id: (0, timePeriod_1.toMonthYearPeriodId)(period),
@@ -8,6 +8,7 @@ const responsePayload_1 = require("../../../responsePayload");
8
8
  const companyReducer_1 = require("../../company/companyReducer");
9
9
  const expenseAutomationViewReducer_1 = require("../../../view/expenseAutomationView/expenseAutomationViewReducer");
10
10
  const zeniDayJS_1 = require("../../../zeniDayJS");
11
+ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
11
12
  const fetchAllTenantsEpic = (actions$, state, zeniAPI) => actions$.pipe((0, operators_1.filter)(tenantReducer_1.fetchAllTenants.match), (0, operators_1.switchMap)((action) => zeniAPI
12
13
  .getJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/users/${action.payload.userId}/tenants`, Object.assign({ 'zeni-user-id': action.payload.userId }, { 'zeni-tenant-id': '' }, action.payload.zeniSessionId != null
13
14
  ? { 'zeni-session-id': action.payload.zeniSessionId }
@@ -52,7 +53,7 @@ const fetchAllTenantsEpic = (actions$, state, zeniAPI) => actions$.pipe((0, oper
52
53
  JSON.stringify(error))))))));
53
54
  exports.fetchAllTenantsEpic = fetchAllTenantsEpic;
54
55
  const defaultMonthYearPeriod = {
55
- month: (0, zeniDayJS_1.dateNow)().get('month') + 1,
56
+ month: (0, timePeriod_1.toMonth)((0, zeniDayJS_1.dateNow)().get('month') + 1),
56
57
  year: (0, zeniDayJS_1.dateNow)().get('year'),
57
58
  };
58
59
  const getDefaultSelectedPeriodsForTenants = (tenantsData) => {
@@ -67,7 +68,7 @@ const getDefaultSelectedPeriodsForTenants = (tenantsData) => {
67
68
  const getMonthYearPeriodFromBookCloseDate = (zeniBookCloseDate) => {
68
69
  return zeniBookCloseDate != null
69
70
  ? {
70
- month: zeniBookCloseDate.add(1, 'month').get('month') + 1,
71
+ month: (0, timePeriod_1.toMonth)(zeniBookCloseDate.add(1, 'month').get('month') + 1),
71
72
  year: zeniBookCloseDate.add(1, 'month').get('year'),
72
73
  }
73
74
  : defaultMonthYearPeriod;
@@ -4,7 +4,7 @@ import { VendorExpenseTrend } from './vendorExpenseTrend';
4
4
  import { TimeframeTick } from '../../commonStateTypes/timeframeTick';
5
5
  import { Month } from '../../commonStateTypes/timePeriod';
6
6
  export declare function getVendor(vendorExpenseState: VendorExpenseState, vendorId: ID, timePeriod: TimeframeTick | undefined, firstMonthOfFY?: Month, filter?: VendorSpendTrendFilterTabType): VendorExpenseTrend | undefined;
7
- declare const toVendorSpendTrendFilterTabsType: (v: string) => "last_month" | "last_30_days" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year";
8
- export declare const toVendorSpendTrendFilterTabsTypeStrict: (v: string) => "last_month" | "last_30_days" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year" | undefined;
7
+ declare const toVendorSpendTrendFilterTabsType: (v: string) => "last_month" | "last_30_days" | "variance" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year";
8
+ export declare const toVendorSpendTrendFilterTabsTypeStrict: (v: string) => "last_month" | "last_30_days" | "variance" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year" | undefined;
9
9
  export declare type VendorSpendTrendFilterTabType = ReturnType<typeof toVendorSpendTrendFilterTabsType>;
10
10
  export {};
@@ -22,6 +22,7 @@ function getVendor(vendorExpenseState, vendorId, timePeriod, firstMonthOfFY, fil
22
22
  exports.getVendor = getVendor;
23
23
  const VENDOR_SPEND_TREND_FILTER_TABS_TYPES = [
24
24
  'last_30_days',
25
+ 'variance',
25
26
  'last_90_days',
26
27
  'YTD_spend',
27
28
  'last_month',
@@ -12,7 +12,7 @@ const vendorTypeListReducer_1 = require("../../../vendorTypeList/vendorTypeListR
12
12
  const fetchVendorDetailsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(vendorViewReducer_1.fetchVendorDetails.match), (0, operators_1.switchMap)((action) => {
13
13
  const vendorActions = [];
14
14
  const state = state$.value;
15
- if (action.payload.cacheOverride == true) {
15
+ if (action.payload.cacheOverride === true) {
16
16
  vendorActions.push((0, accountListReducer_1.fetchAccountList)('accountList', true));
17
17
  vendorActions.push((0, classListReducer_1.fetchClassList)());
18
18
  vendorActions.push((0, vendorTypeListReducer_1.fetchVendorTypeList)());
@@ -5,8 +5,8 @@ import { VendorDetailLocalData, VendorViewState, VendorContactInfo } from './ven
5
5
  import { Recommendation } from '../../../commonStateTypes/recommendationBase';
6
6
  export declare const initialVendorDetailLocalData: VendorDetailLocalData;
7
7
  export declare const initialState: VendorViewState;
8
- export declare const fetchVendorDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any, vendorId?: string | undefined, signal?: AbortSignal | undefined], {
9
- cacheOverride: any;
8
+ export declare const fetchVendorDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride: boolean, vendorId?: string | undefined, signal?: AbortSignal | undefined], {
9
+ cacheOverride: boolean;
10
10
  vendorId: string | undefined;
11
11
  signal: AbortSignal | undefined;
12
12
  }, string, never, never>, fetchVendor: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[vendorId: string, isCreatable?: boolean | undefined, signal?: AbortSignal | undefined], {
@@ -100,7 +100,7 @@ const vendorView = (0, toolkit_1.createSlice)({
100
100
  } });
101
101
  }
102
102
  },
103
- prepare(cacheOverride = false, vendorId, signal) {
103
+ prepare(cacheOverride, vendorId, signal) {
104
104
  return { payload: { cacheOverride, vendorId, signal } };
105
105
  },
106
106
  },
@@ -125,7 +125,7 @@ const vendorView = (0, toolkit_1.createSlice)({
125
125
  payload: {
126
126
  vendorId,
127
127
  isCreatable,
128
- signal
128
+ signal,
129
129
  },
130
130
  };
131
131
  },
@@ -36,8 +36,8 @@ export declare const fetchVendorsTabVendorDetails: import("@reduxjs/toolkit").Ac
36
36
  }, string, never, never>, updateVendorsTabVendorAllTransactionsTabData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
37
37
  timePeriod: TimePeriod;
38
38
  numberOfQuartersFetched: number;
39
- }, string>, resetSelectedTabType: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateSelectedTabType: import("@reduxjs/toolkit").ActionCreatorWithPayload<"spend_transactions" | "all_transactions", string>, updateVendorSpendTrendFilterTabValue: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[vendorSpendTrendfilterTabValue: "last_month" | "last_30_days" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year"], {
40
- vendorSpendTrendfilterTabValue: "last_month" | "last_30_days" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year";
39
+ }, string>, resetSelectedTabType: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateSelectedTabType: import("@reduxjs/toolkit").ActionCreatorWithPayload<"spend_transactions" | "all_transactions", string>, updateVendorSpendTrendFilterTabValue: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[vendorSpendTrendfilterTabValue: "last_month" | "last_30_days" | "variance" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year"], {
40
+ vendorSpendTrendfilterTabValue: "last_month" | "last_30_days" | "variance" | "last_90_days" | "YTD_spend" | "last_3_months" | "last_6_months" | "last_12_months" | "last_year";
41
41
  }, string, never, never>, resetVendorsTabVendorAllTransactionsTabData: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateContactsInVendorTabDetailLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
42
42
  vendorId: ID;
43
43
  localData?: Partial<VendorsTabVendorDetailLocalData> | undefined;
@@ -90,5 +90,6 @@ exports.vendorFiling1099DownloadSuccessState = {
90
90
  hasValidState: vendorFiling1099ListReducer_1.initialState.hasValidState,
91
91
  lastRefreshSuccessTime: undefined,
92
92
  isVendor1099Populated: true,
93
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
93
94
  vendorFiling1099DownloadData: exports.vendorFiling1099DownloadSuccessResponse.data,
94
95
  };
@@ -5,7 +5,6 @@ const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const responsePayload_1 = require("../../../responsePayload");
7
7
  const vendorFiling1099ListReducer_1 = require("./vendorFiling1099ListReducer");
8
- const vendorFiling1099ListReducer_2 = require("./vendorFiling1099ListReducer");
9
8
  const fetchVendorsFiling1099DownloadEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(vendorFiling1099ListReducer_1.fetchVendorsFiling1099Download.match), (0, operators_1.switchMap)((action) => {
10
9
  const type1099Download = action.payload.type1099;
11
10
  const queryParams = {
@@ -27,7 +26,7 @@ const fetchVendorsFiling1099DownloadEpic = (actions$, _state$, zeniAPI) => actio
27
26
  }
28
27
  else {
29
28
  return (0, rxjs_1.of)((0, vendorFiling1099ListReducer_1.updateVendorFiling1099DownloadData)({
30
- response: vendorFiling1099ListReducer_2.initialState.vendorFiling1099DownloadData,
29
+ response: vendorFiling1099ListReducer_1.initialState.vendorFiling1099DownloadData,
31
30
  downloadState: {
32
31
  fetchState: 'Error',
33
32
  },
@@ -35,7 +34,7 @@ const fetchVendorsFiling1099DownloadEpic = (actions$, _state$, zeniAPI) => actio
35
34
  }
36
35
  }), (0, operators_1.catchError)((err) => {
37
36
  return (0, rxjs_1.of)((0, vendorFiling1099ListReducer_1.updateVendorFiling1099DownloadData)({
38
- response: vendorFiling1099ListReducer_2.initialState.vendorFiling1099DownloadData,
37
+ response: vendorFiling1099ListReducer_1.initialState.vendorFiling1099DownloadData,
39
38
  downloadState: {
40
39
  fetchState: 'Error',
41
40
  error: {
@@ -24,7 +24,7 @@ const saveVendorFirstReviewViewEpic = (actions$, state$, zeniAPI) => actions$.pi
24
24
  const { vendorId, markAsEmployee, markAsLocalContractor } = action.payload;
25
25
  const currentVendorLocalData = vendorFirstReviewViewState.vendorFirstReviewViewLocalDataById[vendorId]
26
26
  .vendorFirstReviewViewLocalData;
27
- const currentVendor = (0, vendorSelector_1.getVendorByVendorId)(state$.value.vendorState, vendorId);
27
+ const currentVendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, vendorId);
28
28
  const { vendorName, selectedGlobalMerchant, recommendations, nonExistingRecommendations, } = getSaveVendorFirstReviewViewPayloadDetails(currentVendorLocalData, globalMerchantState, vendorState);
29
29
  const payload = Object.assign({}, prepareSaveVendorFirstReviewViewPayload(vendorName, recommendations, nonExistingRecommendations, markAsEmployee, markAsLocalContractor, currentVendor === null || currentVendor === void 0 ? void 0 : currentVendor.qboId, selectedGlobalMerchant));
30
30
  const queryParam = {
@@ -104,7 +104,7 @@ const saveVendorFirstReviewViewEpic = (actions$, state$, zeniAPI) => actions$.pi
104
104
  actions.push((0, vendorFirstReviewViewReducer_1.updateRecentlySavedErroredVendorData)({
105
105
  vendorId: action.payload.vendorId,
106
106
  vendorNameSentForReview: vendorName,
107
- isQBOMergeError: true,
107
+ isVendorMergeError: true,
108
108
  }));
109
109
  }
110
110
  else if (response.status.details != null) {
@@ -122,13 +122,44 @@ const saveVendorFirstReviewViewEpic = (actions$, state$, zeniAPI) => actions$.pi
122
122
  actions.push((0, vendorFirstReviewViewReducer_1.updateRecentlySavedErroredVendorData)({
123
123
  vendorId: action.payload.vendorId,
124
124
  vendorNameSentForReview: vendorName,
125
- isQBOMergeError: false,
125
+ isVendorMergeError: false,
126
126
  oldRecommendation,
127
127
  newRecommendation,
128
128
  }));
129
129
  }
130
130
  return (0, rxjs_1.from)(actions);
131
131
  }
132
+ else if (response.status.code === 400 &&
133
+ response.status.message.includes('There is already a vendor using that entity name.')) {
134
+ const actions = [];
135
+ actions.push((0, vendorFirstReviewViewReducer_1.updateSavedVendorFirstReviewViewLocalData)({
136
+ vendorId,
137
+ vendors: response.data && response.data.vendors
138
+ ? response.data.vendors
139
+ : [],
140
+ }));
141
+ actions.push((0, vendorFirstReviewViewReducer_1.saveVendorFirstReviewViewSuccessOrFailure)('Error', action.payload.vendorId, markAsEmployee, markAsLocalContractor, response.status));
142
+ actions.push((0, vendorReducer_1.updateVendors)((0, fetchVendorFirstReviewViewEpic_1.mapVendorsPayloadFromVendorFirstReviewViewResponse)(response.data && response.data.vendors
143
+ ? response.data.vendors
144
+ : [])), (0, userReducer_1.updateAllUsers)({
145
+ users: (0, fetchVendorFirstReviewViewEpic_1.mapUsersPayloadFromVendorFirstReviewViewResponse)(response.data && response.data.vendors
146
+ ? response.data.vendors
147
+ : []),
148
+ updateType: 'merge',
149
+ }), (0, globalMerchantReducer_1.updateGlobalMerchantsBase)({
150
+ globalMerchants: (0, fetchVendorFirstReviewViewEpic_1.mapGlobalMerchantsBasePayloadFromVendorFirstReviewViewResponse)(response.data && response.data.vendors
151
+ ? response.data.vendors
152
+ : []),
153
+ }));
154
+ if (response.status.details == null) {
155
+ actions.push((0, vendorFirstReviewViewReducer_1.updateRecentlySavedErroredVendorData)({
156
+ vendorId: action.payload.vendorId,
157
+ vendorNameSentForReview: vendorName,
158
+ isVendorMergeError: true,
159
+ }));
160
+ }
161
+ return (0, rxjs_1.from)(actions);
162
+ }
132
163
  else {
133
164
  return (0, rxjs_1.of)((0, vendorFirstReviewViewReducer_1.saveVendorFirstReviewViewSuccessOrFailure)('Error', action.payload.vendorId, markAsEmployee, markAsLocalContractor, response.status), (0, snackbarReducer_1.openSnackbar)({
134
165
  messageSection: 'save_vendor_sent_for_review',
@@ -43,7 +43,7 @@ export declare const fetchVendorFirstReviewAttachments: import("@reduxjs/toolkit
43
43
  }, string>, updateRecentlySavedErroredVendorData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
44
44
  vendorId: ID;
45
45
  vendorNameSentForReview: string;
46
- isQBOMergeError: boolean;
46
+ isVendorMergeError: boolean;
47
47
  oldRecommendation?: RecommendedNonExistingGlobalMerchant | undefined;
48
48
  newRecommendation?: RecommendedNonExistingGlobalMerchant | undefined;
49
49
  }, string>, clearRecentlySavedErroredVendorData: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, saveVendorFirstReviewViewSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[fetchState: FetchState, vendorId: string, markAsEmployee: boolean, markAsLocalContractor: boolean, error?: ZeniAPIStatus<Record<string, unknown>> | undefined, reviewStatus?: ReviewStatusPayload | undefined], {
@@ -166,8 +166,8 @@ const vendorFirstReviewView = (0, toolkit_1.createSlice)({
166
166
  };
167
167
  },
168
168
  updateRecentlySavedErroredVendorData(draft, action) {
169
- const { isQBOMergeError, vendorId, oldRecommendation, newRecommendation, vendorNameSentForReview, } = action.payload;
170
- if (isQBOMergeError) {
169
+ const { isVendorMergeError, vendorId, oldRecommendation, newRecommendation, vendorNameSentForReview, } = action.payload;
170
+ if (isVendorMergeError) {
171
171
  draft.recentlySavedErroredVendorData = {
172
172
  vendorId,
173
173
  vendorNameSentForReview,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.13.3",
3
+ "version": "4.13.4",
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",