Skip to content

Commit

Permalink
cancel_orders: check created invoices
Browse files Browse the repository at this point in the history
Added a new condition to validate the expiration time of
orders with the creation time of invoices.

Order will now be deleted if the order has expired and there
has been no payment or the payment has been made long ago.

Fixes: lnp2pBot#434

Co-authored-by: Afshin Arani <[email protected]>
  • Loading branch information
Mersho and aarani committed Jan 2, 2024
1 parent 2fbe162 commit 7ede948
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jobs/cancel_orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ const cancelOrders = async bot => {
// or where the buyer didn't add the invoice
const waitingPaymentOrders = await Order.find({
$or: [{ status: 'WAITING_PAYMENT' }, { status: 'WAITING_BUYER_INVOICE' }],
taken_at: { $lte: holdInvoiceTime },
$and: [
{
taken_at: { $lte: holdInvoiceTime },
$or: [
{ invoice_held_at: { $eq: null } },
{ invoice_held_at: { $lte: holdInvoiceTime } },
],
},
],
});
for (const order of waitingPaymentOrders) {
if (order.status === 'WAITING_PAYMENT') {
Expand Down

0 comments on commit 7ede948

Please sign in to comment.