PHP code example of kindy / egyptian-e-invoice
1. Go to this page and download the library: Download kindy/egyptian-e-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/ */
kindy / egyptian-e-invoice example snippets php
ire_once "./config.php";
use Kindy\EgyaptianEInvoice\Document\Document;
use Kindy\EgyaptianEInvoice\Document\DocumentInvoiceLine;
use Kindy\EgyaptianEInvoice\ETAInvoice;
$issuer = [
"address" => [
"branchID" => "0",
"country" => "EG",
"governate" => "Cairo",
"regionCity" => "Nasr City",
"street" => "580 Clementina Key",
"buildingNumber" => "Bldg. 0",
"postalCode" => "68030",
"floor" => "1",
"room" => "123",
"landmark" => "7660 Melody Trail",
"additionalInformation" => "beside Townhall"
],
"type" => "B",
"id" => "500100200",
"name" => "Issuer Company"
];
$receiver = [
"address" => [
"country" => "EG",
"governate" => "Cairo",
"regionCity" => "Nasr City",
"street" => "580 Clementina Key",
"buildingNumber" => "Bldg. 0",
],
"type" => "B",
"id" => "674859545",
"name" => "Recievr Company"
];
$document = new Document();
$document->setIssuer($issuer)
->setReceiver($receiver)
->setDateTimeIssued('2022-05-13T12:35:00Z');
$document->setPurchaseOrderReference('3asd1as');
$invoiceLine = new DocumentInvoiceLine();
$invoiceLine->setDescription('Software ERP')
->setInternalCode('MA123')
->setItemType('EGS')
->setItemCode('EG-500100200-001')
->setUnitType('JOB')
->setQuantity(2)
->setUnitValue('EGP',985)
->setDiscount(137.9,'A')
->setTaxableItems('T1',256.494,14,'V001')
->setItemsDiscount(71.804)
->setTotal();
$document->setInvoiceLine($invoiceLine);
$invoiceLine = new DocumentInvoiceLine();
$invoiceLine->setDescription('Software CRM')
->setInternalCode('CRM123')
->setItemType('EGS')
->setItemCode('EG-500100200-001')
->setUnitType('JOB')
->setQuantity(1)
->setUnitValue('EGP',600)
->setTaxableItems('T1',84,14,'V001')
->setTotal();
$document->setInvoiceLine($invoiceLine);
$document->setInternalID('103333')->setTaxpayerActivityCode('6920')->calculate();
if(isset($_POST['signature']))
{
$document->setSignatures(
[
[
'signatureType' => 'I',
'value' => $_POST['signature']
]
]
);
$invoice = new ETAInvoice($config['client_id'],$config['client_secret'], 'uat');
$finalDocument = [$document->toArray()];
$documentSubmit = $invoice->submitDocument($finalDocument);
echo $documentSubmit->acceptedDocuments[0]->uuid.'-'.$documentSubmit->acceptedDocuments[0]->longId.'-'.$documentSubmit->acceptedDocuments[0]->internalId;
}