Skip to content

Commit

Permalink
as documented with a DocumentCurrencyCode having other value than RON…
Browse files Browse the repository at this point in the history
… has been seen, exposing this insight became a neccesity
  • Loading branch information
danielgp committed Apr 20, 2024
1 parent 28987a9 commit 9731f37
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 44 deletions.
2 changes: 1 addition & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
90 changes: 47 additions & 43 deletions source/TraitUserInterfaceLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

trait TraitUserInterfaceLogic
{

use \danielgp\io_operations\InputOutputFiles;

protected array $arrayConfiguration;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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' => '',
];
}

Expand All @@ -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']),
];
}

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions source/locale/eFactura.pot
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ msgstr ""
msgid "i18n_Clmn_Document_No"
msgstr ""

msgid "i18n_Clmn_DocumentCurrencyCode"
msgstr ""

msgid "i18n_Clmn_Error"
msgstr ""

Expand Down
3 changes: 3 additions & 0 deletions source/locale/en_US/LC_MESSAGES/eFactura.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions source/locale/it_IT/LC_MESSAGES/eFactura.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions source/locale/ro_RO/LC_MESSAGES/eFactura.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 9731f37

Please sign in to comment.