@zeniai/client-epic-state 4.10.68 → 4.10.69
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.
- package/lib/entity/reimbursement/reimbursementPayload.d.ts +4 -3
- package/lib/entity/reimbursement/reimbursementPayload.js +36 -2
- package/lib/entity/reimbursement/reimbursementState.d.ts +4 -4
- package/lib/index.d.ts +4 -4
- package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewPayload.d.ts +5 -1
- package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewPayload.js +50 -0
- package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewReducer.js +19 -16
- package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.d.ts +5 -2
- package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.js +2 -2
- package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewState.d.ts +30 -7
- package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchCurrencyConversionValueEpic.js +1 -1
- package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchRecommendationsAndUpdateMerchantRecommendationsEpic.js +2 -2
- package/lib/view/spendManagement/reimbursement/editRemiView/epics/initializeRemiToLocalStoreEpic.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/editRemiView/epics/initializeRemiToLocalStoreEpic.js +51 -7
- package/lib/view/spendManagement/reimbursement/editRemiView/epics/parseReceiptsToRemiEpic.js +31 -20
- package/lib/view/spendManagement/reimbursement/editRemiView/epics/saveRemiDetailEpic.d.ts +3 -3
- package/lib/view/spendManagement/reimbursement/editRemiView/epics/saveRemiDetailEpic.js +4 -4
- package/lib/view/spendManagement/reimbursement/remiDetailView/epics/fetchDuplicateReimbursementEpic.js +11 -4
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { URLPayload } from '../../commonPayloadTypes/urlPayload';
|
|
2
|
+
import { SegregatedReimbursementLineWithRecommendation } from '../../view/spendManagement/reimbursement/editRemiView/editRemiViewState';
|
|
2
3
|
import { AccountBasePayload } from '../account/accountPayload';
|
|
3
4
|
import { BillAccountPayload, BillPaymentMethodPayload, BillPaymentStatusPayload, BillStagePayload, BillStatusPayload, DeletionInfoPayload } from '../billPay/billTransaction/billTransactionPayload';
|
|
4
5
|
import { ClassBasePayload } from '../class/classPayload';
|
|
@@ -87,9 +88,9 @@ export declare const toReimbursementTransactionType: (v: string) => "reimburseme
|
|
|
87
88
|
export declare const toReimbursementTransactionTypeStrict: (v?: string | undefined) => "reimbursement" | undefined;
|
|
88
89
|
export declare const toReimbursement: (payload: ReimbursementPayload) => Reimbursement;
|
|
89
90
|
export declare const toReimbursementInfo: (payload: ReimbursementInfoPayload) => ReimbursementInfo;
|
|
90
|
-
export declare const toReimbursementLinePayload: (line:
|
|
91
|
-
export declare const toMilageReimbursementLinePayload: (line:
|
|
92
|
-
export declare const toOutofPocketReimbursementLinePayload: (line:
|
|
91
|
+
export declare const toReimbursementLinePayload: (line: SegregatedReimbursementLineWithRecommendation) => ReimbursementLinePayload;
|
|
92
|
+
export declare const toMilageReimbursementLinePayload: (line: SegregatedReimbursementLineWithRecommendation) => MilageReimbursementLinePayload;
|
|
93
|
+
export declare const toOutofPocketReimbursementLinePayload: (line: SegregatedReimbursementLineWithRecommendation) => OutofPocketReimbursementLinePayload;
|
|
93
94
|
export declare const toReimbursementLine: (payload: ReimbursementLinePayload) => ReimbursementLine;
|
|
94
95
|
export declare const toMilageReimbursementLine: (payload: MilageReimbursementLinePayload) => MilageReimbursementLine;
|
|
95
96
|
export declare const toOutofPocketReimbursementLine: (payload: OutofPocketReimbursementLinePayload) => OutofPocketReimbursementLine;
|
|
@@ -81,9 +81,43 @@ const toReimbursementLinePayload = (line) => {
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
exports.toReimbursementLinePayload = toReimbursementLinePayload;
|
|
84
|
-
const toMilageReimbursementLinePayload = (line) =>
|
|
84
|
+
const toMilageReimbursementLinePayload = (line) => {
|
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
86
|
+
const tempLine = {
|
|
87
|
+
lineId: line.lineId,
|
|
88
|
+
type: line.type,
|
|
89
|
+
fileId: line.fileId,
|
|
90
|
+
homeCurrencyConversions: line.homeCurrencyConversions,
|
|
91
|
+
description: (_a = line.mileage.description) !== null && _a !== void 0 ? _a : '',
|
|
92
|
+
lineDetail: (_b = line.mileage.lineDetail) !== null && _b !== void 0 ? _b : {},
|
|
93
|
+
transactionDate: (_c = line.mileage.transactionDate) !== null && _c !== void 0 ? _c : (0, zeniDayJS_1.dateNow)(),
|
|
94
|
+
amount: (_d = line.mileage.amount) !== null && _d !== void 0 ? _d : 0,
|
|
95
|
+
currencyCode: (_e = line.mileage.currencyCode) !== null && _e !== void 0 ? _e : 'USD',
|
|
96
|
+
currencySymbol: (_f = line.mileage.currencySymbol) !== null && _f !== void 0 ? _f : '$',
|
|
97
|
+
};
|
|
98
|
+
const mileage = (_g = line.mileage.distanceMileage) !== null && _g !== void 0 ? _g : {
|
|
99
|
+
value: 0,
|
|
100
|
+
unit: 'miles',
|
|
101
|
+
};
|
|
102
|
+
return Object.assign(Object.assign({}, (0, exports.toReimbursementLineBasePayload)(tempLine)), { distance_mileage: (0, exports.toDistanceMilagePayload)(mileage) });
|
|
103
|
+
};
|
|
85
104
|
exports.toMilageReimbursementLinePayload = toMilageReimbursementLinePayload;
|
|
86
|
-
const toOutofPocketReimbursementLinePayload = (line) =>
|
|
105
|
+
const toOutofPocketReimbursementLinePayload = (line) => {
|
|
106
|
+
var _a, _b, _c, _d, _e, _f;
|
|
107
|
+
const tempLine = {
|
|
108
|
+
lineId: line.lineId,
|
|
109
|
+
type: line.type,
|
|
110
|
+
fileId: line.fileId,
|
|
111
|
+
homeCurrencyConversions: line.homeCurrencyConversions,
|
|
112
|
+
description: (_a = line.outOfPocket.description) !== null && _a !== void 0 ? _a : '',
|
|
113
|
+
lineDetail: (_b = line.outOfPocket.lineDetail) !== null && _b !== void 0 ? _b : {},
|
|
114
|
+
transactionDate: (_c = line.outOfPocket.transactionDate) !== null && _c !== void 0 ? _c : (0, zeniDayJS_1.dateNow)(),
|
|
115
|
+
amount: (_d = line.outOfPocket.amount) !== null && _d !== void 0 ? _d : 0,
|
|
116
|
+
currencyCode: (_e = line.outOfPocket.currencyCode) !== null && _e !== void 0 ? _e : 'USD',
|
|
117
|
+
currencySymbol: (_f = line.outOfPocket.currencySymbol) !== null && _f !== void 0 ? _f : '$',
|
|
118
|
+
};
|
|
119
|
+
return Object.assign(Object.assign({}, (0, exports.toReimbursementLineBasePayload)(tempLine)), { merchant: (0, merchantPayload_1.toMerchantBasePayload)(line.outOfPocket.merchant) });
|
|
120
|
+
};
|
|
87
121
|
exports.toOutofPocketReimbursementLinePayload = toOutofPocketReimbursementLinePayload;
|
|
88
122
|
const toReimbursementLine = (payload) => {
|
|
89
123
|
const remiType = payload.reimbursement_type.code;
|
|
@@ -5,10 +5,10 @@ import { Attachment } from '../transaction/stateTypes/attachment';
|
|
|
5
5
|
import { ZeniUrl as Url } from '../../zeniUrl';
|
|
6
6
|
import { AccountBase } from '../account/accountState';
|
|
7
7
|
import { ClassBase } from '../class/classState';
|
|
8
|
+
import { MerchantBase } from '../merchant/merchant';
|
|
8
9
|
import { BillPaymentStatus, BillStage, BillStatus, DeletionInfo } from '../billPay/billTransaction/billTransactionState';
|
|
9
10
|
import { BillPaymentConfigCodeType, BillPaymentSubConfigCodeType } from '../../view/spendManagement/billPay/billPayConfig/billPayConfigState';
|
|
10
11
|
import { ReimbursementTransactionType } from './reimbursementPayload';
|
|
11
|
-
import { MerchantBase } from '../merchant/merchant';
|
|
12
12
|
export interface Reimbursement {
|
|
13
13
|
id: ID;
|
|
14
14
|
type: ReimbursementTransactionType;
|
|
@@ -47,13 +47,13 @@ export interface ReimbursementLineBase extends Amount {
|
|
|
47
47
|
export interface MilageReimbursementLine extends ReimbursementLineBase {
|
|
48
48
|
distanceMileage: DistanceMilage;
|
|
49
49
|
}
|
|
50
|
+
export interface OutofPocketReimbursementLine extends ReimbursementLineBase {
|
|
51
|
+
merchant?: MerchantBase;
|
|
52
|
+
}
|
|
50
53
|
export interface DistanceMilage {
|
|
51
54
|
unit: DistanceUnitType;
|
|
52
55
|
value: number;
|
|
53
56
|
}
|
|
54
|
-
export interface OutofPocketReimbursementLine extends ReimbursementLineBase {
|
|
55
|
-
merchant?: MerchantBase;
|
|
56
|
-
}
|
|
57
57
|
export interface LineDetail {
|
|
58
58
|
class?: ClassBase;
|
|
59
59
|
account?: AccountBase;
|
package/lib/index.d.ts
CHANGED
|
@@ -447,10 +447,10 @@ import { deleteRemi, fetchRemiDetail, cancelAndDeleteRemi, approveOrRejectRemi,
|
|
|
447
447
|
export { deleteRemi, fetchRemiDetail, cancelAndDeleteRemi, approveOrRejectRemi, clearRemiDetailView, fetchDuplicateReimbursement, clearDuplicateReimbursementDetail, removeDuplicateReimbursementByLineId, };
|
|
448
448
|
import { ReceiptsProcessingPayload } from './view/spendManagement/reimbursement/editRemiView/editRemiViewPayload';
|
|
449
449
|
export { ReceiptsProcessingPayload };
|
|
450
|
-
import { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, getEditRemiDetail, ReimbursementLineWithAttachmentAndRecommendation } from './view/spendManagement/reimbursement/editRemiView/editRemiViewSelector';
|
|
451
|
-
export { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, getEditRemiDetail, ReimbursementLineWithAttachmentAndRecommendation, };
|
|
452
|
-
import { RemiDetailLocalData, AutoFields, OutofPocketReimbursementLineWithRecommendation,
|
|
453
|
-
export { RemiDetailLocalData, AutoFields, OutofPocketReimbursementLineWithRecommendation,
|
|
450
|
+
import { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, SegregatedReimbursementLineWithAttachment, getEditRemiDetail, ReimbursementLineWithAttachmentAndRecommendation } from './view/spendManagement/reimbursement/editRemiView/editRemiViewSelector';
|
|
451
|
+
export { EditRemiDetailSelectorView, ReimbursementLineWithAttachment, SegregatedReimbursementLineWithAttachment, getEditRemiDetail, ReimbursementLineWithAttachmentAndRecommendation, };
|
|
452
|
+
import { RemiDetailLocalData, AutoFields, OutofPocketReimbursementLineWithRecommendation, SegregatedReimbursementLineWithRecommendation, SegregatedReimbursementLine, MilageLine, OutofPocketLine } from './view/spendManagement/reimbursement/editRemiView/editRemiViewState';
|
|
453
|
+
export { RemiDetailLocalData, AutoFields, OutofPocketReimbursementLineWithRecommendation, SegregatedReimbursementLineWithRecommendation, SegregatedReimbursementLine, MilageLine, OutofPocketLine, };
|
|
454
454
|
import { Merchant } from './entity/merchant/merchant';
|
|
455
455
|
export { Merchant };
|
|
456
456
|
import { fetchEditRemiDetailPage, fetchRecommendationsAndUpdateMerchantRecommendations, fetchRemiAndInitializeLocalStore, initializeRemiToLocalStore, saveRemiUpdatesToLocalStore, fetchCurrencyConversionValue, discardRemiUpdatesInLocalStore, removeFileFromRemiUpdatesInLocalStore, saveRemiDetail, saveRemiSuccessOrFailure, parseReceiptsToRemi, clearEditRemiViewDetail, updateAddRemiAutoFields, clearAddRemiAutoFields, updateUploadFetchState, updateTentativeMerchantNames, clearTentativeMerchantName } from './view/spendManagement/reimbursement/editRemiView/editRemiViewReducer';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { FilePayload } from '../../../../entity/file/filePayload';
|
|
2
2
|
import { ZeniAPIResponse } from '../../../../responsePayload';
|
|
3
3
|
import { MerchantPayload } from '../../../../entity/merchant/merchantPayload';
|
|
4
|
-
import { AmountPayload, ReimbursementPayload } from '../../../../entity/reimbursement/reimbursementPayload';
|
|
5
4
|
import { EntityApprovalStatusPayload } from '../../../../entity/entityApprovalStatus/entityApprovalStatusPayload';
|
|
6
5
|
import { ApprovalRulePayload } from '../../../../entity/approvalRule/approvalRulePayload';
|
|
7
6
|
import { UserPayload } from '../../../../entity/user/userPayload';
|
|
8
7
|
import { BankAccountPayload } from '../../../../entity/bankAccount/bankAccountPayload';
|
|
8
|
+
import { AmountPayload, ReimbursementPayload } from '../../../../entity/reimbursement/reimbursementPayload';
|
|
9
9
|
import { ReimbursementConfigPayload } from '../../reimbursement/reimbursementConfig/reimbursementConfigPayload';
|
|
10
|
+
import { MilageReimbursementLine, OutofPocketReimbursementLine } from '../../../../entity/reimbursement/reimbursementState';
|
|
11
|
+
import { SegregatedReimbursementLineWithRecommendation } from './editRemiViewState';
|
|
10
12
|
export interface CurrencyConversionPayload {
|
|
11
13
|
home_currency_conversions: AmountPayload;
|
|
12
14
|
}
|
|
@@ -40,3 +42,5 @@ export interface RemiSavePayload {
|
|
|
40
42
|
export declare type RemiSaveResponse = ZeniAPIResponse<RemiSavePayload>;
|
|
41
43
|
export declare type CurrencyConversionResponse = ZeniAPIResponse<CurrencyConversionPayload>;
|
|
42
44
|
export declare type ReimbursementConfigResponse = ZeniAPIResponse<ReimbursementConfigPayload>;
|
|
45
|
+
export declare const toReimbursementLineWithRecommendationFromMileage: (line: MilageReimbursementLine) => SegregatedReimbursementLineWithRecommendation;
|
|
46
|
+
export declare const toReimbursementLineWithRecommendationFromOutOfPocket: (line: OutofPocketReimbursementLine) => SegregatedReimbursementLineWithRecommendation;
|
|
@@ -1,2 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toReimbursementLineWithRecommendationFromOutOfPocket = exports.toReimbursementLineWithRecommendationFromMileage = void 0;
|
|
4
|
+
const toReimbursementLineWithRecommendationFromMileage = (line) => {
|
|
5
|
+
const convertedLine = {
|
|
6
|
+
type: line.type,
|
|
7
|
+
fileId: line.fileId,
|
|
8
|
+
lineId: line.lineId,
|
|
9
|
+
homeCurrencyConversions: line.homeCurrencyConversions,
|
|
10
|
+
mileage: {
|
|
11
|
+
description: line.description,
|
|
12
|
+
lineDetail: line.lineDetail,
|
|
13
|
+
transactionDate: line.transactionDate,
|
|
14
|
+
amount: line.amount,
|
|
15
|
+
currencyCode: line.currencyCode,
|
|
16
|
+
currencySymbol: line.currencySymbol,
|
|
17
|
+
distanceMileage: line === null || line === void 0 ? void 0 : line.distanceMileage,
|
|
18
|
+
},
|
|
19
|
+
outOfPocket: {
|
|
20
|
+
recommendations: [],
|
|
21
|
+
isCategoryFirstTimeAutofilled: false,
|
|
22
|
+
isCategoryUpdateSelected: false,
|
|
23
|
+
isRetainedCategorySelected: false,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
return convertedLine;
|
|
27
|
+
};
|
|
28
|
+
exports.toReimbursementLineWithRecommendationFromMileage = toReimbursementLineWithRecommendationFromMileage;
|
|
29
|
+
const toReimbursementLineWithRecommendationFromOutOfPocket = (line) => {
|
|
30
|
+
const convertedLine = {
|
|
31
|
+
type: line.type,
|
|
32
|
+
fileId: line.fileId,
|
|
33
|
+
lineId: line.lineId,
|
|
34
|
+
homeCurrencyConversions: line.homeCurrencyConversions,
|
|
35
|
+
mileage: {},
|
|
36
|
+
outOfPocket: {
|
|
37
|
+
merchant: line === null || line === void 0 ? void 0 : line.merchant,
|
|
38
|
+
description: line.description,
|
|
39
|
+
lineDetail: line.lineDetail,
|
|
40
|
+
transactionDate: line.transactionDate,
|
|
41
|
+
amount: line.amount,
|
|
42
|
+
currencyCode: line.currencyCode,
|
|
43
|
+
currencySymbol: line.currencySymbol,
|
|
44
|
+
recommendations: [],
|
|
45
|
+
isCategoryFirstTimeAutofilled: false,
|
|
46
|
+
isCategoryUpdateSelected: false,
|
|
47
|
+
isRetainedCategorySelected: false,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return convertedLine;
|
|
51
|
+
};
|
|
52
|
+
exports.toReimbursementLineWithRecommendationFromOutOfPocket = toReimbursementLineWithRecommendationFromOutOfPocket;
|
|
@@ -350,24 +350,24 @@ exports.default = editRemiView.reducer;
|
|
|
350
350
|
const doUpdateRecommendationForEntity = (draft, lineId, recommendations, shouldAutofill, reimbursementId, reimbursementStageCode) => {
|
|
351
351
|
var _a, _b, _c, _d, _e, _f;
|
|
352
352
|
if (reimbursementId != null) {
|
|
353
|
-
const lineAccount = (_a = draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
354
|
-
.updatesByLineId[lineId].lineDetail) === null || _a === void 0 ? void 0 : _a.account;
|
|
355
|
-
const lineClass = (_b = draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
356
|
-
.updatesByLineId[lineId].lineDetail) === null || _b === void 0 ? void 0 : _b.class;
|
|
357
353
|
if (draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
358
354
|
.updatesByLineId[lineId].type === 'out_of_pocket') {
|
|
355
|
+
const lineAccount = (_a = draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
356
|
+
.updatesByLineId[lineId].outOfPocket.lineDetail) === null || _a === void 0 ? void 0 : _a.account;
|
|
357
|
+
const lineClass = (_b = draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
358
|
+
.updatesByLineId[lineId].outOfPocket.lineDetail) === null || _b === void 0 ? void 0 : _b.class;
|
|
359
359
|
const merchantForCurrentLineId = draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
360
|
-
.updatesByLineId[lineId].merchant;
|
|
360
|
+
.updatesByLineId[lineId].outOfPocket.merchant;
|
|
361
361
|
if (merchantForCurrentLineId != null) {
|
|
362
362
|
const { recommendedAccount } = (0, initializeRemiToLocalStoreEpic_1.getRecommendedCategoryClass)(recommendations, lineAccount, lineClass);
|
|
363
363
|
// autofill the account with recommendedAccount and set isCategoryFirstTimeAutofilled as true
|
|
364
364
|
if (shouldAutofill) {
|
|
365
|
-
draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId] = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
366
|
-
.updatesByLineId[lineId]), { recommendations,
|
|
365
|
+
draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId].outOfPocket = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
366
|
+
.updatesByLineId[lineId].outOfPocket), { recommendations,
|
|
367
367
|
recommendedAccount, isCategoryUpdateSelected: false, isCategoryFirstTimeAutofilled: true });
|
|
368
368
|
//autofilling account with recommendedAccount
|
|
369
|
-
draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId].lineDetail = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
370
|
-
.updatesByLineId[lineId].lineDetail), { account: recommendedAccount });
|
|
369
|
+
draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId].outOfPocket.lineDetail = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
370
|
+
.updatesByLineId[lineId].outOfPocket.lineDetail), { account: recommendedAccount });
|
|
371
371
|
//add account to addRemiAutoFieldsByLineId, since account was autofilled
|
|
372
372
|
if (!((_c = draft.editRemiStateById[reimbursementId].addRemiAutoFieldsByLineId[lineId]) === null || _c === void 0 ? void 0 : _c.includes('account')) &&
|
|
373
373
|
(recommendedAccount === null || recommendedAccount === void 0 ? void 0 : recommendedAccount.accountId) != null) {
|
|
@@ -382,24 +382,27 @@ const doUpdateRecommendationForEntity = (draft, lineId, recommendations, shouldA
|
|
|
382
382
|
}
|
|
383
383
|
// show retain checkbox only in pending approval
|
|
384
384
|
if (reimbursementStageCode === 'pending_approval') {
|
|
385
|
-
draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId] = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
386
|
-
.updatesByLineId[lineId]), { retainedAccount: recommendedAccount != null ? lineAccount : undefined, isRetainedCategorySelected: false });
|
|
385
|
+
draft.editRemiStateById[reimbursementId].remiDetailLocalData.updatesByLineId[lineId].outOfPocket = Object.assign(Object.assign({}, draft.editRemiStateById[reimbursementId].remiDetailLocalData
|
|
386
|
+
.updatesByLineId[lineId].outOfPocket), { retainedAccount: recommendedAccount != null ? lineAccount : undefined, isRetainedCategorySelected: false });
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
else {
|
|
392
|
-
const lineAccount = (_d = draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].lineDetail) === null || _d === void 0 ? void 0 : _d.account;
|
|
393
|
-
const lineClass = (_e = draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].lineDetail) === null || _e === void 0 ? void 0 : _e.class;
|
|
394
392
|
if (draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].type ===
|
|
395
393
|
'out_of_pocket') {
|
|
394
|
+
const lineAccount = (_d = draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
|
|
395
|
+
.outOfPocket.lineDetail) === null || _d === void 0 ? void 0 : _d.account;
|
|
396
|
+
const lineClass = (_e = draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
|
|
397
|
+
.outOfPocket.lineDetail) === null || _e === void 0 ? void 0 : _e.class;
|
|
396
398
|
const { recommendedAccount } = (0, initializeRemiToLocalStoreEpic_1.getRecommendedCategoryClass)(recommendations, lineAccount, lineClass);
|
|
397
399
|
// autofill the account with recommendedAccount and set isCategoryFirstTimeAutofilled as true
|
|
398
400
|
if (shouldAutofill) {
|
|
399
|
-
draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId] = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
|
|
401
|
+
draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].outOfPocket = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
|
|
402
|
+
.outOfPocket), { recommendations,
|
|
400
403
|
recommendedAccount, isCategoryUpdateSelected: false, isCategoryFirstTimeAutofilled: true });
|
|
401
|
-
draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].lineDetail = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
|
|
402
|
-
.lineDetail), { account: recommendedAccount });
|
|
404
|
+
draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId].outOfPocket.lineDetail = Object.assign(Object.assign({}, draft.newRemiState.remiDetailLocalData.updatesByLineId[lineId]
|
|
405
|
+
.outOfPocket.lineDetail), { account: recommendedAccount });
|
|
403
406
|
//add account to addRemiAutoFieldsByLineId, since account was autofilled
|
|
404
407
|
if (!((_f = draft.newRemiState.addRemiAutoFieldsByLineId[lineId]) === null || _f === void 0 ? void 0 : _f.includes('account')) &&
|
|
405
408
|
(recommendedAccount === null || recommendedAccount === void 0 ? void 0 : recommendedAccount.accountId) != null) {
|
|
@@ -4,7 +4,7 @@ import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAnd
|
|
|
4
4
|
import { BillStageCodeType, BillStatusCodeType } from '../../../../entity/billPay/billTransaction/billTransactionState';
|
|
5
5
|
import { AccountListSelectorView } from '../../../accountList/accountListSelector';
|
|
6
6
|
import { ClassListSelectorView } from '../../../classList/classListSelector';
|
|
7
|
-
import { AutoFields,
|
|
7
|
+
import { AutoFields, SegregatedReimbursementLineWithRecommendation, WhatForSection, SegregatedReimbursementLine } from './editRemiViewState';
|
|
8
8
|
import { ReimbursementInfo, ReimbursementLine } from '../../../../entity/reimbursement/reimbursementState';
|
|
9
9
|
import { File } from '../../../../entity/file/fileState';
|
|
10
10
|
import { Attachment } from '../../../../entity/transaction/stateTypes/attachment';
|
|
@@ -62,7 +62,10 @@ export interface EditRemiInitialDetails {
|
|
|
62
62
|
export declare type ReimbursementLineWithAttachment = ReimbursementLine & {
|
|
63
63
|
file?: Attachment;
|
|
64
64
|
};
|
|
65
|
-
export declare type
|
|
65
|
+
export declare type SegregatedReimbursementLineWithAttachment = SegregatedReimbursementLine & {
|
|
66
|
+
file?: Attachment;
|
|
67
|
+
};
|
|
68
|
+
export declare type ReimbursementLineWithAttachmentAndRecommendation = SegregatedReimbursementLineWithRecommendation & {
|
|
66
69
|
file?: Attachment;
|
|
67
70
|
recommendationFetchState: FetchState;
|
|
68
71
|
};
|
|
@@ -121,8 +121,8 @@ const getEditRemiDetail = (state, reimbursementId) => {
|
|
|
121
121
|
Object.keys(lineDetailSectionUpdatesByLineId).forEach((lineId) => {
|
|
122
122
|
var _a, _b, _c, _d, _e, _f;
|
|
123
123
|
if (lineDetailSectionUpdatesByLineId[lineId].type === 'out_of_pocket') {
|
|
124
|
-
const merchantId = (_a = lineDetailSectionUpdatesByLineId[lineId].merchant) === null || _a === void 0 ? void 0 : _a.id;
|
|
125
|
-
const merchantName = (_b = lineDetailSectionUpdatesByLineId[lineId].merchant) === null || _b === void 0 ? void 0 : _b.name;
|
|
124
|
+
const merchantId = (_a = lineDetailSectionUpdatesByLineId[lineId].outOfPocket.merchant) === null || _a === void 0 ? void 0 : _a.id;
|
|
125
|
+
const merchantName = (_b = lineDetailSectionUpdatesByLineId[lineId].outOfPocket.merchant) === null || _b === void 0 ? void 0 : _b.name;
|
|
126
126
|
if (Boolean(merchantId) === true) {
|
|
127
127
|
const { fetchState } = (0, recommendationSelector_1.getRecommendationsForEntity)(state, merchantId, 'merchant');
|
|
128
128
|
lineDetailSection[lineId] = Object.assign(Object.assign({}, lineDetailSectionUpdatesByLineId[lineId]), { file: (_c = sourceRemiDetail.remiDetailLocalData.files) === null || _c === void 0 ? void 0 : _c.find((attachment) => attachment.fileId ===
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Amount } from '../../../../commonStateTypes/amount';
|
|
2
2
|
import { FetchState, FetchStateAndError, ID } from '../../../../commonStateTypes/common';
|
|
3
3
|
import { Recommendation } from '../../../../commonStateTypes/recommendationBase';
|
|
4
|
+
import { ZeniDate } from '../../../../zeniDayJS';
|
|
4
5
|
import { AccountBase, RecommendedAccountBase } from '../../../../entity/account/accountState';
|
|
5
|
-
import {
|
|
6
|
+
import { MerchantBase } from '../../../../entity/merchant/merchant';
|
|
7
|
+
import { DistanceMilage, LineDetail, ReimbursementTypeCode } from '../../../../entity/reimbursement/reimbursementState';
|
|
6
8
|
import { Attachment } from '../../../../entity/transaction/stateTypes/attachment';
|
|
7
9
|
export interface EditRemiDetail {
|
|
8
10
|
fetchStatus: FetchStateAndError;
|
|
@@ -14,7 +16,18 @@ export interface EditRemiDetail {
|
|
|
14
16
|
remiDetailLocalData: RemiDetailLocalData;
|
|
15
17
|
}
|
|
16
18
|
export declare const initialRemiDetail: EditRemiDetail;
|
|
17
|
-
export interface
|
|
19
|
+
export interface SegregatedReimbursementLine {
|
|
20
|
+
lineId: ID;
|
|
21
|
+
type: ReimbursementTypeCode;
|
|
22
|
+
fileId?: ID;
|
|
23
|
+
homeCurrencyConversions: Amount;
|
|
24
|
+
mileage: Partial<MilageLine>;
|
|
25
|
+
outOfPocket: Partial<OutofPocketLine>;
|
|
26
|
+
}
|
|
27
|
+
export interface SegregatedReimbursementLineWithRecommendation extends SegregatedReimbursementLine {
|
|
28
|
+
outOfPocket: OutofPocketReimbursementLineWithRecommendation;
|
|
29
|
+
}
|
|
30
|
+
export interface OutofPocketReimbursementLineWithRecommendation extends Partial<OutofPocketLine> {
|
|
18
31
|
recommendations: Recommendation[];
|
|
19
32
|
recommendedAccount?: RecommendedAccountBase;
|
|
20
33
|
isCategoryUpdateSelected: boolean;
|
|
@@ -22,20 +35,30 @@ export interface OutofPocketReimbursementLineWithRecommendation extends Partial<
|
|
|
22
35
|
retainedAccount?: AccountBase;
|
|
23
36
|
isRetainedCategorySelected: boolean;
|
|
24
37
|
}
|
|
25
|
-
export
|
|
38
|
+
export interface OutofPocketLine extends ReimbursementBaseLineWithoutType {
|
|
39
|
+
merchant: MerchantBase;
|
|
40
|
+
}
|
|
41
|
+
export interface MilageLine extends ReimbursementBaseLineWithoutType {
|
|
42
|
+
distanceMileage: DistanceMilage;
|
|
43
|
+
}
|
|
44
|
+
export interface ReimbursementBaseLineWithoutType extends Amount {
|
|
45
|
+
lineDetail: LineDetail;
|
|
46
|
+
transactionDate: ZeniDate;
|
|
47
|
+
description: string;
|
|
48
|
+
}
|
|
26
49
|
export interface EditRemiDetailViewState {
|
|
27
50
|
newRemiState: EditRemiDetail;
|
|
28
51
|
editRemiStateById: Record<ID, EditRemiDetail>;
|
|
29
52
|
}
|
|
53
|
+
export interface WhatForSection {
|
|
54
|
+
reportTitle?: string;
|
|
55
|
+
}
|
|
30
56
|
export interface RemiDetailLocalData {
|
|
31
57
|
whatForSection?: WhatForSection;
|
|
32
|
-
updatesByLineId: Record<ID,
|
|
58
|
+
updatesByLineId: Record<ID, SegregatedReimbursementLineWithRecommendation>;
|
|
33
59
|
currencyConversionStateByLineId: Record<ID, FetchStateAndError>;
|
|
34
60
|
totalAmount?: Amount;
|
|
35
61
|
files?: Attachment[];
|
|
36
62
|
paymentTo?: ID;
|
|
37
63
|
}
|
|
38
|
-
export interface WhatForSection {
|
|
39
|
-
reportTitle?: string;
|
|
40
|
-
}
|
|
41
64
|
export declare type AutoFields = ('merchant' | 'transactionDate' | 'amount' | 'memo' | 'account' | 'class')[];
|
|
@@ -15,7 +15,7 @@ const fetchCurrencyConversionValueEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
15
15
|
state.editRemiDetailViewState.editRemiStateById[reimbursementId]
|
|
16
16
|
.remiDetailLocalData;
|
|
17
17
|
}
|
|
18
|
-
const currentAmountDetails = remiDetailLocalData.updatesByLineId[lineId];
|
|
18
|
+
const currentAmountDetails = remiDetailLocalData.updatesByLineId[lineId].outOfPocket;
|
|
19
19
|
const payload = {
|
|
20
20
|
amount: {
|
|
21
21
|
amount: (_a = currentAmountDetails.amount) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -92,8 +92,8 @@ state$) => actions$.pipe((0, operators_1.filter)(editRemiViewReducer_1.waitForMe
|
|
|
92
92
|
var _a, _b;
|
|
93
93
|
return reimbursementLineWithRecommendation.type ===
|
|
94
94
|
'out_of_pocket' &&
|
|
95
|
-
(((_a = reimbursementLineWithRecommendation.merchant) === null || _a === void 0 ? void 0 : _a.id) === entityIdOrName ||
|
|
96
|
-
((_b = reimbursementLineWithRecommendation.merchant) === null || _b === void 0 ? void 0 : _b.name) === entityIdOrName);
|
|
95
|
+
(((_a = reimbursementLineWithRecommendation.outOfPocket.merchant) === null || _a === void 0 ? void 0 : _a.id) === entityIdOrName ||
|
|
96
|
+
((_b = reimbursementLineWithRecommendation.outOfPocket.merchant) === null || _b === void 0 ? void 0 : _b.name) === entityIdOrName);
|
|
97
97
|
});
|
|
98
98
|
const lineIds = lineDetails
|
|
99
99
|
.map((lineDetail) => lineDetail.lineId)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { initializeRemiToLocalStore, saveRemiUpdatesToLocalStore } from '../editRemiViewReducer';
|
|
4
3
|
import { RootState } from '../../../../../reducer';
|
|
5
4
|
import { Recommendation } from '../../../../../commonStateTypes/recommendationBase';
|
|
6
5
|
import { AccountBase, RecommendedAccountBase } from '../../../../../entity/account/accountState';
|
|
7
6
|
import { ClassBase, RecommendedClassBase } from '../../../../../entity/class/classState';
|
|
7
|
+
import { initializeRemiToLocalStore, saveRemiUpdatesToLocalStore } from '../editRemiViewReducer';
|
|
8
8
|
export declare type ActionType = ReturnType<typeof initializeRemiToLocalStore> | ReturnType<typeof saveRemiUpdatesToLocalStore>;
|
|
9
9
|
export declare const initializeRemiToLocalStoreEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
10
10
|
export declare const getRecommendedCategoryClass: (recommendation?: Recommendation[] | undefined, account?: AccountBase | undefined, classObj?: ClassBase | undefined) => {
|
package/lib/view/spendManagement/reimbursement/editRemiView/epics/initializeRemiToLocalStoreEpic.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getRecommendedCategoryClass = exports.initializeRemiToLocalStoreEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const editRemiViewReducer_1 = require("../editRemiViewReducer");
|
|
7
6
|
const merchantSelector_1 = require("../../../../../entity/merchant/merchantSelector");
|
|
7
|
+
const editRemiViewReducer_1 = require("../editRemiViewReducer");
|
|
8
8
|
const initializeRemiToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editRemiViewReducer_1.initializeRemiToLocalStore.match), (0, operators_1.mergeMap)((action) => {
|
|
9
9
|
var _a, _b;
|
|
10
10
|
const { reimbursementId } = action.payload;
|
|
@@ -17,23 +17,67 @@ const initializeRemiToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
|
|
|
17
17
|
const isPendingApproval = reimbursement.reimbursementInfo.stage.code === 'pending_approval';
|
|
18
18
|
const updatesByLineId = {};
|
|
19
19
|
(_a = reimbursement.lines) === null || _a === void 0 ? void 0 : _a.forEach((line) => {
|
|
20
|
-
var _a, _b;
|
|
20
|
+
var _a, _b, _c;
|
|
21
21
|
if (line.type === 'out_of_pocket') {
|
|
22
22
|
const merchantId = (_a = line.merchant) === null || _a === void 0 ? void 0 : _a.id;
|
|
23
23
|
const merchant = merchantId != null
|
|
24
24
|
? (0, merchantSelector_1.getMerchantByMerchantId)(state.merchantState, merchantId)
|
|
25
25
|
: undefined;
|
|
26
26
|
const { recommendedAccount } = (0, exports.getRecommendedCategoryClass)(merchant === null || merchant === void 0 ? void 0 : merchant.recommendations, line.lineDetail.account, line.lineDetail.class);
|
|
27
|
-
updatesByLineId[line.lineId] =
|
|
27
|
+
updatesByLineId[line.lineId] = {
|
|
28
|
+
lineId: line.lineId,
|
|
29
|
+
type: line.type,
|
|
30
|
+
fileId: line.fileId,
|
|
31
|
+
homeCurrencyConversions: line.homeCurrencyConversions,
|
|
32
|
+
outOfPocket: {
|
|
33
|
+
recommendations: (_b = merchant === null || merchant === void 0 ? void 0 : merchant.recommendations) !== null && _b !== void 0 ? _b : [],
|
|
34
|
+
recommendedAccount,
|
|
35
|
+
isCategoryUpdateSelected: false,
|
|
36
|
+
isCategoryFirstTimeAutofilled: false,
|
|
37
|
+
isRetainedCategorySelected: false,
|
|
38
|
+
merchant: {
|
|
39
|
+
id: merchant === null || merchant === void 0 ? void 0 : merchant.id,
|
|
40
|
+
name: (_c = merchant === null || merchant === void 0 ? void 0 : merchant.name) !== null && _c !== void 0 ? _c : '',
|
|
41
|
+
},
|
|
42
|
+
amount: line.amount,
|
|
43
|
+
currencyCode: line.currencyCode,
|
|
44
|
+
currencySymbol: line.currencySymbol,
|
|
45
|
+
description: line.description,
|
|
46
|
+
transactionDate: line.transactionDate,
|
|
47
|
+
lineDetail: line.lineDetail,
|
|
48
|
+
},
|
|
49
|
+
mileage: {},
|
|
50
|
+
};
|
|
28
51
|
//show retain checkbox only in pending approval
|
|
29
52
|
if (isPendingApproval) {
|
|
30
|
-
updatesByLineId[line.lineId] = Object.assign(Object.assign({}, updatesByLineId[line.lineId]), { retainedAccount: recommendedAccount != null
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
updatesByLineId[line.lineId] = Object.assign(Object.assign({}, updatesByLineId[line.lineId]), { outOfPocket: Object.assign(Object.assign({}, updatesByLineId[line.lineId].outOfPocket), { retainedAccount: recommendedAccount != null
|
|
54
|
+
? line.lineDetail.account
|
|
55
|
+
: undefined, isRetainedCategorySelected: false }) });
|
|
33
56
|
}
|
|
34
57
|
}
|
|
35
58
|
else {
|
|
36
|
-
updatesByLineId[line.lineId] =
|
|
59
|
+
updatesByLineId[line.lineId] = {
|
|
60
|
+
lineId: line.lineId,
|
|
61
|
+
type: line.type,
|
|
62
|
+
fileId: line.fileId,
|
|
63
|
+
homeCurrencyConversions: line.homeCurrencyConversions,
|
|
64
|
+
mileage: {
|
|
65
|
+
lineDetail: line.lineDetail,
|
|
66
|
+
amount: line.amount,
|
|
67
|
+
currencyCode: line.currencyCode,
|
|
68
|
+
currencySymbol: line.currencySymbol,
|
|
69
|
+
description: line.description,
|
|
70
|
+
transactionDate: line.transactionDate,
|
|
71
|
+
distanceMileage: line
|
|
72
|
+
.distanceMileage,
|
|
73
|
+
},
|
|
74
|
+
outOfPocket: {
|
|
75
|
+
recommendations: [],
|
|
76
|
+
isCategoryFirstTimeAutofilled: false,
|
|
77
|
+
isRetainedCategorySelected: false,
|
|
78
|
+
isCategoryUpdateSelected: false,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
37
81
|
}
|
|
38
82
|
});
|
|
39
83
|
const currencyConversionStateByLineId = {};
|
package/lib/view/spendManagement/reimbursement/editRemiView/epics/parseReceiptsToRemiEpic.js
CHANGED
|
@@ -6,11 +6,11 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const editRemiViewReducer_1 = require("../editRemiViewReducer");
|
|
7
7
|
const zeniDayJS_1 = require("../../../../../zeniDayJS");
|
|
8
8
|
const accountSelector_1 = require("../../../../../entity/account/accountSelector");
|
|
9
|
-
const merchantSelector_1 = require("../../../../../entity/merchant/merchantSelector");
|
|
10
|
-
const merchantPayload_1 = require("../../../../../entity/merchant/merchantPayload");
|
|
11
9
|
const attachmentPayload_1 = require("../../../../../entity/transaction/payloadTypes/attachmentPayload");
|
|
12
10
|
const classSelector_1 = require("../../../../../entity/class/classSelector");
|
|
13
11
|
const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
|
|
12
|
+
const merchantSelector_1 = require("../../../../../entity/merchant/merchantSelector");
|
|
13
|
+
const merchantPayload_1 = require("../../../../../entity/merchant/merchantPayload");
|
|
14
14
|
const parseReceiptsToRemiEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editRemiViewReducer_1.parseReceiptsToRemi.match), (0, operators_1.mergeMap)((action) => {
|
|
15
15
|
var _a;
|
|
16
16
|
const { receiptsProcessingPayload, lineId, reimbursementId, shouldOverwrite, } = action.payload;
|
|
@@ -51,6 +51,7 @@ const parseReceiptsToRemiEpic = (actions$, state$) => actions$.pipe((0, operator
|
|
|
51
51
|
let currentLineId = lineId;
|
|
52
52
|
const merchants = (0, merchantSelector_1.getMerchantsByMerchantIds)(state.merchantState, state.merchantListState.merchantIds);
|
|
53
53
|
receiptsProcessingPayload.receipts.forEach((receipt) => {
|
|
54
|
+
var _a, _b, _c;
|
|
54
55
|
const parsedMerchantId = receipt.merchant_id;
|
|
55
56
|
const parsedMerchant = merchantsById[parsedMerchantId];
|
|
56
57
|
const parsedMerchantName = parsedMerchant === null || parsedMerchant === void 0 ? void 0 : parsedMerchant.name;
|
|
@@ -58,7 +59,18 @@ const parseReceiptsToRemiEpic = (actions$, state$) => actions$.pipe((0, operator
|
|
|
58
59
|
if (parsedMerchantName != null && parsedMerchantName.length > 0) {
|
|
59
60
|
finalMerchant = merchants.filter((merchant) => merchant.name.toLowerCase() === parsedMerchantName.toLowerCase())[0];
|
|
60
61
|
}
|
|
61
|
-
newUpdatesByLineId[currentLineId] =
|
|
62
|
+
newUpdatesByLineId[currentLineId] = {
|
|
63
|
+
lineId: String(currentLineId),
|
|
64
|
+
type: 'out_of_pocket',
|
|
65
|
+
fileId: (_a = receipt.file_id) !== null && _a !== void 0 ? _a : '',
|
|
66
|
+
homeCurrencyConversions: {
|
|
67
|
+
amount: receipt.amount,
|
|
68
|
+
currencyCode: (_b = receipt.currency_code) !== null && _b !== void 0 ? _b : 'USD',
|
|
69
|
+
currencySymbol: (_c = receipt.currency_symbol) !== null && _c !== void 0 ? _c : '$',
|
|
70
|
+
},
|
|
71
|
+
outOfPocket: Object.assign({}, toUpdateLine(state.accountState, state.classState, receipt, finalMerchant, loggedInUserDepartmentId)),
|
|
72
|
+
mileage: {},
|
|
73
|
+
};
|
|
62
74
|
if (receipt.currency_code !== 'USD') {
|
|
63
75
|
currencyConversionActions.push((0, editRemiViewReducer_1.fetchCurrencyConversionValue)('USD', currentLineId.toString(), reimbursementId));
|
|
64
76
|
}
|
|
@@ -93,8 +105,8 @@ const parseReceiptsToRemiEpic = (actions$, state$) => actions$.pipe((0, operator
|
|
|
93
105
|
}
|
|
94
106
|
}));
|
|
95
107
|
exports.parseReceiptsToRemiEpic = parseReceiptsToRemiEpic;
|
|
96
|
-
const toUpdateLine = (accountState, classState, receiptPayload,
|
|
97
|
-
var _a, _b, _c
|
|
108
|
+
const toUpdateLine = (accountState, classState, receiptPayload, finalMerchant, classId) => {
|
|
109
|
+
var _a, _b, _c;
|
|
98
110
|
return {
|
|
99
111
|
merchant: finalMerchant != null
|
|
100
112
|
? {
|
|
@@ -102,15 +114,9 @@ const toUpdateLine = (accountState, classState, receiptPayload, lineId, finalMer
|
|
|
102
114
|
name: finalMerchant.name,
|
|
103
115
|
}
|
|
104
116
|
: undefined,
|
|
105
|
-
fileId: (_a = receiptPayload.file_id) !== null && _a !== void 0 ? _a : '',
|
|
106
|
-
homeCurrencyConversions: {
|
|
107
|
-
amount: receiptPayload.amount,
|
|
108
|
-
currencyCode: (_b = receiptPayload.currency_code) !== null && _b !== void 0 ? _b : 'USD',
|
|
109
|
-
currencySymbol: (_c = receiptPayload.currency_symbol) !== null && _c !== void 0 ? _c : '$',
|
|
110
|
-
},
|
|
111
117
|
description: receiptPayload.transaction_memo,
|
|
112
118
|
lineDetail: {
|
|
113
|
-
account: (0, accountSelector_1.getAccountBase)(accountState, (
|
|
119
|
+
account: (0, accountSelector_1.getAccountBase)(accountState, (_a = finalMerchant === null || finalMerchant === void 0 ? void 0 : finalMerchant.accountId) !== null && _a !== void 0 ? _a : '', 'account_list'),
|
|
114
120
|
class: classId != null
|
|
115
121
|
? (0, classSelector_1.getClassById)(classState, {
|
|
116
122
|
classId,
|
|
@@ -118,24 +124,29 @@ const toUpdateLine = (accountState, classState, receiptPayload, lineId, finalMer
|
|
|
118
124
|
})
|
|
119
125
|
: undefined,
|
|
120
126
|
},
|
|
121
|
-
lineId: String(lineId),
|
|
122
|
-
type: 'out_of_pocket',
|
|
123
127
|
transactionDate: (0, zeniDayJS_1.date)(receiptPayload.transaction_date),
|
|
124
128
|
amount: receiptPayload.amount,
|
|
125
|
-
currencyCode: (
|
|
126
|
-
currencySymbol: (
|
|
129
|
+
currencyCode: (_b = receiptPayload.currency_code) !== null && _b !== void 0 ? _b : 'USD',
|
|
130
|
+
currencySymbol: (_c = receiptPayload.currency_symbol) !== null && _c !== void 0 ? _c : '$',
|
|
131
|
+
recommendations: [],
|
|
132
|
+
isCategoryUpdateSelected: false,
|
|
133
|
+
isCategoryFirstTimeAutofilled: false,
|
|
134
|
+
isRetainedCategorySelected: false,
|
|
127
135
|
};
|
|
128
136
|
};
|
|
129
137
|
const getAutoFieldData = (reimbursementLine) => {
|
|
130
138
|
const fields = [];
|
|
131
|
-
|
|
139
|
+
const lineData = reimbursementLine.type === 'mileage'
|
|
140
|
+
? reimbursementLine.mileage
|
|
141
|
+
: reimbursementLine.outOfPocket;
|
|
142
|
+
Object.keys(lineData).forEach((item) => {
|
|
132
143
|
var _a, _b;
|
|
133
144
|
switch (item) {
|
|
134
145
|
case 'merchant':
|
|
135
146
|
fields.push('merchant');
|
|
136
147
|
break;
|
|
137
148
|
case 'amount':
|
|
138
|
-
if (
|
|
149
|
+
if (lineData.amount !== 0) {
|
|
139
150
|
fields.push('amount');
|
|
140
151
|
}
|
|
141
152
|
break;
|
|
@@ -143,12 +154,12 @@ const getAutoFieldData = (reimbursementLine) => {
|
|
|
143
154
|
fields.push('transactionDate');
|
|
144
155
|
break;
|
|
145
156
|
case 'description':
|
|
146
|
-
if (
|
|
157
|
+
if (lineData.description !== '') {
|
|
147
158
|
fields.push('memo');
|
|
148
159
|
}
|
|
149
160
|
break;
|
|
150
161
|
case 'lineDetail':
|
|
151
|
-
if (((_b = (_a =
|
|
162
|
+
if (((_b = (_a = lineData.lineDetail) === null || _a === void 0 ? void 0 : _a.account) === null || _b === void 0 ? void 0 : _b.accountId) != null) {
|
|
152
163
|
fields.push('account');
|
|
153
164
|
}
|
|
154
165
|
break;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
3
3
|
import { RootState } from '../../../../../reducer';
|
|
4
|
-
import {
|
|
4
|
+
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { updateReimbursement } from '../../../../../entity/reimbursement/reimbursementReducer';
|
|
6
6
|
import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
7
7
|
import { updateApprovalRules } from '../../../../../entity/approvalRule/approvalRuleReducer';
|
|
8
8
|
import { updateEntityApprovalStatus } from '../../../../../entity/entityApprovalStatus/entityApprovalStatusReducer';
|
|
9
|
-
import { clearDuplicateReimbursementDetail, updateRemiDetail } from '../../remiDetailView/remiDetailViewReducer';
|
|
10
9
|
import { updateMerchants } from '../../../../../entity/merchant/merchantReducer';
|
|
11
10
|
import { updateMerchantListIds } from '../../../merchantList/merchantListReducer';
|
|
12
|
-
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
13
11
|
import { updateRecommendationForEntity } from '../../../../recommendation/recommendationReducer';
|
|
12
|
+
import { clearDuplicateReimbursementDetail, updateRemiDetail } from '../../remiDetailView/remiDetailViewReducer';
|
|
13
|
+
import { saveRemiDetail, saveRemiSuccessOrFailure } from '../editRemiViewReducer';
|
|
14
14
|
export declare type ActionType = ReturnType<typeof saveRemiDetail> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateApprovalRules> | ReturnType<typeof updateEntityApprovalStatus> | ReturnType<typeof updateMerchants> | ReturnType<typeof updateRemiDetail> | ReturnType<typeof updateReimbursement> | ReturnType<typeof updateMerchantListIds> | ReturnType<typeof updateRecommendationForEntity> | ReturnType<typeof clearDuplicateReimbursementDetail> | ReturnType<typeof openSnackbar> | ReturnType<typeof saveRemiSuccessOrFailure>;
|
|
15
15
|
export declare const saveRemiDetailEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
|
|
@@ -7,20 +7,20 @@ exports.saveRemiDetailEpic = void 0;
|
|
|
7
7
|
const rxjs_1 = require("rxjs");
|
|
8
8
|
const operators_1 = require("rxjs/operators");
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
const zeniDayJS_1 = require("../../../../../zeniDayJS");
|
|
10
11
|
const responsePayload_1 = require("../../../../../responsePayload");
|
|
11
|
-
const
|
|
12
|
+
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
12
13
|
const reimbursementPayload_1 = require("../../../../../entity/reimbursement/reimbursementPayload");
|
|
13
14
|
const reimbursementReducer_1 = require("../../../../../entity/reimbursement/reimbursementReducer");
|
|
14
15
|
const userReducer_1 = require("../../../../../entity/user/userReducer");
|
|
15
16
|
const approvalRuleReducer_1 = require("../../../../../entity/approvalRule/approvalRuleReducer");
|
|
16
17
|
const entityApprovalStatusReducer_1 = require("../../../../../entity/entityApprovalStatus/entityApprovalStatusReducer");
|
|
17
|
-
const remiDetailViewReducer_1 = require("../../remiDetailView/remiDetailViewReducer");
|
|
18
18
|
const merchantReducer_1 = require("../../../../../entity/merchant/merchantReducer");
|
|
19
19
|
const merchantListReducer_1 = require("../../../merchantList/merchantListReducer");
|
|
20
|
-
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
21
|
-
const zeniDayJS_1 = require("../../../../../zeniDayJS");
|
|
22
20
|
const recommendationHelper_1 = require("../../../../recommendation/recommendationHelper");
|
|
23
21
|
const recommendationReducer_1 = require("../../../../recommendation/recommendationReducer");
|
|
22
|
+
const remiDetailViewReducer_1 = require("../../remiDetailView/remiDetailViewReducer");
|
|
23
|
+
const editRemiViewReducer_1 = require("../editRemiViewReducer");
|
|
24
24
|
const saveRemiDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(editRemiViewReducer_1.saveRemiDetail.match), (0, operators_1.mergeMap)((action) => {
|
|
25
25
|
const state = state$.value;
|
|
26
26
|
const { remiStageCode, reimbursementId, isSubmitted } = action.payload;
|
|
@@ -6,8 +6,9 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const remiDetailViewReducer_1 = require("../remiDetailViewReducer");
|
|
7
7
|
const responsePayload_1 = require("../../../../../responsePayload");
|
|
8
8
|
const reimbursementPayload_1 = require("../../../../../entity/reimbursement/reimbursementPayload");
|
|
9
|
+
const editRemiViewPayload_1 = require("../../editRemiView/editRemiViewPayload");
|
|
9
10
|
const fetchDuplicateReimbursementEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiDetailViewReducer_1.fetchDuplicateReimbursement.match), (0, operators_1.switchMap)((action) => {
|
|
10
|
-
var _a, _b, _c
|
|
11
|
+
var _a, _b, _c;
|
|
11
12
|
const { reimbursementId, signedInUserId, isManuallyTriggered } = action.payload;
|
|
12
13
|
const { editRemiDetailViewState, reimbursementState } = state$.value;
|
|
13
14
|
let lines = [];
|
|
@@ -30,9 +31,15 @@ const fetchDuplicateReimbursementEpic = (actions$, state$, zeniAPI) => actions$.
|
|
|
30
31
|
//reimbursement detail page case
|
|
31
32
|
else if (reimbursementId != null) {
|
|
32
33
|
//get from reimbursememntState
|
|
33
|
-
lines
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const currentLines = (_c = (_b = reimbursementState.reimbursementById[reimbursementId]) === null || _b === void 0 ? void 0 : _b.lines) !== null && _c !== void 0 ? _c : [];
|
|
35
|
+
lines = currentLines.map((line) => {
|
|
36
|
+
if (line.type === 'mileage') {
|
|
37
|
+
return (0, editRemiViewPayload_1.toReimbursementLineWithRecommendationFromMileage)(line);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return (0, editRemiViewPayload_1.toReimbursementLineWithRecommendationFromOutOfPocket)(line);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
36
43
|
}
|
|
37
44
|
const payload = {
|
|
38
45
|
reimbursement_provider: 'zeni',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.69",
|
|
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",
|