@monkeyplus/payscope 1.0.6 → 1.0.8

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
  };
@@ -3068,7 +3070,8 @@ function createGraphql(db) {
3068
3070
  name: true,
3069
3071
  endpoint: true
3070
3072
  } } } }
3071
- }
3073
+ },
3074
+ extras: { totalRefundsCount: (table) => db.$count(refunds, eq(refunds.transactionId, table.id)) }
3072
3075
  });
3073
3076
  },
3074
3077
  updateByPk: async (id, data) => {
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.8",
5
5
  "packageManager": "pnpm@10.8.1",
6
6
  "author": "",
7
7
  "keywords": [],