Version 2.0 of this package offers the ability to read UBL xml files and convert them into a \NumNum\UBL\Invoice or \NumNum\UBL\CreditNote + properties object structure.
To upgrade from 1.0, there are a few small, but breaking changes that need to be considered.
The most significant change is that setAccountingSupplierParty() and setAccountingCustomerParty() now require an AccountingParty object instead of a Party object directly.
Before (v1.x):
$supplierParty = (new \NumNum\UBL\Party())
->setName('Supplier Company Name')
->setPostalAddress($address);
$clientParty = (new \NumNum\UBL\Party())
->setName('My client')
->setPostalAddress($address);
$invoice = (new \NumNum\UBL\Invoice())
->setAccountingSupplierParty($supplierParty)
->setAccountingCustomerParty($clientParty)
->setSupplierAssignedAccountID('10001'); // Was on InvoiceAfter (v2.0):
$supplierParty = (new \NumNum\UBL\Party())
->setName('Supplier Company Name')
->setPostalAddress($address);
$clientParty = (new \NumNum\UBL\Party())
->setName('My client')
->setPostalAddress($address);
// Wrap Party objects in AccountingParty
$accountingSupplierParty = (new \NumNum\UBL\AccountingParty())
->setParty($supplierParty);
$accountingCustomerParty = (new \NumNum\UBL\AccountingParty())
->setParty($clientParty)
->setSupplierAssignedAccountId('10001'); // Now on AccountingParty
$invoice = (new \NumNum\UBL\Invoice())
->setAccountingSupplierParty($accountingSupplierParty)
->setAccountingCustomerParty($accountingCustomerParty);If you were using Invoice::accountingCustomerPartyContact, use AccountingParty::setAccountingContact() instead:
Before (v1.x):
$invoice->accountingCustomerPartyContact($contact);After (v2.0):
$accountingCustomerParty = (new \NumNum\UBL\AccountingParty())
->setParty($clientParty)
->setAccountingContact($contact);Before (v1.x):
$attachment->setFileStream($base64Content);
$content = $attachment->getFileStream();After (v2.0):
$attachment->setBase64Content($base64Content);
$content = $attachment->getBase64Content();All functions with ID suffix have been renamed to use Id for consistency:
| Before (v1.x) | After (v2.0) |
|---|---|
setUBLVersionID() / getUBLVersionID() |
setUBLVersionId() / getUBLVersionId() |
setCustomizationID() / getCustomizationID() |
setCustomizationId() / getCustomizationId() |
setProfileID() / getProfileID() |
setProfileId() / getProfileId() |
setSchemeID() / getSchemeID() |
setSchemeId() / getSchemeId() |
setUnitCodeListID() / getUnitCodeListID() |
setUnitCodeListId() / getUnitCodeListId() |
setSupplierAssignedAccountID() / getSupplierAssignedAccountID() |
setSupplierAssignedAccountId() / getSupplierAssignedAccountId() |
- Wrap
Partyobjects inAccountingPartyfor supplier/customer parties - Move
setSupplierAssignedAccountID()fromInvoicetoAccountingPartyand rename tosetSupplierAssignedAccountId() - Replace
accountingCustomerPartyContact()withAccountingParty::setAccountingContact() - Rename
setFileStream()/getFileStream()tosetBase64Content()/getBase64Content()on Attachments - Update all
*ID()method calls to use*Id()naming