gemcap-be-common 1.2.140 → 1.3.0

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 (303) hide show
  1. package/classes/bank-transaction-item.d.ts +17 -0
  2. package/classes/bank-transaction-item.js +64 -0
  3. package/classes/bank-transaction-item.ts +66 -0
  4. package/classes/bank-uploaded-transaction.d.ts +17 -0
  5. package/classes/bank-uploaded-transaction.js +35 -0
  6. package/classes/bank-uploaded-transaction.ts +35 -0
  7. package/classes/inventory-item.d.ts +41 -0
  8. package/classes/inventory-item.js +44 -0
  9. package/classes/inventory-item.ts +63 -0
  10. package/classes/payable-account-item.d.ts +22 -0
  11. package/classes/payable-account-item.js +27 -0
  12. package/classes/payable-account-item.ts +35 -0
  13. package/classes/quickbook-item.d.ts +37 -0
  14. package/classes/quickbook-item.js +51 -0
  15. package/classes/quickbook-item.ts +59 -0
  16. package/classes/receivable-item.d.ts +26 -0
  17. package/classes/receivable-item.js +28 -0
  18. package/classes/receivable-item.ts +38 -0
  19. package/constants/date-formats.contsants.d.ts +1 -0
  20. package/constants/date-formats.contsants.js +4 -0
  21. package/constants/date-formats.contsants.ts +1 -0
  22. package/db/brokers.db.d.ts +185 -0
  23. package/db/brokers.db.js +35 -2
  24. package/db/brokers.db.ts +34 -1
  25. package/db/collateral-adjustments.db.d.ts +34 -0
  26. package/db/collateral-adjustments.db.js +52 -0
  27. package/db/collateral-adjustments.db.ts +54 -0
  28. package/db/collaterals.db.d.ts +1 -1
  29. package/db/equipment.db.d.ts +40 -0
  30. package/db/equipment.db.js +55 -0
  31. package/db/equipment.db.ts +56 -0
  32. package/db/financial-spreading.db.ts +2 -1
  33. package/db/groups.d.ts +5 -0
  34. package/db/groups.js +57 -0
  35. package/db/groups.ts +52 -0
  36. package/db/inventories.d.ts +91 -0
  37. package/db/inventories.js +449 -0
  38. package/db/inventories.ts +481 -0
  39. package/db/inventory-availability.d.ts +3 -0
  40. package/db/inventory-availability.js +103 -0
  41. package/db/inventory-availability.ts +113 -0
  42. package/db/new-summary.d.ts +31 -0
  43. package/db/new-summary.js +1295 -0
  44. package/db/new-summary.ts +1509 -0
  45. package/db/payable-accounts.d.ts +30 -0
  46. package/db/payable-accounts.js +55 -0
  47. package/db/payable-accounts.ts +50 -0
  48. package/db/reserve.db.d.ts +34 -0
  49. package/db/reserve.db.js +52 -0
  50. package/db/reserve.db.ts +48 -0
  51. package/db/uploads.db.d.ts +2 -0
  52. package/db/uploads.db.js +29 -0
  53. package/db/uploads.db.ts +24 -0
  54. package/helpers/main.helper.d.ts +31 -0
  55. package/helpers/main.helper.js +63 -0
  56. package/helpers/main.helper.ts +63 -0
  57. package/models/AccountPayableItem.model.d.ts +6 -6
  58. package/models/AllocatedBankTransaction.model.d.ts +54 -0
  59. package/models/AllocatedBankTransaction.model.js +70 -0
  60. package/models/AllocatedBankTransaction.model.ts +94 -0
  61. package/models/AllocatedData.model.d.ts +33 -0
  62. package/models/AllocatedData.model.js +19 -0
  63. package/models/AllocatedData.model.ts +24 -0
  64. package/models/BBCDate.model.d.ts +3 -3
  65. package/models/BBCSheet.model.d.ts +3 -3
  66. package/models/Banks.model.d.ts +3 -3
  67. package/models/Borrower.model.d.ts +3 -3
  68. package/models/BorrowerData.model.d.ts +3 -3
  69. package/models/BorrowerDataInsurance.model.d.ts +3 -3
  70. package/models/BorrowerDataTerm.model.d.ts +3 -3
  71. package/models/BorrowerSummary.model.js +1 -1
  72. package/models/BorrowerSummary.model.ts +1 -1
  73. package/models/CalandarDay.model.d.ts +40 -0
  74. package/models/CalandarDay.model.js +47 -0
  75. package/models/CalandarDay.model.ts +61 -0
  76. package/models/CashAllocationProduct.model.d.ts +119 -0
  77. package/models/CashAllocationProduct.model.js +102 -0
  78. package/models/CashAllocationProduct.model.ts +112 -0
  79. package/models/CashAllocationReference.model.d.ts +37 -0
  80. package/models/CashAllocationReference.model.js +27 -0
  81. package/models/CashAllocationReference.model.ts +40 -0
  82. package/models/CollateralAdjustment.model.d.ts +51 -0
  83. package/models/CollateralAdjustment.model.js +61 -0
  84. package/models/CollateralAdjustment.model.ts +98 -0
  85. package/models/Company.model.d.ts +35 -0
  86. package/models/Company.model.js +18 -0
  87. package/models/Company.model.ts +29 -0
  88. package/models/CustomerAPGroup.model.d.ts +32 -0
  89. package/models/CustomerAPGroup.model.js +24 -0
  90. package/models/CustomerAPGroup.model.ts +31 -0
  91. package/models/Equipment.model.d.ts +53 -0
  92. package/models/Equipment.model.js +140 -0
  93. package/models/Equipment.model.ts +172 -0
  94. package/models/FinancialCompliance.model.d.ts +39 -0
  95. package/models/FinancialCompliance.model.js +64 -0
  96. package/models/FinancialCompliance.model.ts +78 -0
  97. package/models/FinancialComplianceBorrower.model.d.ts +58 -0
  98. package/models/FinancialComplianceBorrower.model.js +82 -0
  99. package/models/FinancialComplianceBorrower.model.ts +118 -0
  100. package/models/FinancialIndexes.model.d.ts +36 -0
  101. package/models/FinancialIndexes.model.js +27 -0
  102. package/models/FinancialIndexes.model.ts +37 -0
  103. package/models/Inventory.model.d.ts +18 -18
  104. package/models/InventoryAvailability.model.d.ts +21 -21
  105. package/models/InventoryAvailabilityItem.model.d.ts +6 -6
  106. package/models/InventoryItem.model.d.ts +24 -24
  107. package/models/InventoryManualEntry.model.d.ts +9 -9
  108. package/models/InventorySeasonalRates.model.d.ts +3 -3
  109. package/models/LoanBroker.model.d.ts +3 -3
  110. package/models/LoanCharges.model.d.ts +12 -12
  111. package/models/LoanProducts.model.d.ts +9 -9
  112. package/models/LoanStatementStatus.model.d.ts +35 -0
  113. package/models/LoanStatementStatus.model.js +34 -0
  114. package/models/LoanStatementStatus.model.ts +45 -0
  115. package/models/LoanStatementTransaction.model.d.ts +9 -9
  116. package/models/LoanTransactionFile.model.d.ts +41 -0
  117. package/models/LoanTransactionFile.model.js +44 -0
  118. package/models/LoanTransactionFile.model.ts +61 -0
  119. package/models/MappedGroup.model.d.ts +37 -0
  120. package/models/MappedGroup.model.js +33 -0
  121. package/models/MappedGroup.model.ts +46 -0
  122. package/models/MonthEndData.Model.d.ts +41 -0
  123. package/models/MonthEndData.Model.js +42 -0
  124. package/models/MonthEndData.Model.ts +53 -0
  125. package/models/OrganizationEmails.model.d.ts +44 -0
  126. package/models/OrganizationEmails.model.js +40 -0
  127. package/models/OrganizationEmails.model.ts +54 -0
  128. package/models/ProductBroker.model.d.ts +9 -9
  129. package/models/QuickbooksAccount.model.d.ts +39 -0
  130. package/models/QuickbooksAccount.model.js +43 -0
  131. package/models/QuickbooksAccount.model.ts +57 -0
  132. package/models/Receivable.model.d.ts +12 -12
  133. package/models/ReceivableAvailability.model.d.ts +54 -54
  134. package/models/ReceivableAvailabilityItem.model.d.ts +57 -57
  135. package/models/ReceivableItem.model.d.ts +6 -6
  136. package/models/Reserve.model.d.ts +51 -0
  137. package/models/Reserve.model.js +96 -0
  138. package/models/Reserve.model.ts +125 -0
  139. package/models/TermLoan.model.d.ts +3 -3
  140. package/models/TermLoanCalculated.model.d.ts +6 -6
  141. package/models/TransactionAttachedFile.Model.d.ts +35 -0
  142. package/models/TransactionAttachedFile.Model.js +37 -0
  143. package/models/TransactionAttachedFile.Model.ts +48 -0
  144. package/models/UploadedBankTransaction.model.d.ts +56 -0
  145. package/models/UploadedBankTransaction.model.js +78 -0
  146. package/models/UploadedBankTransaction.model.ts +110 -0
  147. package/models/UploadedData.model.d.ts +36 -0
  148. package/models/UploadedData.model.js +23 -0
  149. package/models/UploadedData.model.ts +35 -0
  150. package/models/UploadedFile.model.d.ts +40 -0
  151. package/models/UploadedFile.model.js +41 -0
  152. package/models/UploadedFile.model.ts +57 -0
  153. package/models/UploadedSheet.model.d.ts +46 -0
  154. package/models/UploadedSheet.model.js +27 -0
  155. package/models/UploadedSheet.model.ts +51 -0
  156. package/package.json +10 -1
  157. package/repositories/globals.repository.d.ts +8 -0
  158. package/repositories/globals.repository.js +24 -0
  159. package/repositories/globals.repository.ts +21 -0
  160. package/services/attached-files.service.d.ts +57 -0
  161. package/services/attached-files.service.js +103 -0
  162. package/services/attached-files.service.ts +123 -0
  163. package/services/availability.service.d.ts +77 -0
  164. package/services/availability.service.js +897 -0
  165. package/services/availability.service.ts +1034 -0
  166. package/services/bank-uploaded-transactions.service.d.ts +33 -0
  167. package/services/bank-uploaded-transactions.service.js +430 -0
  168. package/services/bank-uploaded-transactions.service.ts +475 -0
  169. package/services/banks.service.d.ts +36 -0
  170. package/services/banks.service.js +91 -0
  171. package/services/banks.service.ts +95 -0
  172. package/services/borrower-summary.service.d.ts +35 -0
  173. package/services/borrower-summary.service.js +310 -0
  174. package/services/borrower-summary.service.ts +334 -0
  175. package/services/borrowers.service.d.ts +103 -0
  176. package/services/borrowers.service.js +268 -0
  177. package/services/borrowers.service.ts +302 -0
  178. package/services/brokers.service.d.ts +212 -0
  179. package/services/brokers.service.js +160 -0
  180. package/services/brokers.service.ts +200 -0
  181. package/services/calendar.service.d.ts +53 -0
  182. package/services/calendar.service.js +108 -0
  183. package/services/calendar.service.ts +128 -0
  184. package/services/cash-allocation.service.d.ts +40 -0
  185. package/services/cash-allocation.service.js +92 -0
  186. package/services/cash-allocation.service.ts +105 -0
  187. package/services/collateral-adjustments.service.d.ts +38 -0
  188. package/services/collateral-adjustments.service.js +82 -0
  189. package/services/collateral-adjustments.service.ts +95 -0
  190. package/services/collaterals.service.d.ts +69 -0
  191. package/services/collaterals.service.js +279 -0
  192. package/services/collaterals.service.ts +319 -0
  193. package/services/companies.service.d.ts +5 -0
  194. package/services/companies.service.js +21 -0
  195. package/services/companies.service.ts +23 -0
  196. package/services/compliance-borrowers.service.d.ts +152 -0
  197. package/services/compliance-borrowers.service.js +569 -0
  198. package/services/compliance-borrowers.service.ts +617 -0
  199. package/services/equipment.service.d.ts +42 -0
  200. package/services/equipment.service.js +120 -0
  201. package/services/equipment.service.ts +149 -0
  202. package/services/file-manager.service.d.ts +44 -0
  203. package/services/file-manager.service.js +120 -0
  204. package/services/file-manager.service.ts +146 -0
  205. package/services/financial-compliance.service.d.ts +58 -0
  206. package/services/financial-compliance.service.js +281 -0
  207. package/services/financial-compliance.service.ts +309 -0
  208. package/services/financial-indexes.service.d.ts +20 -0
  209. package/services/financial-indexes.service.js +241 -0
  210. package/services/financial-indexes.service.ts +257 -0
  211. package/services/financial-spreading.service.d.ts +74 -0
  212. package/services/financial-spreading.service.js +450 -0
  213. package/services/financial-spreading.service.ts +517 -0
  214. package/services/globals.service.d.ts +5 -0
  215. package/services/globals.service.js +11 -0
  216. package/services/globals.service.ts +8 -0
  217. package/services/groups.service.d.ts +39 -0
  218. package/services/groups.service.js +65 -0
  219. package/services/groups.service.ts +64 -0
  220. package/services/inventory-availability.service.d.ts +13 -0
  221. package/services/inventory-availability.service.js +170 -0
  222. package/services/inventory-availability.service.ts +187 -0
  223. package/services/inventory.service.d.ts +118 -0
  224. package/services/inventory.service.js +239 -0
  225. package/services/inventory.service.ts +276 -0
  226. package/services/loan-charges.service.d.ts +83 -0
  227. package/services/loan-charges.service.js +343 -0
  228. package/services/loan-charges.service.ts +396 -0
  229. package/services/loan-payments.service.d.ts +94 -0
  230. package/services/loan-payments.service.js +485 -0
  231. package/services/loan-payments.service.ts +541 -0
  232. package/services/loan-products.service.d.ts +12 -0
  233. package/services/loan-products.service.js +55 -0
  234. package/services/loan-products.service.ts +58 -0
  235. package/services/loan-statement-balance.service.d.ts +16 -0
  236. package/services/loan-statement-balance.service.js +106 -0
  237. package/services/loan-statement-balance.service.ts +113 -0
  238. package/services/loan-statement-effects.service.d.ts +8 -0
  239. package/services/loan-statement-effects.service.js +42 -0
  240. package/services/loan-statement-effects.service.ts +41 -0
  241. package/services/loan-statement-status.service.d.ts +208 -0
  242. package/services/loan-statement-status.service.js +159 -0
  243. package/services/loan-statement-status.service.ts +177 -0
  244. package/services/loan-statement.service.d.ts +186 -0
  245. package/services/loan-statement.service.js +935 -0
  246. package/services/loan-statement.service.ts +1040 -0
  247. package/services/loan-transactions.service.d.ts +169 -0
  248. package/services/loan-transactions.service.js +941 -0
  249. package/services/loan-transactions.service.ts +1042 -0
  250. package/services/lock.service.d.ts +6 -0
  251. package/services/lock.service.js +45 -0
  252. package/services/lock.service.ts +45 -0
  253. package/services/manual-entry.service.d.ts +20 -0
  254. package/services/manual-entry.service.js +186 -0
  255. package/services/manual-entry.service.ts +201 -0
  256. package/services/month-end-data.service.d.ts +34 -0
  257. package/services/month-end-data.service.js +30 -0
  258. package/services/month-end-data.service.ts +35 -0
  259. package/services/nodemailer.service.d.ts +96 -0
  260. package/services/nodemailer.service.js +689 -0
  261. package/services/nodemailer.service.ts +774 -0
  262. package/services/organization-emails.service.d.ts +31 -0
  263. package/services/organization-emails.service.js +10 -0
  264. package/services/organization-emails.service.ts +7 -0
  265. package/services/organizations.service.d.ts +34 -0
  266. package/services/organizations.service.js +74 -0
  267. package/services/organizations.service.ts +84 -0
  268. package/services/pdf.service.d.ts +61 -0
  269. package/services/pdf.service.js +547 -0
  270. package/services/pdf.service.ts +642 -0
  271. package/services/quickbooks.service.d.ts +99 -0
  272. package/services/quickbooks.service.js +640 -0
  273. package/services/quickbooks.service.ts +734 -0
  274. package/services/reports/investor-summary.service.d.ts +28 -0
  275. package/services/reports/investor-summary.service.js +136 -0
  276. package/services/reports/investor-summary.service.ts +159 -0
  277. package/services/reports.service.d.ts +126 -0
  278. package/services/reports.service.js +584 -0
  279. package/services/reports.service.ts +702 -0
  280. package/services/reserve.service.d.ts +37 -0
  281. package/services/reserve.service.js +76 -0
  282. package/services/reserve.service.ts +79 -0
  283. package/services/sentry.service.d.ts +11 -0
  284. package/services/sentry.service.js +49 -0
  285. package/services/sentry.service.ts +33 -0
  286. package/services/signs.service.d.ts +69 -0
  287. package/services/signs.service.js +230 -0
  288. package/services/signs.service.ts +260 -0
  289. package/services/term-loan.service.d.ts +30 -0
  290. package/services/term-loan.service.js +614 -0
  291. package/services/term-loan.service.ts +696 -0
  292. package/services/uploads.service.d.ts +134 -0
  293. package/services/uploads.service.js +587 -0
  294. package/services/uploads.service.ts +643 -0
  295. package/services/user-logs.service.d.ts +23 -0
  296. package/services/user-logs.service.js +160 -0
  297. package/services/user-logs.service.ts +177 -0
  298. package/services/users.service.d.ts +4 -4
  299. package/services/yield.service.d.ts +46 -0
  300. package/services/yield.service.js +42 -12
  301. package/services/yield.service.ts +38 -8
  302. package/tsconfig.json +5 -5
  303. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,17 @@
