mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for trailing zeros in quantity column
This commit is contained in:
parent
447dfc1f8c
commit
68f735d43b
@ -104,7 +104,7 @@ class SystemLog extends Model
|
||||
public function resolveRouteBinding($value, $field = null)
|
||||
{
|
||||
if (is_numeric($value)) {
|
||||
throw new ModelNotFoundException("Record with value {$value} not found");
|
||||
throw new \Illuminate\Database\Eloquent\ModelNotFoundException("Record with value {$value} not found");
|
||||
}
|
||||
|
||||
return $this
|
||||
|
@ -49,6 +49,25 @@ class Number
|
||||
return number_format($value, $precision, $decimal, $thousand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a given value based on the clients currency.
|
||||
*
|
||||
* @param float $value The number to be formatted
|
||||
* @param object $currency The client currency object
|
||||
*
|
||||
* @return string The formatted value
|
||||
*/
|
||||
public static function formatValueNoTrailingZeroes($value, $currency) :string
|
||||
{
|
||||
$value = floatval($value);
|
||||
|
||||
$thousand = $currency->thousand_separator;
|
||||
$decimal = $currency->decimal_separator;
|
||||
$precision = $currency->precision;
|
||||
|
||||
return rtrim(rtrim(number_format($value, $precision, $decimal, $thousand), "0"),$decimal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a given value based on the clients currency
|
||||
* BACK to a float.
|
||||
|
@ -303,15 +303,10 @@ trait MakesInvoiceValues
|
||||
$data[$key][$table_type . ".{$_table_type}4"] = $helpers->formatCustomFieldValue($this->client->company->custom_fields, "{$_table_type}4", $item->custom_value4, $this->client);
|
||||
|
||||
// 08-02-2022 - fix for regression below
|
||||
$data[$key][$table_type.'.quantity'] = Number::formatValue($item->quantity, $this->client->currency());
|
||||
// $data[$key][$table_type.'.quantity'] = Number::formatValue($item->quantity, $this->client->currency());
|
||||
|
||||
$data[$key][$table_type.'.quantity'] = Number::formatValueNoTrailingZeroes($item->quantity, $this->client->currency());
|
||||
|
||||
//change quantity from localized number, to decimal format with no trailing zeroes 06/09/21
|
||||
|
||||
//30-01-2022 - improve rounding display for Unit quantity
|
||||
// $data[$key][$table_type.'.quantity'] = $item->quantity >=1 ? rtrim(number_format($item->quantity, $this->client->currency()->precision), $locale_info['decimal_point']) : rtrim(number_format($item->quantity,15), 0);
|
||||
// $data[$key][$table_type.'.quantity'] = rtrim($item->quantity, $locale_info['decimal_point']);
|
||||
|
||||
//30-01-2022 - improve rounding display for Unit Cost
|
||||
$data[$key][$table_type.'.unit_cost'] = Number::formatMoneyNoRounding($item->cost, $this->client);
|
||||
|
||||
$data[$key][$table_type.'.cost'] = Number::formatMoney($item->cost, $this->client);
|
||||
|
Loading…
x
Reference in New Issue
Block a user