From 42c91219a472952756c3c15e919e51aaf55d1fde Mon Sep 17 00:00:00 2001 From: HorstOeko Date: Thu, 3 Oct 2024 11:52:30 +0200 Subject: [PATCH] Fixed CheckStyle Issues --- build/phpmd.xml | 33 +- src/ZugferdDocumentPdfBuilderAbstract.php | 12 +- src/ZugferdDocumentPdfReader.php | 2 +- src/ZugferdDocumentReader.php | 5 +- src/ZugferdObjectHelper.php | 1 + src/ZugferdPdfWriter.php | 4 +- src/jms/ZugferdTypesHandler.php | 20 +- src/quick/ZugferdQuickDescriptor.php | 4 +- tests/assets/extended_invoice.xml | 740 +++++++++---------- tests/testcases/ObjectHelperExtendedTest.php | 2 + tests/testcases/ProfileResolverTest.php | 24 +- 11 files changed, 431 insertions(+), 416 deletions(-) diff --git a/build/phpmd.xml b/build/phpmd.xml index 9fe10f01..8cabf6cf 100644 --- a/build/phpmd.xml +++ b/build/phpmd.xml @@ -1,13 +1,20 @@ - - - Custom rule sets that checks your PHP code. - - - - + + + Custom rule sets that checks your PHP code. + + + + + + + + + + + diff --git a/src/ZugferdDocumentPdfBuilderAbstract.php b/src/ZugferdDocumentPdfBuilderAbstract.php index feb89b6b..89891902 100644 --- a/src/ZugferdDocumentPdfBuilderAbstract.php +++ b/src/ZugferdDocumentPdfBuilderAbstract.php @@ -307,12 +307,12 @@ protected function extractInvoiceInformations(): array $docTypeCode = $docTypeXpath->item(0)->nodeValue; switch ($docTypeCode) { - case ZugferdInvoiceType::CREDITNOTE: - $docTypeName = 'Credit Note'; - break; - default: - $docTypeName = 'Invoice'; - break; + case ZugferdInvoiceType::CREDITNOTE: + $docTypeName = 'Credit Note'; + break; + default: + $docTypeName = 'Invoice'; + break; } $invoiceInformation = array( diff --git a/src/ZugferdDocumentPdfReader.php b/src/ZugferdDocumentPdfReader.php index ba18a48c..4e3de1fb 100644 --- a/src/ZugferdDocumentPdfReader.php +++ b/src/ZugferdDocumentPdfReader.php @@ -128,7 +128,7 @@ public static function getXmlFromContent(string $pdfContent): ?string * @return null|string * @throws Exception */ - private static function internalExtractXMLFromPdfContent(string $pdfContent): ?string + protected static function internalExtractXMLFromPdfContent(string $pdfContent): ?string { $pdfParser = new PdfParser(); $pdfParsed = $pdfParser->parseContent($pdfContent); diff --git a/src/ZugferdDocumentReader.php b/src/ZugferdDocumentReader.php index 741755c1..a09ade3f 100644 --- a/src/ZugferdDocumentReader.php +++ b/src/ZugferdDocumentReader.php @@ -291,7 +291,7 @@ public function setBinaryDataDirectory(string $binarydatadirectory): ZugferdDocu * @throws ZugferdUnknownProfileParameterException * @throws RuntimeException */ - private function readContent(string $xmlcontent): ZugferdDocumentReader + protected function readContent(string $xmlcontent): ZugferdDocumentReader { $this->deserialize($xmlcontent); @@ -2639,10 +2639,9 @@ public function getDocumentUltimateCustomerOrderReferencedDocument(?string &$iss /** * Details of the ultimate customer order * - * @param array|null $refdocs * @return ZugferdDocumentReader */ - public function getDocumentUltimateCustomerOrderReferencedDocuments(?array $refdocs): ZugferdDocumentReader + public function getDocumentUltimateCustomerOrderReferencedDocuments(/*?array $refdocs*/): ZugferdDocumentReader { // TODO: Implemente method getDocumentUltimateCustomerOrderReferencedDocuments return $this; diff --git a/src/ZugferdObjectHelper.php b/src/ZugferdObjectHelper.php index 2f39379f..99fcb2b7 100644 --- a/src/ZugferdObjectHelper.php +++ b/src/ZugferdObjectHelper.php @@ -1371,6 +1371,7 @@ public function getTaxApplicableTradeCurrencyExchangeType(?string $sourceCurrenc $this->tryCall($currencyExchange, "setSourceCurrencyCode", $this->getIdType($sourceCurrencyCode)); $this->tryCall($currencyExchange, "setTargetCurrencyCode", $this->getIdType($targetCurrencyCode)); $this->tryCall($currencyExchange, "setConversionRate", $this->getRateType($rate)); + $this->tryCall($currencyExchange, "setConversionRateDateTime", $this->getDateTimeType($rateDateTime)); return $currencyExchange; } diff --git a/src/ZugferdPdfWriter.php b/src/ZugferdPdfWriter.php index 9cca48d9..c4b43ba3 100644 --- a/src/ZugferdPdfWriter.php +++ b/src/ZugferdPdfWriter.php @@ -190,7 +190,7 @@ public function setPdfMetadataInfos(array $metaDataInfos): void */ protected function _putfiles(): void { - foreach ($this->files as $i => &$info) { + foreach ($this->files as $_ => &$info) { $this->putFileSpecification($info); $info['file_index'] = $this->n; $this->putFileStream($info); @@ -299,7 +299,7 @@ protected function putMetadataDescriptions(): void $s .= '' . "\n"; $this->_newobj(); $this->descriptionIndex = $this->n; - foreach ($this->metaDataDescriptions as $i => $desc) { + foreach ($this->metaDataDescriptions as $_ => $desc) { $s .= $desc . "\n"; } $s .= '' . "\n"; diff --git a/src/jms/ZugferdTypesHandler.php b/src/jms/ZugferdTypesHandler.php index 1fff9198..176cbbd5 100644 --- a/src/jms/ZugferdTypesHandler.php +++ b/src/jms/ZugferdTypesHandler.php @@ -156,11 +156,8 @@ public static function getSubscribingMethods() * * @param XmlSerializationVisitor $visitor * @param mixed $data - * @param array $type - * @param Context $context - * @return DOMText|false */ - public function serializeAmountType(XmlSerializationVisitor $visitor, $data, array $type, Context $context) + public function serializeAmountType(XmlSerializationVisitor $visitor, $data) { $node = $visitor->getDocument()->createTextNode( number_format( @@ -186,11 +183,8 @@ public function serializeAmountType(XmlSerializationVisitor $visitor, $data, arr * * @param XmlSerializationVisitor $visitor * @param mixed $data - * @param array $type - * @param Context $context - * @return DOMText|false */ - public function serializeQuantityType(XmlSerializationVisitor $visitor, $data, array $type, Context $context) + public function serializeQuantityType(XmlSerializationVisitor $visitor, $data) { $node = $visitor->getDocument()->createTextNode( number_format( @@ -216,11 +210,8 @@ public function serializeQuantityType(XmlSerializationVisitor $visitor, $data, a * * @param XmlSerializationVisitor $visitor * @param mixed $data - * @param array $type - * @param Context $context - * @return DOMText|false */ - public function serializePercentType(XmlSerializationVisitor $visitor, $data, array $type, Context $context) + public function serializePercentType(XmlSerializationVisitor $visitor, $data) { $node = $visitor->getDocument()->createTextNode( number_format( @@ -241,11 +232,8 @@ public function serializePercentType(XmlSerializationVisitor $visitor, $data, ar * * @param XmlSerializationVisitor $visitor * @param mixed $data - * @param array $type - * @param Context $context - * @return DOMElement|false */ - public function serializeIndicatorType(XmlSerializationVisitor $visitor, $data, array $type, Context $context) + public function serializeIndicatorType(XmlSerializationVisitor $visitor, $data) { $node = $visitor->getDocument()->createElement('udt:Indicator', $data->getIndicator() == false ? 'false' : 'true'); return $node; diff --git a/src/quick/ZugferdQuickDescriptor.php b/src/quick/ZugferdQuickDescriptor.php index 9941b58e..d488602f 100644 --- a/src/quick/ZugferdQuickDescriptor.php +++ b/src/quick/ZugferdQuickDescriptor.php @@ -962,7 +962,7 @@ public function doAddTradeAllowanceCharge(float $actualAmount, string $reason, s */ public function doAddApplicableTradeTax(float $basisAmount, float $percent, string $categoryCode, ?string $typeCode = null, ?float $allowanceChargeBasisAmount = null, ?string $exemptionReasonCode = null, ?string $exemptionReason = null): ZugferdQuickDescriptor { - $this->addDocumentTax($categoryCode, $typeCode ?? "VAT", $basisAmount, round(0.01 * $percent * $basisAmount, 2), $percent, $exemptionReason, $exemptionReasonCode); + $this->addDocumentTax($categoryCode, $typeCode ?? "VAT", $basisAmount, round(0.01 * $percent * $basisAmount, 2), $percent, $exemptionReason, $exemptionReasonCode, null, $allowanceChargeBasisAmount); return $this; } @@ -1012,7 +1012,7 @@ public function doAddApplicableTradeTax(float $basisAmount, float $percent, stri */ public function doAddApplicableTradeTax2(float $basisAmount, float $calculatedAmount, string $categoryCode, ?string $typeCode = null, ?float $allowanceChargeBasisAmount = null, ?string $exemptionReasonCode = null, ?string $exemptionReason = null): ZugferdQuickDescriptor { - $this->addDocumentTax($categoryCode, $typeCode ?? "VAT", $basisAmount, $calculatedAmount, round($calculatedAmount * 100.0 / $basisAmount, 2), $exemptionReason, $exemptionReasonCode); + $this->addDocumentTax($categoryCode, $typeCode ?? "VAT", $basisAmount, $calculatedAmount, round($calculatedAmount * 100.0 / $basisAmount, 2), $exemptionReason, $exemptionReasonCode, null, $allowanceChargeBasisAmount); return $this; } diff --git a/tests/assets/extended_invoice.xml b/tests/assets/extended_invoice.xml index 66b62eee..02997490 100644 --- a/tests/assets/extended_invoice.xml +++ b/tests/assets/extended_invoice.xml @@ -1,370 +1,370 @@ - - - - - true - - - urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended - - - - KR87654321012 - KOSTENRECHNUNG - 380 - - 20181006 - - - ST3 - Es bestehen Rabatt- oder Bonusvereinbarungen. - AAK - - - EEV - Der Verkäufer bleibt Eigentümer der Waren bis zur vollständigen Erfüllung der Kaufpreisforderung. - AAJ - - - MUSTERLIEFERANT GMBH - BAHNHOFSTRASSE 99 - 99199 MUSTERHAUSEN - Geschäftsführung: - Max Mustermann - USt-IdNr: DE123456789 - Telefon: +49 932 431 0 - www.musterlieferant.de - HRB Nr. 372876 - Amtsgericht Musterstadt - GLN 4304171000002 - - REG - - - - - - 1 - - - 4123456000014 - WA997 - IndustryId - ModelId - Wirkarbeit HT - BatchId - BrandeName - ModelName - - Zählpunkt - DE0001346484600000000000000100038 - - - - - 0.0520 - - - 0.0520 - - - - 10000.0000 - - - - VAT - S - 19.00 - - - 52.00 - - - - - - 2 - - - 4123456000021 - ÖST250 - Ökosteuer Lieferant - - - - 0.0205 - - - 0.0205 - - - - 10000.0000 - - - - VAT - S - 19.00 - - - 20.50 - - - - - - 3 - - - 4260331811362 - - Kommissionierer 1250032 D. Muster - Besteller: Hr. Mayer, Personalnr. 4488 - - - - 15.0000 - - - false - - 4.5000 - Artikelrabatt 1 - - - - 10.5000 - - - - 27.5000 - - - - VAT - S - 19.00 - - - 288.75 - - - - - - 4 - - - 2001015001325 - FB05 - - FALTENBEUTEL 16x6x28 CM - - - - 0.0105 - - - 0.0105 - - - - 3500.0000 - - - - VAT - S - 19.00 - - - 36.75 - - - - - - 5 - - - 4123456000038 - KOP05 - - Kopierpapier A4 - Zählerstand von-bis: 543210 - 544420 - - Zähler-Nr. - MG-X79318 - - - - - 0.0100 - - - 0.0100 - - - - 1210.0000 - - - - VAT - S - 19.00 - - - 12.10 - - - - - 08154712 - - 549910 - 4333741000005 - MUSTERLIEFERANT GMBH - - - +49 932 431 500 - - - max.mustermann@musterlieferant.de - - - - 99199 - BAHNHOFSTRASSE 99 - MUSTERHAUSEN - DE - - - 201/113/40209 - - - - 339420 - 4304171000002 - MUSTER-KUNDE GMBH - - 40235 - KUNDENWEG 88 - DUESSELDORF - DE - - - - A777123 - 130 - - - - - 4304171088093 - MUSTER-MARKT - - 7322 - - - 31157 - HAUPTSTRASSE 44 - SARSTEDT - DE - - - - - 20180930 - - - - L87654321012 - - - - EUR - - 58 - - DE5467894567876500 - - - - 339420 - 4304171000002 - MUSTER-KUNDE GMBH - - 40235 - KUNDENWEG 88 - DUESSELDORF - DE - - - - 76.67 - VAT - 403.55 - 410.10 - -6.55 - S - 19.00 - - - - false - - 410.10 - 21.55 - Sonderrabatt - - VAT - S - 19.00 - - - - Transportkosten: Frachbetrag - 15.00 - - VAT - S - 19.00 - - - - Skontovereinbarung: 2% bei Zahlung innerhalb 10 Tagen nach Rechnungsdatum - - 10 - 2.00 - - - - 410.10 - 15.00 - 21.55 - 403.55 - 76.67 - 480.22 - 0.00 - 480.22 - - - S-INV1 - 83 - - 2024-09-30 - - - - S-INV2 - 84 - - 2024-09-30 - - - - - + + + + + true + + + urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended + + + + KR87654321012 + KOSTENRECHNUNG + 380 + + 20181006 + + + ST3 + Es bestehen Rabatt- oder Bonusvereinbarungen. + AAK + + + EEV + Der Verkäufer bleibt Eigentümer der Waren bis zur vollständigen Erfüllung der Kaufpreisforderung. + AAJ + + + MUSTERLIEFERANT GMBH + BAHNHOFSTRASSE 99 + 99199 MUSTERHAUSEN + Geschäftsführung: + Max Mustermann + USt-IdNr: DE123456789 + Telefon: +49 932 431 0 + www.musterlieferant.de + HRB Nr. 372876 + Amtsgericht Musterstadt + GLN 4304171000002 + + REG + + + + + + 1 + + + 4123456000014 + WA997 + IndustryId + ModelId + Wirkarbeit HT + BatchId + BrandeName + ModelName + + Zählpunkt + DE0001346484600000000000000100038 + + + + + 0.0520 + + + 0.0520 + + + + 10000.0000 + + + + VAT + S + 19.00 + + + 52.00 + + + + + + 2 + + + 4123456000021 + ÖST250 + Ökosteuer Lieferant + + + + 0.0205 + + + 0.0205 + + + + 10000.0000 + + + + VAT + S + 19.00 + + + 20.50 + + + + + + 3 + + + 4260331811362 + + Kommissionierer 1250032 D. Muster + Besteller: Hr. Mayer, Personalnr. 4488 + + + + 15.0000 + + + false + + 4.5000 + Artikelrabatt 1 + + + + 10.5000 + + + + 27.5000 + + + + VAT + S + 19.00 + + + 288.75 + + + + + + 4 + + + 2001015001325 + FB05 + + FALTENBEUTEL 16x6x28 CM + + + + 0.0105 + + + 0.0105 + + + + 3500.0000 + + + + VAT + S + 19.00 + + + 36.75 + + + + + + 5 + + + 4123456000038 + KOP05 + + Kopierpapier A4 + Zählerstand von-bis: 543210 - 544420 + + Zähler-Nr. + MG-X79318 + + + + + 0.0100 + + + 0.0100 + + + + 1210.0000 + + + + VAT + S + 19.00 + + + 12.10 + + + + + 08154712 + + 549910 + 4333741000005 + MUSTERLIEFERANT GMBH + + + +49 932 431 500 + + + max.mustermann@musterlieferant.de + + + + 99199 + BAHNHOFSTRASSE 99 + MUSTERHAUSEN + DE + + + 201/113/40209 + + + + 339420 + 4304171000002 + MUSTER-KUNDE GMBH + + 40235 + KUNDENWEG 88 + DUESSELDORF + DE + + + + A777123 + 130 + + + + + 4304171088093 + MUSTER-MARKT + + 7322 + + + 31157 + HAUPTSTRASSE 44 + SARSTEDT + DE + + + + + 20180930 + + + + L87654321012 + + + + EUR + + 58 + + DE5467894567876500 + + + + 339420 + 4304171000002 + MUSTER-KUNDE GMBH + + 40235 + KUNDENWEG 88 + DUESSELDORF + DE + + + + 76.67 + VAT + 403.55 + 410.10 + -6.55 + S + 19.00 + + + + false + + 410.10 + 21.55 + Sonderrabatt + + VAT + S + 19.00 + + + + Transportkosten: Frachbetrag + 15.00 + + VAT + S + 19.00 + + + + Skontovereinbarung: 2% bei Zahlung innerhalb 10 Tagen nach Rechnungsdatum + + 10 + 2.00 + + + + 410.10 + 15.00 + 21.55 + 403.55 + 76.67 + 480.22 + 0.00 + 480.22 + + + S-INV1 + 83 + + 2024-09-30 + + + + S-INV2 + 84 + + 2024-09-30 + + + + + diff --git a/tests/testcases/ObjectHelperExtendedTest.php b/tests/testcases/ObjectHelperExtendedTest.php index c407d90a..c8207450 100644 --- a/tests/testcases/ObjectHelperExtendedTest.php +++ b/tests/testcases/ObjectHelperExtendedTest.php @@ -1355,6 +1355,8 @@ public function testGetTaxApplicableTradeCurrencyExchangeType(): void $this->assertEquals("EUR", $currencyExchangeType->getSourceCurrencyCode()); $this->assertEquals("USD", $currencyExchangeType->getTargetCurrencyCode()); $this->assertEquals(10.0, $currencyExchangeType->getConversionRate()->value()); + $this->assertEquals("20180305", $currencyExchangeType->getConversionRateDateTime()->getDateTimeString()->value()); + $this->assertEquals("102", $currencyExchangeType->getConversionRateDateTime()->getDateTimeString()->getFormat()); /** * @var \horstoeko\zugferd\entities\extended\ram\TradeCurrencyExchangeType diff --git a/tests/testcases/ProfileResolverTest.php b/tests/testcases/ProfileResolverTest.php index 83755863..3c82eb21 100644 --- a/tests/testcases/ProfileResolverTest.php +++ b/tests/testcases/ProfileResolverTest.php @@ -18,7 +18,13 @@ private function deliverEn16931Header(): string { return << - + urn:cen.eu:en16931:2017 @@ -37,7 +43,13 @@ private function deliverUnknownProfile(): string { return << - + unknown @@ -56,7 +68,13 @@ private function deliverInvalidXml(): string { return << - + HDR; }