mylgeorge / aade
AADE MyData into PHP classes and JMS metadata
v0.3.109
2024-07-05 12:21 UTC
Requires
- php: ^8.1
- dragonbe/vies: ^2.3
- goetas-webservices/xsd2php-runtime: ^0.2
- guzzlehttp/guzzle: ^7.0
- symfony/validator: ^6.0
Requires (Dev)
- goetas-webservices/xsd2php: ^0.4
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^6.0
- vlucas/phpdotenv: ^5.5
README
AADE MyData into PHP classes and JMS metadata
composer require mylgeorge/aade
use \Sofar\Aade\Aade;
use \Sofar\Aade\Models\Invoice;
use \Sofar\Aade\Utils\Validator;
Aade::SetCredential(***AADE_USER***, ***AADE_KEY***);
$invoice = [
'issuer' => [
'vatNumber' => VAT_ID,
'country' => 'GR',
'branch' => 0
],
'invoiceHeader' => [
'aa' => $order->getInvoceNo(),
'series' => "W",
'invoiceType' => '1.0',
'issueDate' => date_create( $order->getDate() ),
'currency' => 'EUR'
],
'paymentMethods' => [
[
'amount' => $total,
'type' => 1
]
],
'counterpart' => [
'vatNumber' => $vatNumber,
'country' => $paymentAddr->getCountry(),
'branch' => 0,
'name' => $paymentAddr->getCompany(),
'address' => [
'city' => $paymentAddr->getCity(),
'number' => $paymentAddr->getNumber(),
'street' => $paymentAddr->getAddress(),
'postalCode' => $paymentAddr->getPostal()
]
],
'invoiceDetails' => [],
'invoiceSummary' => [
'totalNetValue' => $price->getValue(),
'totalVatAmount' => $price->getTaxValue(),
'totalGrossValue' => $total,
],
];
foreach(getProducts() as $product){
$invoice['invoiceDetails'][] = [
'discountOption' => 'true',
'quantity' => $product->getQuantity(),
'netValue' => $product->getPrice()->getValue(),
'vatAmount' => $product->getPrice()->getTaxValue(),
'vatCategory' => Aade::getVatCategory($product->getPrice()->getTaxRate()),
];
}
try {
$response = (new Invoice)->send($invoice);
// OR
// Invoice::create()->sendMany([ $invoice ]);
if($r->getStatusCode() !== 'Success'){
echo 'Error while trying to send invoice';
}
} catch (\Exception $e) {
var_dump(Validator::getErrors());
}