const { Order } = require('./models');
const { Op } = require('sequelize');

async function checkStatus() {
    const targetId = 'ORD/20260121-065/GZ06';
    console.log(`Checking status for: ${targetId}`);

    try {
        const order = await Order.findOne({
            where: {
                [Op.or]: [
                    { invoice_number: targetId },
                    { order_number: targetId }
                ]
            }
        });

        if (order) {
            console.log("FOUND!");
            console.log(`ID: ${order.id}`);
            console.log(`Current Status: '${order.status}'`);

            // Test update
            // order.status = 'cancellation_requested';
            // await order.save();
            // console.log("Updated to cancellation_requested manually.");
        } else {
            console.log("NOT FOUND");
        }
    } catch (error) {
        console.error("Error:", error);
    }
}

checkStatus();
