mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-23 16:48:35 -04:00
#27 Using bc-style operations now.
This commit is contained in:
1 parent
839849bf8d
commit
4ddec66d7b
1 file changed
+1
-1
@@ -614,7 +614,7 @@ class Item extends CI_Model
|
||||
$old_total_quantity = $this->db->get()->row()->quantity;
|
||||
|
||||
$total_quantity = $old_total_quantity + $items_received;
|
||||
$average_price = ($items_received * $new_price + $old_total_quantity * $old_price)/$total_quantity;
|
||||
$average_price = bcdiv(bcadd(bcmul($items_received, $new_price), bcmul($old_total_quantity, $old_price)), $total_quantity);
|
||||
|
||||
$data = array('cost_price' => $average_price);
|
||||
|
||||
|
||||
Reference in new issue
Block a user