Add Iban to invoice list

I would like to add IBAN field to the invoices list, I tried to create an extra field in invoices using the following formula: (($reloadedobj = new bank_account($db)) && ($reloadedobj->fetchNoCompute($obj->id) > 0)) ? $reloadedobj->iban_prefix: ’ ’
But it doesn’t work, can anyone help me?

Thanks

Hi, i managed this in the Module for Invoice, just choose the account which you configured in the Account section, dont forget to add the IBAN.

The payment method is already present, I need to have the IBAN field which is found in the Banks table, and which cannot be selected in the invoice list.

Stefano

Schermata 2023-10-23 alle 01.34.48

Hi,
there is no class “bank-account”.
Use instead these computed field formula to show the iban in list view:

(($reloadedobj = new Facture($db)) && ($reloadedobj->fetchNoCompute($obj->id) > 0)) ? ((($rdobj = new Account($db)) && ($rdobj->fetchNoCompute($reloadedobj->fk_account) > 0)) ? $rdobj->iban: 'no iban'):''

This will not work on the detail view of the invoice.

1 Like

perfect, works great. Thank you very much

1 Like

I can use this Extra field, to display it in an email template. I think it can be done via the substitution variable EXTRAFIELD_XXX putting iban in place of XXX; Unfortunately it’s not working, am I doing something wrong?

The extra field for the list view does not work in the detail view, because the environment is different.
Define an extra field eg. iban1 for the detail view with visibility set to 0

(($reloadedobj = new Account($db)) && ($reloadedobj->fetchNoCompute($object->fk_account) > 0)) ? $reloadedobj->iban: ''

Then use __EXTRAFIELD_iban1__ in the email-template.

BTW: If you look at the formula in the 2 computed fields you see that the new one is the second part of the first one…

I used the formula you indicated to me, it works because I can view it in the invoice detail, if I put visibility 1. Then I put visibility 0, as you suggested and I created an email type, (see screenshot), unfortunately this doesn’t work, I have something wrong?

Ok, I looked at the related code and noticed that the name of the extra field in email templates is to be written in uppercase only.
So please wrote in the template __EXTRAFIELD_IBAN1__ and it should work.

Something has changed, but it still doesn’t work, maybe something to do with visibility or display on the PDF?

The display or replacement is imho independent of the visibility.
My guess is that no bank account was selected in 2023-00311, because if not replaced, the text __EXTRAFIELD_IBAN1__ would be displayed.

No, the value is present, because I see it in the list through the formula you indicated first.
The second formula you sent me works, because I tried to put visibility 1 and it is also seen in the invoice view, but it is not seen if I recall it in the email. Sorry but I can’t figure out how to resolve this.

That’s strange… :thinking:

I think the best way to troubleshoot is to temporarily change the getCommonSubstitutionArray function.

Search in the file ~htdocs\core\lib\functions.lib.php in the function getCommonSubstitutionArray(…
the lines as in the screenshot and add the two lines (7923 and 7924)

Then send the email again and look at the result.


You will hopefully see the extrafields and their substitutions.

The __extrafield_account__ shows the rowid of the table bank_account.
For this you have to add another extrafield with $object->fk_account as computed field.