gemcap-be-common 1.4.198 → 1.4.200

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.
@@ -96,7 +96,7 @@ const checkData = (dataToConvert) => {
96
96
  if (cell.v === null) {
97
97
  console.warn(`❌ cell.t === 'n' but v === null at ${pos}:`, cell);
98
98
  }
99
- else if (typeof cell.v !== 'number') {
99
+ else if (cell.v !== undefined && typeof cell.v !== 'number') {
100
100
  console.warn(`❌ cell.t === 'n' but v is not a number at ${pos}:`, cell);
101
101
  }
102
102
  }
@@ -115,6 +115,9 @@ const checkData = (dataToConvert) => {
115
115
  if (cell.v === null && cell.z) {
116
116
  console.warn(`❌ Null value with format (z) at ${pos}:`, cell);
117
117
  }
118
+ if (cell.v === undefined && cell.z && cell.t === 'n') {
119
+ // allowed: empty numeric cell with format
120
+ }
118
121
  });
119
122
  });
120
123
  }
@@ -91,7 +91,7 @@ const checkData = (dataToConvert: { [sheetName: string]: IExcelDataCellWithStyle
91
91
  if (cell.t === 'n') {
92
92
  if (cell.v === null) {
93
93
  console.warn(`❌ cell.t === 'n' but v === null at ${pos}:`, cell);
94
- } else if (typeof cell.v !== 'number') {
94
+ } else if (cell.v !== undefined && typeof cell.v !== 'number') {
95
95
  console.warn(`❌ cell.t === 'n' but v is not a number at ${pos}:`, cell);
96
96
  }
97
97
  }
@@ -115,6 +115,10 @@ const checkData = (dataToConvert: { [sheetName: string]: IExcelDataCellWithStyle
115
115
  if (cell.v === null && cell.z) {
116
116
  console.warn(`❌ Null value with format (z) at ${pos}:`, cell);
117
117
  }
118
+
119
+ if (cell.v === undefined && cell.z && cell.t === 'n') {
120
+ // allowed: empty numeric cell with format
121
+ }
118
122
  });
119
123
  });
120
124
  }
@@ -24,17 +24,36 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Model } from 'mongoose';
26
26
  export interface ICashAllocationReference {
27
- _id?: mongoose.Types.ObjectId;
27
+ uiId: string;
28
28
  order: number;
29
29
  reference: string;
30
30
  cashAllocationProductId: mongoose.Types.ObjectId;
31
31
  }
32
+ export interface ICashAllocationReferenceDoc extends ICashAllocationReference, Document {
33
+ _id: mongoose.Types.ObjectId;
34
+ createdAt: Date;
35
+ updatedAt: Date;
36
+ }
37
+ export interface ICashAllocationReferenceLean extends ICashAllocationReference {
38
+ _id: mongoose.Types.ObjectId;
39
+ createdAt: Date;
40
+ updatedAt: Date;
41
+ }
42
+ export interface ICashAllocationReferencePlain extends Omit<ICashAllocationReference, 'cashAllocationProductId'> {
43
+ _id: string;
44
+ cashAllocationProductId: string;
45
+ createdAt: Date;
46
+ updatedAt: Date;
47
+ }
32
48
  export type ICashAllocationReferenceStringified = {
33
49
  [K in keyof ICashAllocationReference]: K extends '_id' | 'cashAllocationProductId' ? string : ICashAllocationReference[K];
34
50
  };
