Merge pull request #29 from marteserede/master

Two small edits (#27 and #28)
This commit is contained in:
jekkos
2015-01-30 08:01:22 +01:00
2 changed files with 2 additions and 2 deletions

View File

@@ -344,7 +344,7 @@ class Receivings extends Secure_area
'supplier_id' => $this->input->post('supplier_id') ? $this->input->post('supplier_id') : null,
'employee_id' => $this->input->post('employee_id'),
'comment' => $this->input->post('comment'),
'invoice_number' => $this->input->post('invoice_number')
'invoice_number' => $this->input->post('invoice_number') != '' ? $this->input->post('invoice_number') : null
);
if ($this->Receiving->update($receiving_data, $receiving_id))

View File

@@ -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);