1. Go to this page and download the library: Download ameax/datev-extf 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/ */
ameax / datev-extf example snippets
use ameax\DatevExtf\DatevExtfWriter;
use ameax\DatevExtf\DatevExtfWriterEntry;
use ameax\DatevExtf\Enums\DebitCreditIndicator;
use ameax\DatevExtf\Enums\FormatName;
// Writer mit Formattyp initialisieren
$writer = DatevExtfWriter::make(FormatName::BUCHUNGSSTAPEL);
// Header konfigurieren
$writer->getHeader()->fromArray([
'consultant_number' => 12345,
'client_number' => 67890,
'fiscal_year_start' => new \DateTime('2023-01-01'),
'date_from' => new \DateTime('2023-01-01'),
'date_to' => new \DateTime('2023-12-31'),
'description' => 'Monatliche Buchungen'
]);
// Buchungseintrag erstellen
$entry = new DatevExtfWriterEntry();
$entry->fromArray([
'amount' => 1200.00, // Gleitkommazahl
'debit_credit_indicator' => DebitCreditIndicator::DEBIT,
'account' => '8400',
'contra_account' => '1800',
'document_date' => new \DateTime('2023-05-15'), // DateTime-Objekt
'document_field_1' => 'RE-2023-123',
'posting_text' => 'Software Einkauf',
'tax_rate' => 19.00, // Gleitkommazahl
'due_date' => new \DateTime('2023-06-15') // DateTime-Objekt
]);
// Eintrag zum Writer hinzufügen
$writer->addEntry($entry);
// Verschiedene Ausgabemöglichkeiten:
// 1. Als String erhalten
$content = $writer->toString();
// 2. In Datei speichern
try {
$writer->saveTo('buchungsstapel_export.csv');
} catch (\RuntimeException $e) {
// Fehlerbehandlung
echo "Fehler beim Speichern: " . $e->getMessage();
}
// 3. Datei herunterladen
$writer->download('buchungsstapel_export.csv');
// 4. Inhalt streamen
$writer->stream();
use ameax\DatevExtf\DatevExtfWriter;
use ameax\DatevExtf\DatevExtfWriterParty;
use ameax\DatevExtf\Enums\PartyType;
use ameax\DatevExtf\Enums\AddressType;
use ameax\DatevExtf\Enums\FormatName;
// Writer für Debitoren/Kreditoren initialisieren
$writer = DatevExtfWriter::make(FormatName::DEBITOREN_KREDITOREN);
// Header konfigurieren
$writer->getHeader()->fromArray([
'consultant_number' => 12345,
'client_number' => 67890,
'description' => 'Stammdaten Export'
]);
// Kontakt erstellen
$party = new DatevExtfWriterParty();
$party->fromArray([
'account_number' => '10000',
'company_name' => 'Muster GmbH',
'party_type' => PartyType::COMPANY,
'address_type' => AddressType::STREET,
'street' => 'Musterstraße 123',
'postal_code' => '12345',
'city' => 'Berlin',
'country' => 'DE',
'credit_limit' => 5000.50, // Gleitkommazahl
'address_valid_from' => new \DateTime('2023-01-01'), // DateTime-Objekt
'address_valid_until' => new \DateTime('2027-12-31') // DateTime-Objekt
]);
// Kontakt zum Writer hinzufügen
$writer->addEntry($party);
// Verschiedene Ausgabemöglichkeiten:
// 1. Als String erhalten
$content = $writer->toString();
// 2. In Datei speichern
try {
$writer->saveTo('debitoren_kreditoren_export.csv');
} catch (\RuntimeException $e) {
// Fehlerbehandlung
echo "Fehler beim Speichern: " . $e->getMessage();
}
// 3. Datei herunterladen
$writer->download('debitoren_kreditoren_export.csv');
// 4. Inhalt streamen
$writer->stream();
use Ameax\Datev\DataObjects\DatevAccountLedgerData;
use Ameax\Datev\DataObjects\DatevDocumentData;
use Ameax\Datev\DataObjects\DatevRepositoryData;
use Ameax\Datev\Zip;
use Carbon\Carbon;
$datevDocumentData = new DatevDocumentData();
$ledgerData = new DatevAccountLedgerData(
consolidatedDate: new Carbon('2023-06-14'),
consolidatedDeliveryDate: new Carbon('2023-06-14'),
consolidatedInvoiceId: 'RE12345',
customerName: 'ARANES',
customerCity: 'Aufhausen',
shipFromCountry: 'DE',
accountName: 'ARANES Aufhausen',
dueDate: new Carbon('2023-07-01'),
bpAccountNo: '12345'
);
$ledgerData->addAccountsReceivableLedger(
amount: 119.00,
accountNo: '8400',
information: 'Software',
bookingText: 'Umsatz 19%'
);
$ledgerData->addAccountsReceivableLedger(
amount: 214.00,
accountNo: '8300',
information: 'Bücher',
bookingText: 'Umsatz 7%'
);
$datevDocumentData->buildAccountsReceivableLedger(
datevAccountLedgerData: $ledgerData,
filePaths: ['path-to-invoice.pdf']
);
$datevRepositoryData = new DatevRepositoryData();
$datevDocumentData->addSEPAFile(
nameWithExtension: 'sepa-2023-12345.xml',
filePath: 'path-to-sepafile.xml',
date: new Carbon('2023-05-01'),
datevRepositoryData: $datevRepositoryData
);
$zipPath = $datevDocumentData->generateZip();
use ameax\DatevExtf\DatevExtfWriter;
use ameax\DatevExtf\DatevExtfWriterEntry;
use ameax\DatevExtf\Enums\DebitCreditIndicator;
use ameax\DatevExtf\Enums\FormatName;
// Initialize writer with format type
$writer = DatevExtfWriter::make(FormatName::BUCHUNGSSTAPEL);
// Configure header
$writer->getHeader()->fromArray([
'consultant_number' => 12345,
'client_number' => 67890,
'fiscal_year_start' => new \DateTime('2023-01-01'),
'date_from' => new \DateTime('2023-01-01'),
'date_to' => new \DateTime('2023-12-31'),
'description' => 'Monthly Bookings'
]);
// Create booking entry
$entry = new DatevExtfWriterEntry();
$entry->fromArray([
'amount' => 1200.00, // Floating point number
'debit_credit_indicator' => DebitCreditIndicator::DEBIT,
'account' => '8400',
'contra_account' => '1800',
'document_date' => new \DateTime('2023-05-15'), // DateTime object
'document_field_1' => 'RE-2023-123',
'posting_text' => 'Software Purchase',
'tax_rate' => 19.00, // Floating point number
'due_date' => new \DateTime('2023-06-15') // DateTime object
]);
// Add entry to writer
$writer->addEntry($entry);
// Different output options:
// 1. Get as string
$content = $writer->toString();
// 2. Save to file
try {
$writer->saveTo('booking_batch_export.csv');
} catch (\RuntimeException $e) {
// Error handling
echo "Error saving file: " . $e->getMessage();
}
// 3. Download file
$writer->download('booking_batch_export.csv');
// 4. Stream content
$writer->stream();
use ameax\DatevExtf\DatevExtfWriter;
use ameax\DatevExtf\DatevExtfWriterParty;
use ameax\DatevExtf\Enums\PartyType;
use ameax\DatevExtf\Enums\AddressType;
use ameax\DatevExtf\Enums\FormatName;
// Initialize writer for debtors/creditors
$writer = DatevExtfWriter::make(FormatName::DEBITOREN_KREDITOREN);
// Configure header
$writer->getHeader()->fromArray([
'consultant_number' => 12345,
'client_number' => 67890,
'description' => 'Master Data Export'
]);
// Create contact
$party = new DatevExtfWriterParty();
$party->fromArray([
'account_number' => '10000',
'company_name' => 'Sample Ltd',
'party_type' => PartyType::COMPANY,
'address_type' => AddressType::STREET,
'street' => 'Sample Street 123',
'postal_code' => '12345',
'city' => 'Berlin',
'country' => 'DE',
'credit_limit' => 5000.50, // Floating point number
'address_valid_from' => new \DateTime('2023-01-01'), // DateTime object
'address_valid_until' => new \DateTime('2027-12-31') // DateTime object
]);
// Add contact to writer
$writer->addEntry($party);
// Different output options:
// 1. Get as string
$content = $writer->toString();
// 2. Save to file
try {
$writer->saveTo('debtors_creditors_export.csv');
} catch (\RuntimeException $e) {
// Error handling
echo "Error saving file: " . $e->getMessage();
}
// 3. Download file
$writer->download('debtors_creditors_export.csv');
// 4. Stream content
$writer->stream();
use Ameax\Datev\DataObjects\DatevAccountLedgerData;
use Ameax\Datev\DataObjects\DatevDocumentData;
use Ameax\Datev\DataObjects\DatevRepositoryData;
use Ameax\Datev\Zip;
use Carbon\Carbon;
$datevDocumentData = new DatevDocumentData();
$ledgerData = new DatevAccountLedgerData(
consolidatedDate: new Carbon('2023-06-14'),
consolidatedDeliveryDate: new Carbon('2023-06-14'),
consolidatedInvoiceId: 'RE12345',
customerName: 'ARANES',
customerCity: 'Aufhausen',
shipFromCountry: 'DE',
accountName: 'ARANES Aufhausen',
dueDate: new Carbon('2023-07-01'),
bpAccountNo: '12345'
);
$ledgerData->addAccountsReceivableLedger(
amount: 119.00,
accountNo: '8400',
information: 'Software',
bookingText: 'Revenue 19%'
);
$ledgerData->addAccountsReceivableLedger(
amount: 214.00,
accountNo: '8300',
information: 'Books',
bookingText: 'Revenue 7%'
);
$datevDocumentData->buildAccountsReceivableLedger(
datevAccountLedgerData: $ledgerData,
filePaths: ['path-to-invoice.pdf']
);
$datevRepositoryData = new DatevRepositoryData();
$datevDocumentData->addSEPAFile(
nameWithExtension: 'sepa-2023-12345.xml',
filePath: 'path-to-sepafile.xml',
date: new Carbon('2023-05-01'),
datevRepositoryData: $datevRepositoryData
);
$zipPath = $datevDocumentData->generateZip();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.