1. Go to this page and download the library: Download fajarsulaksono/ubl-invoice library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fajarsulaksono / ubl-invoice example snippets
use UBLInvoice;
$xml = UBLInvoice::invoice($invoice, 'EUR');
use fajarsulaksono\UBL\Invoice\Invoice;
use fajarsulaksono\UBL\Invoice\Generator;
use fajarsulaksono\UBL\Invoice\LegalMonetaryTotal;
use fajarsulaksono\UBL\Invoice\TaxSubTotal;
use fajarsulaksono\UBL\Invoice\Address;
use fajarsulaksono\UBL\Invoice\Country;
use fajarsulaksono\UBL\Invoice\Party;
use fajarsulaksono\UBL\Invoice\Item;
use fajarsulaksono\UBL\Invoice\Price;
use fajarsulaksono\UBL\Invoice\InvoiceLine;
use fajarsulaksono\UBL\Invoice\TaxScheme;
use fajarsulaksono\UBL\Invoice\TaxTotal;
use fajarsulaksono\UBL\Invoice\TaxCategory;
me('Product Name')
->setDescription('Product Description');
// Price
$price = (new Price())
->setBaseQuantity(1)
->setUnitCode('Unit')
->setPriceAmount(10);
// Invoice line
$invoiceLine = (new InvoiceLine())
->setId(0)
->setItem($item)
->setPrice($price)
->setInvoicedQuantity(1);
// Tax
$taxScheme = (new TaxScheme())->setId(0);
$taxCategory = (new TaxCategory())
->setId(0)
->setName('TVA20')
->setPercent(20)
->setTaxScheme($taxScheme);
$taxSubTotal = (new TaxSubTotal())
->setTaxableAmount(10)
->setTaxAmount(2)
->setTaxCategory($taxCategory);
$taxTotal = (new TaxTotal())
->addTaxSubTotal($taxSubTotal)
->setTaxAmount(2);
// Invoice
$invoice = (new Invoice())
->setId(3)
->setIssueDate(new \DateTime())
->setInvoiceTypeCode('invoiceTypeCode')
->setAccountingSupplierParty($company)
->setAccountingCustomerParty($client)
->setInvoiceLines([$invoiceLine])
->setLegalMonetaryTotal(
(new LegalMonetaryTotal())
->setPayableAmount(12)
->setAllowanceTotalAmount(0)
)
->setTaxTotal($taxTotal);
// Generate XML
header('Content-type: text/xml');
echo Generator::invoice($invoice);
use fajarsulaksono\UBL\Invoice\Invoice;
use fajarsulaksono\UBL\Invoice\Generator;
$invoice = new Invoice();
// ... build your invoice ...
// Using the Generator directly
$xml = Generator::invoice($invoice, 'EUR');
// Or using the Facade
$xml = \UBLInvoice::invoice($invoice, 'EUR');