FIX calculation of balance in conciliation page on desc sorting.
This commit is contained in:
parent
bbd97c6e16
commit
0443302c3d
@ -178,7 +178,6 @@ $object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -270,13 +269,15 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', '
|
||||
|
||||
if (!$error) {
|
||||
$param = 'action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id;
|
||||
$param .= '&search_conciliated='.urlencode($search_conciliated);
|
||||
if ($page) {
|
||||
$param .= '&page='.urlencode($page);
|
||||
}
|
||||
if ($offset) {
|
||||
$param .= '&offset='.urlencode($offset);
|
||||
}
|
||||
if ($search_conciliated != '' && $search_conciliated != '-1') {
|
||||
$param .= '&search_conciliated='.urlencode($search_conciliated);
|
||||
}
|
||||
if ($search_thirdparty_user) {
|
||||
$param .= '&search_thirdparty='.urlencode($search_thirdparty_user);
|
||||
}
|
||||
@ -419,7 +420,6 @@ $banklinestatic = new AccountLine($db);
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
|
||||
// Must be before button action
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
@ -757,7 +757,7 @@ if ($resql) {
|
||||
// Confirmation delete
|
||||
if ($action == 'delete') {
|
||||
$text = $langs->trans('ConfirmDeleteTransaction');
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid", 'int'), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1);
|
||||
}
|
||||
|
||||
// Lines of title fields
|
||||
@ -1200,7 +1200,7 @@ if ($resql) {
|
||||
$objforbalance = $db->fetch_object($resqlforbalance);
|
||||
if ($objforbalance) {
|
||||
// If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
|
||||
if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') {
|
||||
if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
|
||||
$balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
|
||||
} else {
|
||||
// If sort is asc,asc,asc then total of previous date is balance of line before the next line to show
|
||||
@ -1285,8 +1285,7 @@ if ($resql) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') {
|
||||
if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) {
|
||||
$balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc)
|
||||
$balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT');
|
||||
} else {
|
||||
|
||||
@ -5378,13 +5378,16 @@ function price2num($amount, $rounding = '', $option = 0)
|
||||
if ($thousand != ',' && $thousand != '.') {
|
||||
$amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
||||
}
|
||||
|
||||
$amount = str_replace(' ', '', $amount); // To avoid spaces
|
||||
$amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
$amount = str_replace($dec, '.', $amount);
|
||||
|
||||
$amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example.
|
||||
}
|
||||
//print ' XX'.$amount.' '.$rounding;
|
||||
|
||||
// Now, make a rounding if required
|
||||
// Now, $amount is a real PHP float number. We make a rounding if required.
|
||||
if ($rounding) {
|
||||
$nbofdectoround = '';
|
||||
if ($rounding == 'MU') {
|
||||
@ -5424,9 +5427,12 @@ function price2num($amount, $rounding = '', $option = 0)
|
||||
if ($thousand != ',' && $thousand != '.') {
|
||||
$amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
||||
}
|
||||
|
||||
$amount = str_replace(' ', '', $amount); // To avoid spaces
|
||||
$amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
$amount = str_replace($dec, '.', $amount);
|
||||
|
||||
$amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example.
|
||||
}
|
||||
|
||||
return $amount;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user