gemcap-be-common 1.4.119 → 1.4.121
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/constants/ai.constants.d.ts +1 -0
- package/constants/ai.constants.js +1 -0
- package/constants/ai.constants.ts +1 -0
- package/models/CashAllocationProduct.model.ts +26 -2
- package/package.json +1 -1
- package/services/bank-uploaded-transactions.service.js +1 -1
- package/services/bank-uploaded-transactions.service.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -27,14 +27,37 @@ export type ICashAllocationProductStringified = {
|
|
|
27
27
|
|
|
28
28
|
type CashAllocationProductModel = Model<ICashAllocationProduct>;
|
|
29
29
|
|
|
30
|
+
const normalizeAccountValue = (
|
|
31
|
+
value: unknown,
|
|
32
|
+
): mongoose.Types.ObjectId | 'BANK' | null => {
|
|
33
|
+
if (value === null || value === undefined || value === '') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (value === 'BANK') {
|
|
38
|
+
return 'BANK';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (typeof value === 'string' && mongoose.isValidObjectId(value)) {
|
|
42
|
+
return new mongoose.Types.ObjectId(value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (value instanceof mongoose.Types.ObjectId) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
51
|
+
|
|
30
52
|
export const AccountSchema = {
|
|
31
53
|
type: Map,
|
|
32
54
|
of: new Schema({
|
|
33
55
|
accountId1: {
|
|
34
56
|
type: Schema.Types.Mixed,
|
|
35
57
|
required: false,
|
|
58
|
+
set: normalizeAccountValue,
|
|
36
59
|
validate: {
|
|
37
|
-
validator: function
|
|
60
|
+
validator: function(value: mongoose.Types.ObjectId | 'BANK' | null) {
|
|
38
61
|
return (
|
|
39
62
|
value === null ||
|
|
40
63
|
mongoose.isValidObjectId(value) ||
|
|
@@ -48,8 +71,9 @@ export const AccountSchema = {
|
|
|
48
71
|
accountId2: {
|
|
49
72
|
type: Schema.Types.Mixed,
|
|
50
73
|
required: false,
|
|
74
|
+
set: normalizeAccountValue,
|
|
51
75
|
validate: {
|
|
52
|
-
validator: function
|
|
76
|
+
validator: function(value: mongoose.Types.ObjectId | 'BANK' | null) {
|
|
53
77
|
return (
|
|
54
78
|
value === null ||
|
|
55
79
|
mongoose.isValidObjectId(value) ||
|
package/package.json
CHANGED
|
@@ -295,7 +295,7 @@ class BankUploadedTransactionsService {
|
|
|
295
295
|
const productIds = new Set();
|
|
296
296
|
await Promise.all(allocatedTransactions.map(async (transactionToConvert) => {
|
|
297
297
|
const transaction = transactions.find((tr) => tr._id.toString() === transactionToConvert.uploadedBankTransactionId.toString());
|
|
298
|
-
if (transaction.isConverted) {
|
|
298
|
+
if (!transaction || transaction.isConverted) {
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
301
|
const splitTransaction = transactionToConvert.splitTransactionId
|
|
@@ -332,7 +332,7 @@ export class BankUploadedTransactionsService {
|
|
|
332
332
|
const productIds = new Set<string>();
|
|
333
333
|
await Promise.all(allocatedTransactions.map(async (transactionToConvert) => {
|
|
334
334
|
const transaction = transactions.find((tr) => tr._id.toString() === transactionToConvert.uploadedBankTransactionId.toString());
|
|
335
|
-
if (transaction.isConverted) {
|
|
335
|
+
if (!transaction || transaction.isConverted) {
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
338
|
const splitTransaction = transactionToConvert.splitTransactionId
|