-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDF generation scripts #17
Conversation
✅ Deploy Preview for tobcalc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
const formattedDecimals = decimals < 10 ? `0${decimals}` : `${decimals}`; | ||
export function formatMoney(value: number, currencyCode = "€", separators: {decimal?: string, thousand?: string} = {}) { | ||
// First obtain formatted value with '.' as decimal separator and ',' as thousand separator (US notation). | ||
let formattedValue = (Math.ceil(value) / 100).toLocaleString("en-US", {minimumFractionDigits: 2, maximumFractionDigits: 2}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the Math.ceil
here, but I was wondering if this makes sense? You can't really pay a 0.1 c€ right? So I wondered if this shouldn't be replaced by Math.round
or even Math.floor
.
Initial impressions look very good! I have exams coming up soon but will try my best to properly review the PR and merge ASAP. |
No hurry, take your time and good luck with the exams! |
The downloading of deno dependencies sometimes throws an error for some reason.
This is despite locking the dependencies to a fixed version. I've rerun the tests and it's all fine. |
Co-authored-by: dcbr <[email protected]>
Amazing work, I really appreciate the time and effort you put into this. I received an email a few months ago asking to add different languages to the PDFs, so I'm sure many users will be happy with this PR as well. The PDF generation code seems like it would've been a real hassle to learn and write, I remember uploading the base PDF to a site to add input boxes manually. Great job! |
Thanks, I hope it will be useful indeed :) And to be honest, I wouldn't have been able to write it entirely from scratch either. I had some experience with PDF text modifications in python already, so that helped a lot. And the |
I think I went down the rabbithole a bit too far with this PR, so sorry for the huge diff. But I think the end result is quite nice and I learned a lot about pdf structure along the way :)
Summary:
formatMoney
function is changed to support "thousand separators". ThefillPdf
function uses '|' as the thousand separator, to bring the style closer to the original forms.