Format Indian Currency - we need to insert a comma after 3 digits then every two-digit thereafter

Hi @pgr / Forum Team,

SuiteCRM is displaying indian currency format as 168,180.32 instead we would need it as 1,68,180.32 i.e we need to insert a comma after 3 digits then every two-digit thereafter.
May I know how this can be achieved.
Thank you in advance for your help.

Regards,
Sravani.

Hello @sravanitedla

To modify the currency format in SuiteCRM to display in the Indian format (1,68,180.32), you’ll need to adjust the number formatting functionality.

Locate the file “modules/Currencies/Currency.php” in your SuiteCRM installation.

Inside this file, find the function “format_number”. This is where the number formatting logic is typically held.

Within the “format_number” function, look for the section that formats the currency and modify it to fit the Indian numbering system. Regular expressions or string manipulation can be used to achieve the desired format.

Once you’ve made the necessary changes, save the file.

After saving the changes, clear the SuiteCRM system cache.

Keep in mind that modifying core files directly can make future upgrades more complex, as your changes can be overwritten. It’s generally recommended to use customizations and extensions when modifying SuiteCRM behaviour.

Thanks.

True, after modifying your file, you could copied it to below directory.

~/custom/modules/Currencies/

  • Run Quick Repair & Rebuild

Hi @rsp / @chirag_biz309

Thank you for your response, This works for line items but not for invoices/quotes , Please find the screenshot. Please note , done quick repair also cleared cache but its still the same.


Kindly suggest your thoughts on the same.

Thank you,
Sravani.

Hello @sravanitedla

Can you tell which file or function you have changed?

hi @chirag_biz309

I have changed format_number function at modules/Currencies/Currency.php

Thank you,
Sravani.

Okay @sravanitedla

You are saying that your code works for line items but not for invoices/quotes.

So first of all you have to copy your file modules/Currencies/Currency.php and place it inside custom/modules/Currencies. So that your code is upgrade-safe way, if you change the default file directly, it is not the right way or upgrade-safe way.

Step 1: After placing the file in the path custom/modules/Currencies/Currency.php.

Step 2: go to the format_number function in that file. And replace the default code with the following code there.

// Original code
$amount = number_format(round($amount, $round), $decimals, $dec_sep, $num_grp_sep);
$amount = format_place_symbol($amount, $symbol, (empty($params['symbol_space']) ? false : true));
// Updated code for Indian numbering system format
$formattedAmount = number_format($amount, $decimals, $dec_sep, $num_grp_sep);
$amount_parts = explode($dec_sep, $formattedAmount);
$integer_part = strrev(implode(',', str_split(strrev($amount_parts[0]), 2)));
$formattedAmount = $integer_part . (isset($amount_parts[1]) ? $dec_sep . $amount_parts[1] : '');

$amount = format_place_symbol($formattedAmount, $symbol, (empty($params['symbol_space']) ? false : true));

Step 3: Run Quick Repair & Rebuild

If you have any questions regarding this, feel free to ask me. Happy Coding!

Thanks.

Hi @chirag_biz309 ,

Thank you so much for responding , Its still the same even with your code. It only works at Line Items but not at invoice ie the result is same as screenshot sent earlier in this thread.

Thank you,
Sravani.