1. Go to this page and download the library: Download dgtlinf/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/ */
dgtlinf / invoice example snippets
use Dgtlinf\Invoice\Facades\Invoice;
use Dgtlinf\Invoice\Models\{LineItem, Party, PaymentDetails, Tax, Quantity, Money};
use Dgtlinf\Invoice\Support\{Currency, UnitType, InvoiceType};
Route::get('/invoice', function () {
$currency = Currency::fromConfig();
$seller = new Party(name: 'DEMO COMPANY ACME LTD', address: 'Main Street 123456', taxId: '123456789');
$buyer = new Party(name: 'Acme, Inc.', address: '1234 Goto street', taxId: '11-2222222');
$items = [
new LineItem(
description: 'Monthly retainer fee',
quantity: Quantity::from(1),
unitPrice: Money::from(15000, $currency),
tax: new Tax('VAT', 0, Money::from(0, $currency)),
unit: UnitType::MONTH
),
// ...more items, discounts, etc.
];
$items = Invoice::applyItemDiscounts($items);
$payment = new PaymentDetails(
bankName: 'GREAT BANK OF WORLD, London, UK',
accountNumber: '000-000000000-11',
iban: 'UK000000000000000'
);
$invoice = Invoice::make([
'number' => 'INV0001',
'type' => InvoiceType::INVOICE,
'seller' => $seller,
'buyer' => $buyer,
'items' => $items,
'amountPaid' => Money::from(0, $currency),
'paymentDetails' => $payment,
'note' => 'The VAT calculation date is the date of supply.',
'dueAt' => now()->addDays(7),
]);
return Invoice::stream(Invoice::calculate($invoice));
});