gemcap-be-common 1.2.25 → 1.2.27

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.
Files changed (93) hide show
  1. package/db/availability.db.d.ts +2 -2
  2. package/db/availability.db.js +7 -7
  3. package/db/availability.db.ts +3 -3
  4. package/db/bbcDates.db.d.ts +2 -2
  5. package/db/bbcDates.db.js +10 -9
  6. package/db/bbcDates.db.ts +3 -2
  7. package/db/bbcSheets.db.d.ts +2 -2
  8. package/db/bbcSheets.db.js +6 -6
  9. package/db/bbcSheets.db.ts +2 -2
  10. package/db/collaterals.db.d.ts +6 -6
  11. package/db/collaterals.db.js +17 -14
  12. package/db/collaterals.db.ts +7 -11
  13. package/db/inventory-availability.db.d.ts +2 -1
  14. package/db/inventory-availability.db.js +8 -7
  15. package/db/inventory-availability.db.ts +2 -3
  16. package/db/inventory-manual-entry.db.d.ts +1 -1
  17. package/db/inventory-manual-entry.db.js +2 -2
  18. package/db/inventory-manual-entry.db.ts +1 -1
  19. package/db/inventory-seasonal-rates.db.d.ts +1 -1
  20. package/db/inventory-seasonal-rates.db.js +5 -5
  21. package/db/inventory-seasonal-rates.db.ts +1 -1
  22. package/db/loan-products.db.d.ts +3 -2
  23. package/db/loan-products.db.js +18 -15
  24. package/db/loan-products.db.ts +9 -10
  25. package/db/loan-statement.db.js +4 -3
  26. package/db/loan-statement.db.ts +2 -1
  27. package/db/microservice-tasks.db.d.ts +2 -2
  28. package/db/microservice-tasks.db.js +9 -9
  29. package/db/microservice-tasks.db.ts +3 -2
  30. package/db/receivables.db.d.ts +1 -1
  31. package/db/receivables.db.js +24 -23
  32. package/db/receivables.db.ts +4 -3
  33. package/db/user-logs.db.d.ts +1 -1
  34. package/db/user-logs.db.js +2 -2
  35. package/db/user-logs.db.ts +1 -1
  36. package/helpers/column-desciptions.helper.d.ts +4 -4
  37. package/helpers/column-desciptions.helper.js +51 -49
  38. package/helpers/column-desciptions.helper.ts +7 -4
  39. package/helpers/numbers.helper.d.ts +1 -1
  40. package/helpers/numbers.helper.js +7 -6
  41. package/helpers/numbers.helper.ts +3 -2
  42. package/helpers/paginator.helper.d.ts +1 -1
  43. package/helpers/paginator.helper.js +2 -2
  44. package/helpers/paginator.helper.ts +1 -1
  45. package/helpers/users.helper.d.ts +2 -1
  46. package/helpers/users.helper.js +4 -4
  47. package/helpers/users.helper.ts +2 -1
  48. package/interfaces/collaterals.interface.d.ts +3 -1
  49. package/interfaces/collaterals.interface.ts +3 -1
  50. package/interfaces/custom-row.interface.d.ts +2 -1
  51. package/interfaces/custom-row.interface.ts +2 -1
  52. package/interfaces/email-addresses.interface.d.ts +1 -1
  53. package/interfaces/email-addresses.interface.ts +1 -1
  54. package/interfaces/query.interface.d.ts +1 -1
  55. package/interfaces/query.interface.ts +1 -1
  56. package/models/AccountPayableItem.model.d.ts +1 -1
  57. package/models/AccountPayableItem.model.ts +1 -1
  58. package/models/InventoryAvailability.model.d.ts +2 -2
  59. package/models/InventoryAvailability.model.js +1 -1
  60. package/models/InventoryAvailability.model.ts +2 -2
  61. package/models/InventoryItem.model.d.ts +1 -1
  62. package/models/InventoryItem.model.ts +1 -1
  63. package/models/LoanCharges.model.d.ts +2 -1
  64. package/models/LoanCharges.model.js +34 -32
  65. package/models/LoanCharges.model.ts +3 -2
  66. package/models/LoanProducts.model.d.ts +1 -1
  67. package/models/LoanProducts.model.ts +1 -1
  68. package/models/LoanTransaction.model.js +5 -5
  69. package/models/LoanTransaction.model.ts +1 -1
  70. package/models/MicroserviceTask.model.d.ts +2 -1
  71. package/models/MicroserviceTask.model.js +2 -1
  72. package/models/MicroserviceTask.model.ts +4 -3
  73. package/models/ReceivableItem.model.d.ts +1 -1
  74. package/models/ReceivableItem.model.ts +1 -1
  75. package/models/Yield.model.d.ts +1 -1
  76. package/models/Yield.model.ts +1 -1
  77. package/package.json +1 -1
  78. package/tsconfig.tsbuildinfo +1 -1
  79. package/db/index.d.ts +0 -12
  80. package/db/index.js +0 -28
  81. package/db/index.ts +0 -12
  82. package/enums/index.d.ts +0 -14
  83. package/enums/index.js +0 -30
  84. package/enums/index.ts +0 -14
  85. package/helpers/index.d.ts +0 -9
  86. package/helpers/index.js +0 -25
  87. package/helpers/index.ts +0 -9
  88. package/interfaces/index.d.ts +0 -14
  89. package/interfaces/index.js +0 -30
  90. package/interfaces/index.ts +0 -14
  91. package/models/index.d.ts +0 -29
  92. package/models/index.js +0 -45
  93. package/models/index.ts +0 -29
