### Install and Initialize firebed/aade-mydata Source: https://context7.com/firebed/aade-mydata/llms.txt Install the library using Composer and initialize your API credentials and environment. For local development, SSL verification can be disabled. ```php // Installation // composer require firebed/aade-mydata use Firebed\AadeMyData\Http\MyDataRequest; // Set environment ("dev" for development, "prod" for production) MyDataRequest::setEnvironment('dev'); MyDataRequest::setCredentials('your-user-id', 'your-subscription-key'); // Alternative one-liner MyDataRequest::init('your-user-id', 'your-subscription-key', 'dev'); // Disable SSL verification for local development (not for production) MyDataRequest::verifyClient(false); ``` -------------------------------- ### Install firebed/aade-mydata via Composer Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Use this command to add the package to your project's dependencies. ```bash composer require firebed/aade-mydata ``` -------------------------------- ### Send Invoices using AADE myDATA API Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Prepare Invoice objects, instantiate SendInvoices, and handle the response. This example shows how to process successful submissions and errors, including retrieving invoice UIDs, marks, and QR codes. It also includes error handling for communication failures. ```php use Firebed\AadeMyData\Http\SendInvoices; use Firebed\AadeMyData\Models\Invoice; use Firebed\AadeMyData\Exceptions\MyDataException; // Prepare your invoices, for simplicity we will use an array of empty // Invoice objects. You should populate these objects with your own data. $invoices = [new Invoice(), new Invoice()]; $sender = new SendInvoices(); try { $responses = $sender->handle($invoices); $errors = []; foreach ($responses as $response) { if ($response->isSuccessful()) { // This invoice was successfully sent to myDATA. // Each response has an index value which corresponds // to the index (-1) of the $invoices array. $index = $response->getIndex(); $uid = $response->getInvoiceUid(); $mark = $response->getInvoiceMark(); $cancelledByMark = $response->getCancellationMark(); $qrUrl = $response->getQrUrl(); // If you need to relate the response to your local invoice // $invoice = $invoices[$index - 1]; print_r(compact('index', 'uid', 'mark', 'cancelledByMark', 'qrUrl')); } else { // There were some errors for a specific invoice. See errors for details. foreach ($response->getErrors() as $error) { $errors[$response->getIndex() - 1][] = $error->getCode() . ': ' . $error->getMessage(); } } } } catch (MyDataException $e) { // There was a communication error. None of the invoices were sent. echo "Σφάλμα επικοινωνίας: " . $e->getMessage(); } ``` -------------------------------- ### Configure AADE myDATA Environment and Credentials Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Set the environment (development or production) and provide your user ID and subscription key. For development, client verification can be disabled if not using HTTPS. ```php $env = "dev"; // For production use "prod" $user_id = "your-user-id"; $subscription_key = "your-subscription-key"; MyDataRequest::setEnvironment($env); MyDataRequest::setCredentials($user_id, $subscription_key); ``` ```php MyDataRequest::verifyClient(false); ``` -------------------------------- ### Building a Credit Invoice (TYPE_5_1) Source: https://context7.com/firebed/aade-mydata/llms.txt Demonstrates how to construct a credit invoice by linking it to an original invoice using the `addCorrelatedInvoice()` method. ```APIDOC ## Building a Credit Invoice (TYPE_5_1) Build a correlated credit invoice by linking it to the original invoice's mark via `addCorrelatedInvoice()`. ```php use Firebed\AadeMyData\Models\Invoice; use Firebed\AadeMyData\Models\InvoiceHeader; use Firebed\AadeMyData\Enums\InvoiceType; $header = new InvoiceHeader(); $header->setSeries('A'); $header->setAa(102); $header->setIssueDate('2020-04-10'); $header->setInvoiceType(InvoiceType::TYPE_5_1); // Credit invoice $header->setCurrency('EUR'); $header->addCorrelatedInvoice('400000017716190'); // Mark of the original invoice $invoice = new Invoice(); $invoice->setIssuer($issuer); // same issuer as above $invoice->setCounterpart($counterpart); // same counterpart $invoice->setInvoiceHeader($header); $invoice->addPaymentMethod($payment); $invoice->addInvoiceDetails($row1); $invoice->addInvoiceDetails($row2); $invoice->summarizeInvoice(); ``` ``` -------------------------------- ### Populate InvoiceDetails Model with Constructor and Fluent Setters in PHP Source: https://context7.com/firebed/aade-mydata/llms.txt Models can be populated via the constructor using an array of attributes or through fluent, chainable setters. Use additive helpers for amounts. ```php use Firebed\AadeMyData\Models\InvoiceDetails; use Firebed\AadeMyData\Enums\RecType; use Firebed\AadeMyData\Enums\IncomeClassificationType; use Firebed\AadeMyData\Enums\IncomeClassificationCategory; // Array-based constructor $row = new InvoiceDetails([ 'lineNumber' => 1, 'netValue' => 5.00, 'recType' => RecType::TYPE_2, 'incomeClassification' => [ [ 'classificationType' => IncomeClassificationType::E3_561_001, 'classificationCategory' => IncomeClassificationCategory::CATEGORY_1_1, 'amount' => '5.00', ], ], ]); // Fluent chainable setters $invoice->setIssuer($issuer) ->setCounterpart($counterpart) ->setInvoiceHeader($header); // Additive amount helpers $row->addNetValue(5.00); $row->addVatAmount(1.20); ``` -------------------------------- ### Run Composer Tests Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Execute the project's test suite using Composer. This command is typically used to ensure code quality and verify functionality. ```shell composer test ``` -------------------------------- ### Build a Credit Invoice (TYPE_5_1) Source: https://context7.com/firebed/aade-mydata/llms.txt Create a credit invoice by linking it to the original invoice's mark using `addCorrelatedInvoice()`. Ensure all necessary header and invoice details are set. ```php use Firebed\AadeMyData\Models\Invoice; use Firebed\AadeMyData\Models\InvoiceHeader; use Firebed\AadeMyData\Enums\InvoiceType; $header = new InvoiceHeader(); $header->setSeries('A'); $header->setAa(102); $header->setIssueDate('2020-04-10'); $header->setInvoiceType(InvoiceType::TYPE_5_1); // Credit invoice $header->setCurrency('EUR'); $header->addCorrelatedInvoice('400000017716190'); // Mark of the original invoice $invoice = new Invoice(); $invoice->setIssuer($issuer); // same issuer as above $invoice->setCounterpart($counterpart); // same counterpart $invoice->setInvoiceHeader($header); $invoice->addPaymentMethod($payment); $invoice->addInvoiceDetails($row1); $invoice->addInvoiceDetails($row2); $invoice->summarizeInvoice(); ``` -------------------------------- ### Build a Complete Sales Invoice (TYPE_1_1) Source: https://context7.com/firebed/aade-mydata/llms.txt Construct a detailed sales invoice object, including issuer, counterpart, header, line items, taxes, and payment methods. Call `summarizeInvoice()` to automatically compute all required totals. ```php use Firebed\AadeMyData\Models\Issuer; use Firebed\AadeMyData\Models\Address; use Firebed\AadeMyData\Models\Counterpart; use Firebed\AadeMyData\Models\InvoiceHeader; use Firebed\AadeMyData\Models\PaymentMethodDetail; use Firebed\AadeMyData\Models\InvoiceDetails; use Firebed\AadeMyData\Models\TaxTotals; use Firebed\AadeMyData\Models\Invoice; use Firebed\AadeMyData\Enums\PaymentMethod; use Firebed\AadeMyData\Enums\InvoiceType; use Firebed\AadeMyData\Enums\VatCategory; use Firebed\AadeMyData\Enums\IncomeClassificationType; use Firebed\AadeMyData\Enums\IncomeClassificationCategory; use Firebed\AadeMyData\Enums\TaxType; use Firebed\AadeMyData\Enums\WithheldPercentCategory; // Issuer $issuer = new Issuer(); $issuer->setVatNumber('888888888'); $issuer->setCountry('GR'); $issuer->setBranch(1); // Counterpart + Address $address = new Address(); $address->setPostalCode('22222'); $address->setCity('IRAKLIO'); $counterpart = new Counterpart(); $counterpart->setVatNumber('999999999'); $counterpart->setCountry('GR'); $counterpart->setBranch(0); $counterpart->setAddress($address); // Invoice Header $header = new InvoiceHeader(); $header->setSeries('A'); $header->setAa(101); $header->setIssueDate('2020-04-08'); $header->setInvoiceType(InvoiceType::TYPE_1_1); // Sales Invoice $header->setCurrency('EUR'); // Payment $payment = new PaymentMethodDetail(); $payment->setType(PaymentMethod::METHOD_3); $payment->setAmount(1760); $payment->setPaymentMethodInfo('Bank transfer'); // Line items with income classifications $row1 = new InvoiceDetails(); $row1->setLineNumber(1); $row1->setNetValue(1000); $row1->setVatCategory(VatCategory::VAT_1); // 24% $row1->setVatAmount(240); $row1->setDiscountOption(true); $row1->addIncomeClassification( IncomeClassificationType::E3_561_001, IncomeClassificationCategory::CATEGORY_1_2, 1000 ); $row2 = new InvoiceDetails(); $row2->setLineNumber(2); $row2->setNetValue(500); $row2->setVatCategory(VatCategory::VAT_1); $row2->setVatAmount(120); $row2->setDiscountOption(true); $row2->addIncomeClassification( IncomeClassificationType::E3_561_001, IncomeClassificationCategory::CATEGORY_1_3, 500 ); // Tax totals (e.g. withheld tax) $tax = new TaxTotals(); $tax->setTaxType(TaxType::TYPE_1); $tax->setUnderlyingValue(500); $tax->setTaxCategory(WithheldPercentCategory::TAX_2); $tax->setTaxAmount(100); // Assemble invoice and auto-compute summary $invoice = new Invoice(); $invoice->setIssuer($issuer); $invoice->setCounterpart($counterpart); $invoice->setInvoiceHeader($header); $invoice->addPaymentMethod($payment); $invoice->addInvoiceDetails($row1); $invoice->addInvoiceDetails($row2); $invoice->addTaxesTotals($tax); $invoice->summarizeInvoice(); // Calculates all net/VAT/gross totals automatically // Preview the generated XML before sending echo $invoice->toXml(); ``` -------------------------------- ### Retrieve Income Summary with Pagination Source: https://context7.com/firebed/aade-mydata/llms.txt Retrieves income book entries for a specified date range. Supports pagination and filtering by counterpart VAT or invoice type. ```php use Firebed\AadeMyData\Http\RequestMyIncome; use Firebed\AadeMyData\Exceptions\MyDataException; try { $request = new RequestMyIncome(); $response = $request->handle( dateFrom: '01/01/2021', // dd/MM/yyyy format required dateTo: '31/12/2021' ); $bookInfoArray = $response->getBookInfo(); foreach ($bookInfoArray as $bookInfo) { echo $bookInfo->getCounterVatNumber() . PHP_EOL; echo $bookInfo->getIssueDate() . PHP_EOL; echo $bookInfo->getNetValue() . PHP_EOL; } // Paginate if needed $token = $response->getContinuationToken(); } catch (MyDataException $e) { echo $e->getMessage(); } ``` -------------------------------- ### Request Docs Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Requests documents. Refer to the documentation for details on request and response. ```APIDOC ## Request Docs ### Description Requests documents. ### Method GET ### Endpoint /http/request-docs ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Retrieve Expense Summary with Pagination Source: https://context7.com/firebed/aade-mydata/llms.txt Fetches expense book entries for a given date range. The response structure and parameters are similar to `RequestMyIncome`. ```php use Firebed\AadeMyData\Http\RequestMyExpenses; use Firebed\AadeMyData\Exceptions\MyDataException; try { $request = new RequestMyExpenses(); $response = $request->handle( dateFrom: '01/01/2021', dateTo: '31/12/2021' ); foreach ($response->getBookInfo() as $bookInfo) { echo $bookInfo->getCounterVatNumber() . PHP_EOL; echo $bookInfo->getNetValue() . PHP_EOL; } } catch (MyDataException $e) { echo $e->getMessage(); } ``` -------------------------------- ### Request Vat Info Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Requests VAT information. Refer to the documentation for details on request and response. ```APIDOC ## Request Vat Info ### Description Requests VAT information. ### Method GET ### Endpoint /http/request-vat-info ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Request My Income Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Requests income data. Refer to the documentation for details on request and response. ```APIDOC ## Request My Income ### Description Requests income data. ### Method GET ### Endpoint /http/request-my-income ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Transmit Invoices with SendInvoices Source: https://context7.com/firebed/aade-mydata/llms.txt Send one or multiple invoices to myDATA. The `handle()` method accepts a single `Invoice` object, an array of `Invoice` objects, or an `InvoicesDoc`. Iterate the `ResponseDoc` to retrieve invoice UIDs, marks, and QR URLs. Handle `MyDataException` for communication errors. ```php use Firebed\AadeMyData\Http\SendInvoices; use Firebed\AadeMyData\Models\Invoice; use Firebed\AadeMyData\Models\InvoicesDoc; use Firebed\AadeMyData\Exceptions\MyDataException; // --- Send a single invoice --- $request = new SendInvoices(); try { $responses = $request->handle($invoice); // single Invoice object } catch (MyDataException $e) { echo "Communication error: " . $e->getMessage(); } ``` ```php // --- Send multiple invoices via array --- $invoices = [$invoice1, $invoice2, $invoice3]; $request = new SendInvoices(); try { $responses = $request->handle($invoices); } catch (MyDataException $e) { echo "Communication error: " . $e->getMessage(); } ``` ```php // --- Send multiple invoices via InvoicesDoc --- $doc = new InvoicesDoc([new Invoice(), new Invoice()]); $doc->add(new Invoice()); try { $responses = (new SendInvoices())->handle($doc); } catch (MyDataException $e) { echo "Communication error: " . $e->getMessage(); } ``` ```php // --- Process responses (index is 1-based, maps to $invoices[$index-1]) --- $errors = []; foreach ($responses as $response) { if ($response->isSuccessful()) { $index = $response->getIndex(); // 1-based position $uid = $response->getInvoiceUid(); $mark = $response->getInvoiceMark(); $cancellationMark = $response->getCancellationMark(); $qrUrl = $response->getQrUrl(); // Persist uid/mark/qr alongside your local invoice print_r(compact('index', 'uid', 'mark', 'cancellationMark', 'qrUrl')); } else { foreach ($response->getErrors() as $error) { $errors[$response->getIndex()][] = $error->getCode() . ': ' . $error->getMessage(); } } } ``` -------------------------------- ### Request Invoices with RequestDocs Source: https://context7.com/firebed/aade-mydata/llms.txt Fetch invoices, classifications, and cancellations submitted by counterparties. Supports filtering by date range, invoice type, and receiver VAT number. Use `continuationToken` for paginated retrieval. Handle `MyDataException` for errors. ```php use Firebed\AadeMyData\Http\RequestDocs; use Firebed\AadeMyData\Enums\InvoiceType; use Firebed\AadeMyData\Exceptions\MyDataException; try { // First page $request = new RequestDocs(); $response1 = $request->handle( mark: '1234567890', dateFrom: '2021-01-01', dateTo: '2021-12-31', receiverVatNumber: '123456789', invType: InvoiceType::TYPE_1_1, ); $token = $response1->getContinuationToken(); // Next page (if results were paginated) if ($token) { $response2 = (new RequestDocs())->handle( mark: '1234567890', dateFrom: '2021-01-01', dateTo: '2021-12-31', receiverVatNumber: '123456789', invType: InvoiceType::TYPE_1_1, nextPartitionKey: $token->getNextPartitionKey(), nextRowKey: $token->getNextRowKey(), ); } } catch (MyDataException $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Retrieve VAT Report Data with Pagination Source: https://context7.com/firebed/aade-mydata/llms.txt Fetches VAT report details for an entity within a specified date range. Supports pagination. ```php use Firebed\AadeMyData\Http\RequestVatInfo; use Firebed\AadeMyData\Exceptions\MyDataException; $request = new RequestVatInfo(); try { $response = $request->handle( dateFrom: '01/01/2021', // dd/MM/yyyy dateTo: '31/12/2021' ); $token = $response->getContinuationToken(); // for next page print_r($response); } catch (MyDataException $e) { echo $e->getMessage(); } ``` -------------------------------- ### Squash Invoice Rows for ERP/Provider Submission Source: https://context7.com/firebed/aade-mydata/llms.txt Call `squashInvoiceRows()` before `summarizeInvoice()` to collapse multiple detail rows into their grouped totals. This is essential for ERP systems and invoice service providers that require summarized data. Do not use for delivery notes. ```php use Firebed\AadeMyData\Models\Invoice; use Firebed\AadeMyData\Models\InvoiceDetails; $invoice = new Invoice(); $invoice->addInvoiceDetails(new InvoiceDetails(/* row 1 */)); $invoice->addInvoiceDetails(new InvoiceDetails(/* row 2 */)); $invoice->addInvoiceDetails(new InvoiceDetails(/* row 3 */)); // Squash rows before summarizing (do NOT use for delivery notes) $invoice->squashInvoiceRows(); $invoice->summarizeInvoice(); // Preview the resulting XML echo $invoice->toXml(); /* Before squashing — 3 separate invoiceDetails elements: 4.031... 4.031... 4.031... After squashing — merged into 1 element: 12.091... */ ``` -------------------------------- ### RequestMyIncome — Retrieve Income Summary Source: https://context7.com/firebed/aade-mydata/llms.txt Retrieve income book entries for a closed date range, optionally filtered by counterpart VAT or invoice type. Returns an array of `BookInfo` objects. ```APIDOC ## RequestMyIncome — Retrieve Income Summary ### Description Retrieve income book entries for a closed date range, optionally filtered by counterpart VAT or invoice type; returns an array of `BookInfo` objects. ### Method POST (Assumed based on typical API patterns for data retrieval with parameters) ### Endpoint `/myIncome` (Assumed based on class name) ### Parameters #### Path Parameters None #### Query Parameters - **dateFrom** (string) - Required - Start date for the filter (dd/MM/yyyy format required). - **dateTo** (string) - Required - End date for the filter (dd/MM/yyyy format required). - **counterVatNumber** (string) - Optional - Filter by the counterparty's VAT number. - **invoiceType** (InvoiceType Enum) - Optional - Filter by invoice type. ### Request Example ```php $request = new RequestMyIncome(); $response = $request->handle( dateFrom: '01/01/2021', dateTo: '31/12/2021' ); ``` ### Response #### Success Response (200) - **BookInfo** (array) - An array of `BookInfo` objects, each containing details like `counterVatNumber`, `issueDate`, and `netValue`. - **ContinuationToken** (object) - Contains pagination details if available. #### Response Example ```json { "BookInfo": [ { "counterVatNumber": "123456789", "issueDate": "01/01/2021", "netValue": 1000.00 // ... other book info fields } ], "ContinuationToken": { "nextPartitionKey": "...", "nextRowKey": "..." } } ``` ``` -------------------------------- ### Enum Labels and Helper Methods Source: https://context7.com/firebed/aade-mydata/llms.txt Provides access to human-readable Greek labels for various enums and exposes feature-flag helper methods for `InvoiceType` and utility methods for `CountryCode` and `ExpenseClassificationType`. ```APIDOC ## Enum Labels and Helper Methods All enums carry a `label()` method returning the Greek human-readable description; `InvoiceType` enums also expose feature-flag helpers. ```php use Firebed\AadeMyData\Enums\InvoiceType; use Firebed\AadeMyData\Enums\PaymentMethod; use Firebed\AadeMyData\Enums\VatCategory; use Firebed\AadeMyData\Enums\CountryCode; use Firebed\AadeMyData\Enums\ExpenseClassificationType; // Human-readable labels echo InvoiceType::TYPE_1_1->label(); // "Τιμολόγιο Πώλησης" echo InvoiceType::TYPE_1_2->label(); // "Τιμολόγιο Πώλησης / Ενδοκοινοτικές Παραδόσεις" echo PaymentMethod::METHOD_5->label(); // "Επί Πιστώσει" echo VatCategory::VAT_1->label(); // "ΦΠΑ συντελεστής 24%" echo CountryCode::BE->label(); // "Βέλγιο" // Bulk labels array for all cases InvoiceType::labels(); PaymentMethod::labels(); // InvoiceType feature flags $type = InvoiceType::TYPE_1_1; $type->supportsFuelInvoice(); // false $type->hasCounterpart(); // true $type->supportsDeliveryNote(); // false $type->supportsSelfPricing(); // false // CountryCode EU helpers CountryCode::europeanUnionCountries(); // array of EU CountryCode cases CountryCode::BE->isInEuropeanUnion(); // true CountryCode::US->isInEuropeanUnion(); // false // ExpenseClassificationType VAT helpers $type = ExpenseClassificationType::VAT_361; $type->isVatClassification(); // true ExpenseClassificationType::vatClassifications(); // all VAT classification cases ``` ``` -------------------------------- ### RequestGroupQrDetails Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Requests details for a group QR code for Digital Goods Movement. This method is available only for the ERP channel. ```APIDOC ## RequestGroupQrDetails ### Description Request details for a group QR code for Digital Goods Movement. This method is available only for the ERP channel. ### Method GET ### Endpoint /http/digital-goods-movement#requestgroupqrdetails ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Handle Communication and Business Errors in PHP Source: https://context7.com/firebed/aade-mydata/llms.txt Catch specific MyData exceptions for connection or authentication issues, or a general MyDataException for other technical errors. Business errors are returned within the response, not as exceptions. ```php use Firebed\AadeMyData\Exceptions\MyDataException; use Firebed\AadeMyData\Exceptions\MyDataAuthenticationException; use Firebed\AadeMyData\Exceptions\MyDataConnectionException; use Firebed\AadeMyData\Http\SendInvoices; use Firebed\AadeMyData\Models\Invoice; try { $responses = (new SendInvoices())->handle(new Invoice()); } catch (MyDataConnectionException $e) { // No internet, server down, or wrong endpoint URL echo "Connection error: " . $e->getMessage(); } catch (MyDataAuthenticationException $e) { // Wrong user_id or subscription_key echo "Auth error: " . $e->getMessage(); } catch (MyDataException $e) { // Any other technical error (catches all of the above too) echo "Error [{$e->getCode()}]: " . $e->getMessage(); } // Business errors are per-invoice inside the ResponseDoc, not exceptions: foreach ($responses as $response) { if (!$response->isSuccessful()) { foreach ($response->getErrors() as $error) { // Over 100 possible business error codes from myDATA echo $error->getCode() . ': ' . $error->getMessage(); } } } ``` -------------------------------- ### Request My Expenses Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Requests expense data. Refer to the documentation for details on request and response. ```APIDOC ## Request My Expenses ### Description Requests expense data. ### Method GET ### Endpoint /http/request-my-expenses ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Send Payments Method Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Sends payment method information. Refer to the documentation for details on request and response. ```APIDOC ## Send Payments Method ### Description Sends payment method information. ### Method POST ### Endpoint /http/send-payments-method ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Retrieve Transmitted Invoices with Pagination Source: https://context7.com/firebed/aade-mydata/llms.txt Fetches invoices, classifications, and cancellations submitted by the authenticated user. Supports pagination using continuation tokens. ```php use Firebed\AadeMyData\Http\RequestTransmittedDocs; use Firebed\AadeMyData\Enums\InvoiceType; use Firebed\AadeMyData\Exceptions\MyDataException; try { $request = new RequestTransmittedDocs(); $response = $request->handle( mark: '1234567890', dateFrom: '01/01/2021', dateTo: '31/12/2021', receiverVatNumber: '123456789', invType: InvoiceType::TYPE_1_1, ); $token = $response->getContinuationToken(); // Paginate if needed if ($token) { $response2 = (new RequestTransmittedDocs())->handle( mark: '1234567890', dateFrom: '01/01/2021', dateTo: '31/12/2021', nextPartitionKey: $token->getNextPartitionKey(), nextRowKey: $token->getNextRowKey(), ); } } catch (MyDataException $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Enum Labels and Helper Methods Source: https://context7.com/firebed/aade-mydata/llms.txt All enums provide a `label()` method for Greek human-readable descriptions. InvoiceType enums also expose feature-flag helpers for checking invoice capabilities. Use these for displaying user-friendly information and for conditional logic. ```php use Firebed\AadeMyData\Enums\InvoiceType; use Firebed\AadeMyData\Enums\PaymentMethod; use Firebed\AadeMyData\Enums\VatCategory; use Firebed\AadeMyData\Enums\CountryCode; use Firebed\AadeMyData\Enums\ExpenseClassificationType; // Human-readable labels echo InvoiceType::TYPE_1_1->label(); // "Τιμολόγιο Πώλησης" echo InvoiceType::TYPE_1_2->label(); // "Τιμολόγιο Πώλησης / Ενδοκοινοτικές Παραδόσεις" echo PaymentMethod::METHOD_5->label(); // "Επί Πιστώσει" echo VatCategory::VAT_1->label(); // "ΦΠΑ συντελεστής 24%" echo CountryCode::BE->label(); // "Βέλγιο" // Bulk labels array for all cases InvoiceType::labels(); PaymentMethod::labels(); // InvoiceType feature flags $type = InvoiceType::TYPE_1_1; $type->supportsFuelInvoice(); // false $type->hasCounterpart(); // true $type->supportsDeliveryNote(); // false $type->supportsSelfPricing(); // false // CountryCode EU helpers CountryCode::europeanUnionCountries(); // array of EU CountryCode cases CountryCode::BE->isInEuropeanUnion(); // true CountryCode::US->isInEuropeanUnion(); // false // ExpenseClassificationType VAT helpers $type = ExpenseClassificationType::VAT_361; $type->isVatClassification(); // true ExpenseClassificationType::vatClassifications(); // all VAT classification cases ``` -------------------------------- ### GenerateGroupQrCode Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Generates a group QR code for Digital Goods Movement. This method is available only for the ERP channel. ```APIDOC ## GenerateGroupQrCode ### Description Generate a group QR code for Digital Goods Movement. This method is available only for the ERP channel. ### Method POST ### Endpoint /http/digital-goods-movement#generategroupqrcode ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Send Invoices Source: https://github.com/firebed/aade-mydata/blob/5.x/README.md Sends invoices. Refer to the documentation for details on request and response. ```APIDOC ## Send Invoices ### Description Sends invoices. ### Method POST ### Endpoint /http/send-invoices ### Parameters (Refer to external documentation for parameter details) ### Request Example (Refer to external documentation for request example) ### Response (Refer to external documentation for response details) ``` -------------------------------- ### Generate and Request Group QR Code Source: https://context7.com/firebed/aade-mydata/llms.txt Generates a composite group QR code from multiple delivery-note QR URLs and then retrieves its details using the group ID. Handles potential communication errors. ```php use Firebed\AadeMyData\Http\DigitalGoodsMovement\GenerateGroupQrCode; use Firebed\AadeMyData\Http\DigitalGoodsMovement\RequestGroupQrDetails; use Firebed\AadeMyData\Models\DigitalGoodsMovement\GroupQrCode; use Firebed\AadeMyData\Exceptions\MyDataException; try { // Generate group QR $qrUrls = [ 'https://mydataapidev.aade.gr/TimologioQR/QRInfo?q=url1', 'https://mydataapidev.aade.gr/TimologioQR/QRInfo?q=url2', ]; $generateResponse = (new GenerateGroupQrCode())->generateFromQrUrls($qrUrls); echo "Group QR URL: " . $generateResponse->getGroupQrUrl() . PHP_EOL; echo "Group ID: " . $generateResponse->getGroupId() . PHP_EOL; echo "QR count: " . $generateResponse->getQrUrlsCount() . PHP_EOL; echo "Expires at: " . $generateResponse->getExpiresAt() . PHP_EOL; // Retrieve group QR details by group ID $detailsResponse = (new RequestGroupQrDetails())->handle($generateResponse->getGroupId()); echo "Creator VAT: " . $detailsResponse->getGroupQrCreatorVatNumber() . PHP_EOL; foreach ($detailsResponse->getQrUrls() as $url) { echo " - " . $url . PHP_EOL; } } catch (MyDataException $e) { echo "Communication error: " . $e->getMessage(); } ``` -------------------------------- ### RejectDeliveryNote Source: https://context7.com/firebed/aade-mydata/llms.txt Rejects a delivery note using its mark or QR URL, with an optional rejection reason. ```APIDOC ## RejectDeliveryNote ### Description Reject a delivery note using its mark or QR URL with an optional rejection reason. ### Method POST (Implied by the `rejectUsingMark` and `rejectUsingQrUrl` method usages) ### Endpoint Not explicitly defined, but related to Digital Goods Movement. ### Parameters #### Method: `rejectUsingMark` - **mark** (integer) - Required - The mark of the delivery note to reject. - **reason** (string) - Optional - The reason for rejection. #### Method: `rejectUsingQrUrl` - **qrUrl** (string) - Required - The QR code URL of the delivery note to reject. - **reason** (string) - Optional - The reason for rejection. ### Request Example ```php use Firebed\AadeMyData\Http\DigitalGoodsMovement\RejectDeliveryNote; $reject = new RejectDeliveryNote(); // Reject by mark $response = $reject->rejectUsingMark(400002969517846, 'Damaged goods'); // Or reject by QR URL // $response = $reject->rejectUsingQrUrl( // 'https://mydataapidev.aade.gr/TimologioQR/QRInfo?q=test_url', // 'Damaged goods' // ); ``` ### Response #### Success Response - **rejectMark** (string) - The mark associated with the rejected delivery note. #### Response Example ```json [ { "isSuccessful": true, "rejectMark": "987654321098765" } ] ``` ``` -------------------------------- ### GenerateGroupQrCode / RequestGroupQrDetails Source: https://context7.com/firebed/aade-mydata/llms.txt Generates a composite group QR code from multiple delivery-note QR URLs and retrieves its details. ```APIDOC ## GenerateGroupQrCode / RequestGroupQrDetails ### Description Generate a composite group QR code from multiple delivery-note QR URLs, then retrieve its details. ### Method POST (Implied for `GenerateGroupQrCode`) GET (Implied for `RequestGroupQrDetails`) ### Endpoint Not explicitly defined, but related to Digital Goods Movement. ### Parameters #### Method: `GenerateGroupQrCode` - **qrUrls** (array of strings) - Required - An array of delivery note QR code URLs. #### Method: `RequestGroupQrDetails` - **groupId** (string) - Required - The ID of the group QR code. ### Request Example ```php use Firebed\AadeMyData\Http\DigitalGoodsMovement\GenerateGroupQrCode; use Firebed\AadeMyData\Http\DigitalGoodsMovement\RequestGroupQrDetails; // Generate group QR $qrUrls = [ 'https://mydataapidev.aade.gr/TimologioQR/QRInfo?q=url1', 'https://mydataapidev.aade.gr/TimologioQR/QRInfo?q=url2', ]; $generateResponse = (new GenerateGroupQrCode())->generateFromQrUrls($qrUrls); // Retrieve group QR details by group ID $detailsResponse = (new RequestGroupQrDetails())->handle($generateResponse->getGroupId()); ``` ### Response #### `GenerateGroupQrCode` Response - **groupQrUrl** (string) - The generated group QR code URL. - **groupId** (string) - The unique ID for the group QR code. - **qrUrlsCount** (integer) - The number of QR codes included in the group. - **expiresAt** (string) - The expiration timestamp for the group QR code. #### `RequestGroupQrDetails` Response - **groupQrCreatorVatNumber** (string) - The VAT number of the creator of the group QR code. - **qrUrls** (array of strings) - An array of the original delivery note QR code URLs included in the group. #### Response Example (GenerateGroupQrCode) ```json { "groupQrUrl": "https://mydataapidev.aade.gr/GroupQR/XYZ123", "groupId": "XYZ123", "qrUrlsCount": 2, "expiresAt": "2023-10-27T15:00:00Z" } ``` #### Response Example (RequestGroupQrDetails) ```json { "groupQrCreatorVatNumber": "111111111", "qrUrls": [ "https://mydataapidev.aade.gr/TimologioQR/QRInfo?q=url1", "https://mydataapidev.aade.gr/TimologioQR/QRInfo?q=url2" ] } ``` ``` -------------------------------- ### SendInvoices — Transmit One or Multiple Invoices Source: https://context7.com/firebed/aade-mydata/llms.txt This operation allows you to send one or multiple invoices to myDATA. It supports sending single `Invoice` objects, arrays of `Invoice` objects, or an `InvoicesDoc`. The response provides details for each transmitted invoice, including its UID, mark, and QR URL. ```APIDOC ## SendInvoices — Transmit One or Multiple Invoices Send one invoice, an array of invoices, or an `InvoicesDoc` to myDATA; iterate the `ResponseDoc` to retrieve each invoice's `uid`, `mark`, and QR URL. ```php use Firebed\AadeMyData\Http\SendInvoices; use Firebed\AadeMyData\Models\Invoice; use Firebed\AadeMyData\Models\InvoicesDoc; use Firebed\AadeMyData\Exceptions\MyDataException; // --- Send a single invoice --- $request = new SendInvoices(); try { $responses = $request->handle($invoice); // single Invoice object } catch (MyDataException $e) { echo "Communication error: " . $e->getMessage(); } // --- Send multiple invoices via array --- $invoices = [$invoice1, $invoice2, $invoice3]; $request = new SendInvoices(); try { $responses = $request->handle($invoices); } catch (MyDataException $e) { echo "Communication error: " . $e->getMessage(); } // --- Send multiple invoices via InvoicesDoc --- $doc = new InvoicesDoc([new Invoice(), new Invoice()]); $doc->add(new Invoice()); try { $responses = (new SendInvoices())->handle($doc); } catch (MyDataException $e) { echo "Communication error: " . $e->getMessage(); } // --- Process responses (index is 1-based, maps to $invoices[$index-1]) --- $errors = []; foreach ($responses as $response) { if ($response->isSuccessful()) { $index = $response->getIndex(); // 1-based position $uid = $response->getInvoiceUid(); $mark = $response->getInvoiceMark(); $cancellationMark = $response->getCancellationMark(); $qrUrl = $response->getQrUrl(); // Persist uid/mark/qr alongside your local invoice print_r(compact('index', 'uid', 'mark', 'cancellationMark', 'qrUrl')); } else { foreach ($response->getErrors() as $error) { $errors[$response->getIndex()][] = $error->getCode() . ': ' . $error->getMessage(); } } } ``` ``` -------------------------------- ### RequestVatInfo — Retrieve VAT Report Data Source: https://context7.com/firebed/aade-mydata/llms.txt Fetch VAT report details for an entity over a date range. Returns a `VatInfo` collection with pagination support. ```APIDOC ## RequestVatInfo — Retrieve VAT Report Data ### Description Fetch VAT report details for an entity over a date range; returns a `VatInfo` collection with pagination support. ### Method POST (Assumed based on typical API patterns for data retrieval with parameters) ### Endpoint `/vatInfo` (Assumed based on class name) ### Parameters #### Path Parameters None #### Query Parameters - **dateFrom** (string) - Required - Start date for the report (dd/MM/yyyy format). - **dateTo** (string) - Required - End date for the report (dd/MM/yyyy format). ### Request Example ```php $request = new RequestVatInfo(); $response = $request->handle( dateFrom: '01/01/2021', dateTo: '31/12/2021' ); ``` ### Response #### Success Response (200) - **VatInfo** (object) - Contains VAT report details. - **ContinuationToken** (object) - Contains pagination details if available. #### Response Example ```json { "VatInfo": { // ... VAT report fields ... }, "ContinuationToken": { "nextPartitionKey": "...", "nextRowKey": "..." } } ``` ``` -------------------------------- ### SendPaymentsMethod — Transmit Payment Methods for Existing Invoices Source: https://context7.com/firebed/aade-mydata/llms.txt Associate POS-type and other payment method details with an already-submitted invoice identified by its `mark`. The total amount must equal the invoice's `totalGrossValue`. ```APIDOC ## SendPaymentsMethod — Transmit Payment Methods for Existing Invoices ### Description Associate POS-type and other payment method details with an already-submitted invoice identified by its `mark`; the total amount must equal the invoice's `totalGrossValue`. ### Method POST (Assumed based on typical API patterns for data submission) ### Endpoint `/sendPaymentsMethod` (Assumed based on class name) ### Parameters #### Path Parameters None #### Request Body - **PaymentMethod** (object) - Required - Contains invoice mark and payment method details. - **invoiceMark** (string) - Required - The mark of the invoice to associate payment with. - **paymentMethodDetails** (array) - Required - A list of payment method details. - **type** (PaymentMethod Enum) - Required - The type of payment method (e.g., POS). - **amount** (float) - Required - The amount of the payment. - **ecrToken** (ECRToken object) - Optional - Token for electronic cash register. - **authorId** (string) - Required - Author ID for the ECR token. - **sessionNumber** (string) - Required - Session number for the ECR token. ### Request Example ```php $ecrToken = new ECRToken('signing-author-id', 'session-number'); $details = new PaymentMethodDetail(); $details->setType(Payments::METHOD_7); // POS $details->setAmount(1000); $details->setECRToken($ecrToken); $paymentMethod = new PaymentMethod(); $paymentMethod->setInvoiceMark('900001234567890'); $paymentMethod->addPaymentMethodDetails($details); $responses = (new SendPaymentsMethod())->handle($paymentMethod); ``` ### Response #### Success Response (200) - **Response** (array) - An array of response objects, one for each payment method submitted. - **invoiceMark** (string) - The mark of the invoice. - **successful** (boolean) - Indicates if the payment method was registered successfully. - **errors** (array) - A list of errors if `successful` is false. - **code** (string) - Error code. - **message** (string) - Error message. #### Response Example ```json [ { "invoiceMark": "900001234567890", "successful": true, "errors": [] } ] ``` ```