Need to remove extra "And" in words

Dear Community,
In Purchase order, the grand total numeric is converted in word,the issue is extra sentence placed. Eg if Grand total is 4040.55 the word should be Four Thousand Forty and Fifty Five Fils only. But it comes like Four Thousand And Forty and Fifty Five Fils only. here extra “And” will comes right after Four Thousand .so how to remove that Extra word.

thanks in Advance

Hi mate,
We are also based in UAE, I have made this macro which returns the correct way in writing money in words as per UAE.

{% macro _words(in_words) %}{% if "Fils" in in_words %}{% set parts = in_words.split(" and ") %}In Words: {{ parts[0].replace("AED ", "") }} Dirhams and {{ parts[1] }}{% else %}In Words: {{ in_words.replace("AED ", "").replace("only", "Dirhams only") }}{% endif %}{% endmacro %}

How to use it



In Words: One Thousand, Four Hundred And Twenty One Dirhams and Seventy Seven Fils only.


In Words: Twenty Three Thousand, Nine Hundred And Fifty Eight Dirhams only.

Thanks for your response sir.But it not about currency i got extra “And” in every sentence here it comes as Four Thousand And Forty and Fifty Five Fils only but i need Four Thousand Forty and Fifty Five Fils only. that extra “And” should remove it should for all currency.

Just remove the “and” from the macro.
The macro we have is legally accepted as we print our cheques (with Emirates NBD)

{% macro _words(in_words) %}
{% set parts = in_words.split(" and “) %}
{% if parts|length > 1 %}
In Words: {{ parts[0].strip() }} {{ parts[1].strip() }}
{% else %}
In Words: {{ in_words.replace(” only", “”) }}
{% endif %}
{% endmacro %}


here am removing “and” in between this code
In Words: {{ parts[0].strip() }} {{ parts[1].strip() }}

Now output like,

In Words: Four Thousand And Forty Fifty Fils only.

but how it can make as In Words: Four Thousand Forty And Fifty Fils only.

Please try it.

{{ doc.in_words | replace (" And", " ")}}


Its Works for me.

In Words :                    

{% set amount_in_words = frappe.utils.money_in_words(doc.grand_total, doc.currency) %}

{% set modified_amount_in_words = amount_in_words.replace(“And”, “”) %}

{% set modified_amount_in_words = modified_amount_in_words.replace(" Thousand", " Thousand") %}

{{ modified_amount_in_words}}


You can tailor the system to suit your specific needs based on the scenario. I have provided the basic structure, so please apply your own logic to customize it further.