reports graphical discount

This commit is contained in:
Erastus
2018-08-20 23:42:47 -05:00
parent 325ce79bed
commit 8b29fc7fea
4 changed files with 12 additions and 10 deletions

View File

@@ -65,6 +65,7 @@ $route['reports/summary_:any'] = 'reports/date_input';
$route['reports/(graphical_:any)/([^/]+)/([^/]+)'] = 'reports/$1/$2/$3/$4';
$route['reports/graphical_summary_expenses_categories'] = 'reports/date_input_only';
$route['reports/graphical_summary_discounts'] = 'reports/summary_discounts_input';
$route['reports/graphical_:any'] = 'reports/date_input';
$route['reports/(inventory_:any)/([^/]+)'] = 'reports/$1/$2';

View File

@@ -721,9 +721,9 @@ class Reports extends Secure_Controller
}
//Graphical summary discounts report
public function graphical_summary_discounts($start_date, $end_date, $sale_type, $location_id = 'all')
public function graphical_summary_discounts($start_date, $end_date, $sale_type, $location_id = 'all', $discount_type=0)
{
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id,'discount_type'=>$discount_type);
$this->load->model('reports/Summary_discounts');
$model = $this->Summary_discounts;
@@ -737,7 +737,7 @@ class Reports extends Secure_Controller
{
$row = $this->xss_clean($row);
$labels[] = $row['discount_percent'];
$labels[] = $row['discount'];
$series[] = $row['count'];
}
@@ -749,7 +749,7 @@ class Reports extends Secure_Controller
'series_data_1' => $series,
'summary_data_1' => $summary,
'yaxis_title' => $this->lang->line('reports_count'),
'xaxis_title' => $this->lang->line('reports_discount_percent'),
'xaxis_title' => $this->lang->line('reports_discount'),
'show_currency' => FALSE
);

View File

@@ -1214,6 +1214,12 @@ class Sale_lib
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed']);
$discount = bcadd($discount, $item_discount);
}
if($item['discount_fixed'] > 0)
{
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed']);
$discount = bcadd($discount, $item_discount);
}
}
return $discount;
@@ -1290,10 +1296,7 @@ class Sale_lib
$total = bcmul($quantity, $price);
$discount_fraction = bcdiv($discount_percentage, 100);
$discount_amount=bcadd(bcmul($total, $discount_fraction), $discount_fixed);
return round($discount_amount, totals_decimals(), PHP_ROUND_HALF_UP);
return round(bcadd(bcmul($total, $discount_fraction),$discount_fixed), totals_decimals(), PHP_ROUND_HALF_UP);
}
public function get_item_tax($quantity, $price, $discount_percentage, $discount_fixed, $tax_percentage)

View File

@@ -211,8 +211,6 @@ if(isset($success))
?>
<span class="input-group-btn">
<?php echo form_checkbox(array('id'=>'discount_toggle', 'name'=>'discount_toggle', 'value'=>1, 'data-toggle'=>"toggle",'data-size'=>'small', 'data-onstyle'=>'success', 'data-on'=>'<b>'.$this->config->item('currency_symbol').'</b>', 'data-off'=>'<b>%</b>', 'data-line'=>$line, 'checked'=>$item['discount_type'])); ?>
</span>
</div>
</td>