Hello guys,
I’m going to describe my problem and if someone can help me ill be more than thankful
When I click on menu, then print, a PDF will open, so here in this page I want to add in balance column beside the amount “DR” if its a Debit or “CR” if its a Credit. Check 1st part of the picture. in this picture, I showed an example, even if the display is false but I want to display it like this. Red section.
so in atom, I should update my .html file in order to add it, I tried many times but I didn’t get the result I want. Check 2nd part of the picture to see the code.
first of all thanks for your help, but i tried this nothing happens this means that there is an error because the page didn’t even open. and yesterday, i tried something similar, i don’t know if its right, but also it didn’t work.
Sorry, I was thinking you just wanted the credit or debit formatted. I also gave you the JavaScript ternary syntax and I think you want the server side one (python)
flt(data[i].balance) because currency is stored as a string. So it won’t compare it to 0 (the number).
The other syntax error you’ve got is this: data[i].balance[(“CR”)] which it probably can’t parse because data[i].balance doesn’t have a key or attribute named “CR”.
I tried the first option u gave me, and it worked but i had to change a little bit in it in order to display the total balance in the field, but i have a problem now that CR and DR are displayed in a wrong way. in the picture, you can find an example.
the red section should display beside the balance “CR”.
I also tried to create a variable and put inside the balance so i can check if its <0 or >0 in order to display CR/DR, if its a negative number it should display CR and the opposite for DR.
{% var bal = format_currency(data[i].balance); %}
{%= bal < 0 ? (format_currency(data[i].balance, filters.presentation_currency)) + " CR" : (format_currency(data[i].balance, filters.presentation_currency)) + " DR" %}
Thank you very much for your replies!
Why the topic was closed! i didnt get the result i want!!