@@ -7,18 +7,21 @@ exports.useFloatingBalance = exports.getAverageBalance = exports.getPostponedTra
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
8
  const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const minMax_1 = __importDefault(require("dayjs/plugin/minMax"));
10
- const helpers_1 = require("../helpers");
11
- const loan_statement_db_1 = require("./loan-statement.db");
12
- const models_1 = require("../models");
13
10
  const decimal_js_1 = __importDefault(require("decimal.js"));
14
- const enums_1 = require("../enums");
11
+ const date_helper_1 = require("../helpers/date.helper");
12
+ const numbers_helper_1 = require("../helpers/numbers.helper");
13
+ const loan_statement_db_1 = require("./loan-statement.db");
14
+ const PostponedTransactions_model_1 = require("../models/PostponedTransactions.model");
15
+ const LoanProducts_model_1 = require("../models/LoanProducts.model");
16
+ const LoanTransaction_model_1 = require("../models/LoanTransaction.model");
17
+ const loan_types_enum_1 = require("../enums/loan-types.enum");
15
18
  dayjs_1.default.extend(minMax_1.default);
16
19
  const getLoanProductById = async (productId) => {
17
- return models_1.LoanProduct.findById(productId).lean();
20
+ return LoanProducts_model_1.LoanProduct.findById(productId).lean();
18
21
  };
19
22
  exports.getLoanProductById = getLoanProductById;
