uctoplus/ubl-wrapper

A PHP wrapper for UBL documents

v1.2.6 2023-07-12 07:38 UTC

This package is auto-updated.

Last update: 2024-04-24 15:09:41 UTC


README

GitHub Workflow Status (branch) Codecov

About The Project

You can install new

$ composer require uctoplus/ubl-wrapper

Supported UBL versions

UBL 2.1

http://docs.oasis-open.org/ubl/os-UBL-2.1/UBL-2.1.html

[comming soon] UBL 2.3

http://docs.oasis-open.org/ubl/os-UBL-2.3/UBL-2.3.html

Getting Started

To get a local copy up and running follow these simple steps.

Generate UBL Documents

$generator = new Generator();

$invoice = new Invoice();
$invoice->setID(1);
$invoice->setIssueDate(Carbon::now());
$invoice->addNote("Note No. 1!!!");
$invoice->addNote(new NoteType("Note No. 2!!!", ["languageID" => "en"]));


// Create AccountingSupplierParty
$accountingSupplierParty = new SupplierPartyType();
$invoice->setAccountingSupplierParty($accountingSupplierParty);

// Create AccountingCustomerParty
$accountingCustomerParty = new CustomerPartyType();
$invoice->setAccountingCustomerParty($accountingCustomerParty);

// Create LegalMonetaryTotal
$legalMonetaryTotal = new MonetaryTotalType();

$payableAmount = new PayableAmountType();
$payableAmount->setCurrencyIDAttribute("EUR");
$payableAmount->setValue(15.35);
$legalMonetaryTotal->setPayableAmount($payableAmount);
$invoice->setLegalMonetaryTotal($legalMonetaryTotal);

// Create InvoiceLine
$invoiceLine = new InvoiceLineType();
$invoiceLine->setID("1");
$invoiceLine->setLineExtensionAmount(new LineExtensionAmountType("555", ["currencyID" => "EUR"]));

$item = new ItemType();
$item->setName("Item");

$invoiceLine->setItem($item);

$invoice->addInvoiceLine($invoiceLine);

$generator->addDocument($invoice);
$generator->save( 'path/to/file.xml' );

When multiple documents are provided to generator zip file will be generated as default. When flag $aggregated=true is provided to $generator->save( $file_path, $aggregated = false);, aggregated XML will be generated using UCT xsd scheme. This is useful for Import/Export in large amount of documents.

Parse UBL Documents

$parser = new Parser();
$parser->fromFile('tests/resources/UBL-Invoice-2.1-Example.xml');

$parser->getDocuments();

About The Author

This package was created by Účto+ / doq.to to provide support for UBL standard.