ameax/datev-extf 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ameax/datev-extf

Composer 安装命令:

composer require ameax/datev-extf

包简介

README 文档

README

Eine PHP-Bibliothek für die Erstellung von Datendateien im DATEV Export-Format (EXTF).

English version below

Features

  • Unterstützung für Buchungsstapel (Transaktionen)
  • Unterstützung für Debitoren/Kreditoren (Stammdaten)
  • Typgerechte Datenkonvertierung gemäß DATEV-Format
  • PHP 7.x kompatibel
  • Unterstützung für Gleitkommazahlen (float)
  • Unterstützung für DateTime-Objekte für alle Datumsfelder

Installation

composer require ameax/datev-extf

Beispiel: Buchungsstapel

<?php
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();

Beispiel: Debitoren/Kreditoren

<?php
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();

Datumsfelder (DateTime)

Alle Datumsfelder akzeptieren jetzt DateTime-Objekte und werden automatisch in das entsprechende DATEV-Format konvertiert:

Buchungsstapel (DatevExtfWriterEntry)

  • document_date (Format: TTMM)
  • assigned_due_date (Format: TTMMJJJJ)
  • cost_date (Format: TTMMJJJJ)
  • posting_lock_until (Format: TTMMJJJJ)
  • service_date (Format: TTMMJJJJ)
  • tax_period_date (Format: TTMMJJJJ)
  • due_date (Format: TTMMJJJJ)

Debitoren/Kreditoren (DatevExtfWriterParty)

  • address_valid_from (Format: TTMMJJJJ)
  • address_valid_until (Format: TTMMJJJJ)
  • reminder_block_until (Format: TTMMJJJJ)
  • bank_valid_from_1 bis bank_valid_from_10 (Format: TTMMJJJJ)
  • bank_valid_until_1 bis bank_valid_until_10 (Format: TTMMJJJJ)
  • direct_debit_block_until (Format: TTMMJJJJ)
  • payment_block_until (Format: TTMMJJJJ)

Header (DatevExtfHeader)

  • created_at (Format: YYYYMMDDHHMMSSFFF)
  • fiscal_year_start (Format: YYYYMMDD)
  • date_from (Format: YYYYMMDD)
  • date_to (Format: YYYYMMDD)

Gleitkommazahlen (Float)

Zahlreiche numerische Felder akzeptieren jetzt float-Werte und werden automatisch in das entsprechende DATEV-Format mit Komma als Dezimaltrennzeichen konvertiert.

Verwandte Projekte

DATEV XML Format

Wir bieten auch eine Bibliothek zur Erstellung von DATEV XML-Dokumenten an: ameax/datev-xml

Diese Bibliothek ermöglicht:

  • Generierung von DATEV XML-Dateien nach DATEV-Standard
  • Erstellung von Forderungsbuchungssätzen
  • Erstellen von ZIP-Dateien für den direkten Import in DATEV
  • Hinzufügen von SEPA-Dateien zu Dokumenten

Beispiel: DATEV XML

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();

DATEV Export-Format (EXTF) PHP Library (English)

A PHP library for creating data files in DATEV Export-Format (EXTF).

Features

  • Support for booking batches (transactions)
  • Support for debtors/creditors (master data)
  • Type-appropriate data conversion according to DATEV format
  • PHP 7.x compatible
  • Support for floating point numbers (float)
  • Support for DateTime objects for all date fields

Installation

composer require ameax/datev-extf

Example: Booking Batch

<?php
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();

Example: Debtors/Creditors

<?php
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();

Date Fields (DateTime)

All date fields now accept DateTime objects and are automatically converted to the corresponding DATEV format:

Booking Batch (DatevExtfWriterEntry)

  • document_date (Format: DDMM)
  • assigned_due_date (Format: DDMMYYYY)
  • cost_date (Format: DDMMYYYY)
  • posting_lock_until (Format: DDMMYYYY)
  • service_date (Format: DDMMYYYY)
  • tax_period_date (Format: DDMMYYYY)
  • due_date (Format: DDMMYYYY)

Debtors/Creditors (DatevExtfWriterParty)

  • address_valid_from (Format: DDMMYYYY)
  • address_valid_until (Format: DDMMYYYY)
  • reminder_block_until (Format: DDMMYYYY)
  • bank_valid_from_1 to bank_valid_from_10 (Format: DDMMYYYY)
  • bank_valid_until_1 to bank_valid_until_10 (Format: DDMMYYYY)
  • direct_debit_block_until (Format: DDMMYYYY)
  • payment_block_until (Format: DDMMYYYY)

Header (DatevExtfHeader)

  • created_at (Format: YYYYMMDDHHMMSSFFF)
  • fiscal_year_start (Format: YYYYMMDD)
  • date_from (Format: YYYYMMDD)
  • date_to (Format: YYYYMMDD)

Floating Point Numbers (Float)

Numerous numeric fields now accept float values and are automatically converted to the corresponding DATEV format with comma as decimal separator.

Related Projects

DATEV XML Format

We also offer a library for creating DATEV XML documents: ameax/datev-xml

This library enables:

  • Generation of DATEV XML files according to DATEV standard
  • Creation of accounts receivable ledger entries
  • Creation of ZIP files for direct import into DATEV
  • Adding SEPA files to documents

Example: DATEV XML

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();

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

ameax/datev-extf 适用场景与选型建议

ameax/datev-extf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.26k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ameax/datev-extf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ameax/datev-extf 我们能提供哪些服务?
定制开发 / 二次开发

基于 ameax/datev-extf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-22