Tax inclusion option should be added to the configuration screen. For Europe (Belgium at least) most of the time prices are always tax inclusive. this means that a user will enter tax inclusive prices in the system and the receipt should only mention prices in which a tax has already been incorporated.
This means on one hand that if the option is enabled, no extra tax should be added to the subtotal, as is done now the American way.
This is only different when you make 'invoices', which means that you don't charge any tax to the customer you're selling to. In this case the is_taxable flag would be set to false.
in that case behavior of the receipt should change to calculate the totals with the following formula (use price and substract the included tax value)
price * quantity (1 - discount / 100) * (100 / 100 + taxrate)
// get_taxes from libaries/Sales_lib.php
function get_taxes()
{
$customer_id = $this->get_customer();
$customer = $this->CI->Customer->get_info($customer_id);
$tax_included = $this->CI->config->config['tax_included'];
//Do not charge sales tax if we have a customer that is not taxable
if (!$customer->taxable and $customer_id!=-1)
{
return array();
}
$taxes = array();
foreach($this->get_cart() as $line=>$item)
{
$tax_info = $this->CI->Item_taxes->get_info($item['item_id']);
foreach($tax_info as $tax)
{
$name = $tax['percent'].'% ' . $tax['name'];
if ( $tax_included )
{
$tax_amount=($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100)*($tax['percent'])/(($tax['percent']+100));
}
else
{
$tax_amount=($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100)*(($tax['percent'])/100);
}
if (!isset($taxes[$name]))
{
$taxes[$name] = 0;
}
$taxes[$name] += $tax_amount;
}
}
return $taxes;
}
Diff:
Diff:
Ok I commit a patch to my github for this feature.. Could someone give this a try and provide some feedback??
latest version can be found at https://github.com/jekkos/opensourcepos
just check tax inclusive pricing in the configuration and then all entered prices will be tax inclusive (no added taxes upon checkout).
tax exclusive prices are calculated by substracting all present taxes from the entered item price. If desired I could add a cumulative tax option as well here.
regarding the tax inclusive.
is there anyway to have the line totals and sub totals exclusive of tax.
so for example we can have
2 items at selling price $5 with tax of 15%
the subtotal will be $8.69
the tax will be $1.31
the total $ 10.00
there is certainly a way. But I chose to show the prices all tax inclusive, as I found that showing it exclusive taxes will confuse the customers.
subtotal method will need to be adapted so that the tax is substracted again after summing up the totals. send me a pm if you urgently need this feature.
I live in a country where the tax dept is quite strict, they more concerned about the slip, which prints through a fiscal printer that SMSs the figures to them.
Before I(or get you to) do anything further changes, let me see if I can modify the slip to suit their needs
That's my working line :)
just change tax_amount calculation by:
$tax_amount=-1(($item['price']$item['quantity']-$item['price']$item['quantity']$item['discount']/100)/(($tax['percent'])/100+1)-($item['price']$item['quantity']-$item['price']$item['quantity']*$item['discount']/100));
To be changed in application/models/reports/summary_taxes.php:
replace:
FROM (SELECT name, CONCAT( percent, '%' ) AS percent, (
item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100
) AS subtotal, ROUND( (
item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100
) * ( 1 + ( percent /100 ) ) , 2 ) AS total, ROUND( (
item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100
) * ( percent /100 ) , 2 ) AS tax
by:
FROM (SELECT name, CONCAT( percent, '%' ) AS percent, (
and the last one, application/models/sale.php in order to get correct value for the summary
change this:
(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100)(1-(SUM(percent)/100)) as subtotal,
".$this->db->dbprefix('sales_items').".line as line, serialnumber, ".$this->db->dbprefix('sales_items').".description as description,
(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100) as total,
(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100)(SUM(percent)/100) as tax,
(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100)(1-(SUM(percent)/100)) - (item_cost_pricequantity_purchased) as profit
by:
(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100)/(1+SUM(percent)/100)
as subtotal,
".$this->db->dbprefix('sales_items').".line as line, serialnumber, ".$this->db->dbprefix('sales_items').".description as description,
(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100)
as total,
((item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100)/(1+SUM(percent)/100)-(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100))-1
as tax,
(item_unit_pricequantity_purchased-item_unit_pricequantity_purchaseddiscount_percent/100)/(1+SUM(percent)/100) - (item_cost_price*quantity_purchased)
as profit
Last edit: Jerome 2014-12-02
Think you will experience rounding errors with this approach. There is no guaranteed precision when using the regular math operators. Check the latest commits on github to see how it works. (github.com/jekkos/opensourcepos)
implementation done and will be included in 2.3.1 (see github)
Thanks for the update, I will keep an eye on 2.3.1 :)