num-num / ubl-invoice Goto Github PK
View Code? Open in Web Editor NEWA modern object-oriented PHP library to create valid UBL and Peppol BIS files
License: MIT License
A modern object-oriented PHP library to create valid UBL and Peppol BIS files
License: MIT License
Hi,
We are running into a little issue with rounding. We receive invoice data from one application, create a UBL file for it and then forward it to another accounting software.
However, the lineExtensionAmount
value for each individual invoice lines will be rounded when serializing the XML (see InvoiceLine#247). Because the data we receive is keeping 4 decimals for quantities and monetary values, this will end up inserting a different value in some invoice lines in the generated UBL.
This results in a different total when you add them all up. That means that the total we pass to Invoice::setLegalMonetaryTotal()
will not always match with the sum of each invoice line.
I was trying to find some guidelines on how many decimals are allowed according to the specs, but I could not find any definitive answers. Do you know if it is actually required to restrict these values to 2 decimals according to the standards definition?
Thanks,
Steven
PS: for good measure, some example numbers:
Original After number_format()
70.4145 70.41
54.1645 54.16
21.6645 21.66
330.4145 330.41
----------------------
476.658 476.64
Hi, Are there any plans for compatibility with PHP 8?
Hi!
I am trying to set a unit code on a invoice line, but can't seem to be able to get it right. How can I declare a custom unit code?
What I have so far
$productClassified = (new \NumNum\UBL\ClassifiedTaxCategory())
->setID('S')
->setPercent($response['cota_tva'])
->setTaxScheme($taxScheme);
$productItem = (new \NumNum\UBL\Item())
->setName($val['nume_produs'])
->setClassifiedTaxCategory($productClassified);
$price = (new \NumNum\UBL\Price())
->setUnitCode(\NumNum\UBL\UnitCode::UNIT)
->setPriceAmount($val['pret']);
$invoiceLines[] = (new \NumNum\UBL\InvoiceLine())
->setId($val['id_unic'])
->setItem($productItem)
->setPrice($price)
->setInvoicedQuantity($val['cant_aviz'])
->setLineExtensionAmount($val['total_unitar']);
If I try to change this line setUnitCode(\NumNum\UBL\UnitCode::UNIT) with ->setUnitCode($val['unit_m']), nothing happens, every time the value, MON is inserted in the XML. If I try to play with the InvoiceLine.php file (where MON is declared as private $unitCode = 'MON';) I keep getting an error.
Thanks,
Chris
TaxTotal Class doesn't have roundingAmount node, for example:
<cac:TaxTotal>
<cbc:TaxAmount currencyID="USD">30.00</cbc:TaxAmount>
<cbc:RoundingAmount currencyID="USD">230.00</cbc:RoundingAmount>
</cac:TaxTotal>
Rounding Amount is a total amount of line item.
Hi,
I'm trying to attach a file to an ubl file. This works when i have my file locally:
$ublInvoice->setAdditionalDocumentReference(
(new AdditionalDocumentReference())
//->setDocumentType('application/pdf')
->setAttachment(
(new Attachment())
->setFilePath(
getcwd()."/test.pdf"
)
)
);
Now i'm storing my files on amazon s3, i'm using flysystem to store and read my files from amazon.
How do I attach a file without having to pass the path, but instead passing the binary data?
Is there any reason why those attributes are at e.g. TaxCategory ID?
All Validators are warning that that should not be present.
I can't upload the file to two Peppol Access Points.
I didn't find Setter/Getter methods in src/ClassifiedTaxCategory Class
Also in same Class, cannot find any usage for constant: UNCL5305
Are you planning to support manage UBLExtensions.
As described here: http://www.datypic.com/sc/ubl21/e-ext_UBLExtensions.html
With SI-UBL/PEPPOL the schemeID should be added to the companyID (both supplier and party). Like this:
<cbc:CompanyID schemeID="0106">12313134</cbc:CompanyID>
The schemeID comes from: https://docs.peppol.eu/poacc/billing/3.0/codelist/ICD/ and in the above example 106 means the Dutch COC.
In Party Class, the PartyIdentificationID may have an attribute for schemeID, such as:
$writer->write([
Schema::CAC . 'PartyIdentification' => [
'name' => Schema::CBC . 'ID',
'value' => $this->partyIdentificationId,
'attributes' => [
'schemeID' => $this->partyIdentificationSchemeId ?? 'OTH'
]
],
]);
Price tag inside invoiceLine doesn't have AllowanceCharge, for example:
<cac:InvoiceLine>
...
<cac:Price>
<cbc:PriceAmount currencyID="USD">22.00</cbc:PriceAmount>
<cac:AllowanceCharge>
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
<cbc:Amount currencyID="USD">2.00</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
</cac:InvoiceLine>
Hello!
I am trying to find a way to put multiple payment means in an invoice but I can get it to work. What I am doing wrong?
$supplier_bank_details = (new \NumNum\UBL\FinancialInstitutionBranch())
->setID('Bank Name 1');
$supplier_iban_details = (new \NumNum\UBL\PayeeFinancialAccount())
->setID('IBAN1')
->setFinancialInstitutionBranch($supplier_bank_details);
$supplier_bank_details2 = (new \NumNum\UBL\FinancialInstitutionBranch())
->setID('Bank Name 2');
$supplier_iban_details2 = (new \NumNum\UBL\PayeeFinancialAccount())
->setID('IBAN2')
->setFinancialInstitutionBranch($supplier_bank_details2);
.....
$supplier_payment_means = (new \NumNum\UBL\PaymentMeans())
->setPaymentMeansCode(21)
->setPayeeFinancialAccount($supplier_iban_details);
$supplier_payment_means2 = (new \NumNum\UBL\PaymentMeans())
->setPaymentMeansCode(21)
->setPayeeFinancialAccount($supplier_iban_details2);
.....
$invoice = (new \NumNum\UBL\Invoice())
.....
->setAccountingCustomerParty($clientCompany)
->setPaymentMeans($supplier_payment_means)
->setPaymentMeans($supplier_payment_means2)
->setTaxTotal($taxTotal)
->setLegalMonetaryTotal($legalMonetaryTotal)
->setInvoiceLines($invoiceLines);
This package to support the UBL 2.1 Invoice? Because exists fields not mapped... for example: UBL Extensions... or do i see bad?
Hello Dear
Thanks for the library, but I don't know how to use it!
Any help!
Thanks
Using the sample of Version 1.5 to test your wonderful plugin.
The generated file does not pass UBL validation.
https://peppol.helger.com/public/locale-en_US/menuitem-validation-upload
UBL Invoice 2.1
XML Schema - schemas/ubl21/maindoc/UBL-Invoice-2.1.xsd
Error
Location: file:///root/sample.php01.xml(71:18)
Error message: [SAX] cvc-complex-type.2.4.b: The content of element 'cac:TaxTotal' is not complete. One of '{"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":TaxAmount}' is expected.
Technical details: cvc-complex-type.2.4.b: The content of element 'cac:TaxTotal' is not complete. One of '{"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2":TaxAmount}' is expected.
This is due the presence of a cac:TaxTotal/ tag in InvoiceLine. If I comment out this line the file passes validation.
InvoiceLine.php#L195
Schema::CAC . 'TaxTotal' => $this->taxTotal,
Is this a bug or did you add that line for a reason please?
On mac os: PHP 7.4.3
composer version: Composer version 1.10.0 2020-03-10 14:08:05
Getting this error...
Deprecation Notice: Class NumNum\UBL\TaxTotal located in ./vendor/num-num/ubl-invoice/src/classes/TaxTotal.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\InvoiceLine located in ./vendor/num-num/ubl-invoice/src/classes/InvoiceLine.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\PaymentTerms located in ./vendor/num-num/ubl-invoice/src/classes/PaymentTerms.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\TaxScheme located in ./vendor/num-num/ubl-invoice/src/classes/TaxScheme.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\SettlementPeriod located in ./vendor/num-num/ubl-invoice/src/classes/SettlementPeriod.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Country located in ./vendor/num-num/ubl-invoice/src/classes/Country.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Address located in ./vendor/num-num/ubl-invoice/src/classes/Address.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\TaxSubTotal located in ./vendor/num-num/ubl-invoice/src/classes/TaxSubTotal.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\LegalMonetaryTotal located in ./vendor/num-num/ubl-invoice/src/classes/LegalMonetaryTotal.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Party located in ./vendor/num-num/ubl-invoice/src/classes/Party.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\ClassifiedTaxCategory located in ./vendor/num-num/ubl-invoice/src/classes/ClassifiedTaxCategory.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Contact located in ./vendor/num-num/ubl-invoice/src/classes/Contact.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\LegalEntity located in ./vendor/num-num/ubl-invoice/src/classes/LegalEntity.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\AllowanceCharge located in ./vendor/num-num/ubl-invoice/src/classes/AllowanceCharge.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\TaxCategory located in ./vendor/num-num/ubl-invoice/src/classes/TaxCategory.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Price located in ./vendor/num-num/ubl-invoice/src/classes/Price.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Invoice located in ./vendor/num-num/ubl-invoice/src/classes/Invoice.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Item located in ./vendor/num-num/ubl-invoice/src/classes/Item.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Schema located in ./vendor/num-num/ubl-invoice/src/classes/Schema.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\PaymentMeans located in ./vendor/num-num/ubl-invoice/src/classes/PaymentMeans.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\AdditionalDocumentReference located in ./vendor/num-num/ubl-invoice/src/classes/AdditionalDocumentReference.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
Deprecation Notice: Class NumNum\UBL\Attachment located in ./vendor/num-num/ubl-invoice/src/classes/Attachment.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.10.0/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:185
When specifying a DueDate the generated XML is not valid. DueDate must sit between IssueDate and InvoiceTypeCode
#13 fixes this.
While testing the creation of an xml i got the following error:
Call to undefined method NumNum\UBL\Invoice::setUBLVersionID()
I've added the package with composer and it shows i have version: * 1.6.2
Any idea what went wrong?
Hi,
When using AdditionalDocumentReference for adding an attachment, it also adds the DocumentType xml key. Although it's empty and does not contain anything it's should not be there. It gives the following warning:
[UBL-CR-114]-A UBL invoice should not include the AdditionalDocumentReference DocumentType
So I think it's best to hide that element when it's not set.
When using "setContractDocumentReference" on Invoice, it generates invalid UBL Invoice 2.1 XML.
According to the XSD, when generating the XML Invoice, the section "cac:ContractDocumentReference" should be right before "cac:AdditionalDocumentReference".
/**
* @return int
*/
public function getMultiplierFactorNumeric(): ?int
{
return $this->multiplierFactorNumeric;
}
/**
* @param int $multiplierFactorNumeric
* @return AllowanceCharge
*/
public function setMultiplierFactorNumeric(?int $multiplierFactorNumeric): AllowanceCharge
{
$this->multiplierFactorNumeric = $multiplierFactorNumeric;
return $this;
}
I think it should be a real number. For example, if you have a fixed value discount $35 on an item with net price $456, you have to calculate the corresponding percentage 7.675438596% which is not an integer value.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.