DoliCloud / DoliMods

The DoliMods is the repository of the Dolibarr ERP CRM modules, developed by the DoliCloud.com team.
https://www.dolibarr.org
GNU General Public License v3.0
52 stars 50 forks source link

Numberwords Currency #67

Open KreativeKrise opened 1 month ago

KreativeKrise commented 1 month ago

The module only ever returns the default currency from Dolibarr. It does not matter which currency I select in an invoice, for example.

I'm using dol_convertToWord($amount, $outputlangs, $object->multicurrency_code, true);. But this method just calls $langs->getLabelFromNumber($num, $type); in the background. This method does not recognize any currency, which is why the default currency is used.

So if the default Dolibarr method is not working, which method shall I use?

KreativeKrise commented 1 month ago

My workaround for now:

if (isModEnabled('numberwords')) {
    dol_include_once('/numberwords/core/substitutions/functions_numberwords.lib.php');
    $textAmount = numberwords_getLabelFromNumber($outputlangs, $amount, $object->multicurrency_code);
} else {
    $textAmount = dol_convertToWord($amount, $outputlangs, $object->multicurrency_code, true);
}
eldy commented 3 weeks ago

Can you try this fix: Replace the line: $langs->getLabelFromNumber($num, $type); with $langs->getLabelFromNumber($num, $currency);

is it ok with this change ?