const fs = require('fs');

if (fs.existsSync('sales_purchases_module.js')) {
    let js = fs.readFileSync('sales_purchases_module.js', 'utf8');
    
    // Fix deleteItem('transactions', ${inv.id}) -> deleteInvoice(${inv.id})
    js = js.replace(/deleteItem\('transactions',\s*\$\{inv\.id\}\)/g, 'deleteInvoice(${inv.id})');
    
    fs.writeFileSync('sales_purchases_module.js', js, 'utf8');
    console.log('Patched sales_purchases_module.js delete button bug');
}
