@zeniai/client-epic-state 4.15.18 → 4.15.20
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/customer/customerPayload.d.ts +1 -1
- package/lib/entity/customer/customerPayload.js +16 -6
- package/lib/entity/transaction/payloadTypes/customerTransactionPayload.d.ts +1 -1
- package/lib/entity/transaction/payloadTypes/customerTransactionPayload.js +1 -2
- package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/transactionPayload.js +7 -3
- package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.d.ts +9 -1
- package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.js +23 -2
- package/lib/entity/transaction/stateTypes/transaction.d.ts +2 -0
- package/lib/entity/transaction/stateTypes/vendorTransaction.d.ts +5 -0
- package/lib/entity/transaction/stateTypes/vendorTransaction.js +5 -1
- package/lib/entity/transaction/toSupportedTransaction.js +6 -1
- package/lib/entity/transaction/transactionState.d.ts +4 -4
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +16 -12
- package/lib/view/expenseAutomationView/epics/transactionCategorization/updateTransactionCategorizationEpic.js +20 -4
- package/lib/view/expenseAutomationView/helpers/saveTransactionHelper.js +81 -30
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +54 -10
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +5 -4
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +8 -0
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +13 -4
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +16 -3
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +22 -5
- package/lib/view/transactionDetail/transactionDetailState.d.ts +1 -0
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +6 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ export interface CustomerBasePayload {
|
|
|
7
7
|
logo?: URLPayload;
|
|
8
8
|
}
|
|
9
9
|
export declare const toCustomerBase: (payload: CustomerBasePayload, parseOutParentName: boolean) => CustomerBase;
|
|
10
|
-
export declare const toCustomerBasePayload: (customer: CustomerBase | undefined) => CustomerBasePayload;
|
|
10
|
+
export declare const toCustomerBasePayload: (customer: CustomerBase | undefined, customerUpdates?: CustomerBase) => CustomerBasePayload;
|
|
11
11
|
export interface CustomerPayload extends CustomerBasePayload {
|
|
12
12
|
currency_symbol: string | null;
|
|
13
13
|
currency_code: string | null;
|
|
@@ -12,13 +12,23 @@ const toCustomerBase = (payload, parseOutParentName) => ({
|
|
|
12
12
|
logo: payload.logo != null ? (0, urlPayload_1.toURL)(payload.logo) : undefined,
|
|
13
13
|
});
|
|
14
14
|
exports.toCustomerBase = toCustomerBase;
|
|
15
|
-
const toCustomerBasePayload = (customer) => {
|
|
15
|
+
const toCustomerBasePayload = (customer, customerUpdates) => {
|
|
16
16
|
var _a, _b;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
if (customer != null && customer.id != null) {
|
|
18
|
+
return {
|
|
19
|
+
customer_id: customer.id,
|
|
20
|
+
customer_name: customer.name,
|
|
21
|
+
qbo_id: customer.qboId,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Customer field is read-only in v1. Will require customerUpdates when made editable
|
|
26
|
+
return {
|
|
27
|
+
customer_id: (_a = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.id) !== null && _a !== void 0 ? _a : '',
|
|
28
|
+
customer_name: (_b = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.name) !== null && _b !== void 0 ? _b : '',
|
|
29
|
+
qbo_id: customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.qboId,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
22
32
|
};
|
|
23
33
|
exports.toCustomerBasePayload = toCustomerBasePayload;
|
|
24
34
|
const toCustomer = (payload, parseOutParentName = false) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomerBasePayload } from '../../customer/customerPayload';
|
|
2
2
|
import { CustomerTransaction } from '../stateTypes/customerTransaction';
|
|
3
3
|
import { TransactionPayload } from './transactionPayload';
|
|
4
|
-
export interface CustomerTransactionPayload extends TransactionPayload, CustomerBasePayload {
|
|
4
|
+
export interface CustomerTransactionPayload extends Omit<TransactionPayload, 'customer_id' | 'customer_name'>, CustomerBasePayload {
|
|
5
5
|
document_id: string;
|
|
6
6
|
payment_type?: string;
|
|
7
7
|
payment_type_name?: string;
|
|
@@ -17,7 +17,6 @@ const toCustomerTransaction = (payload) => {
|
|
|
17
17
|
exports.toCustomerTransaction = toCustomerTransaction;
|
|
18
18
|
const toCustomerTransactionPayload = (transaction) => {
|
|
19
19
|
const payload = (0, transactionPayload_1.toTransactionPayload)(transaction);
|
|
20
|
-
return transaction.customer
|
|
21
|
-
? Object.assign(Object.assign({}, payload), { customer_id: transaction.customer.id, customer_name: transaction.customer.name }) : payload;
|
|
20
|
+
return Object.assign(Object.assign({}, payload), (0, customerPayload_1.toCustomerBasePayload)(transaction.customer));
|
|
22
21
|
};
|
|
23
22
|
exports.toCustomerTransactionPayload = toCustomerTransactionPayload;
|
|
@@ -32,6 +32,8 @@ export interface TransactionPayload extends TransactionIDPayload, AccountBasePay
|
|
|
32
32
|
company_inc_date: string | null;
|
|
33
33
|
vendor_id?: string | null;
|
|
34
34
|
vendor_name?: string | null;
|
|
35
|
+
customer_id?: string | null;
|
|
36
|
+
customer_name?: string | null;
|
|
35
37
|
recipient_total_amount?: number;
|
|
36
38
|
recipient_currency_code?: string;
|
|
37
39
|
recipient_currency_symbol?: string;
|
|
@@ -38,12 +38,16 @@ const toTransaction = (payload) => {
|
|
|
38
38
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
39
39
|
const amount = (0, exports.getTransactionPayloadAmount)(payload);
|
|
40
40
|
const recipientAmount = getTransactionPayloadRecipientAmount(payload);
|
|
41
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, transactionIDPayload_1.toTransactionID)(payload)), { typeOfTransaction: 'supported', typeName: payload.transaction_type_name, createTime: (0, zeniDayJS_1.date)(payload.transaction_create_time), updateTime: payload.transaction_update_time != null
|
|
41
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, transactionIDPayload_1.toTransactionID)(payload)), { typeOfTransaction: 'supported', typeName: payload.transaction_type_name, createTime: (0, zeniDayJS_1.date)(payload.transaction_create_time), updateTime: payload.transaction_update_time != null
|
|
42
42
|
? (0, zeniDayJS_1.date)(payload.transaction_update_time)
|
|
43
|
-
: undefined, date: (0, zeniDayJS_1.date)(payload.transaction_date), amount: amount, memo: payload.transaction_memo, description: payload.transaction_description, documentId: payload.document_id, logo: (0, urlPayload_1.toURL)(payload.logo), attachments: (_a = payload.attachments) === null || _a === void 0 ? void 0 : _a.map((attachmentPayload) => (0, attachmentPayload_1.toAttachment)(attachmentPayload)) }), (payload.vendor_id
|
|
43
|
+
: undefined, date: (0, zeniDayJS_1.date)(payload.transaction_date), amount: amount, memo: payload.transaction_memo, description: payload.transaction_description, documentId: payload.document_id, logo: (0, urlPayload_1.toURL)(payload.logo), attachments: (_a = payload.attachments) === null || _a === void 0 ? void 0 : _a.map((attachmentPayload) => (0, attachmentPayload_1.toAttachment)(attachmentPayload)) }), (payload.vendor_id !== null && payload.vendor_id !== ''
|
|
44
44
|
? { vendorId: payload.vendor_id }
|
|
45
|
-
: {})), (payload.vendor_name
|
|
45
|
+
: {})), (payload.vendor_name !== null && payload.vendor_name !== ''
|
|
46
46
|
? { vendorName: payload.vendor_name }
|
|
47
|
+
: {})), (payload.customer_id !== null && payload.customer_id !== ''
|
|
48
|
+
? { customerId: payload.customer_id }
|
|
49
|
+
: {})), (payload.customer_name !== null && payload.customer_name !== ''
|
|
50
|
+
? { customerName: payload.customer_name }
|
|
47
51
|
: {})), { linkedTransactions: (_b = payload.linked_transactions) === null || _b === void 0 ? void 0 : _b.map((transactionIDPayload) => (0, transactionIDPayload_1.toTransactionID)(transactionIDPayload)), lines: (_c = payload === null || payload === void 0 ? void 0 : payload.lines) === null || _c === void 0 ? void 0 : _c.map((linePayload) => (0, transactionLinePayload_1.toLine)(linePayload, amount, recipientAmount)), account: payloadHasAccountInfo(payload)
|
|
48
52
|
? (0, accountPayload_1.mapAccountBasePayloadToAccountBase)(payload)
|
|
49
53
|
: undefined, syncToken: (_d = payload.sync_token) === null || _d === void 0 ? void 0 : _d.toString(), paymentType: (_e = payload.payment_type) !== null && _e !== void 0 ? _e : undefined, paymentTypeName: (_f = payload.payment_type_name) !== null && _f !== void 0 ? _f : undefined, isUpdatingTransaction: (_g = payload === null || payload === void 0 ? void 0 : payload.is_updating_transaction) !== null && _g !== void 0 ? _g : false, bookCloseDate: (payload === null || payload === void 0 ? void 0 : payload.book_close_date) != null
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { CustomerBase } from '../../customer/customerState';
|
|
1
2
|
import { VendorBasePayload } from '../../vendor/vendorPayload';
|
|
2
3
|
import { VendorBase } from '../../vendor/vendorState';
|
|
3
|
-
import { VendorTransaction } from '../stateTypes/vendorTransaction';
|
|
4
|
+
import { VendorTransaction, VendorTransactionWithCustomer } from '../stateTypes/vendorTransaction';
|
|
4
5
|
import { TransactionPayload } from './transactionPayload';
|
|
5
6
|
export interface VendorTransactionPayload extends VendorBasePayload, Omit<TransactionPayload, 'vendor_id' | 'vendor_name'> {
|
|
6
7
|
document_id: string;
|
|
@@ -10,6 +11,13 @@ export interface VendorTransactionPayload extends VendorBasePayload, Omit<Transa
|
|
|
10
11
|
balance?: number;
|
|
11
12
|
due_date?: string;
|
|
12
13
|
}
|
|
14
|
+
export interface VendorTransactionWithCustomerPayload extends VendorTransactionPayload {
|
|
15
|
+
customer_id: string;
|
|
16
|
+
customer_name: string;
|
|
17
|
+
}
|
|
13
18
|
export declare const isVendorTransactionPayload: (payload: TransactionPayload) => boolean;
|
|
14
19
|
export declare const toVendorTransaction: (payload: VendorTransactionPayload) => VendorTransaction;
|
|
15
20
|
export declare const toVendorTransactionPayload: (transaction: VendorTransaction, vendorUpdates?: VendorBase) => Partial<VendorTransactionPayload>;
|
|
21
|
+
export declare const isVendorTransactionWithCustomerPayload: (payload: TransactionPayload) => boolean;
|
|
22
|
+
export declare const toVendorTransactionWithCustomer: (payload: VendorTransactionWithCustomerPayload) => VendorTransactionWithCustomer;
|
|
23
|
+
export declare const toVendorTransactionWithCustomerPayload: (transaction: VendorTransactionWithCustomer, vendorUpdates?: VendorBase, customerUpdates?: CustomerBase) => Partial<VendorTransactionWithCustomerPayload>;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toVendorTransactionPayload = exports.toVendorTransaction = exports.isVendorTransactionPayload = void 0;
|
|
3
|
+
exports.toVendorTransactionWithCustomerPayload = exports.toVendorTransactionWithCustomer = exports.isVendorTransactionWithCustomerPayload = exports.toVendorTransactionPayload = exports.toVendorTransaction = exports.isVendorTransactionPayload = void 0;
|
|
4
4
|
const amount_1 = require("../../../commonStateTypes/amount");
|
|
5
5
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
6
|
+
const customerPayload_1 = require("../../customer/customerPayload");
|
|
6
7
|
const vendorPayload_1 = require("../../vendor/vendorPayload");
|
|
7
8
|
const paymentType_1 = require("../stateTypes/paymentType");
|
|
8
9
|
const transactionType_1 = require("../stateTypes/transactionType");
|
|
9
10
|
const transactionPayload_1 = require("./transactionPayload");
|
|
10
11
|
const isVendorTransactionPayload = (payload) => (0, transactionType_1.toVendorTransactionTypeStrict)(payload.transaction_type) != null;
|
|
11
12
|
exports.isVendorTransactionPayload = isVendorTransactionPayload;
|
|
12
|
-
|
|
13
|
+
function buildVendorTransactionBase(payload) {
|
|
13
14
|
const transaction = (0, transactionPayload_1.toTransaction)(payload);
|
|
14
15
|
return Object.assign(Object.assign({}, transaction), { documentId: payload.document_id, vendor: payload.vendor_id != null
|
|
15
16
|
? (0, vendorPayload_1.mapVendorBasePayloadToVendorBase)(payload)
|
|
16
17
|
: undefined, paymentType: (0, paymentType_1.toPaymentTypeStrict)(payload.payment_type), paymentTypeName: payload.payment_type_name, paymentMethodName: payload.payment_method_name, balance: payload.balance != null
|
|
17
18
|
? (0, amount_1.toAmountWC)(payload.balance, transaction.amount)
|
|
18
19
|
: undefined, dueDate: payload.due_date != null ? (0, zeniDayJS_1.date)(payload.due_date) : undefined });
|
|
20
|
+
}
|
|
21
|
+
const toVendorTransaction = (payload) => {
|
|
22
|
+
return buildVendorTransactionBase(payload);
|
|
19
23
|
};
|
|
20
24
|
exports.toVendorTransaction = toVendorTransaction;
|
|
21
25
|
const toVendorTransactionPayload = (transaction, vendorUpdates) => {
|
|
@@ -23,3 +27,20 @@ const toVendorTransactionPayload = (transaction, vendorUpdates) => {
|
|
|
23
27
|
return Object.assign(Object.assign({}, payload), (0, vendorPayload_1.toVendorBasePayload)(transaction.vendor, vendorUpdates));
|
|
24
28
|
};
|
|
25
29
|
exports.toVendorTransactionPayload = toVendorTransactionPayload;
|
|
30
|
+
/*
|
|
31
|
+
This is used to check if the transaction is a vendor transaction with a customer
|
|
32
|
+
*/
|
|
33
|
+
const isVendorTransactionWithCustomerPayload = (payload) => (0, transactionType_1.toVendorTransactionTypeStrict)(payload.transaction_type) != null &&
|
|
34
|
+
Boolean(payload.customer_id) === true &&
|
|
35
|
+
Boolean(payload.customer_name) === true;
|
|
36
|
+
exports.isVendorTransactionWithCustomerPayload = isVendorTransactionWithCustomerPayload;
|
|
37
|
+
const toVendorTransactionWithCustomer = (payload) => {
|
|
38
|
+
return Object.assign(Object.assign({}, buildVendorTransactionBase(payload)), { customer: Boolean(payload.customer_id) === true
|
|
39
|
+
? (0, customerPayload_1.toCustomerBase)(payload, false)
|
|
40
|
+
: undefined });
|
|
41
|
+
};
|
|
42
|
+
exports.toVendorTransactionWithCustomer = toVendorTransactionWithCustomer;
|
|
43
|
+
const toVendorTransactionWithCustomerPayload = (transaction, vendorUpdates, customerUpdates) => {
|
|
44
|
+
return Object.assign(Object.assign({}, (0, exports.toVendorTransactionPayload)(transaction, vendorUpdates)), (0, customerPayload_1.toCustomerBasePayload)(transaction.customer, customerUpdates));
|
|
45
|
+
};
|
|
46
|
+
exports.toVendorTransactionWithCustomerPayload = toVendorTransactionWithCustomerPayload;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
2
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
3
|
+
import { CustomerBase } from '../../customer/customerState';
|
|
3
4
|
import { VendorBase } from '../../vendor/vendorState';
|
|
4
5
|
import { PaymentType } from './paymentType';
|
|
5
6
|
import { Transaction } from './transaction';
|
|
@@ -11,4 +12,8 @@ export interface VendorTransaction extends Transaction {
|
|
|
11
12
|
balance?: Amount;
|
|
12
13
|
dueDate?: ZeniDate;
|
|
13
14
|
}
|
|
15
|
+
export interface VendorTransactionWithCustomer extends VendorTransaction {
|
|
16
|
+
customer?: CustomerBase;
|
|
17
|
+
}
|
|
14
18
|
export declare const isVendorTransaction: (transaction: Transaction) => boolean;
|
|
19
|
+
export declare const isVendorTransactionWithCustomer: (transaction: Transaction) => boolean;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isVendorTransaction = void 0;
|
|
3
|
+
exports.isVendorTransactionWithCustomer = exports.isVendorTransaction = void 0;
|
|
4
4
|
const transactionType_1 = require("./transactionType");
|
|
5
5
|
const isVendorTransaction = (transaction) => (0, transactionType_1.toVendorTransactionTypeStrict)(transaction.type) != null;
|
|
6
6
|
exports.isVendorTransaction = isVendorTransaction;
|
|
7
|
+
const isVendorTransactionWithCustomer = (transaction) => (0, transactionType_1.toVendorTransactionTypeStrict)(transaction.type) != null &&
|
|
8
|
+
Boolean(transaction.customerId) === true &&
|
|
9
|
+
Boolean(transaction.customerName) === true;
|
|
10
|
+
exports.isVendorTransactionWithCustomer = isVendorTransactionWithCustomer;
|
|
@@ -10,7 +10,12 @@ function toSupportedTransaction(payload) {
|
|
|
10
10
|
return (0, customerTransactionPayload_1.toCustomerTransaction)(payload);
|
|
11
11
|
}
|
|
12
12
|
else if ((0, vendorTransactionPayload_1.isVendorTransactionPayload)(payload)) {
|
|
13
|
-
|
|
13
|
+
if ((0, vendorTransactionPayload_1.isVendorTransactionWithCustomerPayload)(payload)) {
|
|
14
|
+
return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomer)(payload);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return (0, vendorTransactionPayload_1.toVendorTransaction)(payload);
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
else if ((0, otherTransactionPayload_1.isTransferTransactionPayload)(payload)) {
|
|
16
21
|
return (0, otherTransactionPayload_1.toTransferTransaction)(payload);
|
|
@@ -2,14 +2,14 @@ import { ID } from '../../commonStateTypes/common';
|
|
|
2
2
|
import { TransactionDetailKey, ZeniTransactionDetailKey } from '../../view/transactionDetail/transactionDetailState';
|
|
3
3
|
import { CustomerTransactionPayload } from './payloadTypes/customerTransactionPayload';
|
|
4
4
|
import { TransactionPayload } from './payloadTypes/transactionPayload';
|
|
5
|
-
import { VendorTransactionPayload } from './payloadTypes/vendorTransactionPayload';
|
|
5
|
+
import { VendorTransactionPayload, VendorTransactionWithCustomerPayload } from './payloadTypes/vendorTransactionPayload';
|
|
6
6
|
import { CustomerTransaction } from './stateTypes/customerTransaction';
|
|
7
7
|
import { MatchedTransaction } from './stateTypes/reconciliationTransaction';
|
|
8
8
|
import { ScheduleTransaction } from './stateTypes/scheduleTransaction';
|
|
9
9
|
import { Transaction } from './stateTypes/transaction';
|
|
10
|
-
import { VendorTransaction } from './stateTypes/vendorTransaction';
|
|
11
|
-
export type SupportedTransaction = Transaction | CustomerTransaction | VendorTransaction;
|
|
12
|
-
export type SupportedTransactionPayload = TransactionPayload | CustomerTransactionPayload | VendorTransactionPayload;
|
|
10
|
+
import { VendorTransaction, VendorTransactionWithCustomer } from './stateTypes/vendorTransaction';
|
|
11
|
+
export type SupportedTransaction = Transaction | CustomerTransaction | VendorTransaction | VendorTransactionWithCustomer;
|
|
12
|
+
export type SupportedTransactionPayload = TransactionPayload | CustomerTransactionPayload | VendorTransactionPayload | VendorTransactionWithCustomerPayload;
|
|
13
13
|
export type AllSupportedTransactions = SupportedTransaction | undefined;
|
|
14
14
|
export interface TransactionState {
|
|
15
15
|
transactionById: Record<ID | TransactionDetailKey, SupportedTransaction | undefined>;
|
|
@@ -14,6 +14,8 @@ const transactionsViewReducer_1 = require("../../reducers/transactionsViewReduce
|
|
|
14
14
|
const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(expenseAutomationViewReducer_1.fetchAllExpenseAutomationTabs.match), (0, operators_1.switchMap)((action) => {
|
|
15
15
|
const { cacheOverride, refreshViewInBackground } = action.payload;
|
|
16
16
|
const state = state$.value;
|
|
17
|
+
const { monthEndCloseChecksState } = state;
|
|
18
|
+
const { monthEndCloseChecksByTenantId } = monthEndCloseChecksState;
|
|
17
19
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
18
20
|
const companyId = currentTenant.companyId;
|
|
19
21
|
const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -22,23 +24,24 @@ const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0
|
|
|
22
24
|
const timePeriodStart = (0, timePeriod_1.toAbsoluteDay)(period.start);
|
|
23
25
|
const timePeriodEnd = (0, timePeriod_1.toAbsoluteDay)(period.end);
|
|
24
26
|
const monthYearPeriodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
27
|
+
const monthEndCheckState = monthEndCloseChecksByTenantId[currentTenant.tenantId][monthYearPeriodId];
|
|
28
|
+
const reconciliationEnabled = monthEndCheckState.monthEndCloseCheckList.find((list) => list.id === 'reconciliation');
|
|
25
29
|
if (timePeriodStart == null ||
|
|
26
30
|
timePeriodEnd == null ||
|
|
27
31
|
companyId == null) {
|
|
28
32
|
throw Error(`Invalid start - ${timePeriodStart} and end - ${timePeriodEnd} period from given ${selectedPeriod}`);
|
|
29
33
|
}
|
|
30
34
|
if (cacheOverride === true) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
(0,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
]);
|
|
35
|
+
const actions = [];
|
|
36
|
+
actions.push((0, transactionsViewReducer_1.fetchTransactionCategorizationView)(selectedTransactionCategorizationTab, { start: timePeriodStart, end: timePeriodEnd }, cacheOverride, false, undefined, undefined, refreshViewInBackground), (0, missingReceiptsViewReducer_1.fetchMissingReceipts)({ start: timePeriodStart, end: timePeriodEnd }, {
|
|
37
|
+
amount: 75.0,
|
|
38
|
+
currencyCode: 'USD',
|
|
39
|
+
currencySymbol: '$',
|
|
40
|
+
}, cacheOverride, refreshViewInBackground), (0, fluxAnalysisViewReducer_1.fetchFluxAnalysisView)(selectedPeriod, cacheOverride, refreshViewInBackground, null), (0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
|
|
41
|
+
if (reconciliationEnabled) {
|
|
42
|
+
actions.push((0, reconciliationViewReducer_1.fetchReconciliation)(selectedPeriod, undefined, cacheOverride, refreshViewInBackground));
|
|
43
|
+
}
|
|
44
|
+
return (0, rxjs_1.from)(actions);
|
|
42
45
|
}
|
|
43
46
|
else {
|
|
44
47
|
const fetchActions = [];
|
|
@@ -74,7 +77,8 @@ const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0
|
|
|
74
77
|
'In-Progress' &&
|
|
75
78
|
state.expenseAutomationReconciliationViewState
|
|
76
79
|
.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId] ==
|
|
77
|
-
null
|
|
80
|
+
null &&
|
|
81
|
+
reconciliationEnabled) {
|
|
78
82
|
fetchActions.push((0, reconciliationViewReducer_1.fetchReconciliation)(selectedPeriod, undefined, cacheOverride, refreshViewInBackground));
|
|
79
83
|
}
|
|
80
84
|
if (state.expenseAutomationTransactionsViewState
|
|
@@ -40,11 +40,12 @@ const updateTransactionCategorizationEpic = (actions$, state$, zeniAPI) => actio
|
|
|
40
40
|
}));
|
|
41
41
|
exports.updateTransactionCategorizationEpic = updateTransactionCategorizationEpic;
|
|
42
42
|
function prepareTransactionPayload(selectedTab, transactionState, vendorState, transactionsViewState, transactionId, saveUpdates) {
|
|
43
|
-
var _a;
|
|
43
|
+
var _a, _b;
|
|
44
44
|
const detail = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionId);
|
|
45
45
|
const tranDetail = (0, get_1.default)(transactionsViewState.transactionCategorizationView[selectedTab]
|
|
46
46
|
.transactionReviewLocalDataById, transactionId, undefined);
|
|
47
47
|
const tranVendorUpdates = (_a = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionReviewLocalData) === null || _a === void 0 ? void 0 : _a.vendorUpdates;
|
|
48
|
+
const tranCustomerUpdates = (_b = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionReviewLocalData) === null || _b === void 0 ? void 0 : _b.customerUpdates;
|
|
48
49
|
let vendorUpdates = undefined;
|
|
49
50
|
if ((tranVendorUpdates === null || tranVendorUpdates === void 0 ? void 0 : tranVendorUpdates.qboId) != null) {
|
|
50
51
|
const vendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, tranVendorUpdates.qboId);
|
|
@@ -61,8 +62,15 @@ function prepareTransactionPayload(selectedTab, transactionState, vendorState, t
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
}
|
|
65
|
+
let customerUpdates = undefined;
|
|
66
|
+
if ((tranCustomerUpdates === null || tranCustomerUpdates === void 0 ? void 0 : tranCustomerUpdates.qboId) != null) {
|
|
67
|
+
customerUpdates = {
|
|
68
|
+
id: tranCustomerUpdates.qboId,
|
|
69
|
+
name: tranCustomerUpdates.name,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
64
72
|
if (detail != null) {
|
|
65
|
-
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates);
|
|
73
|
+
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates, customerUpdates);
|
|
66
74
|
const entityUpdates = toEntityUpdatePayload(saveUpdates.entityRelatedUpdates);
|
|
67
75
|
return {
|
|
68
76
|
entity_related_updates: entityUpdates,
|
|
@@ -91,12 +99,14 @@ function preparePayload(selectedTab, transactionState, vendorState, transactions
|
|
|
91
99
|
return payload;
|
|
92
100
|
}
|
|
93
101
|
}
|
|
94
|
-
const toTransactionUpdatePayload = (updates, detail, vendorUpdates) => {
|
|
102
|
+
const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpdates) => {
|
|
95
103
|
var _a, _b;
|
|
96
104
|
const transaction = Object.assign({}, detail);
|
|
97
105
|
transaction.memo = (_a = updates.memo) !== null && _a !== void 0 ? _a : '';
|
|
98
106
|
transaction.vendorId = vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.id;
|
|
99
107
|
transaction.vendorName = vendorUpdates === null || vendorUpdates === void 0 ? void 0 : vendorUpdates.name;
|
|
108
|
+
transaction.customerId = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.id;
|
|
109
|
+
transaction.customerName = customerUpdates === null || customerUpdates === void 0 ? void 0 : customerUpdates.name;
|
|
100
110
|
const recommendationUpdates = {};
|
|
101
111
|
for (const key in updates.updatesByLineId) {
|
|
102
112
|
const lineUpdates = updates.updatesByLineId[key];
|
|
@@ -133,11 +143,17 @@ const toTransactionUpdatePayload = (updates, detail, vendorUpdates) => {
|
|
|
133
143
|
transaction.lines = newLineMap;
|
|
134
144
|
}
|
|
135
145
|
transaction.recommendations = recommendationUpdates;
|
|
146
|
+
// Added this check because now customer are also part of Expense,Journal Entry and Check type of transactions
|
|
136
147
|
if ((0, customerTransaction_1.isCustomerTransaction)(transaction)) {
|
|
137
148
|
return (0, customerTransactionPayload_1.toCustomerTransactionPayload)(transaction);
|
|
138
149
|
}
|
|
139
150
|
else if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
140
|
-
|
|
151
|
+
if ((0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction)) {
|
|
152
|
+
return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomerPayload)(transaction, vendorUpdates, customerUpdates);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return (0, vendorTransactionPayload_1.toVendorTransactionPayload)(transaction, vendorUpdates);
|
|
156
|
+
}
|
|
141
157
|
}
|
|
142
158
|
else if ((0, otherTransaction_1.isTransferTransaction)(transaction)) {
|
|
143
159
|
return (0, otherTransactionPayload_1.toTransferTransactionPayload)(transaction);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toTransactionUpdatesFromTransactionCategorizationLocalData = void 0;
|
|
4
4
|
const entity_1 = require("../../../entity/genericEntity/entity");
|
|
5
|
+
const customerTransaction_1 = require("../../../entity/transaction/stateTypes/customerTransaction");
|
|
5
6
|
const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
|
|
6
7
|
const recommendationState_1 = require("../../recommendation/recommendationState");
|
|
7
8
|
const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTransactionHelper");
|
|
@@ -10,7 +11,7 @@ const saveTransactionHelper_1 = require("../../transactionDetail/epics/saveTrans
|
|
|
10
11
|
* @param transactionCategorizationLocalData
|
|
11
12
|
*/
|
|
12
13
|
const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionCategorizationLocalData, transaction, uncategorizedIncomeExpense) => {
|
|
13
|
-
var _a, _b
|
|
14
|
+
var _a, _b;
|
|
14
15
|
const updates = {
|
|
15
16
|
updatesByLineId: {},
|
|
16
17
|
};
|
|
@@ -22,22 +23,18 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
22
23
|
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) === true) {
|
|
23
24
|
updates.vendorId = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.id;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
qboId: transaction.vendorId,
|
|
31
|
-
zeniId: transaction.vendorId,
|
|
32
|
-
}
|
|
33
|
-
: undefined;
|
|
26
|
+
// This needs to be changed to customerUpdates as of now we are not updating customerId so we are using the one from the transaction
|
|
27
|
+
if ((0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction) === true) {
|
|
28
|
+
updates.customerId = transaction.customerId;
|
|
29
|
+
}
|
|
30
|
+
const entity = getEntityFromTransaction(transaction);
|
|
34
31
|
let lastUpdatedCategory;
|
|
35
32
|
let lastUpdatedClass;
|
|
36
33
|
// single recommendation to just pick the last recommendation in the list of lines
|
|
37
|
-
(
|
|
38
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
39
|
-
const updatedEntityId = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId;
|
|
40
|
-
const entityDetails = getEntityDetails(entity, transactionCategorizationLocalData.lineItemById[line.id], transactionCategorizationLocalData.vendorUpdates);
|
|
34
|
+
(_b = transaction.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
36
|
+
const updatedEntityId = (_b = (_a = transactionCategorizationLocalData.vendorUpdates) === null || _a === void 0 ? void 0 : _a.qboId) !== null && _b !== void 0 ? _b : (_c = transactionCategorizationLocalData.customerUpdates) === null || _c === void 0 ? void 0 : _c.qboId;
|
|
37
|
+
const entityDetails = getEntityDetails(entity, transactionCategorizationLocalData.lineItemById[line.id], transactionCategorizationLocalData.vendorUpdates, transactionCategorizationLocalData.customerUpdates);
|
|
41
38
|
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
42
39
|
line.type === 'transaction_with_product_or_service_line' ||
|
|
43
40
|
line.type === 'journal_entry_transaction_line') {
|
|
@@ -50,24 +47,28 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
50
47
|
};
|
|
51
48
|
if (line.type === 'journal_entry_transaction_line' ||
|
|
52
49
|
line.platformLineDetailType === 'deposit_line_detail') {
|
|
53
|
-
updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { vendor: lineItem.vendor });
|
|
50
|
+
updatesByLineId[line.id] = Object.assign(Object.assign({}, updatesByLineId[line.id]), { vendor: lineItem.vendor, customer: lineItem.customer });
|
|
54
51
|
}
|
|
55
52
|
let hasCategoryChanged = false;
|
|
56
53
|
let hasClassChanged = false;
|
|
57
54
|
const accountLine = line;
|
|
58
55
|
hasCategoryChanged =
|
|
59
|
-
((
|
|
60
|
-
Boolean((
|
|
56
|
+
((_d = lineItem.account) === null || _d === void 0 ? void 0 : _d.qboId) !== accountLine.account.qboId &&
|
|
57
|
+
Boolean((_e = lineItem.account) === null || _e === void 0 ? void 0 : _e.qboId);
|
|
61
58
|
hasClassChanged =
|
|
62
|
-
Boolean((
|
|
63
|
-
((
|
|
59
|
+
Boolean((_f = lineItem.class) === null || _f === void 0 ? void 0 : _f.qboId) &&
|
|
60
|
+
((_g = lineItem.class) === null || _g === void 0 ? void 0 : _g.qboId) !== accountLine.class.qboId;
|
|
64
61
|
const recommendedAccountBase = (0, saveTransactionHelper_1.toRecommendedAccountBase)(lineItem.amount.amount, lineItem.account);
|
|
65
62
|
const recommendedClassBase = (0, saveTransactionHelper_1.toRecommendedClassBase)(lineItem.amount.amount, lineItem.class);
|
|
66
|
-
const updatedLineEntityId = ((
|
|
67
|
-
? ((
|
|
68
|
-
? (
|
|
69
|
-
: (
|
|
70
|
-
:
|
|
63
|
+
const updatedLineEntityId = ((_h = accountLine.vendor) === null || _h === void 0 ? void 0 : _h.id) != null
|
|
64
|
+
? ((_j = accountLine.vendor) === null || _j === void 0 ? void 0 : _j.id) != ((_k = lineItem.vendor) === null || _k === void 0 ? void 0 : _k.id)
|
|
65
|
+
? (_l = lineItem.vendor) === null || _l === void 0 ? void 0 : _l.id
|
|
66
|
+
: (_m = accountLine.vendor) === null || _m === void 0 ? void 0 : _m.id
|
|
67
|
+
: ((_o = accountLine.customer) === null || _o === void 0 ? void 0 : _o.id) != null
|
|
68
|
+
? ((_p = accountLine.customer) === null || _p === void 0 ? void 0 : _p.id) != ((_q = lineItem.customer) === null || _q === void 0 ? void 0 : _q.id)
|
|
69
|
+
? (_r = lineItem.customer) === null || _r === void 0 ? void 0 : _r.id
|
|
70
|
+
: (_s = accountLine.customer) === null || _s === void 0 ? void 0 : _s.id
|
|
71
|
+
: undefined;
|
|
71
72
|
if (entityDetails != null &&
|
|
72
73
|
(hasCategoryChanged === true || hasClassChanged === true)) {
|
|
73
74
|
lastUpdatedCategory =
|
|
@@ -83,16 +84,16 @@ const toTransactionUpdatesFromTransactionCategorizationLocalData = (transactionC
|
|
|
83
84
|
if (recommended.class != null ||
|
|
84
85
|
recommended.account != null ||
|
|
85
86
|
updatedEntityId != null) {
|
|
86
|
-
const vendorIdToUpdate = (
|
|
87
|
-
let entityId = entityDetails.entityId;
|
|
87
|
+
const vendorIdToUpdate = (_t = transactionCategorizationLocalData.vendorUpdates) === null || _t === void 0 ? void 0 : _t.qboId;
|
|
88
88
|
if (line.type === 'journal_entry_transaction_line' ||
|
|
89
89
|
line.platformLineDetailType === 'deposit_line_detail') {
|
|
90
|
-
const entityId = (
|
|
90
|
+
const entityId = (_v = (_u = accountLine.vendor) === null || _u === void 0 ? void 0 : _u.id) !== null && _v !== void 0 ? _v : (_w = accountLine.customer) === null || _w === void 0 ? void 0 : _w.id;
|
|
91
91
|
if (entityId != null) {
|
|
92
92
|
doUpdateEntityUpdates(entityUpdates, entityId, entityDetails.entityType, recommended, false, updatedLineEntityId);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
|
+
let entityId = entityDetails.entityId;
|
|
96
97
|
if (vendorIdToUpdate != null) {
|
|
97
98
|
entityId = vendorIdToUpdate;
|
|
98
99
|
}
|
|
@@ -135,8 +136,8 @@ const doUpdateEntityUpdates = (entityUpdates, entityId, entityType, recommendati
|
|
|
135
136
|
entityUpdates[entityKey] = Object.assign(Object.assign({}, entityUpdate), { recommendations: recommendation });
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
|
-
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
|
|
139
|
-
var _a, _b, _c;
|
|
139
|
+
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates) => {
|
|
140
|
+
var _a, _b, _c, _d;
|
|
140
141
|
if (entity != null) {
|
|
141
142
|
return {
|
|
142
143
|
entityId: (_a = entity.qboId) !== null && _a !== void 0 ? _a : entity.id,
|
|
@@ -155,7 +156,19 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
|
|
|
155
156
|
entityType: 'vendor',
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
|
-
if (
|
|
159
|
+
if (customerUpdates != null && customerUpdates.id != null) {
|
|
160
|
+
return {
|
|
161
|
+
entityId: customerUpdates.id,
|
|
162
|
+
entityType: 'customer',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (((_c = lineItemLocalData.customer) === null || _c === void 0 ? void 0 : _c.id) != null) {
|
|
166
|
+
return {
|
|
167
|
+
entityId: lineItemLocalData.customer.id,
|
|
168
|
+
entityType: 'customer',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (((_d = lineItemLocalData.vendor) === null || _d === void 0 ? void 0 : _d.id) != null) {
|
|
159
172
|
return {
|
|
160
173
|
entityId: lineItemLocalData.vendor.id,
|
|
161
174
|
entityType: 'vendor',
|
|
@@ -163,3 +176,41 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
|
|
|
163
176
|
}
|
|
164
177
|
return undefined;
|
|
165
178
|
};
|
|
179
|
+
const getEntityFromTransaction = (transaction) => {
|
|
180
|
+
if ((0, vendorTransaction_1.isVendorTransaction)(transaction) ||
|
|
181
|
+
(0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction)) {
|
|
182
|
+
const vendor = transaction.vendor;
|
|
183
|
+
const customer = transaction.customer;
|
|
184
|
+
if (customer != null) {
|
|
185
|
+
return {
|
|
186
|
+
id: customer.id,
|
|
187
|
+
name: customer.name,
|
|
188
|
+
type: (0, entity_1.toEntityType)('customer'),
|
|
189
|
+
qboId: customer.id,
|
|
190
|
+
zeniId: customer.id,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (vendor != null) {
|
|
194
|
+
return {
|
|
195
|
+
id: vendor.id,
|
|
196
|
+
name: vendor.name,
|
|
197
|
+
type: (0, entity_1.toEntityType)('vendor'),
|
|
198
|
+
qboId: vendor.id,
|
|
199
|
+
zeniId: vendor.id,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if ((0, customerTransaction_1.isCustomerTransaction)(transaction)) {
|
|
204
|
+
const customer = transaction.customer;
|
|
205
|
+
if (customer) {
|
|
206
|
+
return {
|
|
207
|
+
id: customer.id,
|
|
208
|
+
name: customer.name,
|
|
209
|
+
type: (0, entity_1.toEntityType)('customer'),
|
|
210
|
+
qboId: customer.id,
|
|
211
|
+
zeniId: customer.id,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return undefined;
|
|
216
|
+
};
|
package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
|
8
8
|
import { TransactionReviewLocalData, TransactionsTabViewState } from '../types/transactionsViewState';
|
|
9
9
|
export declare const MAX_SELECTION_LIMIT = 5;
|
|
10
10
|
export declare const toTransactionDetailLocalData: (transaction: SupportedTransaction) => TransactionReviewLocalData;
|
|
11
|
-
export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, updatedItem: "category" | "class", uncategorizedAccounts: UncategorizedAccounts, vendorId?: ID, selectedAccount?: AccountBase, selectedClassBase?: ClassBase) => TransactionReviewLocalData;
|
|
11
|
+
export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, updatedItem: "category" | "class", uncategorizedAccounts: UncategorizedAccounts, vendorId?: ID, customerId?: ID, selectedAccount?: AccountBase, selectedClassBase?: ClassBase) => TransactionReviewLocalData;
|
|
12
12
|
export declare const setEntityRecommendationForLineIdInLocalData: (draft: TransactionsTabViewState, transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData, entity: Entity, recommendationLineIds: ID[], uncategorizedAccounts: UncategorizedAccounts, recommendationByLineId?: RecommendationByLineId) => TransactionReviewLocalData;
|
|
13
13
|
export declare const checkIfAllLineItemsAreCategoryClassFilled: (transaction: SupportedTransaction, transactionDetailLocalData: TransactionReviewLocalData, uncategorizedAccounts: UncategorizedAccounts) => boolean;
|
|
@@ -19,7 +19,29 @@ const toTransactionDetailLocalData = (transaction) => {
|
|
|
19
19
|
logo: transaction.logo,
|
|
20
20
|
}
|
|
21
21
|
: undefined;
|
|
22
|
+
transactionLocal.customer =
|
|
23
|
+
transaction.customerId != null &&
|
|
24
|
+
transaction.customerName != null &&
|
|
25
|
+
Boolean(transaction.customerId) === true &&
|
|
26
|
+
Boolean(transaction.customerName) === true
|
|
27
|
+
? {
|
|
28
|
+
id: transaction.customerId,
|
|
29
|
+
name: transaction.customerName,
|
|
30
|
+
logo: transaction.logo,
|
|
31
|
+
}
|
|
32
|
+
: undefined;
|
|
22
33
|
transactionLocal.vendorUpdates = undefined;
|
|
34
|
+
if ((0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction) &&
|
|
35
|
+
transaction.customerName != null) {
|
|
36
|
+
transactionLocal.customerUpdates = {
|
|
37
|
+
id: transaction.customerId,
|
|
38
|
+
name: transaction.customerName,
|
|
39
|
+
qboId: transaction.customerId,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
transactionLocal.customerUpdates = undefined;
|
|
44
|
+
}
|
|
23
45
|
transactionLocal.lineItemById =
|
|
24
46
|
transaction.lines != null && transaction.lines.length > 0
|
|
25
47
|
? buildLineItemById(transaction, transaction.recommendations)
|
|
@@ -53,7 +75,16 @@ const buildLineItemById = (transaction, recommendations) => {
|
|
|
53
75
|
logo: accountLine.vendor.logo,
|
|
54
76
|
}
|
|
55
77
|
: undefined;
|
|
56
|
-
record.customer =
|
|
78
|
+
record.customer =
|
|
79
|
+
accountLine.customer != null &&
|
|
80
|
+
Boolean(accountLine.customer.id) === true &&
|
|
81
|
+
Boolean(accountLine.customer.name) === true
|
|
82
|
+
? {
|
|
83
|
+
id: accountLine.customer.id,
|
|
84
|
+
name: accountLine.customer.name,
|
|
85
|
+
logo: accountLine.customer.logo,
|
|
86
|
+
}
|
|
87
|
+
: undefined;
|
|
57
88
|
record.billable = accountLine.billable;
|
|
58
89
|
record.categorizationStatus = accountLine.categorizationStatus;
|
|
59
90
|
record.reviewPendingReasons = accountLine.reviewPendingReasons;
|
|
@@ -89,7 +120,7 @@ const buildLineItemById = (transaction, recommendations) => {
|
|
|
89
120
|
});
|
|
90
121
|
return lineItemData;
|
|
91
122
|
};
|
|
92
|
-
const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, transactionLineId, transactionDetailLocalData, updatedItem, uncategorizedAccounts, vendorId, selectedAccount, selectedClassBase) => {
|
|
123
|
+
const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, transactionLineId, transactionDetailLocalData, updatedItem, uncategorizedAccounts, vendorId, customerId, selectedAccount, selectedClassBase) => {
|
|
93
124
|
const newLineItems = {};
|
|
94
125
|
let selectedCheckBoxTransactionIds = draft.selectedCheckBoxTransactionIds;
|
|
95
126
|
if (transaction.lines != null) {
|
|
@@ -124,8 +155,11 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
124
155
|
}
|
|
125
156
|
}
|
|
126
157
|
else {
|
|
127
|
-
if ((transactionDetailLocalData.
|
|
128
|
-
transactionDetailLocalData.
|
|
158
|
+
if ((transactionDetailLocalData.customer != null &&
|
|
159
|
+
transactionDetailLocalData.customer.id === customerId) ||
|
|
160
|
+
(record.customer != null && record.customer.id === customerId) ||
|
|
161
|
+
(transactionDetailLocalData.vendor != null &&
|
|
162
|
+
transactionDetailLocalData.vendor.id === vendorId) ||
|
|
129
163
|
(record.vendor != null && record.vendor.id === vendorId)) {
|
|
130
164
|
// if the vendor is same, then set the account and class with the selected ones and add the transaction to the selected list
|
|
131
165
|
if (selectedAccount != null &&
|
|
@@ -174,7 +208,7 @@ const toSetAllLineItemsToCategoryClass = (draft, transaction, transactionId, tra
|
|
|
174
208
|
}
|
|
175
209
|
});
|
|
176
210
|
}
|
|
177
|
-
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendor: transactionDetailLocalData.vendor, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails });
|
|
211
|
+
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendor: transactionDetailLocalData.vendor, customer: transactionDetailLocalData.customer, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, customerDetails: transactionDetailLocalData.customerDetails });
|
|
178
212
|
if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData, uncategorizedAccounts)) {
|
|
179
213
|
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
180
214
|
}
|
|
@@ -238,7 +272,7 @@ const setEntityRecommendationForLineIdInLocalData = (draft, transaction, transac
|
|
|
238
272
|
const newLineItem = newLineItems[matchingEntityLineId];
|
|
239
273
|
newLineItems[matchingEntityLineId] = Object.assign(Object.assign({}, newLineItem), { class: matchingRecord.class, account: matchingRecord.account, lineEntity: matchingRecord.lineEntity });
|
|
240
274
|
}
|
|
241
|
-
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendorUpdates: transactionDetailLocalData.vendorUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, vendor: transactionDetailLocalData.vendor });
|
|
275
|
+
const newLocalData = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization.transactionReviewLocalData), { sortedLineItems: transactionDetailLocalData.sortedLineItems, memo: transactionDetailLocalData.memo, lineItemById: newLineItems, transactionDate: transactionDetailLocalData.transactionDate, transactionType: transactionDetailLocalData.transactionType, transactionTypeName: transactionDetailLocalData.transactionTypeName, vendorUpdates: transactionDetailLocalData.vendorUpdates, customerUpdates: transactionDetailLocalData.customerUpdates, vendorDetails: transactionDetailLocalData.vendorDetails, customerDetails: transactionDetailLocalData.customerDetails, vendor: transactionDetailLocalData.vendor, customer: transactionDetailLocalData.customer });
|
|
242
276
|
if (!(0, exports.checkIfAllLineItemsAreCategoryClassFilled)(transaction, newLocalData, uncategorizedAccounts)) {
|
|
243
277
|
selectedCheckBoxTransactionIds = selectedCheckBoxTransactionIds.filter((id) => id !== transaction.id);
|
|
244
278
|
}
|
|
@@ -250,7 +284,7 @@ const checkIfAllLineItemsAreCategoryClassFilled = (transaction, transactionDetai
|
|
|
250
284
|
const lineItems = Object.values(transactionDetailLocalData.lineItemById);
|
|
251
285
|
const isVendorTransactionAvailable = (0, vendorTransaction_1.isVendorTransaction)(transaction);
|
|
252
286
|
return lineItems.every((lineItem) => {
|
|
253
|
-
var _a, _b, _c
|
|
287
|
+
var _a, _b, _c;
|
|
254
288
|
return lineItem.account != null &&
|
|
255
289
|
Boolean(lineItem.account.qboId) === true &&
|
|
256
290
|
lineItem.class != null &&
|
|
@@ -260,10 +294,20 @@ const checkIfAllLineItemsAreCategoryClassFilled = (transaction, transactionDetai
|
|
|
260
294
|
(_b = uncategorizedAccounts.expense) === null || _b === void 0 ? void 0 : _b.qboId,
|
|
261
295
|
(_c = uncategorizedAccounts.income) === null || _c === void 0 ? void 0 : _c.qboId,
|
|
262
296
|
].includes(lineItem.account.qboId)) &&
|
|
263
|
-
(isVendorTransactionAvailable
|
|
264
|
-
?
|
|
297
|
+
((isVendorTransactionAvailable
|
|
298
|
+
? transactionDetailLocalData.vendor != null &&
|
|
299
|
+
transactionDetailLocalData.vendor.id != null &&
|
|
265
300
|
Boolean(transactionDetailLocalData.vendor.id) === true
|
|
266
|
-
:
|
|
301
|
+
: lineItem.vendor != null &&
|
|
302
|
+
lineItem.vendor.id != null &&
|
|
303
|
+
Boolean(lineItem.vendor.id) === true) ||
|
|
304
|
+
(isVendorTransactionAvailable
|
|
305
|
+
? transactionDetailLocalData.customer != null &&
|
|
306
|
+
transactionDetailLocalData.customer.id != null &&
|
|
307
|
+
Boolean(transactionDetailLocalData.customer.id) === true
|
|
308
|
+
: lineItem.customer != null &&
|
|
309
|
+
lineItem.customer.id != null &&
|
|
310
|
+
Boolean(lineItem.customer.id) === true));
|
|
267
311
|
});
|
|
268
312
|
};
|
|
269
313
|
exports.checkIfAllLineItemsAreCategoryClassFilled = checkIfAllLineItemsAreCategoryClassFilled;
|
|
@@ -76,12 +76,13 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
76
76
|
selectedTransaction: SupportedTransaction;
|
|
77
77
|
uncategorizedAccounts: UncategorizedAccounts;
|
|
78
78
|
updatedVendor?: VendorBase;
|
|
79
|
-
}, "expenseAutomationTransactionsView/updateSelectedVendorForTransaction">, setAllItemsToCategoryClassInLocalDataForCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionId: string, lineId: string, transactions: SupportedTransaction[], uncategorizedAccounts: UncategorizedAccounts, vendorId?: string | undefined, selectedAccount?: AccountBase | undefined, selectedClassBase?: ClassBase | undefined, lineEntity?: Entity | undefined, recommendations?: Recommendation[] | undefined], {
|
|
79
|
+
}, "expenseAutomationTransactionsView/updateSelectedVendorForTransaction">, setAllItemsToCategoryClassInLocalDataForCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionId: string, lineId: string, transactions: SupportedTransaction[], uncategorizedAccounts: UncategorizedAccounts, vendorId?: string | undefined, customerId?: string | undefined, selectedAccount?: AccountBase | undefined, selectedClassBase?: ClassBase | undefined, lineEntity?: Entity | undefined, recommendations?: Recommendation[] | undefined], {
|
|
80
80
|
selectedTab: "review" | "autoCategorized";
|
|
81
81
|
transactionId: string;
|
|
82
82
|
lineId: string;
|
|
83
83
|
transactions: SupportedTransaction[];
|
|
84
84
|
vendorId: string | undefined;
|
|
85
|
+
customerId: string | undefined;
|
|
85
86
|
lineEntity: Entity | undefined;
|
|
86
87
|
selectedAccount: AccountBase | undefined;
|
|
87
88
|
selectedClassBase: ClassBase | undefined;
|
|
@@ -261,7 +261,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
261
261
|
},
|
|
262
262
|
setAllItemsToCategoryClassInLocalDataForCategorization: {
|
|
263
263
|
reducer(draft, action) {
|
|
264
|
-
const { vendorId, selectedAccount, selectedClassBase, transactions, transactionId, lineId, selectedTab, uncategorizedAccounts, } = action.payload;
|
|
264
|
+
const { vendorId, customerId, selectedAccount, selectedClassBase, transactions, transactionId, lineId, selectedTab, uncategorizedAccounts, } = action.payload;
|
|
265
265
|
const transactionLocalData = (0, get_1.default)(draft.transactionCategorizationView[selectedTab]
|
|
266
266
|
.transactionReviewLocalDataById, transactionId, undefined);
|
|
267
267
|
const existingAccount = transactionLocalData === null || transactionLocalData === void 0 ? void 0 : transactionLocalData.transactionReviewLocalData.lineItemById[lineId].account;
|
|
@@ -285,7 +285,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
285
285
|
];
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
if (vendorId != null) {
|
|
288
|
+
if (vendorId != null || customerId != null) {
|
|
289
289
|
transactions.forEach((transaction) => {
|
|
290
290
|
const transactionLocalData = (0, get_1.default)(draft.transactionCategorizationView[selectedTab]
|
|
291
291
|
.transactionReviewLocalDataById, transaction.id, undefined);
|
|
@@ -294,13 +294,13 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
294
294
|
transactionId: transaction.id,
|
|
295
295
|
transactionReviewLocalData: (0, transactionCategorizationLocalDataHelper_1.toSetAllLineItemsToCategoryClass)(draft.transactionCategorizationView[selectedTab], transaction, transactionId, lineId, transactionLocalData.transactionReviewLocalData, (existingAccount === null || existingAccount === void 0 ? void 0 : existingAccount.accountId) !== (selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountId)
|
|
296
296
|
? 'category'
|
|
297
|
-
: 'class', uncategorizedAccounts, vendorId, selectedAccount, selectedClassBase),
|
|
297
|
+
: 'class', uncategorizedAccounts, vendorId, customerId, selectedAccount, selectedClassBase),
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
},
|
|
303
|
-
prepare(selectedTab, transactionId, lineId, transactions, uncategorizedAccounts, vendorId, selectedAccount, selectedClassBase, lineEntity, recommendations) {
|
|
303
|
+
prepare(selectedTab, transactionId, lineId, transactions, uncategorizedAccounts, vendorId, customerId, selectedAccount, selectedClassBase, lineEntity, recommendations) {
|
|
304
304
|
return {
|
|
305
305
|
payload: {
|
|
306
306
|
selectedTab,
|
|
@@ -308,6 +308,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
308
308
|
lineId,
|
|
309
309
|
transactions,
|
|
310
310
|
vendorId,
|
|
311
|
+
customerId,
|
|
311
312
|
lineEntity,
|
|
312
313
|
selectedAccount,
|
|
313
314
|
selectedClassBase,
|
|
@@ -60,16 +60,23 @@ export interface TransactionReviewLocalData {
|
|
|
60
60
|
lineItemById: Record<ID, TransactionCategorizationLineItemData>;
|
|
61
61
|
sortedLineItems: ID[];
|
|
62
62
|
vendor?: VendorBase;
|
|
63
|
+
customer?: CustomerBase;
|
|
63
64
|
memo?: string;
|
|
64
65
|
vendorDetails?: {
|
|
65
66
|
id: ID;
|
|
66
67
|
qboId: string;
|
|
67
68
|
name: string;
|
|
68
69
|
};
|
|
70
|
+
customerDetails?: {
|
|
71
|
+
id: ID;
|
|
72
|
+
qboId: string;
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
69
75
|
transactionDate?: ZeniDate;
|
|
70
76
|
transactionType?: TransactionType;
|
|
71
77
|
transactionTypeName?: string;
|
|
72
78
|
vendorUpdates?: TransactionVendorUpdates;
|
|
79
|
+
customerUpdates?: TransactionVendorUpdates;
|
|
73
80
|
}
|
|
74
81
|
export interface SupportedTransactionCategorization {
|
|
75
82
|
transactionReviewLocalData: TransactionReviewLocalData;
|
|
@@ -103,6 +110,7 @@ export interface TransactionUpdates {
|
|
|
103
110
|
memo?: string;
|
|
104
111
|
updatesByLineId: Record<ID, TransactionLineUpdates>;
|
|
105
112
|
vendorId?: ID;
|
|
113
|
+
customerId?: ID;
|
|
106
114
|
}
|
|
107
115
|
export interface EntityRelatedRecommendationUpdates {
|
|
108
116
|
entityId: ID;
|
|
@@ -25,7 +25,7 @@ const recommendationState_1 = require("../../recommendation/recommendationState"
|
|
|
25
25
|
* additionally fire “Mark as not miscat” for every point above.
|
|
26
26
|
*/
|
|
27
27
|
const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLocalData, transaction, isExpenseAutomationEnabled) => {
|
|
28
|
-
var _a, _b, _c;
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
29
|
const updates = {
|
|
30
30
|
updatesByLineId: {},
|
|
31
31
|
};
|
|
@@ -39,15 +39,16 @@ const toTransactionUpdatesFromTransactionDetailLocalData = (transactionDetailLoc
|
|
|
39
39
|
: undefined;
|
|
40
40
|
if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
41
41
|
updates.vendorId = (_b = transactionDetailLocalData.vendorUpdates) === null || _b === void 0 ? void 0 : _b.id;
|
|
42
|
+
updates.customerId = (_c = transactionDetailLocalData.customerUpdates) === null || _c === void 0 ? void 0 : _c.id;
|
|
42
43
|
}
|
|
43
44
|
let isBulkUpdate = false;
|
|
44
45
|
const entity = getEntityFromTransaction(transaction);
|
|
45
46
|
let lastUpdatedCategory;
|
|
46
47
|
let lastUpdatedClass;
|
|
47
48
|
// single recommendation to just pick the last recommendation in the list of lines
|
|
48
|
-
(
|
|
49
|
+
(_d = transaction.lines) === null || _d === void 0 ? void 0 : _d.forEach((line) => {
|
|
49
50
|
var _a, _b, _c, _d, _e, _f;
|
|
50
|
-
const entityDetails = getEntityDetails(entity, transactionDetailLocalData.lineItemById[line.id], transactionDetailLocalData.vendorUpdates);
|
|
51
|
+
const entityDetails = getEntityDetails(entity, transactionDetailLocalData.lineItemById[line.id], transactionDetailLocalData.vendorUpdates, transactionDetailLocalData.customerUpdates);
|
|
51
52
|
if (line.type === 'transaction_with_account_and_class_line' ||
|
|
52
53
|
line.type === 'transaction_with_product_or_service_line' ||
|
|
53
54
|
line.type === 'journal_entry_transaction_line') {
|
|
@@ -229,7 +230,7 @@ const getEntityFromTransaction = (transaction) => {
|
|
|
229
230
|
}
|
|
230
231
|
return entity;
|
|
231
232
|
};
|
|
232
|
-
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
|
|
233
|
+
const getEntityDetails = (entity, lineItemLocalData, vendorUpdates, customerUpdates) => {
|
|
233
234
|
var _a, _b, _c, _d;
|
|
234
235
|
if (entity != null) {
|
|
235
236
|
return {
|
|
@@ -243,6 +244,14 @@ const getEntityDetails = (entity, lineItemLocalData, vendorUpdates) => {
|
|
|
243
244
|
entityType: lineItemLocalData.vendor != null ? 'vendor' : 'customer',
|
|
244
245
|
};
|
|
245
246
|
}
|
|
247
|
+
if (customerUpdates != null &&
|
|
248
|
+
Boolean(customerUpdates.id) === true &&
|
|
249
|
+
customerUpdates.id != null) {
|
|
250
|
+
return {
|
|
251
|
+
entityId: customerUpdates.id,
|
|
252
|
+
entityType: 'customer',
|
|
253
|
+
};
|
|
254
|
+
}
|
|
246
255
|
if (vendorUpdates != null && vendorUpdates.id != null) {
|
|
247
256
|
return {
|
|
248
257
|
entityId: vendorUpdates.id,
|
|
@@ -126,6 +126,7 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
|
|
|
126
126
|
const detail = (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionDetailKey);
|
|
127
127
|
const tranDetail = (0, get_1.default)(transactionDetailState.transactionDetailById, transactionDetailKey, undefined);
|
|
128
128
|
const tranVendorUpdates = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionDetailLocalData.vendorUpdates;
|
|
129
|
+
const tranCustomerUpdates = tranDetail === null || tranDetail === void 0 ? void 0 : tranDetail.transactionDetailLocalData.customerUpdates;
|
|
129
130
|
let vendorUpdates = undefined;
|
|
130
131
|
if ((tranVendorUpdates === null || tranVendorUpdates === void 0 ? void 0 : tranVendorUpdates.qboId) != null) {
|
|
131
132
|
const vendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, tranVendorUpdates.qboId);
|
|
@@ -142,8 +143,15 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
|
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
145
|
}
|
|
146
|
+
let customerUpdates = undefined;
|
|
147
|
+
if ((tranCustomerUpdates === null || tranCustomerUpdates === void 0 ? void 0 : tranCustomerUpdates.qboId) != null) {
|
|
148
|
+
customerUpdates = {
|
|
149
|
+
id: tranCustomerUpdates.qboId,
|
|
150
|
+
name: tranCustomerUpdates.name,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
145
153
|
if (detail != null) {
|
|
146
|
-
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates);
|
|
154
|
+
const transUpdates = toTransactionUpdatePayload(saveUpdates.updates, detail, vendorUpdates, customerUpdates);
|
|
147
155
|
const entityUpdates = toEntityUpdatePayload(saveUpdates.entityRelatedUpdates);
|
|
148
156
|
return {
|
|
149
157
|
entity_related_updates: entityUpdates,
|
|
@@ -153,7 +161,7 @@ function preparePayload(transactionState, vendorState, transactionDetailState, t
|
|
|
153
161
|
}
|
|
154
162
|
return undefined;
|
|
155
163
|
}
|
|
156
|
-
const toTransactionUpdatePayload = (updates, detail, vendorUpdates) => {
|
|
164
|
+
const toTransactionUpdatePayload = (updates, detail, vendorUpdates, customerUpdates) => {
|
|
157
165
|
var _a, _b;
|
|
158
166
|
const transaction = Object.assign({}, detail);
|
|
159
167
|
transaction.memo = (_a = updates.memo) !== null && _a !== void 0 ? _a : '';
|
|
@@ -197,7 +205,12 @@ const toTransactionUpdatePayload = (updates, detail, vendorUpdates) => {
|
|
|
197
205
|
return (0, customerTransactionPayload_1.toCustomerTransactionPayload)(transaction);
|
|
198
206
|
}
|
|
199
207
|
else if ((0, vendorTransaction_1.isVendorTransaction)(transaction)) {
|
|
200
|
-
|
|
208
|
+
if ((0, vendorTransaction_1.isVendorTransactionWithCustomer)(transaction)) {
|
|
209
|
+
return (0, vendorTransactionPayload_1.toVendorTransactionWithCustomerPayload)(transaction, vendorUpdates, customerUpdates);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return (0, vendorTransactionPayload_1.toVendorTransactionPayload)(transaction, vendorUpdates);
|
|
213
|
+
}
|
|
201
214
|
}
|
|
202
215
|
else if ((0, otherTransaction_1.isTransferTransaction)(transaction)) {
|
|
203
216
|
return (0, otherTransactionPayload_1.toTransferTransactionPayload)(transaction);
|
|
@@ -6,8 +6,9 @@ const customerTransaction_1 = require("../../entity/transaction/stateTypes/custo
|
|
|
6
6
|
const vendorTransaction_1 = require("../../entity/transaction/stateTypes/vendorTransaction");
|
|
7
7
|
const transactionDetailState_1 = require("./transactionDetailState");
|
|
8
8
|
const toTransactionDetailLocalData = (transaction, vendorId, uncategorizedIncomeExpense) => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
10
10
|
const transactionLocal = Object.assign({}, transactionDetailState_1.initialSupportedTransactionDetail.transactionDetailLocalData);
|
|
11
|
+
const customerId = transaction.customerId;
|
|
11
12
|
transactionLocal.memo = transaction.memo;
|
|
12
13
|
transactionLocal.vendorUpdates =
|
|
13
14
|
(0, vendorTransaction_1.isVendorTransaction)(transaction) && vendorId != null
|
|
@@ -17,12 +18,28 @@ const toTransactionDetailLocalData = (transaction, vendorId, uncategorizedIncome
|
|
|
17
18
|
qboId: (_c = transaction.vendor) === null || _c === void 0 ? void 0 : _c.id,
|
|
18
19
|
}
|
|
19
20
|
: undefined;
|
|
21
|
+
transactionLocal.customerUpdates =
|
|
22
|
+
(0, customerTransaction_1.isCustomerTransaction)(transaction) && customerId != null
|
|
23
|
+
? {
|
|
24
|
+
id: customerId,
|
|
25
|
+
name: (_e = (_d = transaction.customer) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : '',
|
|
26
|
+
qboId: (_g = (_f = transaction.customer) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : '',
|
|
27
|
+
}
|
|
28
|
+
: undefined;
|
|
20
29
|
transactionLocal.vendorDetails =
|
|
21
30
|
(0, vendorTransaction_1.isVendorTransaction)(transaction) && vendorId != null
|
|
22
31
|
? {
|
|
23
32
|
id: vendorId,
|
|
24
|
-
qboId: (
|
|
25
|
-
name: (
|
|
33
|
+
qboId: (_j = (_h = transaction.vendor) === null || _h === void 0 ? void 0 : _h.id) !== null && _j !== void 0 ? _j : '',
|
|
34
|
+
name: (_l = (_k = transaction.vendor) === null || _k === void 0 ? void 0 : _k.name) !== null && _l !== void 0 ? _l : '',
|
|
35
|
+
}
|
|
36
|
+
: undefined;
|
|
37
|
+
transactionLocal.customerDetails =
|
|
38
|
+
(0, customerTransaction_1.isCustomerTransaction)(transaction) && customerId != null
|
|
39
|
+
? {
|
|
40
|
+
id: customerId,
|
|
41
|
+
qboId: (_o = (_m = transaction.customer) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : '',
|
|
42
|
+
name: (_q = (_p = transaction.customer) === null || _p === void 0 ? void 0 : _p.name) !== null && _q !== void 0 ? _q : '',
|
|
26
43
|
}
|
|
27
44
|
: undefined;
|
|
28
45
|
transactionLocal.lineItemById =
|
|
@@ -661,12 +678,12 @@ const toSetAllLineItemsToVendor = (transaction, transactionDetailLocalData, enti
|
|
|
661
678
|
? toVendorBaseFromLineEntity(entity)
|
|
662
679
|
: undefined;
|
|
663
680
|
if (line.type === 'transaction_with_product_or_service_line') {
|
|
664
|
-
const lineRecord = Object.assign(Object.assign({}, transactionDetailLocalData.lineItemById[lineId]), { vendor: record.vendor });
|
|
681
|
+
const lineRecord = Object.assign(Object.assign({}, transactionDetailLocalData.lineItemById[lineId]), { vendor: record.vendor, customer: record.customer });
|
|
665
682
|
record.item = lineRecord.item;
|
|
666
683
|
record.lineDetailType = lineRecord.lineDetailType;
|
|
667
684
|
}
|
|
668
685
|
if (line.type === 'journal_entry_transaction_line') {
|
|
669
|
-
const lineRecord = Object.assign(Object.assign({}, transactionDetailLocalData.lineItemById[lineId]), { vendor: record.vendor });
|
|
686
|
+
const lineRecord = Object.assign(Object.assign({}, transactionDetailLocalData.lineItemById[lineId]), { vendor: record.vendor, customer: record.customer });
|
|
670
687
|
record.lineTransactionType = lineRecord.lineTransactionType;
|
|
671
688
|
record.postingType = lineRecord.postingType;
|
|
672
689
|
record.postingTypeName = lineRecord.postingTypeName;
|
|
@@ -44,6 +44,12 @@ export interface TransactionDetailLocalData {
|
|
|
44
44
|
name: string;
|
|
45
45
|
qboId: ID;
|
|
46
46
|
};
|
|
47
|
+
customerDetails?: {
|
|
48
|
+
id: ID;
|
|
49
|
+
name: string;
|
|
50
|
+
qboId: ID;
|
|
51
|
+
};
|
|
52
|
+
customerUpdates?: TransactionVendorUpdates;
|
|
47
53
|
vendorUpdates?: TransactionVendorUpdates;
|
|
48
54
|
updatePreviousTransactionsWithUpdatedVendor?: boolean;
|
|
49
55
|
isVendorUpdateAllChecked: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.20",
|
|
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",
|