const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
require('fake-indexeddb/auto');
const idb = require('idb');

async function debugInvoice() {
    const db = await idb.openDB('ERP_DB', 1);
    const invoiceId = 1780582173244; // Wait, let me check the screenshot again... the number ends in 4 or 5? It says 1780582173244 and 1780582173245? The title says #1780582173244, the desc says 1780582173245. I'll just get all recent sales invoices.
    const allInvoices = await db.getAll('transactions');
    const sales = allInvoices.filter(i => i.type === 'sales').sort((a,b) => b.id - a.id).slice(0, 5);
    
    console.log(JSON.stringify(sales, null, 2));
}

debugInvoice();
