@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.
- package/dist/_chunks/db.d.mts +1 -0
- package/dist/_chunks/lib.mjs +6 -3
- package/package.json +1 -1
package/dist/_chunks/db.d.mts
CHANGED
|
@@ -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;
|
package/dist/_chunks/lib.mjs
CHANGED
|
@@ -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
|
-
|
|
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 (
|
|
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) => {
|