1
+ import { ELoanTransactionTypes, ILoanTransactionUpload } from '../models/LoanTransaction.model';
2
+ import { BorrowerService } from '../services/borrowers.service';
3
+ export declare class LoanTransactionItem implements ILoanTransactionUpload {
4
+ private readonly borrowerService;
5
+ amount: number;
6
+ customerId: string;
7
+ date: Date;
8
+ description: string;
9
+ ledgerAccountCode: string;
10
+ reference: string;
11
+ bankAccountNumber: string;
12
+ transactionType: ELoanTransactionTypes;
13
+ isStatement: boolean;
14
+ constructor(item: Partial<ILoanTransactionUpload>, borrowerService: BorrowerService);
15
+ initialize(): Promise<any[]>;
16
+ validateData(): Promise<any[]>;
17
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LoanTransactionItem = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const column_desciptions_helper_1 = require("../helpers/column-desciptions.helper");
9
+ const collaterals_enum_1 = require("../enums/collaterals.enum");
10
+ const LoanTransaction_model_1 = require("../models/LoanTransaction.model");
11
+ const LoanProducts_model_1 = require("../models/LoanProducts.model");
12
+ const Borrower_model_1 = require("../models/Borrower.model");
13
+ const banks_service_1 = require("../services/banks.service");
14
+ const loan_charges_service_1 = require("../services/loan-charges.service");
15
+ class LoanTransactionItem {
16
+ borrowerService;
17
+ amount = 0;
18
+ customerId = '';
19
+ date = new Date();
20
+ description = '';
21
+ ledgerAccountCode = '';
22
+ reference = '';
23
+ bankAccountNumber = '';
24
+ transactionType = null;
25
+ isStatement = false;
26
+ constructor(item, borrowerService) {
27
+ this.borrowerService = borrowerService;
28
+ const itemWithDates = (0, column_desciptions_helper_1.convertIntoDates)(item, collaterals_enum_1.ECollaterals.LOAN_TRANSACTIONS);
29
+ const itemWithoutNulls = lodash_1.default.omitBy(itemWithDates, (value) => value === null);
30
+ this.transactionType = item.amount < 0 ? LoanTransaction_model_1.ELoanTransactionTypes.COLLECTION : LoanTransaction_model_1.ELoanTransactionTypes.DISBURSEMENT;
31
+ Object.assign(this, itemWithoutNulls);
32
+ }
33
+ async initialize() {
34
+ return await this.validateData();
35
+ }
36
+ async validateData() {
37
+ const errors = [];
38
+ const banksService = new banks_service_1.BanksService();
39
+ const foundBank = await banksService.findBankByNumber(this.bankAccountNumber);
40
+ const loanChargesService = new loan_charges_service_1.LoanChargesService(this.borrowerService);
41
+ const foundProductId = await loanChargesService.getLoanProductIdByCode(this.ledgerAccountCode);
42
+ const foundChargeId = await loanChargesService.getLoanChargeIdByCode(this.ledgerAccountCode);
43
+ if (foundChargeId) {
44
+ this.isStatement = true;
45
+ }
46
+ if (!foundBank) {
47
+ errors.push({ bankAccountNumber: [{ error: `no bank with this code` }] });
48
+ }
49
+ if (!foundProductId && !foundChargeId) {
50
+ errors.push({ ledgerAccountCode: [{ error: `no product with this code` }] });
51
+ }
52
+ if (foundProductId) {
53
+ const product = await LoanProducts_model_1.LoanProduct.findById(foundProductId).lean();
54
+ if (product) {
55
+ const borrower = await Borrower_model_1.BorrowerModel.findById(product.borrowerId).lean();
56
+ if (!borrower.active) {
57
+ errors.push({ borrower: [{ error: `borrower is not active` }] });
58
+ }
59
+ }
60
+ }
61
+ return errors;
62
+ }
63
+ }
64
+ exports.LoanTransactionItem = LoanTransactionItem;
@@ -0,0 +1,66 @@
1
+ import _ from 'lodash';
2
+
3
+ import { convertIntoDates } from '../helpers/column-desciptions.helper';
4
+ import { ECollaterals } from '../enums/collaterals.enum';
5
+ import { ELoanTransactionTypes, ILoanTransactionUpload } from '../models/LoanTransaction.model';
6
+ import { LoanProduct } from '../models/LoanProducts.model';
7
+ import { BorrowerModel } from '../models/Borrower.model';
8
+ import { BanksService } from '../services/banks.service';
9
+ import { LoanChargesService } from '../services/loan-charges.service';
10
+ import { BorrowerService } from '../services/borrowers.service';
11
+
12
+ export class LoanTransactionItem implements ILoanTransactionUpload {
13
+
14
+ amount = 0;
15
+ customerId = '';
16
+ date = new Date();
17
+ description = '';
18
+ ledgerAccountCode = '';
19
+ reference = '';
20
+ bankAccountNumber = '';
21
+ transactionType: ELoanTransactionTypes = null;
22
+ isStatement = false;
23
+
24
+ constructor(
25
+ item: Partial<ILoanTransactionUpload>,
26
+ private readonly borrowerService: BorrowerService,
27
+ ) {
28
+ const itemWithDates = convertIntoDates(item, ECollaterals.LOAN_TRANSACTIONS);
29
+ const itemWithoutNulls = _.omitBy(itemWithDates, (value) => value === null);
30
+ this.transactionType = item.amount < 0 ? ELoanTransactionTypes.COLLECTION : ELoanTransactionTypes.DISBURSEMENT;
31
+ Object.assign(this, itemWithoutNulls);
32
+ }
33
+
34
+ async initialize() {
35
+ return await this.validateData();
36
+ }
37
+
38
+ async validateData() {
39
+ const errors = [];
40
+ const banksService: BanksService = new BanksService();
41
+ const foundBank = await banksService.findBankByNumber(this.bankAccountNumber);
42
+ const loanChargesService: LoanChargesService = new LoanChargesService(this.borrowerService);
43
+ const foundProductId = await loanChargesService.getLoanProductIdByCode(this.ledgerAccountCode);
44
+ const foundChargeId = await loanChargesService.getLoanChargeIdByCode(this.ledgerAccountCode);
45
+ if (foundChargeId) {
46
+ this.isStatement = true;
47
+ }
48
+ if (!foundBank) {
49
+ errors.push({ bankAccountNumber: [{ error: `no bank with this code` }] });
50
+ }
51
+ if (!foundProductId && !foundChargeId) {
52
+ errors.push({ ledgerAccountCode: [{ error: `no product with this code` }] });
53
+ }
54
+ if (foundProductId) {
55
+ const product = await LoanProduct.findById(foundProductId).lean();
56
+ if (product) {
57
+ const borrower = await BorrowerModel.findById(product.borrowerId).lean();
58
+ if (!borrower.active) {
59
+ errors.push({ borrower: [{ error: `borrower is not active` }] });
60
+ }
61
+ }
62
+ }
63
+ return errors;
64
+ }
65
+
66
+ }
@@ -0,0 +1,17 @@
1
+ import { IUploadedBankTransaction } from '../models/UploadedBankTransaction.model';
2
+ export declare class BankUploadedTransactionItem implements IUploadedBankTransaction {
3
+ date: Date;
4
+ accountNumber: string;
5
+ amount: number;
6
+ transactionType: string;
7
+ reference: string;
8
+ detail1: string;
9
+ detail2: string;
10
+ detail3: string;
11
+ isConverted: boolean;
12
+ splitTransactions: any[];
13
+ order: number;
14
+ constructor(item: Partial<IUploadedBankTransaction>, options: {
15
+ [extraOption: string]: string;
16
+ });
17
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BankUploadedTransactionItem = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const column_desciptions_helper_1 = require("../helpers/column-desciptions.helper");
9
+ const collaterals_enum_1 = require("../enums/collaterals.enum");
10
+ class BankUploadedTransactionItem {
11
+ date = new Date();
12
+ accountNumber = '';
13
+ amount = 0;
14
+ transactionType = '';
15
+ reference = '';
16
+ detail1 = '';
17
+ detail2 = '';
18
+ detail3 = '';
19
+ isConverted = false;
20
+ splitTransactions = [];
21
+ order;
22
+ constructor(item, options) {
23
+ if (options && options.bankAccountNumber && (!item.accountNumber || item.accountNumber.toString().trim() === '')) {
24
+ item.accountNumber = options.bankAccountNumber;
25
+ }
26
+ const itemWithDates = (0, column_desciptions_helper_1.convertIntoDates)(item, collaterals_enum_1.ECollaterals.UPLOADED_BANK_TRANSACTIONS);
27
+ const itemWithoutNulls = lodash_1.default.omitBy(itemWithDates, (value) => value === null);
28
+ Object.assign(this, itemWithoutNulls);
29
+ this.amount = item.amount ?? 0;
30
+ if (!this.amount) {
31
+ this.amount = item.credit - item.debit;
32
+ }
33
+ }
34
+ }
35
+ exports.BankUploadedTransactionItem = BankUploadedTransactionItem;
@@ -0,0 +1,35 @@
1
+ import _ from 'lodash';
2
+
3
+ import { convertIntoDates } from '../helpers/column-desciptions.helper';
4
+ import { ECollaterals } from '../enums/collaterals.enum';
5
+
6
+ import { IUploadedBankTransaction } from '../models/UploadedBankTransaction.model';
7
+
8
+ export class BankUploadedTransactionItem implements IUploadedBankTransaction {
9
+
10
+ date = new Date();
11
+ accountNumber = '';
12
+ amount = 0;
13
+ transactionType = '';
14
+ reference = '';
15
+ detail1 = '';
16
+ detail2 = '';
17
+ detail3 = '';
18
+ isConverted = false;
19
+ splitTransactions = [];
20
+ order: number;
21
+
22
+ constructor(item: Partial<IUploadedBankTransaction>, options: { [extraOption: string]: string }) {
23
+ if (options && options.bankAccountNumber && (!item.accountNumber || item.accountNumber.toString().trim() === '')) {
24
+ item.accountNumber = options.bankAccountNumber;
25
+ }
26
+ const itemWithDates = convertIntoDates(item, ECollaterals.UPLOADED_BANK_TRANSACTIONS);
27
+ const itemWithoutNulls = _.omitBy(itemWithDates, (value) => value === null);
28
+ Object.assign(this, itemWithoutNulls);
29
+ this.amount = item.amount ?? 0;
30
+ if (!this.amount) {
31
+ this.amount = item.credit - item.debit;
32
+ }
33
+ }
34
+
35
+ }
@@ -0,0 +1,41 @@
1
+ interface IInventoryItemLocal {
2
+ bbcDate: Date;
3
+ sku: number;
4
+ lotNumber: number;
5
+ category: string;
6
+ location: string;
7
+ skuDescription1: string;
8
+ skuDescription2: string;
9
+ skuDescription3: string;
10
+ detail1: string;
11
+ detail2: string;
12
+ detail3: string;
13
+ skuDate: Date;
14
+ expiryDate: string;
15
+ qty: number;
16
+ unitCost: number;
17
+ value: number;
18
+ }
19
+ export declare class InventoryItem implements IInventoryItemLocal {
20
+ bbcDate: Date;
21
+ category: string;
22
+ expiryDate: string;
23
+ location: string;
24
+ lotNumber: number;
25
+ qty: number;
26
+ sku: number;
27
+ skuDate: Date;
28
+ skuDescription1: string;
29
+ skuDescription2: string;
30
+ skuDescription3: string;
31
+ detail1: string;
32
+ detail2: string;
33
+ detail3: string;
34
+ unitCost: number;
35
+ value: number;
36
+ constructor(item: Partial<InventoryItem>, bbcDate?: any, skuDates?: {
37
+ _id: string;
38
+ oldestDate: string;
39
+ }[]);
40
+ }
41
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InventoryItem = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const column_desciptions_helper_1 = require("../helpers/column-desciptions.helper");
9
+ const collaterals_enum_1 = require("../enums/collaterals.enum");
10
+ class InventoryItem {
11
+ bbcDate = null;
12
+ category = 'NO CATEGORY';
13
+ expiryDate = '';
14
+ location = '';
15
+ lotNumber = 0;
16
+ qty = 1;
17
+ sku = 0;
18
+ skuDate = null;
19
+ skuDescription1 = '';
20
+ skuDescription2 = '';
21
+ skuDescription3 = '';
22
+ detail1 = '';
23
+ detail2 = '';
24
+ detail3 = '';
25
+ unitCost = 0;
26
+ value = 0;
27
+ constructor(item, bbcDate = null, skuDates = []) {
28
+ const itemWithDates = (0, column_desciptions_helper_1.convertIntoDates)(item, collaterals_enum_1.ECollaterals.INVENTORY);
29
+ const itemWithoutNulls = lodash_1.default.omitBy(itemWithDates, (value) => value === null);
30
+ Object.assign(this, itemWithoutNulls);
31
+ this.bbcDate = bbcDate;
32
+ if (!this.skuDate && item.sku) {
33
+ const previousSKUDate = skuDates.find((d) => item.sku.toString().trim() === d._id);
34
+ if (!previousSKUDate) {
35
+ this.skuDate = this.bbcDate;
36
+ }
37
+ else {
38
+ const isPreviousDateGreaterThanSubmittedDate = new Date(previousSKUDate.oldestDate).getTime() > new Date(this.bbcDate).getTime();
39
+ this.skuDate = isPreviousDateGreaterThanSubmittedDate ? this.bbcDate : new Date(previousSKUDate.oldestDate);
40
+ }
41
+ }
42
+ }
43
+ }
44
+ exports.InventoryItem = InventoryItem;
@@ -0,0 +1,63 @@
1
+ import _ from 'lodash';
2
+
3
+ import { convertIntoDates } from '../helpers/column-desciptions.helper';
4
+ import { ECollaterals } from '../enums/collaterals.enum';
5
+
6
+ interface IInventoryItemLocal {
7
+ bbcDate: Date;
8
+ sku: number;
9
+ lotNumber: number;
10
+ category: string;
11
+ location: string;
12
+ skuDescription1: string;
13
+ skuDescription2: string;
14
+ skuDescription3: string;
15
+ detail1: string;
16
+ detail2: string;
17
+ detail3: string;
18
+ skuDate: Date;
19
+ expiryDate: string;
20
+ qty: number;
21
+ unitCost: number;
22
+ value: number;
23
+ }
24
+
25
+ export class InventoryItem implements IInventoryItemLocal {
26
+ bbcDate: Date = null;
27
+ category: string = 'NO CATEGORY';
28
+ expiryDate: string = '';
29
+ location: string = '';
30
+ lotNumber: number = 0;
31
+ qty: number = 1;
32
+ sku: number = 0;
33
+ skuDate: Date = null;
34
+ skuDescription1: string = '';
35
+ skuDescription2: string = '';
36
+ skuDescription3: string = '';
37
+ detail1: string = '';
38
+ detail2: string = '';
39
+ detail3: string = '';
40
+ unitCost: number = 0;
41
+ value: number = 0;
42
+
43
+ constructor(
44
+ item: Partial<InventoryItem>,
45
+ bbcDate = null,
46
+ skuDates: { _id: string; oldestDate: string }[] = [],
47
+ ) {
48
+ const itemWithDates = convertIntoDates(item, ECollaterals.INVENTORY);
49
+ const itemWithoutNulls = _.omitBy(itemWithDates, (value) => value === null);
50
+ Object.assign(this, itemWithoutNulls);
51
+ this.bbcDate = bbcDate;
52
+ if (!this.skuDate && item.sku) {
53
+ const previousSKUDate = skuDates.find((d) => item.sku.toString().trim() === d._id);
54
+ if (!previousSKUDate) {
55
+ this.skuDate = this.bbcDate;
56
+ } else {
57
+ const isPreviousDateGreaterThanSubmittedDate = new Date(previousSKUDate.oldestDate).getTime() > new Date(this.bbcDate).getTime();
58
+ this.skuDate = isPreviousDateGreaterThanSubmittedDate ? this.bbcDate : new Date(previousSKUDate.oldestDate);
59
+ }
60
+ }
61
+ }
62
+
63
+ }
@@ -0,0 +1,22 @@
1
+ interface IPayableAccountLocal {
2
+ bbcDate: Date;
3
+ apDate: string;
4
+ poNumber: string;
5
+ customerName: string;
6
+ amount: number;
7
+ otherInformation1: string;
8
+ otherInformation2: string;
9
+ otherInformation3: string;
10
+ }
11
+ export declare class PayableAccountItem implements IPayableAccountLocal {
12
+ bbcDate: Date;
13
+ apDate: string;
14
+ poNumber: string;
15
+ customerName: string;
16
+ amount: number;
17
+ otherInformation1: string;
18
+ otherInformation2: string;
19
+ otherInformation3: string;
20
+ constructor(item: Partial<PayableAccountItem>, bbcDate?: any);
21
+ }
22
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PayableAccountItem = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const column_desciptions_helper_1 = require("../helpers/column-desciptions.helper");
9
+ const collaterals_enum_1 = require("../enums/collaterals.enum");
10
+ class PayableAccountItem {
11
+ bbcDate = null;
12
+ apDate = '';
13
+ poNumber = '';
14
+ customerName = '';
15
+ amount = 0;
16
+ otherInformation1 = '';
17
+ otherInformation2 = '';
18
+ otherInformation3 = '';
19
+ constructor(item, bbcDate = null) {
20
+ const itemWithDates = (0, column_desciptions_helper_1.convertIntoDates)(item, collaterals_enum_1.ECollaterals.ACCOUNT_PAYABLE);
21
+ const itemWithoutNulls = lodash_1.default.omitBy(itemWithDates, (value) => value === null);
22
+ Object.assign(this, itemWithoutNulls);
23
+ this.bbcDate = bbcDate;
24
+ this.apDate = !this.apDate ? (new Date()).toISOString() : this.apDate;
25
+ }
26
+ }
27
+ exports.PayableAccountItem = PayableAccountItem;
@@ -0,0 +1,35 @@
1
+ import _ from 'lodash';
2
+
3
+ import { convertIntoDates } from '../helpers/column-desciptions.helper';
4
+ import { ECollaterals } from '../enums/collaterals.enum';
5
+
6
+ interface IPayableAccountLocal {
7
+ bbcDate: Date;
8
+ apDate: string;
9
+ poNumber: string;
10
+ customerName: string;
11
+ amount: number;
12
+ otherInformation1: string;
13
+ otherInformation2: string;
14
+ otherInformation3: string;
15
+ }
16
+
17
+ export class PayableAccountItem implements IPayableAccountLocal {
18
+
19
+ bbcDate: Date = null;
20
+ apDate: string = '';
21
+ poNumber: string = '';
22
+ customerName: string = '';
23
+ amount: number = 0;
24
+ otherInformation1: string = '';
25
+ otherInformation2: string = '';
26
+ otherInformation3: string = '';
27
+
28
+ constructor(item: Partial<PayableAccountItem>, bbcDate = null) {
29
+ const itemWithDates = convertIntoDates(item, ECollaterals.ACCOUNT_PAYABLE);
30
+ const itemWithoutNulls = _.omitBy(itemWithDates, (value) => value === null);
31
+ Object.assign(this, itemWithoutNulls);
32
+ this.bbcDate = bbcDate;
33
+ this.apDate = !this.apDate ? (new Date()).toISOString() : this.apDate;
34
+ }
35
+ }
@@ -0,0 +1,37 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose from 'mongoose';
26
+ import { IQuickbooksAccount } from '../models/QuickbooksAccount.model';
27
+ export declare class IQuickbooksUploadItem implements IQuickbooksAccount {
28
+ accountCode: string;
29
+ fullName: string;
30
+ description: string;
31
+ companyId: mongoose.Types.ObjectId;
32
+ constructor(item: Partial<IQuickbooksAccount>, options: {
33
+ [extraOption: string]: string;
34
+ });
35
+ initialize(): Promise<any[]>;
36
+ validateData(): Promise<any[]>;
37
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IQuickbooksUploadItem = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ function convertNumberToString(obj) {
9
+ let newObj = {};
10
+ for (const prop in obj) {
11
+ if (Object.prototype.hasOwnProperty.call(obj, prop)) {
12
+ if (obj[prop] === null) {
13
+ newObj[prop] = '';
14
+ }
15
+ else {
16
+ newObj[prop] = (typeof obj[prop] === 'number') ? obj[prop].toString() : obj[prop];
17
+ }
18
+ }
19
+ }
20
+ return newObj;
21
+ }
22
+ class IQuickbooksUploadItem {
23
+ accountCode = '';
24
+ fullName = '';
25
+ description = '';
26
+ companyId = null;
27
+ constructor(item, options) {
28
+ if (options && options.companyId) {
29
+ item.companyId = new mongoose_1.default.Types.ObjectId(options.companyId);
30
+ }
31
+ item = convertNumberToString(item);
32
+ Object.assign(this, item);
33
+ }
34
+ async initialize() {
35
+ return await this.validateData();
36
+ }
37
+ async validateData() {
38
+ const errors = [];
39
+ if (!this.accountCode || this.accountCode.trim().length === 0) {
40
+ errors.push({ accountCode: [{ error: `account code is too short` }] });
41
+ }
42
+ if (!this.fullName || this.fullName.trim().length === 0) {
43
+ errors.push({ fullName: [{ error: `full name is too short` }] });
44
+ }
45
+ if (!this.companyId) {
46
+ errors.push({ fullName: [{ error: `company is required` }] });
47
+ }
48
+ return errors;
49
+ }
50
+ }
51
+ exports.IQuickbooksUploadItem = IQuickbooksUploadItem;
@@ -0,0 +1,59 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ import { IQuickbooksAccount } from '../models/QuickbooksAccount.model';
4
+
5
+ function convertNumberToString(obj: Object): Object {
6
+ let newObj = {};
7
+ for (const prop in obj) {
8
+ if (Object.prototype.hasOwnProperty.call(obj, prop)) {
9
+ if (obj[prop] === null) {
10
+ newObj[prop] = '';
11
+ } else {
12
+ newObj[prop] = (typeof obj[prop] === 'number') ? obj[prop].toString() : obj[prop];
13
+ }
14
+ }
15
+ }
16
+ return newObj;
17
+ }
18
+
19
+ export class IQuickbooksUploadItem implements IQuickbooksAccount {
20
+
21
+ accountCode: string = '';
22
+ fullName: string = '';
23
+ description: string = '';
24
+ companyId: mongoose.Types.ObjectId = null;
25
+
26
+ constructor(
27
+ item: Partial<IQuickbooksAccount>,
28
+ options: { [extraOption: string]: string }
29
+ ) {
30
+ if (options && options.companyId) {
31
+ item.companyId = new mongoose.Types.ObjectId(options.companyId);
32
+ }
33
+ item = convertNumberToString(item);
34
+ Object.assign(this, item);
35
+ }
36
+
37
+ async initialize() {
38
+ return await this.validateData();
39
+ }
40
+
41
+ async validateData() {
42
+ const errors = [];
43
+
44
+ if (!this.accountCode || this.accountCode.trim().length === 0) {
45
+ errors.push({ accountCode: [{ error: `account code is too short` }] });
46
+ }
47
+
48
+ if (!this.fullName || this.fullName.trim().length === 0) {
49
+ errors.push({ fullName: [{ error: `full name is too short` }] });
50
+ }
51
+
52
+ if (!this.companyId) {
53
+ errors.push({ fullName: [{ error: `company is required` }] });
54
+ }
55
+
56
+ return errors;
57
+ }
58
+
59
+ }
@@ -0,0 +1,26 @@
1
+ interface IReceivableItemLocal {
2
+ bbcDate: Date;
3
+ invoiceDate: Date;
4
+ invoiceNumber: string;
5
+ customerTitle: string;
6
+ dueDate: Date;
7
+ invoiceAmount: number;
8
+ originalAmount: number;
9
+ invoiceDetail1: string;
10
+ invoiceDetail2: string;
11
+ invoiceDetail3: string;
12
+ }
13
+ export declare class ReceivableItem implements IReceivableItemLocal {
14
+ bbcDate: Date;
15
+ invoiceDate: Date;
16
+ invoiceNumber: string;
17
+ customerTitle: string;
18
+ dueDate: Date;
19
+ invoiceAmount: number;
20
+ originalAmount: number;
21
+ invoiceDetail1: string;
22
+ invoiceDetail2: string;
23
+ invoiceDetail3: string;
24
+ constructor(item: Partial<ReceivableItem>, bbcDate?: any);
25
+ }
26
+ export {};