From 0f88d6462d0a99be3ab0019c42f8cbce4c04dbfb Mon Sep 17 00:00:00 2001 From: jekkos Date: Thu, 7 Jul 2016 21:11:33 +0200 Subject: [PATCH] Add fixes for register + receiving validation (#458) --- application/controllers/Receivings.php | 2 +- application/controllers/Sales.php | 4 ++-- application/libraries/Sale_lib.php | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/application/controllers/Receivings.php b/application/controllers/Receivings.php index 737659202..427d17694 100644 --- a/application/controllers/Receivings.php +++ b/application/controllers/Receivings.php @@ -101,7 +101,7 @@ class Receivings extends Secure_Controller function numeric($str) { - return (bool) preg_match('/^[\-+]?[0-9]*[\.,]?[0-9]+$/', $str); + return (bool) preg_match('/^[\-+]?([0-9]*[\.,])*?[0-9]+$/', $str); } public function edit_item($item_id) diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index 6e3da6bb5..099fa9ea4 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -180,7 +180,7 @@ class Sales extends Secure_Controller public function add_payment() { $data = array(); - $this->form_validation->set_rules('amount_tendered', 'lang:sales_amount_tendered', 'trim|required|numeric'); + $this->form_validation->set_rules('amount_tendered', 'lang:sales_amount_tendered', 'trim|required|callback_numeric'); $payment_type = $this->input->post('payment_type'); $amount_tendered = parse_decimals($this->input->post('amount_tendered')); @@ -282,7 +282,7 @@ class Sales extends Secure_Controller function numeric($str) { - return (bool) preg_match('/^[\-+]?[0-9]*[\.,]?[0-9]+$/', $str); + return (bool) preg_match('/^[\-+]?([0-9]*[\.,])*?[0-9]+$/', $str); } public function edit_item($item_id) diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php index 16d50aa7a..fd9c8e75f 100644 --- a/application/libraries/Sale_lib.php +++ b/application/libraries/Sale_lib.php @@ -180,7 +180,7 @@ class Sale_lib $subtotal = bcadd($payments['payment_amount'], $subtotal, PRECISION); } - return to_currency_no_money($subtotal); + return $subtotal; } // Multiple Payments @@ -189,7 +189,7 @@ class Sale_lib $payment_total = $this->get_payments_total(); $sales_total = $this->get_total(); - return to_currency_no_money(bcsub($sales_total, $payment_total, PRECISION)); + return bcsub($sales_total, $payment_total, PRECISION); } public function get_customer() @@ -306,7 +306,7 @@ class Sale_lib $updatekey = $item['line']; if(!$item_info->is_serialized) { - $quantity += $items[$updatekey]['quantity']; + $quantity = bcadd($quantity, $items[$updatekey]['quantity']); } } } @@ -603,7 +603,7 @@ class Sale_lib public function get_subtotal($include_discount=FALSE, $exclude_tax=FALSE) { $subtotal = $this->calculate_subtotal($include_discount, $exclude_tax); - return to_currency_no_money($subtotal); + return $subtotal; } public function get_item_total_tax_exclusive($item_id, $quantity, $price, $discount_percentage, $include_discount = FALSE) @@ -687,7 +687,7 @@ class Sale_lib } } - return to_currency_no_money($total); + return $total; } public function validate_item(&$item_id)