Round amount due before comparing with zero (#759)

Bump version chartist tooltip
This commit is contained in:
jekkos
2016-07-30 10:13:07 +02:00
parent 05628ddaff
commit 956f18e55c
7 changed files with 10 additions and 15 deletions

View File

@@ -531,12 +531,6 @@ class Sales extends Secure_Controller
return $this->sale_lib->get_invoice_number();
}
private function _payments_cover_total()
{
$minimum = 5 * pow(10, -1 * ($this->config->item('currency_decimals') + 1));
return $this->sale_lib->get_amount_due() < $minimum;
}
private function _load_customer_data($customer_id, &$data, $totals = FALSE)
{
$customer_info = '';
@@ -649,7 +643,7 @@ class Sales extends Secure_Controller
$data['invoice_number'] = $this->_substitute_invoice_number($customer_info);
$data['invoice_number_enabled'] = $this->sale_lib->is_invoice_number_enabled();
$data['print_after_sale'] = $this->sale_lib->is_print_after_sale();
$data['payments_cover_total'] = $this->_payments_cover_total();
$data['payments_cover_total'] = $this->sale_lib->get_amount_due() == 0;
$data = $this->xss_clean($data);

View File

@@ -82,8 +82,6 @@ function parse_decimals($number)
$config = get_instance()->config;
$fmt = new \NumberFormatter( $config->item('number_locale'), \NumberFormatter::DECIMAL );
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item('quantity_decimals'));
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $config->item('quantity_decimals'));
return $fmt->parse($number);
}

View File

@@ -188,8 +188,11 @@ class Sale_lib
{
$payment_total = $this->get_payments_total();
$sales_total = $this->get_total();
return bcsub($sales_total, $payment_total);
$amount_due = bcsub($sales_total, $payment_total);
$precision = $this->CI->config->item('currency_decimals');
$rounded_due = bccomp(round($amount_due, $precision, PHP_ROUND_HALF_EVEN), 0, $precision);
// take care of rounding error introduced by round tripping payment amount to the browser
return $rounded_due == 0 ? 0 : $amount_due;
}
public function get_customer()

View File

@@ -17,7 +17,7 @@
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=0ad5e454a4"/>
<!-- end mincss template tags -->
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=52a2324353"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=ea16f5c215"></script>
<!-- end minjs template tags -->
<?php endif; ?>

View File

@@ -39,7 +39,7 @@
"chartist": "^0.9.8",
"chartist-plugin-axistitle": "^0.1.0",
"chartist-plugin-pointlabels": "^0.0.4",
"chartist-plugin-tooltip": "https://github.com/Globegitter/chartist-plugin-tooltip/archive/master.zip",
"chartist-plugin-tooltip": "^0.0.13",
"remarkable-bootstrap-notify": "^3.1.3",
"js-cookie": "^2.1.2"
},

View File

File diff suppressed because one or more lines are too long

View File

@@ -18,7 +18,7 @@
<!-- end mincss template tags -->
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/style.css"/>
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=52a2324353"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=ea16f5c215"></script>
<!-- end minjs template tags -->
<?php endif; ?>