mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Report sorting is broken with comma decimal separator #1438
This commit is contained in:
parent
801b80c767
commit
47fce2d163
@ -80,4 +80,39 @@ class AbstractReport
|
|||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert the date format to one supported by tablesorter
|
||||||
|
public function convertDateFormat()
|
||||||
|
{
|
||||||
|
$account = Auth::user()->account;
|
||||||
|
$format = $account->getMomentDateFormat();
|
||||||
|
$format = strtolower($format);
|
||||||
|
$format = str_replace('do', '', $format);
|
||||||
|
|
||||||
|
$orignalFormat = $format;
|
||||||
|
$format = preg_replace("/[^mdy]/", '', $format);
|
||||||
|
|
||||||
|
$lastLetter = false;
|
||||||
|
$reportParts = [];
|
||||||
|
$phpParts = [];
|
||||||
|
|
||||||
|
foreach (str_split($format) as $letter) {
|
||||||
|
if ($lastLetter && $letter == $lastLetter) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$lastLetter = $letter;
|
||||||
|
if ($letter == 'm') {
|
||||||
|
$reportParts[] = 'mm';
|
||||||
|
$phpParts[] = 'm';
|
||||||
|
} elseif ($letter == 'd') {
|
||||||
|
$reportParts[] = 'dd';
|
||||||
|
$phpParts[] = 'd';
|
||||||
|
} elseif ($letter == 'y') {
|
||||||
|
$reportParts[] = 'yyyy';
|
||||||
|
$phpParts[] = 'Y';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return join('', $reportParts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,6 +288,14 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// parse 1,000.00 or 1.000,00
|
||||||
|
function convertStringToNumber(str) {
|
||||||
|
str = str + '' || '';
|
||||||
|
var number = Number(str.replace(/[^0-9]+/g,""));
|
||||||
|
return number / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
$(".tablesorter-data").tablesorter({
|
$(".tablesorter-data").tablesorter({
|
||||||
@if (! request()->group_when_sorted)
|
@if (! request()->group_when_sorted)
|
||||||
@ -296,6 +304,12 @@
|
|||||||
theme: 'bootstrap',
|
theme: 'bootstrap',
|
||||||
widgets: ['zebra', 'uitheme', 'filter'{!! request()->group_when_sorted ? ", 'group'" : "" !!}, 'columnSelector'],
|
widgets: ['zebra', 'uitheme', 'filter'{!! request()->group_when_sorted ? ", 'group'" : "" !!}, 'columnSelector'],
|
||||||
headerTemplate : '{content} {icon}',
|
headerTemplate : '{content} {icon}',
|
||||||
|
dateFormat: '{{ $report->convertDateFormat() }}',
|
||||||
|
numberSorter: function(a, b, direction) {
|
||||||
|
var a = convertStringToNumber(a);
|
||||||
|
var b = convertStringToNumber(b);
|
||||||
|
return direction ? a - b : b - a;
|
||||||
|
},
|
||||||
widgetOptions : {
|
widgetOptions : {
|
||||||
columnSelector_container : $('#columnSelector'),
|
columnSelector_container : $('#columnSelector'),
|
||||||
filter_cssFilter: 'form-control',
|
filter_cssFilter: 'form-control',
|
||||||
@ -310,8 +324,8 @@
|
|||||||
}
|
}
|
||||||
var subtotal = 0;
|
var subtotal = 0;
|
||||||
$rows.each(function() {
|
$rows.each(function() {
|
||||||
var txt = $(this).find("td").eq(i).text().replace(/[$,]/g, '');
|
var txt = $(this).find("td").eq(i).text();
|
||||||
subtotal += parseFloat(txt || 0);
|
subtotal += convertStringToNumber(txt);
|
||||||
});
|
});
|
||||||
$cell.find(".group-count").append(' - ' + label + ': ' + roundToTwo(subtotal));
|
$cell.find(".group-count").append(' - ' + label + ': ' + roundToTwo(subtotal));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user