@monkeyplus/payscope 1.0.6 → 1.0.7

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.
@@ -1745,6 +1745,7 @@ type Session = typeof sessions.$inferSelect & {
1745
1745
  type Transaction = typeof transactions.$inferSelect & {
1746
1746
  checkout: typeof checkouts.$inferSelect;
1747
1747
  session: Session;
1748
+ totalRefundsCount?: number;
1748
1749
  };
1749
1750
  type Taxe = typeof taxes.$inferSelect & {
1750
1751
  type: typeof typeTaxes.$inferSelect;
@@ -410,7 +410,9 @@ function refundPayment({ providers, transaction }) {
410
410
  });
411
411
  const _transaction = await transaction.read(uid);
412
412
  assertTransactionProvider(provider, _transaction.provider);
413
- if (_transaction.ref && !_transaction.refunds.totalCount) {
413
+ const totalRefunds = _transaction?.refund?.totalCount || _transaction.totalRefundsCount;
414
+ console.log("totalRefunds::", totalRefunds);
415
+ if (_transaction.ref && !totalRefunds) {
414
416
  const totalAmount = Number(_transaction.checkout.total || 0);
415
417
  const requestedAmount = Number(options?.amount || 0);
416
418
  const refundAmount = requestedAmount > 0 && requestedAmount < totalAmount ? requestedAmount : totalAmount;
@@ -431,7 +433,7 @@ function refundPayment({ providers, transaction }) {
431
433
  payload: details
432
434
  };
433
435
  } else {
434
- if (_transaction.refunds.totalCount) return { message: "Esta transacción ya fue reversada" };
436
+ if (totalRefunds) return { message: "Esta transacción ya fue reversada" };
435
437
  return { message: " Esta transacción no tiene ref" };
436
438
  }
437
439
  };
@@ -3055,7 +3057,8 @@ function createGraphql(db) {
3055
3057
  name: true,
3056
3058
  endpoint: true
3057
3059
  } } } }
3058
- }
3060
+ },
3061
+ extras: { totalRefundsCount: (table) => db.$count(refunds, eq(refunds.transactionId, table.id)) }
3059
3062
  });
3060
3063
  },
3061
3064
  findByPk: async (id) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@monkeyplus/payscope",
3
3
  "type": "module",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "packageManager": "pnpm@10.8.1",
6
6
  "author": "",
7
7
  "keywords": [],