Closed mario8754 closed 7 months ago
Hi, what config are you using?
im using nodejs ts en then version [3.0.47] of easy invoice
import easyinvoice, { InvoiceData } from "easyinvoice"; import path from "path"; import fs from "fs";
interface InvoiceProduct { description?: string; price?: number;
orderNumber?: string; adres?: string; postCode?: string; city?: string; land?: string; date?: string; name?: string; } export const data: InvoiceData = { // Customize enables ydou to provide your own templates // Please review the documentation for instructions and examples customize: { // "template": fs.readFileSync('template.html', 'base64') // Must be base64 encoded html }, // apiKey: process.env.APIKEY, images: { logo: "https://public.budgetinvoice.com/img/logo_en_original.png", background: "https://public.budgetinvoice.com/img/watermark_draft.jpg", //logo: "https:/.nl/img/logo.a6e4aac4.png",
}, sender: { company: " ", address: " ", zip: " ", city: " ", country: " ", }, client: { company: "", address: "", zip: "", city: "", country: "", }, information: { number: "", date: "", // "due-date": "31-12-2021", }, products: [ // { // quantity: 1, // description: " ", // "tax-rate": 21, // price: 0, // }, ], bottomNotice: "test",
// Settings to customize your invoice settings: { currency: "EUR", // See documentation 'Locales and Currency' for more info. Leave empty for no currency. locale: "nl-NL", // Defaults to en-US, used for number formatting (See documentation 'Locales and Currency') marginTop: 25, // Defaults to '25' marginRight: 25, // Defaults to '25' marginLeft: 25, // Defaults to '25' marginBottom: 25, // Defaults to '25' format: "A4", // Defaults to A4, options: A3, A4, A5, Legal, Letter, Tabloid // height: "1000px", // width: "500px", // orientation: "landscape", // portrait or landscape, defaults to portrait }, // Translate your invoice to your preferred language translate: { invoice: "Factuur", // Default to 'INVOICE' number: "Nummer", // Defaults to 'Number' date: "Datum", // Default to 'Date' dueDate: "Betaaldatum", // Defaults to 'Due Date' subtotal: "Subtotaal", // Defaults to 'Subtotal' products: "kavelnummers", // Defaults to 'Products' quantity: "Aantal", // Default to 'Quantity' price: "Prijs", // Defaults to 'Price' productTotal: "Totaal", // Defaults to 'Total' total: "Totaal", // Defaults to 'Total' vat: "btw", // Defaults to 'vat' }, };
export function generateInvoice(data: InvoiceData, fileName: string) {
const invoicesDirectory = path.join(
__dirname,
"..",
"..",
"folders/facturen"
);
console.log({ invoicesDirectory });
if (!fs.existsSync(invoicesDirectory)) {
fs.mkdirSync(invoicesDirectory);
}
const filePath = path.join(invoicesDirectory, fileName);
console.log(filePath);
return new Promise
is there something change or just the apikey that needs to be added
Hi, sorry, we didn't get a chance to respond yet. Had your issue been fixed?
Im getting an error when tryning to create an invoice
[Node] { result: { statusCode: 500, message: 'Internal server error' } } [Node] node:internal/process/promises:279 [Node] triggerUncaughtException(err, true / fromPromise /); [Node] ^ [Node] [Node] [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#