From 9731f3722d89ea2daf6781faf15eed2e226edbaf Mon Sep 17 00:00:00 2001 From: Daniel Popiniuc Date: Sat, 20 Apr 2024 17:58:40 +0300 Subject: [PATCH] as documented with a DocumentCurrencyCode having other value than RON has been seen, exposing this insight became a neccesity --- nbproject/project.properties | 2 +- source/TraitUserInterfaceLogic.php | 90 +++++++++++---------- source/locale/eFactura.pot | 3 + source/locale/en_US/LC_MESSAGES/eFactura.po | 3 + source/locale/it_IT/LC_MESSAGES/eFactura.po | 3 + source/locale/ro_RO/LC_MESSAGES/eFactura.po | 3 + 6 files changed, 60 insertions(+), 44 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index 9b363a8..948f639 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -26,7 +26,7 @@ file.reference.eFactura-testing=testing ignore.path= include.path=\ ${php.global.include.path} -php.version=PHP_82 +php.version=PHP_83 project.license=epl20 source.encoding=UTF-8 src.dir=source diff --git a/source/TraitUserInterfaceLogic.php b/source/TraitUserInterfaceLogic.php index 25a4547..31da5f1 100644 --- a/source/TraitUserInterfaceLogic.php +++ b/source/TraitUserInterfaceLogic.php @@ -16,6 +16,7 @@ trait TraitUserInterfaceLogic { + use \danielgp\io_operations\InputOutputFiles; protected array $arrayConfiguration; @@ -58,18 +59,19 @@ private function getDocumentDetails(array $arrayData): array $arrayBasic = $arrayElectronicInv['Header']['CommonBasicComponents-2']; $arrayAggregate = $arrayElectronicInv['Header']['CommonAggregateComponents-2']; $arrayStandardized = [ - 'Customer' => $arrayAggregate['AccountingCustomerParty']['Party'], - 'ID' => $arrayBasic['ID'], - 'IssueDate' => $arrayBasic['IssueDate'], - 'No_of_Lines' => count($arrayElectronicInv['Lines']), - 'Supplier' => $arrayAggregate['AccountingSupplierParty']['Party'], - 'TOTAL' => (float) $arrayAggregate['LegalMonetaryTotal']['TaxInclusiveAmount']['value'], - 'wo_VAT' => (float) $arrayAggregate['LegalMonetaryTotal']['TaxExclusiveAmount']['value'], + 'Customer' => $arrayAggregate['AccountingCustomerParty']['Party'], + 'ID' => $arrayBasic['ID'], + 'IssueDate' => $arrayBasic['IssueDate'], + 'DocumentCurrencyCode' => $arrayBasic['DocumentCurrencyCode'], + 'No_of_Lines' => count($arrayElectronicInv['Lines']), + 'Supplier' => $arrayAggregate['AccountingSupplierParty']['Party'], + 'TOTAL' => (float) $arrayAggregate['LegalMonetaryTotal']['TaxInclusiveAmount']['value'], + 'wo_VAT' => (float) $arrayAggregate['LegalMonetaryTotal']['TaxExclusiveAmount']['value'], ]; return $arrayStandardized; } - private function handleResponseFile(\SplFileInfo | string $strFile): array + private function handleResponseFile(\SplFileInfo|string $strFile): array { $arrayToReturn = []; $strFileMime = mime_content_type($strFile->getRealPath()); @@ -172,23 +174,24 @@ private function setDefaultsToInvoiceDetailsArray(array $arrayData): array { return [ 'Response_DateTime' => '', - 'Response_Index' => $arrayData['Response_Index'], - 'Response_Size' => $arrayData['Response_Size'], - 'Loading_Index' => '', - 'Size' => '', - 'Document_No' => '', - 'Issue_Date' => '', - 'Issue_YearMonth' => '', - 'Amount_wo_VAT' => '', - 'Amount_TOTAL' => '', - 'Amount_VAT' => '', - 'Supplier_CUI' => '', - 'Supplier_Name' => '', - 'Customer_CUI' => '', - 'Customer_Name' => '', - 'No_of_Lines' => '', - 'Error' => '', - 'Days_Between' => '', + 'Response_Index' => $arrayData['Response_Index'], + 'Response_Size' => $arrayData['Response_Size'], + 'Loading_Index' => '', + 'Size' => '', + 'Document_No' => '', + 'Issue_Date' => '', + 'Issue_YearMonth' => '', + 'DocumentCurrencyCode' => '', + 'Amount_wo_VAT' => '', + 'Amount_TOTAL' => '', + 'Amount_VAT' => '', + 'Supplier_CUI' => '', + 'Supplier_Name' => '', + 'Customer_CUI' => '', + 'Customer_Name' => '', + 'No_of_Lines' => '', + 'Error' => '', + 'Days_Between' => '', ]; } @@ -201,12 +204,12 @@ private function setErrorsFromExtendedMarkupLaguage(array $arrayData, string $st xml_parse_into_struct($parser, $arrayData['strInvoiceContent'], $arrayErrors); xml_parser_free($parser); return [ - 'Loading_Index' => $arrayErrors[0]['attributes']['Index_incarcare'], - 'Size' => $arrayData['Size'], + 'Loading_Index' => $arrayErrors[0]['attributes']['Index_incarcare'], + 'Size' => $arrayData['Size'], 'Response_DateTime' => $arrayData['FileDateTime'], - 'Supplier_CUI' => 'RO' . $arrayErrors[0]['attributes']['Cif_emitent'], - 'Supplier_Name' => '??????????', - 'Error' => sprintf($strErrorTag, $arrayErrors[1]['attributes']['errorMessage']), + 'Supplier_CUI' => 'RO' . $arrayErrors[0]['attributes']['Cif_emitent'], + 'Supplier_Name' => '??????????', + 'Error' => sprintf($strErrorTag, $arrayErrors[1]['attributes']['errorMessage']), ]; } @@ -239,20 +242,21 @@ private function setStandardizedFeedbackArray(array $arrayData): array ); $arrayAttr = $this->getDocumentDetails($arrayData); $arrayTemp = [ - 'Loading_Index' => substr($arrayData['Matches'][0][0], 0, -4), - 'Size' => $arrayData['Size'], - 'Document_No' => $arrayAttr['ID'], - 'Issue_Date' => $arrayAttr['IssueDate'], - 'Issue_YearMonth' => $strFormatter->format(new \DateTime($arrayAttr['IssueDate'])), + 'Loading_Index' => substr($arrayData['Matches'][0][0], 0, -4), + 'Size' => $arrayData['Size'], + 'Document_No' => $arrayAttr['ID'], + 'Issue_Date' => $arrayAttr['IssueDate'], + 'Issue_YearMonth' => $strFormatter->format(new \DateTime($arrayAttr['IssueDate'])), 'Response_DateTime' => $arrayData['FileDateTime'], - 'Amount_wo_VAT' => $arrayAttr['wo_VAT'], - 'Amount_TOTAL' => $arrayAttr['TOTAL'], - 'Amount_VAT' => round(($arrayAttr['TOTAL'] - $arrayAttr['wo_VAT']), 2), - 'Supplier_CUI' => $this->setDataSupplierOrCustomer($arrayAttr['Supplier']), - 'Supplier_Name' => $arrayAttr['Supplier']['PartyLegalEntity']['RegistrationName'], - 'Customer_CUI' => $this->setDataSupplierOrCustomer($arrayAttr['Customer']), - 'Customer_Name' => $arrayAttr['Customer']['PartyLegalEntity']['RegistrationName'], - 'No_of_Lines' => $arrayAttr['No_of_Lines'], + 'DocumentCurrencyCode' => $arrayAttr['DocumentCurrencyCode'], + 'Amount_wo_VAT' => $arrayAttr['wo_VAT'], + 'Amount_TOTAL' => $arrayAttr['TOTAL'], + 'Amount_VAT' => round(($arrayAttr['TOTAL'] - $arrayAttr['wo_VAT']), 2), + 'Supplier_CUI' => $this->setDataSupplierOrCustomer($arrayAttr['Supplier']), + 'Supplier_Name' => $arrayAttr['Supplier']['PartyLegalEntity']['RegistrationName'], + 'Customer_CUI' => $this->setDataSupplierOrCustomer($arrayAttr['Customer']), + 'Customer_Name' => $arrayAttr['Customer']['PartyLegalEntity']['RegistrationName'], + 'No_of_Lines' => $arrayAttr['No_of_Lines'], 'Days_Between' => $this->setDaysElapsed($arrayAttr['IssueDate'], $arrayData['FileDateTime']), ]; $arrayToReturn = array_merge($arrayToReturn, $arrayTemp); diff --git a/source/locale/eFactura.pot b/source/locale/eFactura.pot index 86c2faa..2a52c6d 100644 --- a/source/locale/eFactura.pot +++ b/source/locale/eFactura.pot @@ -39,6 +39,9 @@ msgstr "" msgid "i18n_Clmn_Document_No" msgstr "" +msgid "i18n_Clmn_DocumentCurrencyCode" +msgstr "" + msgid "i18n_Clmn_Error" msgstr "" diff --git a/source/locale/en_US/LC_MESSAGES/eFactura.po b/source/locale/en_US/LC_MESSAGES/eFactura.po index e8a8a5d..efb173e 100644 --- a/source/locale/en_US/LC_MESSAGES/eFactura.po +++ b/source/locale/en_US/LC_MESSAGES/eFactura.po @@ -40,6 +40,9 @@ msgstr "Days issue-response" msgid "i18n_Clmn_Document_No" msgstr "Document ID" +msgid "i18n_Clmn_DocumentCurrencyCode" +msgstr "Document Currency Code" + msgid "i18n_Clmn_Error" msgstr "Error" diff --git a/source/locale/it_IT/LC_MESSAGES/eFactura.po b/source/locale/it_IT/LC_MESSAGES/eFactura.po index 3ef4988..e0d49f9 100644 --- a/source/locale/it_IT/LC_MESSAGES/eFactura.po +++ b/source/locale/it_IT/LC_MESSAGES/eFactura.po @@ -40,6 +40,9 @@ msgstr "Giorni tra emissione e risposta" msgid "i18n_Clmn_Document_No" msgstr "Numero del documento" +msgid "i18n_Clmn_DocumentCurrencyCode" +msgstr "Codice valuta del documento" + msgid "i18n_Clmn_Error" msgstr "Errore" diff --git a/source/locale/ro_RO/LC_MESSAGES/eFactura.po b/source/locale/ro_RO/LC_MESSAGES/eFactura.po index 74f68d5..1e933f9 100644 --- a/source/locale/ro_RO/LC_MESSAGES/eFactura.po +++ b/source/locale/ro_RO/LC_MESSAGES/eFactura.po @@ -41,6 +41,9 @@ msgstr "Zile emitere-răspuns" msgid "i18n_Clmn_Document_No" msgstr "Identificator document" +msgid "i18n_Clmn_DocumentCurrencyCode" +msgstr "Cod valută document" + msgid "i18n_Clmn_Error" msgstr "Eroare"