function _invoice_round_and_format_money in Invoice 6
Same name and namespace in other branches
- 7 invoice_helpers.inc \_invoice_round_and_format_money()
Returns a rounded and formatted number according to the locale set on the invoice settings page
Parameters
mixed $number:
integer $precision:
Return value
mixed
6 calls to _invoice_round_and_format_money()
- invoice_delete_item in ./
invoice_ajax.inc - Delete an invoice item
- invoice_form in ./
invoice_form.inc - Implementatin of node_form()
- invoice_invoices in ./
invoice.module - Overview of all invoices
- invoice_load in ./
invoice.module - Implementation of hook_load()
- invoice_save_item in ./
invoice_ajax.inc - Add an invoice item
File
- ./
invoice_helpers.inc, line 189 - Invoice module
Code
function _invoice_round_and_format_money($number, $precision = 2) {
// If the precision is larger than 2 and the rounded number has no more than 2 decimals,
// then still only 2 decimals will be displayed.
$rounded_number = _invoice_round($number, $precision);
// Count the amount of decimals
$exp = explode('.', $rounded_number);
$decimals = strlen($exp[1]);
// Display at least 2 decimals
if ($decimals < 2) {
$decimals = 2;
}
// Money format the rounded number
return $rounded_and_formatted_number = _invoice_format_money($rounded_number, $decimals);
}