From 476db84e8671d63d0e7485c83298958563c8c57a Mon Sep 17 00:00:00 2001 From: Steve Ireland Date: Sun, 22 Jan 2017 16:40:20 -0500 Subject: [PATCH] Change SUM to MAX and a couple of indent issues. --- application/models/Receiving.php | 12 +++--- application/models/Sale.php | 8 ++-- .../models/reports/Detailed_receivings.php | 38 +++++++++---------- application/views/reports/listing.php | 14 +++---- .../{2.4_to_3.1.0.sql => 3.02_to_3.1.0.sql} | 0 5 files changed, 36 insertions(+), 36 deletions(-) rename database/{2.4_to_3.1.0.sql => 3.02_to_3.1.0.sql} (100%) diff --git a/application/models/Receiving.php b/application/models/Receiving.php index a4bf6fa8a..689d4186b 100644 --- a/application/models/Receiving.php +++ b/application/models/Receiving.php @@ -247,18 +247,18 @@ class Receiving extends CI_Model MAX(employee_id) AS employee_id, items.item_id, MAX(receivings.supplier_id) AS supplier_id, - SUM(quantity_purchased) AS quantity_purchased, - SUM(receivings_items.receiving_quantity) AS receiving_quantity, + MAX(quantity_purchased) AS quantity_purchased, + MAX(receivings_items.receiving_quantity) AS receiving_quantity, MAX(item_cost_price) AS item_cost_price, MAX(item_unit_price) AS item_unit_price, MAX(discount_percent) AS discount_percent, receivings_items.line, MAX(serialnumber) AS serialnumber, MAX(receivings_items.description) AS description, - SUM(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal, - SUM(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total, - SUM((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit, - SUM(item_cost_price * quantity_purchased) AS cost + MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal, + MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total, + MAX((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit, + MAX(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 diff --git a/application/models/Sale.php b/application/models/Sale.php index 993e51a7d..06113718e 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -64,8 +64,8 @@ class Sale extends CI_Model MAX(customer_p.comments) AS comments, ' . " IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due, - SUM(payments.sale_payment_amount) AS amount_tendered, - (SUM(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due, + MAX(payments.sale_payment_amount) AS amount_tendered, + (MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due, " . ' MAX(payments.payment_type) AS payment_type '); @@ -845,7 +845,7 @@ class Sale extends CI_Model MAX(items.name) AS name, MAX(items.category) AS category, MAX(items.supplier_id) AS supplier_id, - SUM(sales_items.quantity_purchased) AS quantity_purchased, + MAX(sales_items.quantity_purchased) AS quantity_purchased, MAX(sales_items.item_cost_price) AS item_cost_price, MAX(sales_items.item_unit_price) AS item_unit_price, MAX(sales_items.discount_percent) AS discount_percent, @@ -854,7 +854,7 @@ class Sale extends CI_Model MAX(sales_items.item_location) AS item_location, MAX(sales_items.description) AS description, MAX(payments.payment_type) AS payment_type, - SUM(payments.sale_payment_amount) AS sale_payment_amount, + MAX(payments.sale_payment_amount) AS sale_payment_amount, IFNULL(SUM(sales_items_taxes.percent), 0) AS item_tax_percent, ' . " ROUND($sale_subtotal, $decimals) AS subtotal, diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php index 83904400c..e6f85b1eb 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -26,7 +26,7 @@ class Detailed_receivings extends Report array('supplier' => $this->lang->line('reports_supplied_by')), array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), array('payment_type' => $this->lang->line('reports_payment_type')), - array('comment' => $this->lang->line('reports_comments')), + array('comment' => $this->lang->line('reports_comments')), array('reference' => $this->lang->line('receivings_reference'))), 'details' => array( $this->lang->line('reports_item_number'), @@ -57,27 +57,27 @@ class Detailed_receivings extends Report $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'); $this->db->where('receiving_id', $receiving_id); - $this->db->group_by('receiving_id'); + $this->db->group_by('receiving_id'); - return $this->db->get()->row_array(); - } + return $this->db->get()->row_array(); + } - public function getData(array $inputs) - { + public function getData(array $inputs) + { - $this->db->select('receiving_id, - MAX(receiving_date) as receiving_date, - SUM(quantity_purchased) AS items_purchased, - MAX(CONCAT(employee.first_name," ",employee.last_name)) AS employee_name, - MAX(supplier.company_name) AS supplier_name, - SUM(total) AS total, - SUM(profit) AS profit, - MAX(payment_type) AS payment_type, - MAX(comment) AS comment, - MAX(reference) AS reference'); - $this->db->from('receivings_items_temp AS 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'); + $this->db->select('receiving_id, + MAX(receiving_date) as receiving_date, + SUM(quantity_purchased) AS items_purchased, + MAX(CONCAT(employee.first_name," ",employee.last_name)) AS employee_name, + MAX(supplier.company_name) AS supplier_name, + SUM(total) AS total, + SUM(profit) AS profit, + MAX(payment_type) AS payment_type, + MAX(comment) AS comment, + MAX(reference) AS reference'); + $this->db->from('receivings_items_temp AS 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'); if($inputs['location_id'] != 'all') { diff --git a/application/views/reports/listing.php b/application/views/reports/listing.php index bd860545d..71b7caf34 100644 --- a/application/views/reports/listing.php +++ b/application/views/reports/listing.php @@ -10,14 +10,14 @@ if(isset($error))
-
+

 lang->line('reports_graphical_reports'); ?>

-
+
-
+

 lang->line('reports_summary_reports'); ?>

-
+
-
+

 lang->line('reports_detailed_reports'); ?>

-
+
session->userdata('person_id'); diff --git a/database/2.4_to_3.1.0.sql b/database/3.02_to_3.1.0.sql similarity index 100% rename from database/2.4_to_3.1.0.sql rename to database/3.02_to_3.1.0.sql