PHP code example of lsr / abra-flexi

1. Go to this page and download the library: Download lsr/abra-flexi 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/ */

    

lsr / abra-flexi example snippets




sr\AbraFlexi\AbraFlexiConfiguration;
use Lsr\AbraFlexi\AbraFlexiInvoiceGateway;
use Lsr\AbraFlexi\AbraFlexiPriceListGateway;
use Psr\Log\NullLogger;

$configuration = new AbraFlexiConfiguration(
    enabled: true,
    apiUrl: (string) getenv('ABRA_API_URL'),
    company: (string) getenv('ABRA_COMPANY'),
    username: (string) getenv('ABRA_USERNAME'),
    password: (string) getenv('ABRA_PASSWORD'),
    currencyCode: 'CZK',
);
$logger = new NullLogger();
$invoices = new AbraFlexiInvoiceGateway($configuration, $logger);
$priceList = new AbraFlexiPriceListGateway($configuration, $logger);

$item = $priceList->findByCode('SERVICE-90');

use Lsr\AbraFlexi\Dto\IssueInvoiceLine;
use Lsr\AbraFlexi\Dto\IssueInvoiceRequest;

$request = new IssueInvoiceRequest(
    orderNumber: 'ORDER-0042',
    recipientName: 'Example customer',
    externalId: 'ext:billing:invoice.42',
    paymentMethodCode: null,
    debitAccountCode: null,
    creditAccountCode: null,
    documentTypeCode: 'FAKTURA',
    numberSeriesCode: null,
    issuedOn: null,
    taxPointOn: null,
    dueOn: null,
    currencyCode: 'CZK',
    paymentReference: '0042',
    lines: [new IssueInvoiceLine(
        description: 'Consulting',
        quantity: '1',
        unitCode: null,
        unitPriceMinor: 12100,
        netAmountMinor: 10000,
        vatAmountMinor: 2100,
        grossAmountMinor: 12100,
        priceTypeCode: 'typCeny.sDph',
        vatRateTypeCode: 'typSzbDph.dphZakl',
        vatRateBasisPoints: 2100,
    )],
    recipient: null,
);

$invoice = $invoices->issue($request);

$existing = $invoices->findByExternalId($request->externalId);
$pdf = $invoices->downloadPdf($request->externalId);