firegento-pdf
firegento-pdf copied to clipboard
Creditmemo needs to refer to origin invoice
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.
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.
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).