Conditional display of bank account depending on currency

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 5k18a
    Member
    • Jul 2025
    • 37

    #1

    Conditional display of bank account depending on currency

    I want to show different bank accounts in invoice PDF depending on the invoice currency (amountCurrency). Example:
    • if currency = PLN → show PLN account
    • if currency = EUR → show EUR account

    I tried directly in the template:
    {{#if (eq amountCurrency "PLN")}}
    Konto [PLN]: xxxxxxxxxx
    {{else}}
    Konto [EUR]: xxxxxxxxxx
    {{/if}}


    Also tried with nested {{#if}} blocks and with a formula:
    if (amountCurrency == 'PLN') {
    cBankAccount = 'xxxxxxxxxx';
    } else {
    cBankAccount = 'xxxxxxxxxx';
    }


    But none of these worked - in PDF it either shows both accounts, or the field stays empty.What is the correct way to make conditions based on amountCurrency in PDF templates (or via formula)?
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1731

    #2
    Hi, wrong tagging. Read here about the if and ifEqual: https://docs.espocrm.com/user-guide/printing-to-pdf/
    it should be something like

    {{#IfEqual amountCurrency 'PLN'}}
    Konto [PLN]: xxxxxx
    {{else}}
    Konto [EUR]. xxxxxx
    {{/ifEqual}}

    Put this in the code view of the PDF-Editor, also comment it out with <!--{{CODE}}-->

    Comment

    • yuri
      EspoCRM product developer
      • Mar 2014
      • 9354

      #3


      eq => equals

      I recommend using the x-if attribute instead: https://docs.espocrm.com/user-guide/...attribute-x-if
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • Omaxentus
        Junior Member
        • Aug 2025
        • 1

        #4
        I ran into this issue when setting up PDF invoices. What worked for me was creating a small helper field in the data layer that sets the account based on amountCurrency, then just calling that field in the template. That way the PDF only shows the correct one. Did the same thing after sorting company setup with Your Company Formations Ltd, keeping everything clean and automatic so I didn’t have to tweak templates manually each time.
        Last edited by Omaxentus; 09-06-2025, 12:09 PM.

        Comment

        Working...