firegento-pdf icon indicating copy to clipboard operation
firegento-pdf copied to clipboard

Creditmemo needs to refer to origin invoice

Open nige-one opened this issue 8 years ago • 2 comments

German law requires the invoice number and invoice date on the creditmemo it's based on.

See here

Die Stornorechnung muss sich eindeutig auf die Ursprungsrechnung beziehen. Anzugeben sind also

  • die ursprüngliche Rechnungsnummer
  • und das Datum der Ausstellung der alten Rechnung.

I will PR this with other things.

nige-one avatar Jun 13 '16 11:06 nige-one

Hmm okay, thank you!

Re "with other things": Please make your PRs small. One PR per bugfix / per feature please. This is much easier to check and merge.

sprankhub avatar Jun 13 '16 11:06 sprankhub

I propose to add this information as final note of the creditmemo, adding a little bit of code to: function _insertNote in /app/code/community/FireGento/Pdf/Model/Engine/Abstract.php

if ($mode == 'creditmemo') {
    $i = 0;
    if ($order->hasInvoices()) {
        $invIncrementIDs = '';
        foreach ($order->getInvoiceCollection() as $inv) {
            $i++;
            $invIncrementIDs = Mage::helper('firegento_pdf')->__('Ref. ') . $inv->getIncrementId() . " "
                . Mage::helper('firegento_pdf')->__('issued on ') . date('d-m-Y', strtotime($inv->getCreatedAt()))
                . ' ';
        }
        if ($i === 1) {
            $note = Mage::helper('firegento_pdf')->__('This credit memo refers to the following invoice: ')
                . $invIncrementIDs;
        }
        if ($i > 1) {
            $note = Mage::helper('firegento_pdf')->__('This credit memo refers to the following invoices: ')
                . $invIncrementIDs;
        }
        if (!empty($note)) {
            $tmpNotes = explode("\n", $note);
            $notes    = array_merge($notes, $tmpNotes);
        }
    }
}
// Draw notes on PDF.

The problem is that Magento allows several invoices for one order and, in my mind, a creditmemo is not explicitly related to one of them but only related to the order. Most of the time, only one invoice will appear on the note I propose but sometime it could happen to have more. So, my solution covers the case (with plural in the text to add to FireGento_Pdf.csv) but it's not lawfully perfect. I think it's better than nothing. (In some langages, plural and singular text forms have more differencies than in english).

zuiko avatar Sep 28 '17 21:09 zuiko