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') + ?> +

+ ',array_filter([$buyername, $buyeraddressline1, $buyeraddressline2, $buyeraddressline3, $buyercounty . ' ' . $buyerpostcode . ' ' . $buyercity])); ?> +

+

+ translateWithoutPlaceholders($documenttypecode, 'documenttype') ?> +

+

+ + + + + + + + + + + + + + + + + + + + + +
translateWithoutPlaceholders('documentdate', 'generaltexts') ?>translateWithoutPlaceholders('deliverydate', 'generaltexts') ?>translateWithoutPlaceholders('documentno', 'generaltexts') ?>translateWithoutPlaceholders('customerno', 'generaltexts') ?>translateWithoutPlaceholders('reference', 'generaltexts') ?>translateWithoutPlaceholders('routingid', 'generaltexts') ?>
format($dateFormat); ?>format($dateFormat) : $documentdate->format($dateFormat); ?>
+

+

+ translateWithoutPlaceholders('greeting', 'generaltexts') ?>, +

+

+ translateWithoutPlaceholders('leadingtext1', '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()) { ?> + + + + + nextDocumentPositionNote()); ?> + + + + + + + firstDocumentPositionTax()) { ?> + getDocumentPositionTax($categoryCode, $typeCode, $rateApplicablePercent, $calculatedAmount, $exemptionReason, $exemptionReasonCode); ?> + + + + + + firstDocumentPositionGrossPriceAllowanceCharge()) { ?> + + getDocumentPositionGrossPrice($grossAmount, $grossBasisQuantity, $grossBasisQuantityUnitCode); ?> + getDocumentPositionGrossPriceAllowanceCharge($actualAmount, $isCharge, $calculationPercent, $basisAmount, $reason, $taxTypeCode, $taxCategoryCode, $rateApplicablePercent, $sequence, $basisQuantity, $basisQuantityUnitCode, $reasonCode); ?> + + + + + + + nextDocumentPositionGrossPriceAllowanceCharge()); ?> + + + nextDocumentPosition()); ?> + + + + + firstDocumentAllowanceCharge()) { ?> + + + + + + + + + + getDocumentAllowanceCharge($actualAmount, $isCharge, $taxCategoryCode, $taxTypeCode, $rateApplicablePercent, $sequence, $calculationPercent, $basisAmount, $basisQuantity, $basisQuantityUnitCode, $reasonCode, $reason); ?> + + + + + + + + nextDocumentAllowanceCharge()); ?> + + + + + getDocumentSummation($grandTotalAmount, $duePayableAmount, $lineTotalAmount, $chargeTotalAmount, $allowanceTotalAmount, $taxBasisTotalAmount, $taxTotalAmount, $roundingAmount, $totalPrepaidAmount); ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + firstDocumentTax()) { ?> + + + + + + + + + + + getDocumentTax($categoryCode, $typeCode, $basisAmount, $calculatedAmount, $rateApplicablePercent, $exemptionReason, $exemptionReasonCode, $lineTotalBasisAmount, $allowanceChargeBasisAmount, $taxPointDate, $dueDateTypeCode); ?> + + + + + + + + + nextDocumentTax()); ?> + + + + + + + + + + + firstDocumentPaymentTerms()) { ?> + + + + getDocumentPaymentTerm($description, $dueDate, $directDebitMandateID); ?> + + + + nextDocumentPaymentTerms()); ?> + + +
translateWithoutPlaceholders('postableheader.posno', 'generaltexts') ?>translateWithoutPlaceholders('postableheader.description', 'generaltexts') ?>translateWithoutPlaceholders('postableheader.quantity', 'generaltexts') ?>translateWithoutPlaceholders('postableheader.price', 'generaltexts') ?>translateWithoutPlaceholders('postableheader.linemount', 'generaltexts') ?>translateWithoutPlaceholders('postableheader.vatpercent', 'generaltexts') ?>
  + getDocumentPositionNote($posnoteContent, $posnoteContentCode, $posnoteSubjectCode); ?> + + +
translateWithoutPlaceholders($billedquantityunitcode, 'unitcodes') ?> % 
 translateWithoutPlaceholders('chargeindicator.charge', 'generaltexts') : $translator->translateWithoutPlaceholders('chargeindicator.allowance', 'generaltexts')) ?>  ()
 
 translateWithoutPlaceholders('chargeindicator.allowance', 'generaltexts') ?>/translateWithoutPlaceholders('chargeindicator.charge', 'generaltexts') ?>
 
 
 translateWithoutPlaceholders('totals.heading', 'generaltexts') ?>
 translateWithoutPlaceholders('totals.netamount', 'generaltexts') ?>
 translateWithoutPlaceholders('totals.chargetotalamount', 'generaltexts') ?>
 translateWithoutPlaceholders('totals.allowancetotalamount', 'generaltexts') ?>
 translateWithoutPlaceholders('totals.taxtotalamount', 'generaltexts') ?>
 translateWithoutPlaceholders('totals.grandtotalamount', 'generaltexts') ?>
 translateWithoutPlaceholders('totals.alreadypaid', 'generaltexts') ?>
 translateWithoutPlaceholders('totals.amounttopay', 'generaltexts') ?>
 
 translateWithoutPlaceholders('vattotals.heading', 'generaltexts') ?>
 %
 translateWithoutPlaceholders('vattotals.heading2', 'generaltexts') ?>
+ +
+ + \ No newline at end of file