Doc Script

If you want to use scripts that, for example, convert currency characters or written-out currency names into ISO codes, you can activate this in the settings under Module > Document Type > Doc Script.

Next, go to the desired document type, for this example we will use Invoice, and open Scripts. Copy the script below and replace the example with this one. Then click on SAVE.

The result should look like this:

Script to copy:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
currency_map = {
    "€": "EUR",
    "EURO": "EUR",
    "$": "USD",
    "£": "GBP"
}

currency_value = get_field_value(fields_dict, "currency", None)

if currency_value:
    currency_value = currency_value.upper()
    if currency_value in currency_map:
        currency_value = currency_map[currency_value]
    set_field_value(fields_dict, "currency", currency_value)

In the next step, upload a document with one of the following criteria: , EURO, $ or £.

When the document is ready for validation, open it and click in the Currency validation field. You will be prompted to select the appropriate area on the image. Now do this with the sign.

You will then immediately see that € is converted to EUR by the script.

The same is done by the script when you mark EURO on the invoice.