From ce9a2f67279a6ee7a52e141a41e338221898e5d5 Mon Sep 17 00:00:00 2001
From: HorstOeko
Date: Mon, 23 Dec 2024 12:23:34 +0100
Subject: [PATCH] [ENH] Added enhanced default template, added missing unitcode
translations
---
src/ZugferdVisualizer.php | 12 +
src/assets/translation/de.php | 49 +++-
src/assets/translation/en.php | 41 +++-
src/template/default-enh.tmpl | 431 ++++++++++++++++++++++++++++++++++
4 files changed, 519 insertions(+), 14 deletions(-)
create mode 100644 src/template/default-enh.tmpl
diff --git a/src/ZugferdVisualizer.php b/src/ZugferdVisualizer.php
index 11470e7..185b629 100644
--- a/src/ZugferdVisualizer.php
+++ b/src/ZugferdVisualizer.php
@@ -211,6 +211,18 @@ public function setDefaultTemplate(): void
$this->setTemplate(dirname(__FILE__) . "/template/default.tmpl");
}
+
+ /**
+ * Sets the built-in template in an enhanced version (and switch the markup-rendering engine to the default renderer)
+ *
+ * @return void
+ */
+ public function setDefaultTemplateEnhanced(): void
+ {
+ $this->setRenderer(new ZugferdVisualizerDefaultRenderer());
+ $this->setTemplate(dirname(__FILE__) . "/template/default-enh.tmpl");
+ }
+
/**
* Add an additional directory where the PDF-Engine will
* search for fonts
diff --git a/src/assets/translation/de.php b/src/assets/translation/de.php
index 6f2bebf..54f8bc4 100644
--- a/src/assets/translation/de.php
+++ b/src/assets/translation/de.php
@@ -1,24 +1,52 @@
[
+ ZugferdUnitCodes::REC20_PIECE => 'St.',
+ ZugferdUnitCodes::REC21_PIECE => 'St.',
+ ZugferdUnitCodes::REC20_KILOGRAM => 'kg',
+ ZugferdUnitCodes::REC20_LITRE => 'l',
+ ZugferdUnitCodes::REC20_SQUARE_METRE => 'm2',
+ ZugferdUnitCodes::REC20_ONE => '',
+ ZugferdUnitCodes::REC20_DAY => 'Tag',
+ ZugferdUnitCodes::REC20_MINUTE_UNIT_OF_TIME => 'min',
+ ZugferdUnitCodes::REC20_KILOWATT_HOUR => 'kWh',
+ ZugferdUnitCodes::REC20_LUMP_SUM => 'pausch.',
+ ZugferdUnitCodes::REC20_SQUARE_MILLIMETRE => 'mm2',
+ ZugferdUnitCodes::REC20_MILLIMETRE => 'mm',
+ ZugferdUnitCodes::REC20_CUBIC_METRE => 'm3',
+ ZugferdUnitCodes::REC20_METRE => 'm',
+ ZugferdUnitCodes::REC20_NUMBER_OF_ARTICLES => 'mal',
+ ZugferdUnitCodes::REC20_PERCENT => '%',
+ ZugferdUnitCodes::REC20_SET => 'Set(s)',
+ ZugferdUnitCodes::REC20_TONNE_METRIC_TON => 't',
+ ZugferdUnitCodes::REC20_RECIPROCAL_WEEK => 'Woche',
+ ZugferdUnitCodes::REC20_HOUR => 'h',
+ 'KTM' => 'km',
],
'documenttype' => [
- '380' => 'Rechnung',
- '381' => 'Gutschrift',
- '384' => 'Rechnungskorrektur',
- '386' => 'Vorauszahlungsrechnung',
+ ZugferdInvoiceType::INVOICE => 'Rechnung',
+ ZugferdInvoiceType::CREDITNOTE => 'Gutschrift',
+ ZugferdInvoiceType::CORRECTION => 'Rechnungskorrektur',
+ ZugferdInvoiceType::PREPAYMENTINVOICE => 'Vorauszahlungsrechnung',
],
'generaltexts' => [
'greeting' => 'Werter Kunde',
- 'leadingtext1' => 'Wir nehmen die Freiheit, folgende Positionen zu berechnen',
+ 'leadingtext1' => 'Wir erlauben uns, folgende Positionen zu berechnen',
+ 'documentno' => 'Rechnungsnummer',
'documentdate' => 'Rechnungsdatum',
+ 'deliverydate' => 'Lieferdatum',
+ 'customerno' => 'Kundennummer',
+ 'reference' => 'Kundenreferenz',
'postableheader' => [
'posno' => 'Pos.',
'description' => 'Beschreibung',
'quantity' => 'Menge',
- 'price' => 'Preis',
- 'linemount' => 'Betrag',
+ 'price' => 'Einzelpreis',
+ 'linemount' => 'Gesamtpreis',
'vatpercent' => 'Steuer %',
],
'chargeindicator' => [
@@ -36,8 +64,11 @@
'amounttopay' => 'Fälliger Gesamtbetrag',
],
'vattotals' => [
- 'heading' => 'Steuer',
+ 'heading' => 'SteuerĂĽbersicht',
'heading2' => 'Total',
- ]
+ ],
+ 'formats' => [
+ 'date' => 'd.m.Y',
+ ],
],
];
diff --git a/src/assets/translation/en.php b/src/assets/translation/en.php
index 5c0d0fc..8f158c3 100644
--- a/src/assets/translation/en.php
+++ b/src/assets/translation/en.php
@@ -1,18 +1,46 @@
[
+ ZugferdUnitCodes::REC20_PIECE => 'pc',
+ ZugferdUnitCodes::REC21_PIECE => 'pc',
+ ZugferdUnitCodes::REC20_KILOGRAM => 'kg',
+ ZugferdUnitCodes::REC20_LITRE => 'l',
+ ZugferdUnitCodes::REC20_SQUARE_METRE => 'm2',
+ ZugferdUnitCodes::REC20_ONE => '',
+ ZugferdUnitCodes::REC20_DAY => 'day',
+ ZugferdUnitCodes::REC20_MINUTE_UNIT_OF_TIME => 'min',
+ ZugferdUnitCodes::REC20_KILOWATT_HOUR => 'kWh',
+ ZugferdUnitCodes::REC20_LUMP_SUM => 'lump sum',
+ ZugferdUnitCodes::REC20_SQUARE_MILLIMETRE => 'mm2',
+ ZugferdUnitCodes::REC20_MILLIMETRE => 'mm',
+ ZugferdUnitCodes::REC20_CUBIC_METRE => 'm3',
+ ZugferdUnitCodes::REC20_METRE => 'm',
+ ZugferdUnitCodes::REC20_NUMBER_OF_ARTICLES => 'times',
+ ZugferdUnitCodes::REC20_PERCENT => '%',
+ ZugferdUnitCodes::REC20_SET => 'Set(s)',
+ ZugferdUnitCodes::REC20_TONNE_METRIC_TON => 't',
+ ZugferdUnitCodes::REC20_RECIPROCAL_WEEK => 'week',
+ ZugferdUnitCodes::REC20_HOUR => 'h',
+ 'KTM' => 'km',
],
'documenttype' => [
- '380' => 'Invoice',
- '381' => 'Credit Note',
- '384' => 'Corrected Invoice',
- '386' => 'Prepayment Invoice',
+ ZugferdInvoiceType::INVOICE => 'Invoice',
+ ZugferdInvoiceType::CREDITNOTE => 'Credit Note',
+ ZugferdInvoiceType::CORRECTION => 'Corrected Invoice',
+ ZugferdInvoiceType::PREPAYMENTINVOICE => 'Prepayment Invoice',
],
'generaltexts' => [
'greeting' => 'Dear customer',
'leadingtext1' => 'We take the liberty of invoicing you for the following items',
+ 'documentno' => 'Invoice No.',
'documentdate' => 'Invoice date',
+ 'deliverydate' => 'Delivery date',
+ 'customerno' => 'Customer No.',
+ 'reference' => 'Reference',
'postableheader' => [
'posno' => 'Pos.',
'description' => 'Desc.',
@@ -38,6 +66,9 @@
'vattotals' => [
'heading' => 'VAT Breakdown',
'heading2' => 'Total',
- ]
+ ],
+ 'formats' => [
+ 'date' => 'd.m.Y',
+ ],
],
];
diff --git a/src/template/default-enh.tmpl b/src/template/default-enh.tmpl
new file mode 100644
index 0000000..734195d
--- /dev/null
+++ b/src/template/default-enh.tmpl
@@ -0,0 +1,431 @@
+
+
+
+
+
+ getDocumentInformation($documentno, $documenttypecode, $documentdate, $invoiceCurrency, $taxCurrency, $documentname, $documentlanguage, $effectiveSpecifiedPeriod);
+ $document->getDocumentBuyer($buyername, $buyerids, $buyerdescription);
+ $document->getDocumentBuyerAddress($buyeraddressline1, $buyeraddressline2, $buyeraddressline3, $buyerpostcode, $buyercity, $buyercounty, $buyersubdivision);
+ $document->getDocumentBuyerOrderReferencedDocument($bt13, $btX147);
+ $document->getDocumentBuyerReference($buyerRef);
+ $document->getDocumentSupplyChainEvent($bt72);
+ $dateFormat = $translator->translateWithoutPlaceholders('formats.date', 'generaltexts')
+ ?>
+
+ = implode('
',array_filter([$buyername, $buyeraddressline1, $buyeraddressline2, $buyeraddressline3, $buyercounty . ' ' . $buyerpostcode . ' ' . $buyercity])); ?>
+
+
+ = $translator->translateWithoutPlaceholders($documenttypecode, 'documenttype') ?>
+
+
+
+
+
+ = $translator->translateWithoutPlaceholders('greeting', 'generaltexts') ?>,
+
+
+ = $translator->translateWithoutPlaceholders('leadingtext1', 'generaltexts') ?>
+
+
+
+
+ = $translator->translateWithoutPlaceholders('postableheader.posno', 'generaltexts') ?> |
+ = $translator->translateWithoutPlaceholders('postableheader.description', 'generaltexts') ?> |
+ = $translator->translateWithoutPlaceholders('postableheader.quantity', 'generaltexts') ?> |
+ = $translator->translateWithoutPlaceholders('postableheader.price', 'generaltexts') ?> |
+ = $translator->translateWithoutPlaceholders('postableheader.linemount', 'generaltexts') ?> |
+ = $translator->translateWithoutPlaceholders('postableheader.vatpercent', 'generaltexts') ?> |
+
+
+
+ firstDocumentPosition()) {
+ $isfirstposition = true;
+ do {
+ $document->getDocumentPositionGenerals($lineid, $linestatuscode, $linestatusreasoncode);
+ $document->getDocumentPositionProductDetails($prodname, $proddesc, $prodsellerid, $prodbuyerid, $prodglobalidtype, $prodglobalid);
+ $document->getDocumentPositionGrossPrice($grosspriceamount, $grosspricebasisquantity, $grosspricebasisquantityunitcode);
+ $document->getDocumentPositionNetPrice($netpriceamount, $netpricebasisquantity, $netpricebasisquantityunitcode);
+ $document->getDocumentPositionLineSummation($lineTotalAmount, $totalAllowanceChargeAmount);
+ $document->getDocumentPositionQuantity($billedquantity, $billedquantityunitcode, $chargeFreeQuantity, $chargeFreeQuantityunitcode, $packageQuantity, $packageQuantityunitcode);
+ ?>
+ firstDocumentPositionNote()) { ?>
+
+ |
+
+ getDocumentPositionNote($posnoteContent, $posnoteContentCode, $posnoteSubjectCode); ?>
+ = $posnoteContent; ?>
+
+ |
+
+ nextDocumentPositionNote()); ?>
+
+ = $lineid; ?> |
+ = $prodname; ?> |
+ = $billedquantity; ?> = $translator->translateWithoutPlaceholders($billedquantityunitcode, 'unitcodes') ?> |
+ = number_format($netpriceamount, 2); ?> = $invoiceCurrency; ?> |
+ = number_format($lineTotalAmount, 2); ?> = $invoiceCurrency; ?> |
+ firstDocumentPositionTax()) { ?>
+ getDocumentPositionTax($categoryCode, $typeCode, $rateApplicablePercent, $calculatedAmount, $exemptionReason, $exemptionReasonCode); ?>
+ = number_format($rateApplicablePercent, 2); ?> % |
+
+ |
+
+
+ firstDocumentPositionGrossPriceAllowanceCharge()) { ?>
+
+ getDocumentPositionGrossPrice($grossAmount, $grossBasisQuantity, $grossBasisQuantityUnitCode); ?>
+ getDocumentPositionGrossPriceAllowanceCharge($actualAmount, $isCharge, $calculationPercent, $basisAmount, $reason, $taxTypeCode, $taxCategoryCode, $rateApplicablePercent, $sequence, $basisQuantity, $basisQuantityUnitCode, $reasonCode); ?>
+
+ |
+ = ($isCharge ? $translator->translateWithoutPlaceholders('chargeindicator.charge', 'generaltexts') : $translator->translateWithoutPlaceholders('chargeindicator.allowance', 'generaltexts')) ?> |
+ |
+ = number_format($actualAmount, 2); ?> (= number_format($grossAmount, 2); ?>) = $invoiceCurrency; ?> |
+
+ nextDocumentPositionGrossPriceAllowanceCharge()); ?>
+
+
+ nextDocumentPosition()); ?>
+
+
+
+
+ firstDocumentAllowanceCharge()) { ?>
+
+ |
+
+
+ |
+ = $translator->translateWithoutPlaceholders('chargeindicator.allowance', 'generaltexts') ?>/= $translator->translateWithoutPlaceholders('chargeindicator.charge', 'generaltexts') ?> |
+
+
+
+ getDocumentAllowanceCharge($actualAmount, $isCharge, $taxCategoryCode, $taxTypeCode, $rateApplicablePercent, $sequence, $calculationPercent, $basisAmount, $basisQuantity, $basisQuantityUnitCode, $reasonCode, $reason); ?>
+
+ |
+ = $reason ? $reason : ($isCharge ? "Charge" : "Allowance"); ?> |
+ = number_format($basisAmount, 2); ?> = $invoiceCurrency; ?> |
+ = number_format($actualAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+ nextDocumentAllowanceCharge()); ?>
+
+
+
+
+ getDocumentSummation($grandTotalAmount, $duePayableAmount, $lineTotalAmount, $chargeTotalAmount, $allowanceTotalAmount, $taxBasisTotalAmount, $taxTotalAmount, $roundingAmount, $totalPrepaidAmount); ?>
+
+ |
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.heading', 'generaltexts') ?> |
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.netamount', 'generaltexts') ?> |
+ = number_format($lineTotalAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.chargetotalamount', 'generaltexts') ?> |
+ = number_format($chargeTotalAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.allowancetotalamount', 'generaltexts') ?> |
+ = number_format($allowanceTotalAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.taxtotalamount', 'generaltexts') ?> |
+ = number_format($taxTotalAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.grandtotalamount', 'generaltexts') ?> |
+ = number_format($grandTotalAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.alreadypaid', 'generaltexts') ?> |
+ = number_format($totalPrepaidAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+ |
+ = $translator->translateWithoutPlaceholders('totals.amounttopay', 'generaltexts') ?> |
+ = number_format($duePayableAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+
+
+ firstDocumentTax()) { ?>
+
+ |
+
+
+ |
+ = $translator->translateWithoutPlaceholders('vattotals.heading', 'generaltexts') ?> |
+
+
+
+
+ getDocumentTax($categoryCode, $typeCode, $basisAmount, $calculatedAmount, $rateApplicablePercent, $exemptionReason, $exemptionReasonCode, $lineTotalBasisAmount, $allowanceChargeBasisAmount, $taxPointDate, $dueDateTypeCode); ?>
+
+ |
+ = number_format($rateApplicablePercent, 2); ?>% |
+ = number_format($basisAmount,2) ?> = $invoiceCurrency; ?> |
+ = number_format($calculatedAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+
+ nextDocumentTax()); ?>
+
+ |
+ = $translator->translateWithoutPlaceholders('vattotals.heading2', 'generaltexts') ?> |
+ = number_format($sumbasisamount, 2); ?> = $invoiceCurrency; ?> |
+ = number_format($taxTotalAmount, 2); ?> = $invoiceCurrency; ?> |
+
+
+
+
+
+ firstDocumentPaymentTerms()) { ?>
+
+
+
+ getDocumentPaymentTerm($description, $dueDate, $directDebitMandateID); ?>
+
+ = $description; ?>
+ |
+
+
+ nextDocumentPaymentTerms()); ?>
+
+
+
+
+
\ No newline at end of file