@riocrypto/common-server 1.0.2459 → 1.0.2460

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.
@@ -13,12 +13,10 @@ exports.getBulkPaymentFromReference = void 0;
13
13
  const common_1 = require("@riocrypto/common");
14
14
  const bulk_bank_payment_1 = require("../models/bulk-bank-payment");
15
15
  const getBulkPaymentFromReference = (reference, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
16
- // Ensure reference is defined and exactly 6 characters long
17
- if (!reference || reference.length !== 8) {
18
- throw new Error("Invalid reference. It must be exactly 8 characters long.");
16
+ if (!reference) {
17
+ throw new Error("Invalid reference. Reference cannot be empty.");
19
18
  }
20
- // Convert reference to lowercase to ensure case-insensitive comparison
21
- const bulkPaymentIdPart = reference.slice(2).toLowerCase();
19
+ const referenceText = reference.toLowerCase();
22
20
  const BulkBankPayment = (0, bulk_bank_payment_1.buildBulkBankPayment)(mongoose);
23
21
  const bulkPayments = yield BulkBankPayment.find({
24
22
  status: {
@@ -29,7 +27,11 @@ const getBulkPaymentFromReference = (reference, mongoose) => __awaiter(void 0, v
29
27
  ],
30
28
  },
31
29
  });
32
- const bulkPayment = bulkPayments.find((bulkPayment) => bulkPayment.id.toString().endsWith(bulkPaymentIdPart));
30
+ const bulkPayment = bulkPayments.find((bulkPayment) => {
31
+ const bulkPaymentId = bulkPayment.id.toString().toLowerCase();
32
+ const last6Chars = bulkPaymentId.slice(-6);
33
+ return referenceText.includes(last6Chars);
34
+ });
33
35
  if (!bulkPayment) {
34
36
  throw new Error("Bulk payment not found");
35
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2459",
3
+ "version": "1.0.2460",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",