3

I have an urgent problem with invoices. For our finance department, I have to print out all invoices we generated this year. On the invoice, it HAS to display the date the invoice was issued, but instead it displays the date that I print the invoice.

In the template, the line

{ts}Invoice Date:{/ts} {$invoice_date}

gives me the CURRENT date, not the date the invoice was issued.

I have looked for other variables I could use, but I had no luck finding anything.

Does anyone have a solution for this?

2
  • To clarify: by invoice, you mean the receipt (email) or generated pdf?
    – Xavier
    Nov 1, 2017 at 10:17
  • I mean the generated pdf that went through wkhtmltopdf
    – nwtnsqrd
    Nov 1, 2017 at 11:14

2 Answers 2

5

EDIT (petednz) - there is a newer solution in 2024 - see other answer

I came accross the same issue. The invoice date gives the current date and that is in most cases not correct.

We have used the receive date of the contribution in the invoice template as follows.

...
{crmAPI var='contribution' entity='Contribution' action='getsingle' id=$id}
...
{ts}Invoice Date:{/ts} {$contribution.receive_date|crmDate:$config->dateformatFull}
...

The top line with {crmApi...} could be present already in the template. So check whether you can find that line. The {crmApi...} line is not defined before the {$contribution....}

4
  • This would perhaps be the desired default behaviour for CiviCRM, i assume. Feb 26, 2019 at 14:04
  • Thank you so much! You have no idea how grateful I am! This helped my question on how to add new items in my invoice, like check_number and payment_instrument. Mar 19, 2019 at 4:49
  • Is this still the way to do this? or is there something newer via docs.civicrm.org/user/en/latest/common-workflows/…
    – petednz - fuzion
    Mar 6, 2023 at 4:16
  • There is a better way to do this now replace $invoice_date with {contribution.receive_date|crmDate:"Full"} - we will probably make that change in the template that ships with core lab.civicrm.org/dev/core/-/issues/4940
    – eileen
    Jan 28 at 3:12
3

The best approach in recent versions of CiviCRM is to replace $invoice_date with

{contribution.receive_date|crmDate:"Full"}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.