PHP code example of dakataa / nra-audit

1. Go to this page and download the library: Download dakataa/nra-audit 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/ */

    

dakataa / nra-audit example snippets




namespace App\Repository;

use Dakataa\NraAudit\Model\NraOrder;
use Dakataa\NraAudit\Model\NraOrderArticle;
use Dakataa\NraAudit\Repository\NraOrderRepositoryInterface;

class NraOrderRepository implements NraOrderRepositoryInterface
{
	public function getOrderByNumber(int|string $number): ?NraOrderInterface {
       
		// ... your implementation

		return new NraOrder(
		    ...
		);
	}
	
	public function getOrdersByShop(NraShopInterface $shop, int $year = null, int $month = null): Generator
	{
		// Find orders depend on arguments
		// ...
		
		foreach ($orders as $order) {
			yield new NraOrder(
				number: $order->id,
				date: $order->payedAt,
				document: $order->receiptNumber,
				paymentMethod: PaymentMethodEnum::VPOS,
				amount: $order->amountWithoutVat,
				vatAmount: $order->amountVat,
				discountAmount: $order->discountAmount
				articles: [
					new NraOrderArticle(
						name: 'Product 1',
						amount: '8.99',
						quantity: 1,
						vatRate: 20
					),
					new NraOrderArticle(
						name: 'Product 2',
						amount: '8.99',
						quantity: 1,
						vatRate: 20
					),
				],
				// VPOS Terminal Number
				virtualPOSNumber: $order->virualPOSTerminalId,
				transactionNumber: $order->virualPOSTransactionNumber,
				// Bulstat or VAT Number
				processorId: $order->processorEIKorVATNumber
			);
		}
	}
	
	
}


use App\Repository\NraOrderRepository;
use Dakataa\NraAudit\Model\NraShop;
use Dakataa\NraAudit\NraAuditGenerator;

// ....

$shop = new NraShop(
	type: ShopTypeEnum::Own,
	// NRA - Website registration number
	number: 'RF0015001',
	name: 'Фирма ЕООД',
	address: 'ул. Адрес №1',
	eik: '130107280',
	mol: 'Иван Иванов Иванов',
	domain: 'www.example.com',
	email: '[email protected]',
	phone: '+359 888 8888 8888'
); 

$repository = new NraOrderRepository;
$generator = new NraAuditGenerator($repository)

$document = $generator->generate($shop, 2025, 10);
$document->save('nra-audit.xml');