mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Fix Detailed sale tax rounding, reorder reports to subtotal, tax, total, cost, profit (#976)
This commit is contained in:
@@ -54,8 +54,8 @@ class Reports extends Secure_Controller
|
||||
$tabular_data[] = $this->xss_clean(array($row['sale_date'],
|
||||
to_quantity_decimals($row['quantity_purchased']),
|
||||
to_currency($row['subtotal']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['tax']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['cost']),
|
||||
to_currency($row['profit'])
|
||||
));
|
||||
@@ -89,8 +89,8 @@ class Reports extends Secure_Controller
|
||||
$tabular_data[] = $this->xss_clean(array($row['category'],
|
||||
to_quantity_decimals($row['quantity_purchased']),
|
||||
to_currency($row['subtotal']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['tax']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['cost']),
|
||||
to_currency($row['profit'])
|
||||
));
|
||||
@@ -124,8 +124,8 @@ class Reports extends Secure_Controller
|
||||
$tabular_data[] = $this->xss_clean(array($row['customer'],
|
||||
to_quantity_decimals($row['quantity_purchased']),
|
||||
to_currency($row['subtotal']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['tax']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['cost']),
|
||||
to_currency($row['profit'])
|
||||
));
|
||||
@@ -159,8 +159,8 @@ class Reports extends Secure_Controller
|
||||
$tabular_data[] = $this->xss_clean(array($row['supplier'],
|
||||
to_quantity_decimals($row['quantity_purchased']),
|
||||
to_currency($row['subtotal']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['tax']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['cost']),
|
||||
to_currency($row['profit'])
|
||||
));
|
||||
@@ -194,8 +194,8 @@ class Reports extends Secure_Controller
|
||||
$tabular_data[] = $this->xss_clean(array($row['name'],
|
||||
to_quantity_decimals($row['quantity_purchased']),
|
||||
to_currency($row['subtotal']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['tax']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['cost']),
|
||||
to_currency($row['profit'])
|
||||
));
|
||||
@@ -229,8 +229,8 @@ class Reports extends Secure_Controller
|
||||
$tabular_data[] = $this->xss_clean(array($row['employee'],
|
||||
to_quantity_decimals($row['quantity_purchased']),
|
||||
to_currency($row['subtotal']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['tax']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['cost']),
|
||||
to_currency($row['profit'])
|
||||
));
|
||||
@@ -264,8 +264,8 @@ class Reports extends Secure_Controller
|
||||
$tabular_data[] = $this->xss_clean(array($row['percent'],
|
||||
$row['count'],
|
||||
to_currency($row['subtotal']),
|
||||
to_currency($row['total']),
|
||||
to_currency($row['tax'])
|
||||
to_currency($row['tax']),
|
||||
to_currency($row['total'])
|
||||
));
|
||||
}
|
||||
|
||||
@@ -723,11 +723,11 @@ class Reports extends Secure_Controller
|
||||
|
||||
foreach($report_data['summary'] as $key => $row)
|
||||
{
|
||||
$summary_data[] = $this->xss_clean(array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), $row['sale_date'], to_quantity_decimals($row['items_purchased']), $row['employee_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']));
|
||||
$summary_data[] = $this->xss_clean(array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), $row['sale_date'], to_quantity_decimals($row['items_purchased']), $row['employee_name'], to_currency($row['subtotal']), to_currency($row['tax']), to_currency($row['total']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']));
|
||||
|
||||
foreach($report_data['details'][$key] as $drow)
|
||||
{
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,11 +776,11 @@ class Reports extends Secure_Controller
|
||||
|
||||
foreach($report_data['summary'] as $key => $row)
|
||||
{
|
||||
$summary_data[] = $this->xss_clean(array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), $row['sale_date'], to_quantity_decimals($row['items_purchased']), $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']));
|
||||
$summary_data[] = $this->xss_clean(array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), $row['sale_date'], to_quantity_decimals($row['items_purchased']), $row['customer_name'], to_currency($row['subtotal']), to_currency($row['tax']), to_currency($row['total']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']));
|
||||
|
||||
foreach($report_data['details'][$key] as $drow)
|
||||
{
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,11 +831,11 @@ class Reports extends Secure_Controller
|
||||
|
||||
foreach($report_data['summary'] as $key => $row)
|
||||
{
|
||||
$summary_data[] = $this->xss_clean(array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), $row['sale_date'], to_quantity_decimals($row['items_purchased']), $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),/*to_currency($row['profit']),*/ $row['payment_type'], $row['comment']));
|
||||
$summary_data[] = $this->xss_clean(array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), $row['sale_date'], to_quantity_decimals($row['items_purchased']), $row['customer_name'], to_currency($row['subtotal']), to_currency($row['tax']), to_currency($row['total']), to_currency($row['profit']), $row['payment_type'], $row['comment']));
|
||||
|
||||
foreach($report_data['details'][$key] as $drow)
|
||||
{
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']),/*to_currency($drow['profit']),*/ $drow['discount_percent'].'%'));
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -869,8 +869,8 @@ class Reports extends Secure_Controller
|
||||
'employee' => $report_data['employee_name'],
|
||||
'customer' => $report_data['customer_name'],
|
||||
'subtotal' => to_currency($report_data['subtotal']),
|
||||
'total' => to_currency($report_data['total']),
|
||||
'tax' => to_currency($report_data['tax']),
|
||||
'total' => to_currency($report_data['total']),
|
||||
'cost' => to_currency($report_data['cost']),
|
||||
'profit' => to_currency($report_data['profit']),
|
||||
'payment_type' => $report_data['payment_type'],
|
||||
@@ -909,8 +909,8 @@ class Reports extends Secure_Controller
|
||||
'employee' => $row['employee_name'],
|
||||
'customer' => $row['customer_name'],
|
||||
'subtotal' => to_currency($row['subtotal']),
|
||||
'total' => to_currency($row['total']),
|
||||
'tax' => to_currency($row['tax']),
|
||||
'total' => to_currency($row['total']),
|
||||
'cost' => to_currency($row['cost']),
|
||||
'profit' => to_currency($row['profit']),
|
||||
'payment_type' => $row['payment_type'],
|
||||
@@ -927,7 +927,7 @@ class Reports extends Secure_Controller
|
||||
{
|
||||
$quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
|
||||
}
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $quantity_purchased, to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $quantity_purchased, to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,8 @@ class Sale extends CI_Model
|
||||
customer.company_name AS company_name,
|
||||
' . "
|
||||
ROUND($sale_subtotal, $decimals) AS subtotal,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
|
||||
IFNULL(ROUND($sale_tax, $decimals), 0) AS tax,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
|
||||
ROUND($sale_cost, $decimals) AS cost,
|
||||
ROUND($sale_total - IFNULL($sale_tax, 0) - $sale_cost, $decimals) AS profit,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
|
||||
@@ -731,8 +731,7 @@ class Sale extends CI_Model
|
||||
|
||||
$sale_cost = '(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
|
||||
// increase the rounding of one decimal on top of the selected ones to avoid accumulative rounding errors in the totals
|
||||
$decimals = totals_decimals() + 1;
|
||||
$decimals = totals_decimals();
|
||||
|
||||
if(empty($input['sale_id']))
|
||||
{
|
||||
@@ -795,8 +794,8 @@ class Sale extends CI_Model
|
||||
IFNULL(SUM(sales_items_taxes.percent), 0) AS item_tax_percent,
|
||||
' . "
|
||||
ROUND($sale_subtotal, $decimals) AS subtotal,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
|
||||
IFNULL(ROUND($sale_tax, $decimals), 0) AS tax,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
|
||||
ROUND($sale_cost, $decimals) AS cost,
|
||||
ROUND($sale_total - IFNULL($sale_tax, 0) - $sale_cost, $decimals) AS profit
|
||||
" . '
|
||||
|
||||
@@ -25,8 +25,8 @@ class Detailed_sales extends Report
|
||||
'employee' => $this->lang->line('reports_sold_by'),
|
||||
'customer' => $this->lang->line('reports_sold_to'),
|
||||
'subtotal' => $this->lang->line('reports_subtotal'),
|
||||
'total' => $this->lang->line('reports_total'),
|
||||
'tax' => $this->lang->line('reports_tax'),
|
||||
'total' => $this->lang->line('reports_total'),
|
||||
'cost' => $this->lang->line('reports_cost'),
|
||||
'profit' => $this->lang->line('reports_profit'),
|
||||
'payment_type' => $this->lang->line('sales_amount_tendered'),
|
||||
@@ -39,8 +39,8 @@ class Detailed_sales extends Report
|
||||
$this->lang->line('reports_description'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
@@ -49,7 +49,7 @@ class Detailed_sales extends Report
|
||||
|
||||
public function getDataBySaleId($sale_id)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
|
||||
@@ -58,7 +58,7 @@ class Detailed_sales extends Report
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
|
||||
if($inputs['location_id'] != 'all')
|
||||
@@ -84,7 +84,7 @@ class Detailed_sales extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, total, tax, cost, profit, discount_percent');
|
||||
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, tax, total, cost, profit, discount_percent');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
@@ -95,7 +95,7 @@ class Detailed_sales extends Report
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
|
||||
if($inputs['location_id'] != 'all')
|
||||
|
||||
@@ -17,14 +17,37 @@ class Specific_customer extends Report
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_quantity'), $this->lang->line('reports_sold_by'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'), $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
|
||||
'details' => array($this->lang->line('reports_name'), $this->lang->line('reports_category'), $this->lang->line('reports_serial_number'), $this->lang->line('reports_description'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'), $this->lang->line('reports_discount'))
|
||||
return array(
|
||||
'summary' => array(
|
||||
$this->lang->line('reports_sale_id'),
|
||||
$this->lang->line('reports_date'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_sold_by'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_payment_type'),
|
||||
$this->lang->line('reports_comments')),
|
||||
'details' => array(
|
||||
$this->lang->line('reports_name'),
|
||||
$this->lang->line('reports_category'),
|
||||
$this->lang->line('reports_serial_number'),
|
||||
$this->lang->line('reports_description'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
}
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('customer_id', $inputs['customer_id']);
|
||||
|
||||
@@ -46,7 +69,7 @@ class Specific_customer extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
@@ -57,7 +80,7 @@ class Specific_customer extends Report
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('customer_id', $inputs['customer_id']);
|
||||
|
||||
|
||||
@@ -17,14 +17,35 @@ class Specific_discount extends Report
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_quantity'), $this->lang->line('reports_sold_to'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), /*$this->lang->line('reports_profit'),*/ $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
|
||||
'details' => array($this->lang->line('reports_name'), $this->lang->line('reports_category'), $this->lang->line('reports_serial_number'), $this->lang->line('reports_description'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), /*$this->lang->line('reports_profit'),*/ $this->lang->line('reports_discount'))
|
||||
return array(
|
||||
'summary' => array(
|
||||
$this->lang->line('reports_sale_id'),
|
||||
$this->lang->line('reports_date'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_sold_to'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_payment_type'),
|
||||
$this->lang->line('reports_comments')),
|
||||
'details' => array(
|
||||
$this->lang->line('reports_name'),
|
||||
$this->lang->line('reports_category'),
|
||||
$this->lang->line('reports_serial_number'),
|
||||
$this->lang->line('reports_description'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
}
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
|
||||
@@ -46,7 +67,7 @@ class Specific_discount extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, serialnumber, category, description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
|
||||
$this->db->select('name, serialnumber, category, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
@@ -57,7 +78,7 @@ class Specific_discount extends Report
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
|
||||
|
||||
@@ -17,14 +17,37 @@ class Specific_employee extends Report
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_quantity'), $this->lang->line('reports_sold_to'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'), $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
|
||||
'details' => array($this->lang->line('reports_name'), $this->lang->line('reports_category'), $this->lang->line('reports_serial_number'), $this->lang->line('reports_description'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'), $this->lang->line('reports_discount'))
|
||||
return array(
|
||||
'summary' => array(
|
||||
$this->lang->line('reports_sale_id'),
|
||||
$this->lang->line('reports_date'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_sold_to'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_payment_type'),
|
||||
$this->lang->line('reports_comments')),
|
||||
'details' => array(
|
||||
$this->lang->line('reports_name'),
|
||||
$this->lang->line('reports_category'),
|
||||
$this->lang->line('reports_serial_number'),
|
||||
$this->lang->line('reports_description'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
}
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('employee_id', $inputs['employee_id']);
|
||||
|
||||
@@ -46,7 +69,7 @@ class Specific_employee extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
@@ -57,7 +80,7 @@ class Specific_employee extends Report
|
||||
|
||||
public function getSummaryData(array $inputs)
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('employee_id', $inputs['employee_id']);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class Summary_categories extends Summary_report
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array($this->lang->line('reports_category'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
return array($this->lang->line('reports_category'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_tax'), $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
}
|
||||
|
||||
protected function _select(array $inputs)
|
||||
|
||||
@@ -11,7 +11,7 @@ class Summary_customers extends Summary_report
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array($this->lang->line('reports_customer'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
return array($this->lang->line('reports_customer'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_tax'), $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
}
|
||||
|
||||
protected function _select(array $inputs)
|
||||
|
||||
@@ -11,7 +11,7 @@ class Summary_employees extends Summary_report
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array($this->lang->line('reports_employee'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
return array($this->lang->line('reports_employee'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_tax'), $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
}
|
||||
|
||||
protected function _select(array $inputs)
|
||||
|
||||
@@ -11,7 +11,7 @@ class Summary_items extends Summary_report
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array($this->lang->line('reports_item'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
return array($this->lang->line('reports_item'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_tax'), $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
}
|
||||
|
||||
protected function _select(array $inputs)
|
||||
|
||||
@@ -53,8 +53,8 @@ abstract class Summary_report extends Report
|
||||
|
||||
$this->db->select("
|
||||
ROUND($sale_subtotal, $decimals) AS subtotal,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
|
||||
IFNULL(ROUND($sale_tax, $decimals), 0) AS tax,
|
||||
IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
|
||||
ROUND($sale_cost, $decimals) AS cost,
|
||||
ROUND($sale_total - IFNULL($sale_tax, 0) - $sale_cost, $decimals) AS profit
|
||||
");
|
||||
|
||||
@@ -11,7 +11,7 @@ class Summary_sales extends Summary_report
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array($this->lang->line('reports_date'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
return array($this->lang->line('reports_date'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_tax'), $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
}
|
||||
|
||||
protected function _select(array $inputs)
|
||||
|
||||
@@ -11,7 +11,7 @@ class Summary_suppliers extends Summary_report
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array($this->lang->line('reports_supplier'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
return array($this->lang->line('reports_supplier'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_tax'), $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
}
|
||||
|
||||
protected function _select(array $inputs)
|
||||
|
||||
@@ -11,7 +11,7 @@ class Summary_taxes extends Summary_report
|
||||
|
||||
protected function _get_data_columns()
|
||||
{
|
||||
return array($this->lang->line('reports_tax_percent'), $this->lang->line('reports_count'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'));
|
||||
return array($this->lang->line('reports_tax_percent'), $this->lang->line('reports_count'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_tax'), $this->lang->line('reports_total'));
|
||||
}
|
||||
|
||||
public function getData(array $inputs)
|
||||
@@ -47,13 +47,13 @@ class Summary_taxes extends Summary_report
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
$query = $this->db->query("SELECT percent, count(*) AS count, ROUND(SUM(subtotal), $decimals) AS subtotal, ROUND(SUM(total), $decimals) AS total, ROUND(SUM(tax), $decimals) AS tax
|
||||
$query = $this->db->query("SELECT percent, count(*) AS count, ROUND(SUM(subtotal), $decimals) AS subtotal, ROUND(SUM(tax), $decimals) AS tax, ROUND(SUM(total), $decimals) AS total
|
||||
FROM (
|
||||
SELECT
|
||||
CONCAT(IFNULL(ROUND(percent, $decimals), 0), '%') AS percent,
|
||||
$sale_subtotal AS subtotal,
|
||||
IFNULL($sale_total, $sale_subtotal) AS total,
|
||||
IFNULL($sale_tax, 0) AS tax
|
||||
IFNULL($sale_tax, 0) AS tax,
|
||||
IFNULL($sale_total, $sale_subtotal) AS total
|
||||
FROM " . $this->db->dbprefix('sales_items') . ' AS sales_items
|
||||
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
|
||||
ON sales_items.sale_id = sales.sale_id
|
||||
|
||||
Reference in New Issue
Block a user