<@ULEFXLCRH> I do not know if there's a better sol...
# suitescript
c
@blue I do not know if there's a better solution but I'd just use a small JS library to create the text and save it in a custom field. Assuming you can find a reliable library / function - this can be done in SuiteScript on whichever record provides fields to your PDF - pretty quick job.
b
Hi Craig thanks for the input. I was thinking more of a solution using SQL expressions so we don't have to script. There is a sample CASE formula in some SA articles but the output is incorrect so I'm thinking a tweak in the formula is all that's needed.
c
Yeah that could work too but for me I wouldn't do it like that because it's not a solution I'm comfortable with
b
This is the formula I got from the SA article btw and just pasted: CASE WHEN {total}=0 THEN 'ZERO' ELSE TO_CHAR(TO_DATE(TO_CHAR(TRUNC({total}, 0)),'J'),'JSP') || ' ' || ' ' || {currency} || (CASE WHEN LENGTH(TO_CHAR(REGEXP_REPLACE({total}, '^[0-9]+\.', ''))) = 1 THEN TO_CHAR(TO_DATE(TO_CHAR(TRUNC(REGEXP_REPLACE({total}, '^[0-9]+\.', ''), 0)*10),'J'),'JSP') || 'cents' ELSE TO_CHAR(TO_DATE(TO_CHAR(TRUNC(REGEXP_REPLACE({total}, '^[0-9]+\.', ''), 0)),'J'),'JSP') || '(s) Only' END) END
c
If you ask for a solution in a SuiteScript channel the answer will usually be script
Any reason you're against scripting?
b
Yes you're correct my bad for posting here...actually I'm not a technical person and our technical resource is still a beginner. We have an external resource but we'd want to avoid external fees so I'm looking at standard solutions for now.
c
Yeah I see what you're saying - I do think the statement you posted will be a massive pain to debug - it's cramming a lot of logic into one line.
b
I'll keep that in mind. Thanks!
c
@blue if you're happu with the way I'd do it, get your technical guy on here and I'll walk him through it - I'm happy to set 30 mins aside to get on a call with him if you want,.
I don't think it's difficult thing to script as long as you're happy with it being a script.
Up to you.
b
Thanks for the offer Craig. For now though I don't think she can she's loaded with projects. But I'll DM you if ever thanks!
c
No worries - in the meantime, you can expect to see a blog post from me walking through a potential solution. I'll ping you a link when it's done in the next week or so 🙂
👀 1
It's a good topic - never seen this requirement before but I can see why it would be useful.
b
Wow nice. Thanks so much I'll definitely read it 😄
Link to your blog?
b
id imagine that this would be something simple for something like https://github.com/yamadapc/js-written-number
s
what about using N/format/i18n module? there is format.spellOut method which would work
c
@Selcuk Dogru I didn't know about that function - I'll take a look at it.
If it does what it says - that removes the requirement for a custom module to convert the number to text - everything stays the same - good find!
s
for integers it works fine. for decimals, you may need to divide and apply both parts
b
Hi @Craig just wondering if you wrote that article? Would be interested to read it