ztechno_core 0.0.112 → 0.0.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -636,6 +636,7 @@ class InvoiceService {
|
|
|
636
636
|
});
|
|
637
637
|
// === COMPANY LOGO (left-aligned) ===
|
|
638
638
|
const logoPath = path_1.default.join(process.cwd(), '../zwebsite/public/img/invoice/invoice-logo.png');
|
|
639
|
+
const certPath = path_1.default.join(process.cwd(), '../zwebsite/public/img/invoice/invoice-certificates.png');
|
|
639
640
|
if (fs_1.default.existsSync(logoPath)) {
|
|
640
641
|
doc.image(logoPath, 50, 50, { width: 150 }); // Left side of A4 page
|
|
641
642
|
}
|
|
@@ -714,8 +715,10 @@ class InvoiceService {
|
|
|
714
715
|
return this;
|
|
715
716
|
},
|
|
716
717
|
text(text, x, opts, gap = 12) {
|
|
717
|
-
|
|
718
|
-
|
|
718
|
+
const o = opts ?? {};
|
|
719
|
+
const h = doc.heightOfString(text, o);
|
|
720
|
+
doc.text(text, x, this.y, o);
|
|
721
|
+
this.y += Math.max(h, gap);
|
|
719
722
|
return this;
|
|
720
723
|
},
|
|
721
724
|
row(label, labelX, value, valueX, gap = 14) {
|
|
@@ -798,28 +801,44 @@ class InvoiceService {
|
|
|
798
801
|
P.bold();
|
|
799
802
|
P.row('Totaal incl. BTW:', 370, this.formatMoney(grandTotal, invoice.currency), col5, 20);
|
|
800
803
|
P.normal();
|
|
801
|
-
// ===
|
|
804
|
+
// === TWO-COLUMN FOOTER: Description & Terms (left) | Bank details (right) ===
|
|
805
|
+
const footerStartY = P.y + 10;
|
|
806
|
+
// LEFT COLUMN: Description + Payment terms
|
|
807
|
+
P.y = footerStartY;
|
|
802
808
|
if (invoice.description) {
|
|
803
809
|
P.size(10).bold();
|
|
804
|
-
P.
|
|
810
|
+
P.text('Omschrijving:', 50, {}, 12);
|
|
805
811
|
P.normal();
|
|
806
|
-
P.text(invoice.description, 50, {}, 12);
|
|
812
|
+
P.text(invoice.description, 50, { width: 260 }, 12);
|
|
813
|
+
P.skip(4);
|
|
807
814
|
}
|
|
808
|
-
// === PAYMENT TERMS (Dutch law recommended) ===
|
|
809
815
|
if (invoice.payment_terms) {
|
|
810
816
|
P.size(10).bold();
|
|
811
|
-
P.
|
|
817
|
+
P.text('Betalingsvoorwaarden:', 50, {}, 12);
|
|
812
818
|
P.normal();
|
|
813
|
-
P.text(invoice.payment_terms, 50, {}, 12);
|
|
819
|
+
P.text(invoice.payment_terms, 50, { width: 260 }, 12);
|
|
814
820
|
}
|
|
815
|
-
|
|
821
|
+
const leftColEndY = P.y;
|
|
822
|
+
// RIGHT COLUMN: Bank details
|
|
823
|
+
P.y = footerStartY;
|
|
824
|
+
const bankCol = 340;
|
|
816
825
|
P.size(10).bold();
|
|
817
|
-
P.
|
|
826
|
+
P.text('Betalingsgegevens:', bankCol, { width: 220 }, 14);
|
|
818
827
|
P.normal();
|
|
819
|
-
P.text(`IBAN: ${cfg.company.iban}`,
|
|
820
|
-
if (cfg.company.bankName) P.text(`Bank: ${cfg.company.bankName}`,
|
|
821
|
-
P.text(`T.n.v.: ${cfg.company.company}`,
|
|
822
|
-
P.text(`O.v.v.: ${invoice.invoice_number}`,
|
|
828
|
+
P.text(`IBAN: ${cfg.company.iban}`, bankCol, { width: 220 });
|
|
829
|
+
if (cfg.company.bankName) P.text(`Bank: ${cfg.company.bankName}`, bankCol, { width: 220 });
|
|
830
|
+
P.text(`T.n.v.: ${cfg.company.company}`, bankCol, { width: 220 });
|
|
831
|
+
P.text(`O.v.v.: ${invoice.invoice_number}`, bankCol, { width: 220 });
|
|
832
|
+
const rightColEndY = P.y;
|
|
833
|
+
P.y = Math.max(leftColEndY, rightColEndY);
|
|
834
|
+
// === CERTIFICATES (bottom of page) ===
|
|
835
|
+
if (fs_1.default.existsSync(certPath)) {
|
|
836
|
+
const certWidth = 180; // scaled from 360x100 original
|
|
837
|
+
const certHeight = certWidth * (100 / 360);
|
|
838
|
+
P.skip(20);
|
|
839
|
+
doc.image(certPath, 50, P.y, { width: certWidth, height: certHeight });
|
|
840
|
+
P.skip(certHeight);
|
|
841
|
+
}
|
|
823
842
|
doc.end();
|
|
824
843
|
return await done;
|
|
825
844
|
}
|