const fs = require('fs');

let js = fs.readFileSync('vouchers_returns.js', 'utf8');

// Replace all IDs like 'sales-return-xxx' to 'sales-returns-xxx' to match HTML
js = js.replace(/'sales-return-/g, "'sales-returns-");

fs.writeFileSync('vouchers_returns.js', js, 'utf8');

// Bust cache again just to be 100% sure
let html = fs.readFileSync('index.html', 'utf8');
const version = Date.now().toString();
html = html.replace(/v=\d+/g, 'v=' + version);
fs.writeFileSync('index.html', html, 'utf8');

console.log('Fixed plural IDs in vouchers_returns.js and busted cache.');
