typo
This commit is contained in:
parent
cc73dee749
commit
59282c36f0
@ -2,10 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
use Akaunting\Money\Money;
|
|
||||||
|
|
||||||
use App\Utilities\Chartjs;
|
use App\Utilities\Chartjs;
|
||||||
|
|
||||||
use Balping\JsonRaw\Raw;
|
use Balping\JsonRaw\Raw;
|
||||||
|
|
||||||
trait Charts
|
trait Charts
|
||||||
@ -108,7 +105,7 @@ trait Charts
|
|||||||
'intersect' => 0,
|
'intersect' => 0,
|
||||||
'position' => 'nearest',
|
'position' => 'nearest',
|
||||||
'callbacks' => [
|
'callbacks' => [
|
||||||
'label' => new Raw("function(tooltipItem, data) {
|
'label' => new Raw("function(tooltipItem, data) {
|
||||||
const moneySettings = {
|
const moneySettings = {
|
||||||
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
|
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
|
||||||
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "',
|
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "',
|
||||||
@ -129,7 +126,7 @@ trait Charts
|
|||||||
function numbersToCurrency(numbers, precision) {
|
function numbersToCurrency(numbers, precision) {
|
||||||
var exp = Math.pow(10, precision);
|
var exp = Math.pow(10, precision);
|
||||||
var float = parseFloat(numbers) / exp;
|
var float = parseFloat(numbers) / exp;
|
||||||
|
|
||||||
return float.toFixed(fixed(precision));
|
return float.toFixed(fixed(precision));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -138,18 +135,18 @@ trait Charts
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (typeof input === 'number') {
|
if (typeof input === 'number') {
|
||||||
input = input.toFixed(fixed(opt.precision));
|
input = input.toFixed(fixed(opt.precision));
|
||||||
};
|
};
|
||||||
|
|
||||||
var negative = input.indexOf('-') >= 0 ? '-' : '';
|
var negative = input.indexOf('-') >= 0 ? '-' : '';
|
||||||
var numbers = toStr(input).replace(/\D+/g, '') || '0';
|
var numbers = toStr(input).replace(/\D+/g, '') || '0';
|
||||||
var currency = numbersToCurrency(numbers, opt.precision);
|
var currency = numbersToCurrency(numbers, opt.precision);
|
||||||
var parts = toStr(currency).split('.');
|
var parts = toStr(currency).split('.');
|
||||||
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);;
|
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);
|
||||||
var decimal = parts[1];
|
var decimal = parts[1];
|
||||||
|
|
||||||
if(opt.isPrefix == 1) {
|
if (opt.isPrefix == 1) {
|
||||||
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal)
|
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.symbol;
|
return negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.symbol;
|
||||||
@ -163,7 +160,7 @@ trait Charts
|
|||||||
'yAxes' => [[
|
'yAxes' => [[
|
||||||
'ticks' => [
|
'ticks' => [
|
||||||
'beginAtZero' => true,
|
'beginAtZero' => true,
|
||||||
'callback' => new Raw("function(value, index, values) {
|
'callback' => new Raw("function(value, index, values) {
|
||||||
const moneySettings = {
|
const moneySettings = {
|
||||||
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
|
decimal: '" . config('money.' . setting('default.currency') . '.decimal_mark') . "',
|
||||||
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "',
|
thousands: '". config('money.' . setting('default.currency') . '.thousands_separator') . "',
|
||||||
@ -171,45 +168,45 @@ trait Charts
|
|||||||
isPrefix: '" . config('money.' . setting('default.currency') . '.symbol_first') . "',
|
isPrefix: '" . config('money.' . setting('default.currency') . '.symbol_first') . "',
|
||||||
precision: '" . config('money.' . setting('default.currency') . '.precision') . "',
|
precision: '" . config('money.' . setting('default.currency') . '.precision') . "',
|
||||||
};
|
};
|
||||||
|
|
||||||
const formattedCurrency = function (input, opt = moneySettings) {
|
const formattedCurrency = function (input, opt = moneySettings) {
|
||||||
function fixed (precision) {
|
function fixed (precision) {
|
||||||
return Math.max(0, Math.min(precision, 20));
|
return Math.max(0, Math.min(precision, 20));
|
||||||
};
|
};
|
||||||
|
|
||||||
function toStr(value) {
|
function toStr(value) {
|
||||||
return value ? value.toString() : '';
|
return value ? value.toString() : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
function numbersToCurrency(numbers, precision) {
|
function numbersToCurrency(numbers, precision) {
|
||||||
var exp = Math.pow(10, precision);
|
var exp = Math.pow(10, precision);
|
||||||
var float = parseFloat(numbers) / exp;
|
var float = parseFloat(numbers) / exp;
|
||||||
|
|
||||||
return float.toFixed(fixed(precision));
|
return float.toFixed(fixed(precision));
|
||||||
};
|
};
|
||||||
|
|
||||||
function joinIntegerAndDecimal (integer, decimal, separator) {
|
function joinIntegerAndDecimal (integer, decimal, separator) {
|
||||||
return decimal ? integer + separator + decimal : integer;
|
return decimal ? integer + separator + decimal : integer;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof input === 'number') {
|
if (typeof input === 'number') {
|
||||||
input = input.toFixed(fixed(opt.precision));
|
input = input.toFixed(fixed(opt.precision));
|
||||||
};
|
};
|
||||||
|
|
||||||
var negative = input.indexOf('-') >= 0 ? '-' : '';
|
var negative = input.indexOf('-') >= 0 ? '-' : '';
|
||||||
var numbers = toStr(input).replace(/\D+/g, '') || '0';
|
var numbers = toStr(input).replace(/\D+/g, '') || '0';
|
||||||
var currency = numbersToCurrency(numbers, opt.precision);
|
var currency = numbersToCurrency(numbers, opt.precision);
|
||||||
var parts = toStr(currency).split('.');
|
var parts = toStr(currency).split('.');
|
||||||
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);;
|
var integer = parts[0].replace(/(\d)(?=(?:\d{3})+\b)/gm, opt.thousands);
|
||||||
var decimal = parts[1];
|
var decimal = parts[1];
|
||||||
|
|
||||||
if(opt.isPrefix == 1) {
|
if (opt.isPrefix == 1) {
|
||||||
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal)
|
return opt.symbol + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal);
|
||||||
} else {
|
} else {
|
||||||
return negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.symbol;
|
return negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.symbol;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return formattedCurrency(value, moneySettings);
|
return formattedCurrency(value, moneySettings);
|
||||||
}"),
|
}"),
|
||||||
],
|
],
|
||||||
@ -222,7 +219,7 @@ trait Charts
|
|||||||
'ticks' => [
|
'ticks' => [
|
||||||
'padding' => 10,
|
'padding' => 10,
|
||||||
'fontColor' => '#9e9e9e',
|
'fontColor' => '#9e9e9e',
|
||||||
]],
|
],
|
||||||
'gridLines' => [
|
'gridLines' => [
|
||||||
'drawBorder' => false,
|
'drawBorder' => false,
|
||||||
'color' => 'rgba(29,140,248,0.1)',
|
'color' => 'rgba(29,140,248,0.1)',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user