35
- type CashAllocationReferenceModel = Model<ICashAllocationReference>;
36
- export declare const CashAllocationReferenceSchema: mongoose.Schema<ICashAllocationReference, CashAllocationReferenceModel, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, ICashAllocationReference, mongoose.Document<unknown, {}, mongoose.FlatRecord<ICashAllocationReference>> & mongoose.FlatRecord<ICashAllocationReference> & Required<{
51
+ export type CashAllocationReferenceModel = Model<ICashAllocationReference>;
52
+ export declare const CashAllocationReferenceSchema: mongoose.Schema<ICashAllocationReferenceDoc, mongoose.Model<ICashAllocationReferenceDoc, any, any, any, mongoose.Document<unknown, any, ICashAllocationReferenceDoc> & ICashAllocationReferenceDoc & Required<{
53
+ _id: mongoose.Types.ObjectId;
54
+ }>, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, ICashAllocationReferenceDoc, mongoose.Document<unknown, {}, mongoose.FlatRecord<ICashAllocationReferenceDoc>> & mongoose.FlatRecord<ICashAllocationReferenceDoc> & Required<{
37
55
  _id: mongoose.Types.ObjectId;
38
56
  }>>;
39
- export declare const CashAllocationReference: CashAllocationReferenceModel;
40
- export {};
57
+ export declare const CashAllocationReference: mongoose.Model<ICashAllocationReferenceDoc, {}, {}, {}, mongoose.Document<unknown, {}, ICashAllocationReferenceDoc> & ICashAllocationReferenceDoc & Required<{
58
+ _id: mongoose.Types.ObjectId;
59
+ }>, any>;
@@ -7,6 +7,10 @@ exports.CashAllocationReference = exports.CashAllocationReferenceSchema = void 0
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
8
  const _models_1 = require("./_models");
9
9
  exports.CashAllocationReferenceSchema = new mongoose_1.default.Schema({
10
+ uiId: {
11
+ type: String,
12
+ required: true,
13
+ },
10
14
  order: {
11
15
  type: Number,
12
16
  required: true,
@@ -3,20 +3,43 @@ import mongoose, { Model } from 'mongoose';
3
3
  import { MODEL_NAMES } from './_models';
4
4
 
5
5
  export interface ICashAllocationReference {
6
- _id?: mongoose.Types.ObjectId;
6
+ uiId: string;
7
7
  order: number;
8
8
  reference: string;
9
9
  cashAllocationProductId: mongoose.Types.ObjectId;
10
10
  }
11
11
 
12
+ export interface ICashAllocationReferenceDoc extends ICashAllocationReference, Document {
13
+ _id: mongoose.Types.ObjectId;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }
17
+
18
+ export interface ICashAllocationReferenceLean extends ICashAllocationReference {
19
+ _id: mongoose.Types.ObjectId;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ }
23
+
24
+ export interface ICashAllocationReferencePlain extends Omit<ICashAllocationReference, 'cashAllocationProductId'> {
25
+ _id: string;
26
+ cashAllocationProductId: string;
27
+ createdAt: Date;
28
+ updatedAt: Date;
29
+ }
30
+
12
31
  export type ICashAllocationReferenceStringified = {
13
32
  [K in keyof ICashAllocationReference]: K extends '_id' | 'cashAllocationProductId' ? string : ICashAllocationReference[K];
14
33
  };
15
34
 
16
- type CashAllocationReferenceModel = Model<ICashAllocationReference>;
35
+ export type CashAllocationReferenceModel = Model<ICashAllocationReference>;
17
36
 
18
- export const CashAllocationReferenceSchema = new mongoose.Schema<ICashAllocationReference, CashAllocationReferenceModel>(
37
+ export const CashAllocationReferenceSchema = new mongoose.Schema<ICashAllocationReferenceDoc>(
19
38
  {
39
+ uiId: {
40
+ type: String,
41
+ required: true,
42
+ },
20
43
  order: {
21
44
  type: Number,
22
45
  required: true,
@@ -37,4 +60,4 @@ export const CashAllocationReferenceSchema = new mongoose.Schema<ICashAllocation
37
60
  },
38
61
  );
39
62
 
40
- export const CashAllocationReference = mongoose.model<ICashAllocationReference, CashAllocationReferenceModel>(MODEL_NAMES.cashAllocationReferences, CashAllocationReferenceSchema);
63
+ export const CashAllocationReference = mongoose.model<ICashAllocationReferenceDoc>(MODEL_NAMES.cashAllocationReferences, CashAllocationReferenceSchema);
@@ -31,8 +31,8 @@ export declare const allSchemas: {
31
31
  createdAt: NativeDate;
32
32
  updatedAt: NativeDate;
33
33
  } & {
34
- bbcSheetId: import("mongoose").Types.ObjectId;
35
34
  order: number;
35
+ bbcSheetId: import("mongoose").Types.ObjectId;
36
36
  apDate: Date;
37
37
  amount: number;
38
38
  __v?: number;
@@ -45,8 +45,8 @@ export declare const allSchemas: {
45
45
  createdAt: NativeDate;
46
46
  updatedAt: NativeDate;
47
47
  } & {
48
- bbcSheetId: import("mongoose").Types.ObjectId;
49
48
  order: number;
49
+ bbcSheetId: import("mongoose").Types.ObjectId;
50
50
  apDate: Date;
51
51
  amount: number;
52
52
  __v?: number;
@@ -59,8 +59,8 @@ export declare const allSchemas: {
59
59
  createdAt: NativeDate;
60
60
  updatedAt: NativeDate;
61
61
  } & {
62
- bbcSheetId: import("mongoose").Types.ObjectId;
63
62
  order: number;
63
+ bbcSheetId: import("mongoose").Types.ObjectId;
64
64
  apDate: Date;
65
65
  amount: number;
66
66
  __v?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.198",
3
+ "version": "1.4.200",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -84,10 +84,10 @@ export declare class BorrowerService {
84
84
  getBorrowerCodesMap(): Promise<Map<string, string>>;
85
85
  getBorrowerStatementDetails(borrowers: IBorrowerDoc[]): Promise<{
86
86
  [x: string]: {
87
- SELECTED_PERIOD?: boolean;
88
- ENTIRE_LOAN?: boolean;
89
87
  LAST_MONTH?: boolean;
90
88
  CURRENT_MONTH?: boolean;
89
+ ENTIRE_LOAN?: boolean;
90
+ SELECTED_PERIOD?: boolean;
91
91
  TERM_LOAN?: boolean;
92
92
  };
93
93
  }>;
@@ -24,17 +24,17 @@
24
24
  /// <reference types="mongoose" />
25
25
  /// <reference types="mongoose/types/inferschematype" />
26
26
  import { IUploadedBankTransaction } from '../models/UploadedBankTransaction.model';
27
- import { ICashAllocationReference, ICashAllocationReferenceStringified } from '../models/CashAllocationReference.model';
27
+ import { ICashAllocationReferenceDoc, ICashAllocationReferencePlain } from '../models/CashAllocationReference.model';
28
28
  import { ICashAllocationProduct, ICashAllocationProductStringified } from '../models/CashAllocationProduct.model';
29
29
  export declare class CashAllocationService {
30
30
  createCashAllocation(transactions: IUploadedBankTransaction[]): Promise<void>;
31
31
  getNextOrder(): Promise<number>;
32
- getCashAllocationsByReferences(references: string[]): Promise<(import("mongoose").FlattenMaps<ICashAllocationReference> & Required<{
32
+ getCashAllocationsByReferences(references: string[]): Promise<(import("mongoose").FlattenMaps<ICashAllocationReferenceDoc> & Required<{
33
33
  _id: import("mongoose").Types.ObjectId;
34
34
  }>)[]>;
35
35
  getAllCashAllocations(): Promise<{
36
- references: ICashAllocationReference[];
36
+ references: ICashAllocationReferenceDoc[];
37
37
  products: ICashAllocationProduct[];
38
38
  }>;
39
- updateAllCashAllocation(products: ICashAllocationProductStringified[], references: ICashAllocationReferenceStringified[]): Promise<void>;
39
+ updateAllCashAllocation(products: ICashAllocationProductStringified[], references: ICashAllocationReferencePlain[]): Promise<void>;
40
40
  }
@@ -24,6 +24,7 @@ class CashAllocationService {
24
24
  return;
25
25
  }
26
26
  const cashAllocation = {
27
+ uiId: (0, main_helper_1.getUUID)(),
27
28
  order,
28
29
  reference: transactions.reference.trim(),
29
30
  cashAllocationProductId: null,
@@ -1,9 +1,10 @@
1
1
  import { IUploadedBankTransaction } from '../models/UploadedBankTransaction.model';
2
- import { fieldsToUnset, removeFields } from '../helpers/main.helper';
2
+ import { fieldsToUnset, getUUID, removeFields } from '../helpers/main.helper';
3
3
  import {
4
4
  CashAllocationReference,
5
5
  ICashAllocationReference,
6
- ICashAllocationReferenceStringified,
6
+ ICashAllocationReferenceDoc,
7
+ ICashAllocationReferencePlain,
7
8
  } from '../models/CashAllocationReference.model';
8
9
  import {
9
10
  CashAllocationProduct,
@@ -31,6 +32,7 @@ export class CashAllocationService {
31
32
  return;
32
33
  }
33
34
  const cashAllocation: ICashAllocationReference = {
35
+ uiId: getUUID(),
34
36
  order,
35
37
  reference: transactions.reference.trim(),
36
38
  cashAllocationProductId: null,
@@ -60,12 +62,12 @@ export class CashAllocationService {
60
62
  .find()
61
63
  .sort({ order: 1 });
62
64
  return {
63
- references: cashAllocationReferences.map((i) => removeFields<ICashAllocationReference>(i, fieldsToUnset)),
65
+ references: cashAllocationReferences.map((i) => removeFields<ICashAllocationReferenceDoc>(i, fieldsToUnset)),
64
66
  products: cashAllocationsProducts.map((i) => removeFields<ICashAllocationProduct>(i, fieldsToUnset)),
65
67
  };
66
68
  }
67
69
 
68
- async updateAllCashAllocation(products: ICashAllocationProductStringified[], references: ICashAllocationReferenceStringified[]) {
70
+ async updateAllCashAllocation(products: ICashAllocationProductStringified[], references: ICashAllocationReferencePlain[]) {
69
71
  const existingCashAllocations = await this.getAllCashAllocations();
70
72
 
71
73
  const existingCashAllocationProductIds = existingCashAllocations.products.map((i) => i._id.toString());
@@ -155,7 +155,7 @@ export declare class LoanTransactionsService {
155
155
  getTransactionReport(transactionIds: string[], borrowerId: string, effectiveDate: Date): Promise<{
156
156
  transactionIdsToMark: string[];
157
157
  transactions: {
158
- [x: string]: (string | number | Date | string[])[];
158
+ [x: string]: (string | number | string[] | Date)[];
159
159
  }[];
160
160
  }>;
161
161
  getBorrowerIdsForFile(transactionFileId: string): Promise<{