einfacharchiv/rechnungsmail.de

Extract billing data from text according to rechnungsmail.de

v1.0.4 2019-02-24 00:51 UTC

This package is auto-updated.

Last update: 2024-04-24 12:56:40 UTC


README

Software License

This package provides an easy way to extract billing data from text according to rechnungsmail.de.

einfachArchiv is a German SaaS product to organize your documents in one place and meet all legal requirements. You'll find us on our website.

Requirements

PHP 7.0 and later.

Installation

You can install this package via Composer. Run the following command:

composer require einfacharchiv/rechnungsmail.de

Usage

Extracting billing data is easy.

$email = <<<EOE
Sehr geehrte Frau Mustermann, 

anbei erhalten Sie Rechnung-Nr. 4711 vom 20.11.2077. 
Die Rechnung ist im PDF-Format erstellt worden. Sollten 
Sie Fragen oder Probleme haben, stehen wir Ihnen 
jederzeit zur Verfügung. 

-- 
Mit freundlichen Grüßen,
Max Müller

Rechnungsdaten nach rechnungsmail.de:
Rechnungsnummer:     4711
Rechnungsdatum:      20.11.2077
Rechnungsbetrag:     119,00 EUR
Kundennummer:        123456
Nettobetrag 19%:     100,00 EUR
Umsatzsteuer 19%:    19,00 EUR
Absender-Name:       Max Müller GbR
Ihre Auftragsnummer: 4500006789
Vertragsnummer:      V-4711
EOE;

$rechnungsmail = new \einfachArchiv\Rechnungsmail\Rechnungsmail($email);

// Check if the email contains billing data according to rechnungsmail.de
if ($rechnungsmail->isValid()) {
    $rechnungsmail->getInvoiceId();
    $rechnungsmail->getInvoiceDate();
    $rechnungsmail->getInvoiceAmount(); // Returns an array
    $rechnungsmail->getCustomerId();
    $rechnungsmail->getNetAmount(); // Returns an array
    $rechnungsmail->getTax(); // Returns an array
    $rechnungsmail->getSenderName();
    $rechnungsmail->getOrderId();
    $rechnungsmail->getContractId();
}

If a field is not present or invalid, the method returns null.

The method ->getInvoiceAmount() returns an array like this one:

[
    'amount' => 119,
    'currency' => 'EUR',
];

The methods ->getNetAmount() and ->getTax() return arrays like this one:

[
    'amount' => 100,
    'currency' => 'EUR',
    'taxRate' => 19
];

All amounts are returned as floats.

The invoice date is, if present, a valid date and can be used like this:

$invoiceDate = $rechnungsmail->getInvoiceDate();

if ($invoiceDate) {
    \Carbon\Carbon::parse($invoiceDate)->toDateString();
}

Contributing

Contributions are welcome.

We accept contributions via Pull Requests on Github.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improvement? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

If you've found a security issue, please email support@einfacharchiv.com instead of using the issue tracker.

Happy coding!

Credits

License

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