20
23
  const getLoanProductBalance = async (productId, forDate = new Date()) => {
21
- const simpleTransactions = await models_1.LoanTransaction.aggregate([
24
+ const simpleTransactions = await LoanTransaction_model_1.LoanTransaction.aggregate([
22
25
  {
23
26
  $match: {
24
27
  'productId': new mongoose_1.default.Types.ObjectId(productId),
@@ -34,7 +37,7 @@ const getLoanProductBalance = async (productId, forDate = new Date()) => {
34
37
  $limit: 1,
35
38
  },
36
39
  ]);
37
- const collectionsTransactions = await models_1.LoanTransaction.aggregate([
40
+ const collectionsTransactions = await LoanTransaction_model_1.LoanTransaction.aggregate([
38
41
  {
39
42
  $match: {
40
43
  'productId': new mongoose_1.default.Types.ObjectId(productId),
@@ -51,7 +54,7 @@ const getLoanProductBalance = async (productId, forDate = new Date()) => {
51
54
  $limit: 1,
52
55
  },
53
56
  ]);
54
- const normalTransactions = await models_1.LoanTransaction.aggregate([
57
+ const normalTransactions = await LoanTransaction_model_1.LoanTransaction.aggregate([
55
58
  {
56
59
  $match: {
57
60
  'productId': new mongoose_1.default.Types.ObjectId(productId),
@@ -81,7 +84,7 @@ const getLoanProductBalance = async (productId, forDate = new Date()) => {
81
84
  if (normalTransaction && collectionsTransaction) {
82
85
  const totalCollections = await (0, loan_statement_db_1.getTotalForDate)(productId, collectionsTransaction.effectiveDate);
83
86
  if (normalTransaction.date.valueOf() === collectionsTransaction.date.valueOf()) {
84
- floatedBalance = (0, helpers_1.roundToXDigits)(normalTransaction.floatedBalance + totalCollections);
87
+ floatedBalance = (0, numbers_helper_1.roundToXDigits)(normalTransaction.floatedBalance + totalCollections);
85
88
  }
86
89
  if (normalTransaction.date.valueOf() > collectionsTransaction.date.valueOf()) {
87
90
  floatedBalance = normalTransaction.floatedBalance;
@@ -99,13 +102,13 @@ const getLoanProductBalance = async (productId, forDate = new Date()) => {
99
102
  }
100
103
  return {
101
104
  balance: balance,
102
- floatedBalance: (0, helpers_1.roundToXDigits)(floatedBalance),
105
+ floatedBalance: (0, numbers_helper_1.roundToXDigits)(floatedBalance),
103
106
  };
104
107
  };
105
108
  exports.getLoanProductBalance = getLoanProductBalance;
106
109
  const getPostponedTransactions = async (date, productId, removePostponed = false) => {
107
110
  const currentDay = (0, dayjs_1.default)(new Date(date)).format('YYYY-MM-DD');
108
- const postponedTransactions = await models_1.PostponedTransaction.aggregate([
111
+ const postponedTransactions = await PostponedTransactions_model_1.PostponedTransaction.aggregate([
109
112
  {
110
113
  $match: {
111
114
  'productId': new mongoose_1.default.Types.ObjectId(productId),
@@ -133,9 +136,9 @@ const getPostponedTransactions = async (date, productId, removePostponed = false
133
136
  }, []);
134
137
  let totalAmount = 0;
135
138
  await Promise.all(mappedTransactions.map(async (t) => {
136
- totalAmount = (0, helpers_1.roundToXDigits)(totalAmount + t.transaction.amount);
139
+ totalAmount = (0, numbers_helper_1.roundToXDigits)(totalAmount + t.transaction.amount);
137
140
  if (removePostponed) {
138
- await models_1.PostponedTransaction.findByIdAndDelete(t._id);
141
+ await PostponedTransactions_model_1.PostponedTransaction.findByIdAndDelete(t._id);
139
142
  }
140
143
  }));
141
144
  return totalAmount;
@@ -146,7 +149,7 @@ const getAverageBalance = async (productId, period, charge) => {
146
149
  if (charge) {
147
150
  period.start = dayjs_1.default.max(period.start, (0, dayjs_1.default)(charge.applyFrom));
148
151
  }
149
- const days = (0, helpers_1.getDays)(period);
152
+ const days = (0, date_helper_1.getDays)(period);
150
153
  if (days.length === 0) {
151
154
  return 0;
152
155
  }
@@ -159,6 +162,6 @@ const getAverageBalance = async (productId, period, charge) => {
159
162
  exports.getAverageBalance = getAverageBalance;
160
163
  const useFloatingBalance = async (productId) => {
161
164
  const product = await (0, exports.getLoanProductById)(productId);
162
- return product.type === enums_1.ELoanTypes.REVOLVER;
165
+ return product.type === loan_types_enum_1.ELoanTypes.REVOLVER;
163
166
  };
164
167
  exports.useFloatingBalance = useFloatingBalance;
@@ -1,18 +1,17 @@
1
1
  import mongoose from 'mongoose';
2
2
  import dayjs from 'dayjs';
3
3
  import minMax from 'dayjs/plugin/minMax';
4
+ import Decimal from 'decimal.js';
4
5
 
5
- import { getDays, roundToXDigits } from '../helpers';
6
+ import { getDays } from '../helpers/date.helper';
7
+ import { roundToXDigits } from '../helpers/numbers.helper';
6
8
  import { getTotalForDate } from './loan-statement.db';
7
- import {
8
- IPostponedTransactionWithTransaction,
9
- PostponedTransaction,
10
- LoanProduct,
11
- LoanTransaction,
12
- ILoanTransactionDoc, ILoanChargeView, IStatementPeriod,
13
- } from '../models';
14
- import Decimal from 'decimal.js';
15
- import { ELoanTypes } from '../enums';
9
+ import { IPostponedTransactionWithTransaction, PostponedTransaction } from '../models/PostponedTransactions.model';
10
+ import { LoanProduct } from '../models/LoanProducts.model';
11
+ import { ILoanChargeView } from '../models/LoanCharges.model';
12
+ import { ILoanTransactionDoc, LoanTransaction } from '../models/LoanTransaction.model';
13
+ import { IStatementPeriod } from '../models/LoanStatementTransaction.model';
14
+ import { ELoanTypes } from '../enums/loan-types.enum';
16
15
 
17
16
  dayjs.extend(minMax);
18
17
 
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getTotalForDate = exports.getTotalTransactionAmountForCharge = void 0;
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
- const models_1 = require("../models");
8
+ const LoanStatementTransaction_model_1 = require("../models/LoanStatementTransaction.model");
9
+ const LoanTransaction_model_1 = require("../models/LoanTransaction.model");
9
10
  const getTotalTransactionAmountForCharge = async (chargeId, start, end) => {
10
- const results = await models_1.LoanStatementTransactionModel.aggregate([
11
+ const results = await LoanStatementTransaction_model_1.LoanStatementTransactionModel.aggregate([
11
12
  {
12
13
  '$match': {
13
14
  $and: [
@@ -37,7 +38,7 @@ const getTotalTransactionAmountForCharge = async (chargeId, start, end) => {
37
38
  };
38
39
  exports.getTotalTransactionAmountForCharge = getTotalTransactionAmountForCharge;
39
40
  const getTotalForDate = async (productId, date) => {
40
- const totalAmount = await models_1.LoanTransaction.aggregate([
41
+ const totalAmount = await LoanTransaction_model_1.LoanTransaction.aggregate([
41
42
  {
42
43
  $match: {
43
44
  'productId': new mongoose_1.default.Types.ObjectId(productId),
@@ -1,6 +1,7 @@
1
1
  import mongoose from 'mongoose';
2
2
 
3
- import { LoanStatementTransactionModel, LoanTransaction } from '../models';
3
+ import { LoanStatementTransactionModel } from '../models/LoanStatementTransaction.model';
4
+ import { LoanTransaction } from '../models/LoanTransaction.model';
4
5
 
5
6
  export const getTotalTransactionAmountForCharge = async (chargeId: string, start: Date, end: Date) => {
6
7
  const results = await LoanStatementTransactionModel.aggregate([
@@ -1,5 +1,5 @@
1
- import { IMicroserviceTaskDoc } from '../models';
2
- import { EMicroserviceTask } from '../enums';
1
+ import { EMicroserviceTask } from '../enums/microservice-task.enum';
2
+ import { IMicroserviceTaskDoc } from '../models/MicroserviceTask.model';
3
3
  export declare const createMicroserviceTasks: (cmd: EMicroserviceTask, params: any, executeAt?: Date) => Promise<void>;
4
4
  export declare const findFirstTask: () => Promise<IMicroserviceTaskDoc>;
5
5
  export declare const getAllTasks: () => Promise<IMicroserviceTaskDoc[]>;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteTask = exports.getAllTasks = exports.findFirstTask = exports.createMicroserviceTasks = void 0;
4
- const models_1 = require("../models");
5
- const enums_1 = require("../enums");
4
+ const MicroserviceTask_model_1 = require("../models/MicroserviceTask.model");
5
+ const microservice_task_statuses_enum_1 = require("../enums/microservice-task-statuses.enum");
6
6
  const createMicroserviceTasks = async (cmd, params, executeAt = new Date()) => {
7
- const tasks = await models_1.MicroserviceTaskModel.find({ cmd, params, status: enums_1.EMicroserviceTaskStatuses.SCHEDULED });
7
+ const tasks = await MicroserviceTask_model_1.MicroserviceTaskModel.find({ cmd, params, status: microservice_task_statuses_enum_1.EMicroserviceTaskStatuses.SCHEDULED });
8
8
  if (!tasks.length) {
9
- const newTask = await models_1.MicroserviceTaskModel.create({
9
+ const newTask = await MicroserviceTask_model_1.MicroserviceTaskModel.create({
10
10
  cmd,
11
11
  params,
12
- status: enums_1.EMicroserviceTaskStatuses.SCHEDULED,
12
+ status: microservice_task_statuses_enum_1.EMicroserviceTaskStatuses.SCHEDULED,
13
13
  executeAt
14
14
  });
15
15
  await newTask.save();
@@ -18,10 +18,10 @@ const createMicroserviceTasks = async (cmd, params, executeAt = new Date()) => {
18
18
  exports.createMicroserviceTasks = createMicroserviceTasks;
19
19
  const findFirstTask = async () => {
20
20
  const currentDate = new Date();
21
- const lastTasks = await models_1.MicroserviceTaskModel.aggregate([
21
+ const lastTasks = await MicroserviceTask_model_1.MicroserviceTaskModel.aggregate([
22
22
  {
23
23
  $match: {
24
- 'status': enums_1.EMicroserviceTaskStatuses.SCHEDULED,
24
+ 'status': microservice_task_statuses_enum_1.EMicroserviceTaskStatuses.SCHEDULED,
25
25
  $or: [
26
26
  { 'executeAt': { $exists: false } },
27
27
  { 'executeAt': { $lte: currentDate } }
@@ -42,13 +42,13 @@ const findFirstTask = async () => {
42
42
  };
43
43
  exports.findFirstTask = findFirstTask;
44
44
  const getAllTasks = async () => {
45
- return models_1.MicroserviceTaskModel
45
+ return MicroserviceTask_model_1.MicroserviceTaskModel
46
46
  .find({})
47
47
  .sort({ 'createdAt': 1 });
48
48
  };
49
49
  exports.getAllTasks = getAllTasks;
50
50
  const deleteTask = async (taskId) => {
51
- await models_1.MicroserviceTaskModel
51
+ await MicroserviceTask_model_1.MicroserviceTaskModel
52
52
  .findByIdAndDelete(taskId);
53
53
  };
54
54
  exports.deleteTask = deleteTask;
@@ -1,5 +1,6 @@
1
- import { IMicroserviceTaskDoc, MicroserviceTaskModel } from '../models';
2
- import { EMicroserviceTask, EMicroserviceTaskStatuses } from '../enums';
1
+ import { EMicroserviceTask } from '../enums/microservice-task.enum';
2
+ import { IMicroserviceTaskDoc, MicroserviceTaskModel } from '../models/MicroserviceTask.model';
3
+ import { EMicroserviceTaskStatuses } from '../enums/microservice-task-statuses.enum';
3
4
 
4
5
  export const createMicroserviceTasks = async (cmd: EMicroserviceTask, params: any, executeAt: Date = new Date()): Promise<void> => {
5
6
  const tasks = await MicroserviceTaskModel.find({ cmd, params, status: EMicroserviceTaskStatuses.SCHEDULED });
@@ -23,7 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose from 'mongoose';
26
- import { IReceivableItemDocPopulated } from '../models';
26
+ import { IReceivableItemDocPopulated } from '../models/ReceivableItem.model';
27
27
  export declare const CUSTOMER_NUMBER_SEPARATOR = "~@~";
28
28
  export declare const getLastDigitFromAllValues: (allBbcDates: {
29
29
  bbcDate: Date;
@@ -6,15 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getReceivableItemsCustomerAndValue = exports.setReceivableManualInputsToggle = exports.getUniqInvoices = exports.getFirstLastBBCInvoiceWithNumberOccurrence = exports.getPartialPaidTable = exports.getAverageOverInvoiceSize = exports.getAverageInvoiceSize = exports.getAllCustomers = exports.aggregateBbcExposuresGrouped = exports.aggregateBbcExposures = exports.aggregateAllValuesForBbc = exports.aggregateSKUDateAgingPlot = exports.getReceivablesAndTheirQtyByBorrowerId = exports.getReceivableItemsSKUAndValue = exports.getLastDigitFromAllValues = exports.CUSTOMER_NUMBER_SEPARATOR = void 0;
7
7
  const dayjs_1 = __importDefault(require("dayjs"));
8
8
  const mongoose_1 = __importDefault(require("mongoose"));
9
- const models_1 = require("../models");
9
+ const ReceivableItem_model_1 = require("../models/ReceivableItem.model");
10
10
  const collaterals_db_1 = require("./collaterals.db");
11
- const enums_1 = require("../enums");
12
- const models_2 = require("../models");
11
+ const collaterals_enum_1 = require("../enums/collaterals.enum");
12
+ const Receivable_model_1 = require("../models/Receivable.model");
13
+ const ReceivableAvailability_model_1 = require("../models/ReceivableAvailability.model");
13
14
  const bbcSheets_db_1 = require("./bbcSheets.db");
14
15
  exports.CUSTOMER_NUMBER_SEPARATOR = '~@~';
15
16
  const getLastDigitFromAllValues = async (allBbcDates) => {
16
17
  const allIds = allBbcDates.reduce((acc, bbcDate) => [...acc, ...bbcDate.ids], []);
17
- return models_1.ReceivableItemModel.aggregate([
18
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
18
19
  {
19
20
  $match: {
20
21
  'bbcSheetId': {
@@ -75,7 +76,7 @@ const getLastDigitFromAllValues = async (allBbcDates) => {
75
76
  ]);
76
77
  };
77
78
  exports.getLastDigitFromAllValues = getLastDigitFromAllValues;
78
- const getReceivableItemsSKUAndValue = async (bbcDate, borrowerId) => await models_1.ReceivableModel.aggregate([
79
+ const getReceivableItemsSKUAndValue = async (bbcDate, borrowerId) => await Receivable_model_1.ReceivableModel.aggregate([
79
80
  {
80
81
  $match: { bbcDate, borrowerId },
81
82
  },
@@ -91,7 +92,7 @@ const getReceivableItemsSKUAndValue = async (bbcDate, borrowerId) => await model
91
92
  },
92
93
  ]);
93
94
  exports.getReceivableItemsSKUAndValue = getReceivableItemsSKUAndValue;
94
- const getReceivablesAndTheirQtyByBorrowerId = async (borrowerId, allBbcDates) => await models_1.ReceivableModel.aggregate([
95
+ const getReceivablesAndTheirQtyByBorrowerId = async (borrowerId, allBbcDates) => await Receivable_model_1.ReceivableModel.aggregate([
95
96
  {
96
97
  $match: {
97
98
  borrowerId,
@@ -135,7 +136,7 @@ const aggregateSKUDateAgingPlot = async (bbcSheetIds) => {
135
136
  },
136
137
  },
137
138
  });
138
- const a = await models_1.ReceivableItemModel.aggregate([
139
+ const a = await ReceivableItem_model_1.ReceivableItemModel.aggregate([
139
140
  { $match: { 'bbcSheetId': { $in: bbcSheetIds } } },
140
141
  ...collaterals_db_1.COLLATERALS_LOOKUP,
141
142
  {
@@ -164,7 +165,7 @@ const aggregateSKUDateAgingPlot = async (bbcSheetIds) => {
164
165
  };
165
166
  exports.aggregateSKUDateAgingPlot = aggregateSKUDateAgingPlot;
166
167
  const aggregateAllValuesForBbc = async (sheetIds) => {
167
- return models_1.ReceivableItemModel.aggregate([
168
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
168
169
  {
169
170
  $match: {
170
171
  'bbcSheetId': {
@@ -208,12 +209,12 @@ const aggregateAllValuesForBbc = async (sheetIds) => {
208
209
  };
209
210
  exports.aggregateAllValuesForBbc = aggregateAllValuesForBbc;
210
211
  const aggregateBbcExposures = async (bbcSheetIds) => {
211
- const getTotalBbcValue = await models_1.ReceivableItemModel.aggregate([
212
+ const getTotalBbcValue = await ReceivableItem_model_1.ReceivableItemModel.aggregate([
212
213
  { $match: { 'bbcSheetId': { $in: bbcSheetIds } } },
213
214
  { $group: { _id: 0, total: { $sum: '$invoiceAmount' } } },
214
215
  ]);
215
216
  const receivableTotal = getTotalBbcValue[0].total;
216
- const topItemsForBbc = await models_1.ReceivableItemModel.aggregate([
217
+ const topItemsForBbc = await ReceivableItem_model_1.ReceivableItemModel.aggregate([
217
218
  { $match: { 'bbcSheetId': { $in: bbcSheetIds } } },
218
219
  {
219
220
  $group: {
@@ -301,7 +302,7 @@ const aggregateBbcExposuresGrouped = async (bbcSheetIds) => {
301
302
  },
302
303
  },
303
304
  ];
304
- const getTotalBbcValue = await models_1.ReceivableItemModel.aggregate([
305
+ const getTotalBbcValue = await ReceivableItem_model_1.ReceivableItemModel.aggregate([
305
306
  ...commonAggregation,
306
307
  {
307
308
  $group: {
@@ -313,7 +314,7 @@ const aggregateBbcExposuresGrouped = async (bbcSheetIds) => {
313
314
  },
314
315
  ]);
315
316
  const receivableTotal = getTotalBbcValue[0].total;
316
- const topItemsForBbc = await models_1.ReceivableItemModel.aggregate([
317
+ const topItemsForBbc = await ReceivableItem_model_1.ReceivableItemModel.aggregate([
317
318
  ...commonAggregation,
318
319
  {
319
320
  $group: {
@@ -331,8 +332,8 @@ const aggregateBbcExposuresGrouped = async (bbcSheetIds) => {
331
332
  };
332
333
  exports.aggregateBbcExposuresGrouped = aggregateBbcExposuresGrouped;
333
334
  const getAllCustomers = async (borrowerId) => {
334
- const bbcSheets = await (0, collaterals_db_1.getBBCSheetsForBorrowerAndType)(borrowerId, enums_1.ECollaterals.RECEIVABLE);
335
- return models_1.ReceivableItemModel.aggregate([
335
+ const bbcSheets = await (0, collaterals_db_1.getBBCSheetsForBorrowerAndType)(borrowerId, collaterals_enum_1.ECollaterals.RECEIVABLE);
336
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
336
337
  {
337
338
  $match: {
338
339
  'bbcSheetId': {
@@ -357,9 +358,9 @@ const getAllCustomers = async (borrowerId) => {
357
358
  };
358
359
  exports.getAllCustomers = getAllCustomers;
359
360
  const getAverageInvoiceSize = async (borrowerId) => {
360
- const bbcGroups = await (0, bbcSheets_db_1.getUniqueDates)(borrowerId, 100, enums_1.ECollaterals.RECEIVABLE);
361
+ const bbcGroups = await (0, bbcSheets_db_1.getUniqueDates)(borrowerId, 100, collaterals_enum_1.ECollaterals.RECEIVABLE);
361
362
  const sheetIds = bbcGroups.reduce((acc, bbc) => [...acc, ...bbc.ids], []);
362
- return models_1.ReceivableItemModel.aggregate([
363
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
363
364
  {
364
365
  $match: {
365
366
  'bbcSheetId': {
@@ -407,9 +408,9 @@ const getAverageInvoiceSize = async (borrowerId) => {
407
408
  };
408
409
  exports.getAverageInvoiceSize = getAverageInvoiceSize;
409
410
  const getAverageOverInvoiceSize = async (borrowerId, averageInvoiceSize) => {
410
- const bbcSheets = await (0, bbcSheets_db_1.getBBCSheetsByType)([averageInvoiceSize._id], enums_1.ECollaterals.RECEIVABLE);
411
+ const bbcSheets = await (0, bbcSheets_db_1.getBBCSheetsByType)([averageInvoiceSize._id], collaterals_enum_1.ECollaterals.RECEIVABLE);
411
412
  const sheetIds = bbcSheets.map((sheet) => sheet._id);
412
- return models_1.ReceivableItemModel.aggregate([
413
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
413
414
  {
414
415
  $match: {
415
416
  'bbcSheetId': {
@@ -440,7 +441,7 @@ const getAverageOverInvoiceSize = async (borrowerId, averageInvoiceSize) => {
440
441
  };
441
442
  exports.getAverageOverInvoiceSize = getAverageOverInvoiceSize;
442
443
  const getPartialPaidTable = async (bbcSheetIds) => {
443
- return models_1.ReceivableItemModel.aggregate([
444
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
444
445
  {
445
446
  $match: {
446
447
  'bbcSheetId': { $in: bbcSheetIds },
@@ -456,7 +457,7 @@ const getPartialPaidTable = async (bbcSheetIds) => {
456
457
  };
457
458
  exports.getPartialPaidTable = getPartialPaidTable;
458
459
  const getFirstLastBBCInvoiceWithNumberOccurrence = async (bbcSheetIds, { customerTitle, invoiceNumber, }, firstLast) => {
459
- return models_1.ReceivableItemModel.aggregate([
460
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
460
461
  {
461
462
  $match: {
462
463
  $and: [
@@ -479,7 +480,7 @@ const getFirstLastBBCInvoiceWithNumberOccurrence = async (bbcSheetIds, { custome
479
480
  };
480
481
  exports.getFirstLastBBCInvoiceWithNumberOccurrence = getFirstLastBBCInvoiceWithNumberOccurrence;
481
482
  const getUniqInvoices = async (bbcSheetIds) => {
482
- return models_1.ReceivableItemModel.aggregate([
483
+ return ReceivableItem_model_1.ReceivableItemModel.aggregate([
483
484
  {
484
485
  $match: {
485
486
  'bbcSheetId': {
@@ -504,10 +505,10 @@ const getUniqInvoices = async (bbcSheetIds) => {
504
505
  };
505
506
  exports.getUniqInvoices = getUniqInvoices;
506
507
  const setReceivableManualInputsToggle = async (bbcDateId, useManualInputs) => {
507
- await models_2.ReceivableAvailabilityModel.updateOne({ bbcDateId }, { useManualInputs });
508
+ await ReceivableAvailability_model_1.ReceivableAvailabilityModel.updateOne({ bbcDateId }, { useManualInputs });
508
509
  };
509
510
  exports.setReceivableManualInputsToggle = setReceivableManualInputsToggle;
510
- const getReceivableItemsCustomerAndValue = async (sheetIds) => await models_1.ReceivableItemModel.aggregate([
511
+ const getReceivableItemsCustomerAndValue = async (sheetIds) => await ReceivableItem_model_1.ReceivableItemModel.aggregate([
511
512
  {
512
513
  $match: {
513
514
  bbcSheetId: { $in: sheetIds.map((sheetId) => new mongoose_1.default.Types.ObjectId(sheetId)) },
@@ -1,10 +1,11 @@
1
1
  import dayjs from 'dayjs';
2
2
  import mongoose from 'mongoose';
3
3
 
4
- import { IReceivableItemDocPopulated, ReceivableItemModel, ReceivableModel } from '../models';
4
+ import { IReceivableItemDocPopulated, ReceivableItemModel } from '../models/ReceivableItem.model';
5
5
  import { COLLATERALS_LOOKUP, getBBCSheetsForBorrowerAndType } from './collaterals.db';
6
- import { ECollaterals } from '../enums';
7
- import { ReceivableAvailabilityModel } from '../models';
6
+ import { ECollaterals } from '../enums/collaterals.enum';
7
+ import { ReceivableModel } from '../models/Receivable.model';
8
+ import { ReceivableAvailabilityModel } from '../models/ReceivableAvailability.model';
8
9
  import { getBBCSheetsByType, getUniqueDates } from './bbcSheets.db';
9
10
 
10
11
  export const CUSTOMER_NUMBER_SEPARATOR = '~@~';
@@ -23,7 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose from 'mongoose';
26
- import { ELogActionType, ELogType } from '../models';
26
+ import { ELogActionType, ELogType } from '../models/UserLog.model';
27
27
  export interface ICreateLogParams {
28
28
  logType: ELogType;
29
29
  userId: string;
@@ -5,14 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getLogChanges = exports.createLog = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
- const models_1 = require("../models");
8
+ const UserLog_model_1 = require("../models/UserLog.model");
9
9
  const excludedKeys = ['$set', '$setOnInsert'];
10
10
  const createLogs = true;
11
11
  const createLog = async (params) => {
12
12
  if (!createLogs) {
13
13
  return;
14
14
  }
15
- const newUserLog = new models_1.UserLog({
15
+ const newUserLog = new UserLog_model_1.UserLog({
16
16
  timestamp: new Date(),
17
17
  logType: params.logType,
18
18
  userId: params.userId,
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import mongoose from 'mongoose';
3
3
 
4
- import { ELogActionType, ELogType, UserLog } from '../models';
4
+ import { ELogActionType, ELogType, UserLog } from '../models/UserLog.model';
5
5
 
6
6
  const excludedKeys = ['$set', '$setOnInsert'];
7
7
 
@@ -1,6 +1,6 @@
1
- import { ICustomRow } from '../interfaces';
2
- import { ECollaterals } from '../enums';
3
- export declare const COLLATERALS: {
4
- [key: string]: ICustomRow[];
1
+ import { ICustomRow } from '../interfaces/custom-row.interface';
2
+ import { ECollaterals } from '../enums/collaterals.enum';
3
+ export declare let COLLATERALS: {
4
+ [p: string]: ICustomRow[];
5
5
  };
6
6
  export declare const convertIntoDates: (item: any, collateralType: ECollaterals) => any;