-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvoice-generator.js
More file actions
40 lines (33 loc) · 1.43 KB
/
invoice-generator.js
File metadata and controls
40 lines (33 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Generate a professional invoice using ReportForge API
// Usage: node invoice-generator.js
const lineItems = [
{ description: 'Web Development', quantity: 40, unit_price: 150, amount: 6000, client_name: 'Acme Corp' },
{ description: 'UI/UX Design', quantity: 20, unit_price: 125, amount: 2500, client_name: 'Acme Corp' },
{ description: 'API Integration', quantity: 16, unit_price: 175, amount: 2800, client_name: 'Acme Corp' },
{ description: 'QA Testing', quantity: 10, unit_price: 100, amount: 1000, client_name: 'Acme Corp' },
{ description: 'Project Management', quantity: 8, unit_price: 130, amount: 1040, client_name: 'Acme Corp' },
];
async function generateInvoice() {
const res = await fetch('https://reportforge-api.vercel.app/api/json-to-report', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
data: lineItems,
template: 'invoice',
title: 'Invoice #2026-0042'
})
});
if (!res.ok) {
console.error(`Error: ${res.status}`);
process.exit(1);
}
const { html, meta } = await res.json();
console.log('=== Invoice Generated ===');
console.log(`Template: ${meta.template}`);
console.log(`Line items: ${meta.rowCount}`);
const fs = await import('fs');
fs.writeFileSync('invoice.html', html);
console.log('\nInvoice saved to invoice.html');
console.log('Open in browser and print to PDF for a professional invoice.');
}
generateInvoice();