PHP code example of sharpapi / laravel-invoice-manager
1. Go to this page and download the library: Download sharpapi/laravel-invoice-manager 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/ */
sharpapi / laravel-invoice-manager example snippets
use SharpAPI\InvoiceManager\Jobs\ParseAndStoreInvoiceJob;
ParseAndStoreInvoiceJob::dispatch('/path/to/invoice.pdf');
use SharpAPI\InvoiceManager\Services\InvoiceImporter;
use SharpAPI\InvoiceParser\InvoiceParserService;
$parser = app(InvoiceParserService::class);
$importer = app(InvoiceImporter::class);
$statusUrl = $parser->parseInvoice('/path/to/invoice.pdf');
$job = $parser->fetchResults($statusUrl);
$invoices = $importer->storeMany($job->getResultArray(), [
'sharp_api_job_id' => $job->id,
'source_file_path' => '/path/to/invoice.pdf',
'source_file_name' => 'invoice.pdf',
]);
$invoice = $invoices->first();
$invoice->invoice_number; // "INV-1688"
$invoice->total; // total_payable, falling back to total_incl_tax
$invoice->lineItems; // collection of line items
$invoice->seller->name; // "L Dairy Foods Sdn Bhd"
$invoice->buyer->billing_city; // "Kuala Lumpur"
$invoice->taxDetails; // collection of tax breakdowns
use SharpAPI\InvoiceManager\Events\InvoiceImported;
// In a listener
public function handle(InvoiceImported $event): void
{
$invoice = $event->invoice;
// notify, post to ERP, reconcile, etc.
}