JavaScript in PDF Export

After 2 hours trying to solve this, I give up lol

All I wanna do is

  1. Sum up 2 formulas fields that are inside Invoices database (those are taxes fields that are calculated from another field)

  2. The values of those formulas fields are well setup with 2 decimals and money value but for some reason it appear with 15 decimals and no currency sign


I tried to chat with the AI, tried every solutions suggested but still cant make it work :frowning:

Thank you :slight_smile:

PS: I’d be very cool to have invoices templates (markdown + html) to get us started.

1 Like

Unfortunately I don’t have a solution, but I always wanted to learn how to generate proper PDFs using Fibery. Both applying great visuals and manipulating data. Following this thread, hopefully someone already made this happen :slight_smile:

1 Like

Hey Renato, thanks for commenting. No worries at all, one of the reason I posted is that it would probably help other people from the community!

FYI, I’ve created my HTML template from ChatGPT (using my real invoice from HubSpot as a reference) and then map the fields. Easy peasy

1 Like

Hey! I have an idea of how to fix this, but I tried testing it on my end and don’t get the trailing zeros. Can you share the fields / formulas you used as well as the markdown / html template? It might be a bit of a bug. I’ve had some issues with making invoices like this where the number is off by a few decimals, and just re-running it fixes it. My recommendation: Convert the number to text.

It’s a bit annoying because to then need more fields, but I think its safer. Maybe the Fibery team has a better suggestion / fix.

Try this:

“$” + ToText(Round(Total, 2))

Not sure if the round is needed, you can try with and without.

You can then also add the correct currency symbol in the formula for it to show in the invoice.

Not ideal to have two fields that show the same thing, but I think its safer than maybe getting weirdly formatted numbers in your invoice.

Lmk if it works!

Alright, got it! I checked another other topic to help me

“Taxes” field is a formula field. So :
<%= parseFloat(Entity.Taxes).toLocaleString(‘en’,{style:‘currency’,currency:‘USD’}) %>

and then I have another formula field that includes spaces in the name but this one didn’t work with the formula above which I have no idea why, so I came up with this :

{!Amount without taxes!}

$<%= parseFloat(Entity[‘Amount without taxes’]).toFixed(2) %>

Someone please explain to me why haha!

1 Like

Object properties with a space cannot use the ‘dot notation’
See here:

1 Like