mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-03 21:33:15 -04:00
Fix Receivings report date issue (#853)
This commit is contained in:
@@ -22,7 +22,7 @@ class Receiving extends CI_Model
|
||||
public function exists($receiving_id)
|
||||
{
|
||||
$this->db->from('receivings');
|
||||
$this->db->where('receiving_id',$receiving_id);
|
||||
$this->db->where('receiving_id', $receiving_id);
|
||||
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
@@ -204,33 +204,38 @@ class Receiving extends CI_Model
|
||||
*/
|
||||
public function create_temp_table()
|
||||
{
|
||||
$this->db->query("CREATE TEMPORARY TABLE IF NOT EXISTS " . $this->db->dbprefix('receivings_items_temp') . "
|
||||
(SELECT
|
||||
date(receiving_time) AS receiving_date,
|
||||
" . $this->db->dbprefix('receivings_items') . " . receiving_id,
|
||||
comment,
|
||||
item_location,
|
||||
reference,
|
||||
payment_type,
|
||||
employee_id,
|
||||
" . $this->db->dbprefix('items') . " . item_id,
|
||||
" . $this->db->dbprefix('receivings') . " . supplier_id,
|
||||
quantity_purchased,
|
||||
" . $this->db->dbprefix('receivings_items') . " . receiving_quantity,
|
||||
item_cost_price,
|
||||
item_unit_price,
|
||||
discount_percent,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal,
|
||||
" . $this->db->dbprefix('receivings_items') . " . line AS line,
|
||||
serialnumber,
|
||||
" . $this->db->dbprefix('receivings_items') . " . description AS description,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased) AS profit,
|
||||
(item_cost_price * quantity_purchased) AS cost
|
||||
FROM " . $this->db->dbprefix('receivings_items') . "
|
||||
INNER JOIN " . $this->db->dbprefix('receivings') . " ON " . $this->db->dbprefix('receivings_items') . '.receiving_id=' . $this->db->dbprefix('receivings') . '.receiving_id' . "
|
||||
INNER JOIN " . $this->db->dbprefix('items') . " ON " . $this->db->dbprefix('receivings_items') . '.item_id=' . $this->db->dbprefix('items') . '.item_id' . "
|
||||
GROUP BY receiving_id, item_id, line)"
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') .
|
||||
'(
|
||||
SELECT
|
||||
DATE(receiving_time) AS receiving_date,
|
||||
receiving_time,
|
||||
receivings_items.receiving_id,
|
||||
comment,
|
||||
item_location,
|
||||
reference,
|
||||
payment_type,
|
||||
employee_id,
|
||||
items.item_id,
|
||||
receivings.supplier_id,
|
||||
quantity_purchased,
|
||||
receivings_items.receiving_quantity,
|
||||
item_cost_price,
|
||||
item_unit_price,
|
||||
discount_percent,
|
||||
receivings_items.line,
|
||||
serialnumber,
|
||||
receivings_items.description,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total,
|
||||
(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased) AS profit,
|
||||
(item_cost_price * quantity_purchased) AS cost
|
||||
FROM ' . $this->db->dbprefix('receivings_items') . ' AS receivings_items
|
||||
INNER JOIN ' . $this->db->dbprefix('receivings') . ' AS receivings
|
||||
ON receivings_items.receiving_id = receivings.receiving_id
|
||||
INNER JOIN ' . $this->db->dbprefix('items') . ' AS items
|
||||
ON receivings_items.item_id = items.item_id
|
||||
GROUP BY receivings_items.receiving_id, items.item_id, receivings_items.line
|
||||
)'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Detailed_receivings extends Report
|
||||
|
||||
public function getDataByReceivingId($receiving_id)
|
||||
{
|
||||
$this->db->select('receiving_id, DATE_FORMAT(receiving_date, "%d-%m-%Y") AS receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name, " ", employee.last_name) AS employee_name, supplier.company_name AS supplier_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, reference');
|
||||
$this->db->select('receiving_id, receiving_date, SUM(quantity_purchased) AS items_purchased, CONCAT(employee.first_name, " ", employee.last_name) AS employee_name, supplier.company_name AS supplier_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(profit) AS profit, payment_type, comment, reference');
|
||||
$this->db->from('receivings_items_temp');
|
||||
$this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
|
||||
$this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
|
||||
|
||||
Reference in New Issue
Block a user