mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-07-17 18:32:51 -04:00
Show tax exclusive subtotal in case of tax inclusive pricing
This commit is contained in:
@@ -657,6 +657,7 @@ class Sales extends Secure_area
|
||||
$data['stock_location']=$this->sale_lib->get_sale_location();
|
||||
|
||||
$data['subtotal']=$this->sale_lib->get_subtotal(TRUE);
|
||||
$data['tax_exclusive_subtotal']=$this->sale_lib->get_subtotal(TRUE, TRUE);
|
||||
$data['taxes']=$this->sale_lib->get_taxes();
|
||||
$data['discount']=$this->sale_lib->get_discount();
|
||||
$data['total']=$this->sale_lib->get_total();
|
||||
|
||||
@@ -40,9 +40,9 @@ class Summary_taxes extends Report
|
||||
|
||||
$query = $this->db->query("SELECT percent, SUM(subtotal) as subtotal, sum(total) as total, sum(tax) as tax
|
||||
FROM (SELECT name, CONCAT( percent, '%' ) AS percent,
|
||||
((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $subtotal) AS subtotal,
|
||||
((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $total) AS total,
|
||||
((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $tax) AS tax
|
||||
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $subtotal, 2) AS subtotal,
|
||||
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $total, 2) AS total,
|
||||
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $tax, 2) AS tax
|
||||
FROM ".$this->db->dbprefix('sales_items_taxes')."
|
||||
JOIN ".$this->db->dbprefix('sales_items')." ON "
|
||||
.$this->db->dbprefix('sales_items').'.sale_id='.$this->db->dbprefix('sales_items_taxes').'.sale_id'." and "
|
||||
|
||||
@@ -385,24 +385,24 @@ class Sale extends CI_Model
|
||||
if ($this->config->item('tax_included'))
|
||||
{
|
||||
$total = "1";
|
||||
$subtotal = "(100/(100+SUM(percent)))";
|
||||
$tax="(1 - (100/(100 + SUM(percent))))";
|
||||
$subtotal = "(1 - (SUM(1 - 100/(100+percent))))";
|
||||
$tax="(SUM(1 - 100/(100+percent)))";
|
||||
}
|
||||
else
|
||||
{
|
||||
$tax = "(SUM(percent)/100)";
|
||||
$total = "(1+(SUM(percent)/100))";
|
||||
$total = "(1+(SUM(percent/100)))";
|
||||
$subtotal = "1";
|
||||
}
|
||||
|
||||
$this->db->query("CREATE TEMPORARY TABLE ".$this->db->dbprefix('sales_items_temp')."
|
||||
(SELECT date(sale_time) as sale_date, sale_time, ".$this->db->dbprefix('sales_items').".sale_id, comment,payments.payment_type, customer_id, employee_id,
|
||||
".$this->db->dbprefix('items').".item_id, supplier_id, quantity_purchased, item_cost_price, item_unit_price, SUM(percent) as item_tax_percent,
|
||||
discount_percent, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$subtotal as subtotal,
|
||||
discount_percent, ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$subtotal,2) as subtotal,
|
||||
".$this->db->dbprefix('sales_items').".line as line, serialnumber, ".$this->db->dbprefix('sales_items').".description as description,
|
||||
(item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$total as total,
|
||||
(item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$tax as tax,
|
||||
(item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) - (item_cost_price*quantity_purchased) as profit
|
||||
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$total, 2) as total,
|
||||
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$tax, 2) as tax,
|
||||
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)- (item_cost_price*quantity_purchased), 2) as profit
|
||||
FROM ".$this->db->dbprefix('sales_items')."
|
||||
INNER JOIN ".$this->db->dbprefix('sales')." ON ".$this->db->dbprefix('sales_items').'.sale_id='.$this->db->dbprefix('sales').'.sale_id'."
|
||||
INNER JOIN ".$this->db->dbprefix('items')." ON ".$this->db->dbprefix('sales_items').'.item_id='.$this->db->dbprefix('items').'.item_id'."
|
||||
|
||||
@@ -97,7 +97,7 @@ if (isset($error_message))
|
||||
<?php if ($this->Appconfig->get('receipt_show_taxes')): ?>
|
||||
<tr>
|
||||
<td colspan="3" style='text-align:right;border-top:2px solid #000000;'><?php echo $this->lang->line('sales_sub_total'); ?></td>
|
||||
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($discounted_subtotal); ?></td>
|
||||
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($this->config->item('tax_included') ? $tax_exclusive_subtotal : $discounted_subtotal); ?></td>
|
||||
</tr>
|
||||
<?php foreach($taxes as $name=>$value) { ?>
|
||||
<tr>
|
||||
|
||||
@@ -217,7 +217,7 @@ else
|
||||
|
||||
<div id='sale_details'>
|
||||
<div class="float_left" style="width: 55%;"><?php echo $this->lang->line('sales_sub_total'); ?>:</div>
|
||||
<div class="float_left" style="width: 45%; font-weight: bold;"><?php echo to_currency($subtotal); ?></div>
|
||||
<div class="float_left" style="width: 45%; font-weight: bold;"><?php echo to_currency($this->config->item('tax_included') ? $tax_exclusive_subtotal : $subtotal); ?></div>
|
||||
|
||||
<?php foreach($taxes as $name=>$value) { ?>
|
||||
<div class="float_left" style='width: 55%;'><?php echo $name; ?>:</div>
|
||||
|
||||
Reference in New Issue
Block a user