diff --git a/application/controllers/Config.php b/application/controllers/Config.php
index 1859c9ce5..221657c9d 100644
--- a/application/controllers/Config.php
+++ b/application/controllers/Config.php
@@ -78,6 +78,7 @@ class Config extends Secure_area
'thousands_separator'=>$this->input->post('thousands_separator'),
'decimal_point'=>$this->input->post('decimal_point'),
'currency_decimals'=>$this->input->post('currency_decimals'),
+ 'tax_decimals'=>$this->input->post('tax_decimals'),
'quantity_decimals'=>$this->input->post('quantity_decimals')
);
diff --git a/application/controllers/Receivings.php b/application/controllers/Receivings.php
index a2225e237..2d067a6aa 100644
--- a/application/controllers/Receivings.php
+++ b/application/controllers/Receivings.php
@@ -75,7 +75,7 @@ class Receivings extends Secure_area
$data=array();
$mode = $this->receiving_lib->get_mode();
$item_id_or_number_or_item_kit_or_receipt = $this->input->post('item');
- $quantity = ($mode=="receive" or $mode=="requisition") ? 1:-1;
+ $quantity = ($mode=="receive" or $mode=="requisition") ? 1 : -1;
$item_location = $this->receiving_lib->get_stock_source();
if($mode=='return' && $this->receiving_lib->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
{
@@ -110,7 +110,7 @@ class Receivings extends Secure_area
if ($this->form_validation->run() != FALSE)
{
- $this->receiving_lib->edit_item($item_id,$description,$serialnumber,$quantity,$discount,$price);
+ $this->receiving_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $price);
}
else
{
@@ -191,7 +191,7 @@ class Receivings extends Secure_area
if ( $this->input->post('amount_tendered') != null )
{
$data['amount_tendered'] = $this->input->post('amount_tendered');
- $data['amount_change'] = to_currency($data['amount_tendered'] - round($data['total'], 2));
+ $data['amount_change'] = to_currency($data['amount_tendered'] - $data['total']);
}
$data['employee']=$emp_info->first_name.' '.$emp_info->last_name;
$suppl_info ='';
@@ -244,7 +244,6 @@ class Receivings extends Secure_area
$text=$this->_substitute_supplier($text, $supplier_info);
return $text;
}
-
private function _substitute_supplier($text,$supplier_info)
{
@@ -399,7 +398,7 @@ class Receivings extends Secure_area
{
$receiving_id=$this->input->post('receiving_id');
$invoice_number=$this->input->post('invoice_number');
- $exists=!empty($invoice_number) && $this->Receiving->invoice_number_exists($invoice_number,$receiving_id);
+ $exists=!empty($invoice_number) && $this->Receiving->invoice_number_exists($invoice_number, $receiving_id);
echo !$exists ? 'true' : 'false';
}
}
diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php
index 5600721ab..c9caeefb1 100644
--- a/application/controllers/Reports.php
+++ b/application/controllers/Reports.php
@@ -103,7 +103,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
- $tabular_data[] = array($row['sale_date'], to_quantity($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
+ $tabular_data[] = 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['cost']), to_currency($row['profit']));
}
$data = array(
@@ -128,7 +128,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
- $tabular_data[] = array($row['category'], to_quantity($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
+ $tabular_data[] = array($row['category'], to_quantity_decimals($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -153,7 +153,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
- $tabular_data[] = array($row['customer'], to_quantity($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
+ $tabular_data[] = array($row['customer'], to_quantity_decimals($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -178,7 +178,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
- $tabular_data[] = array($row['supplier'], to_quantity($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
+ $tabular_data[] = array($row['supplier'], to_quantity_decimals($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -203,7 +203,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
- $tabular_data[] = array(character_limiter($row['name'], 40), to_quantity($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
+ $tabular_data[] = array(character_limiter($row['name'], 40), to_quantity_decimals($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -228,7 +228,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
- $tabular_data[] = array($row['employee'], to_quantity($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
+ $tabular_data[] = array($row['employee'], to_quantity_decimals($row['quantity_purchased']), to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -718,11 +718,11 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
- $summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], to_quantity($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[] = 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']);
foreach($report_data['details'][$key] as $drow)
{
- $details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity($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[$key][] = 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'].'%');
}
}
@@ -768,11 +768,11 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
- $summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], to_quantity($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[] = 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']);
foreach($report_data['details'][$key] as $drow)
{
- $details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity($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[$key][] = 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'].'%');
}
}
@@ -818,11 +818,11 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
- $summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], to_quantity($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[] = 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']);
foreach($report_data['details'][$key] as $drow)
{
- $details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']),/*to_currency($drow['profit']),*/ $drow['discount_percent'].'%');
+ $details_data[$key][] = 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'].'%');
}
}
@@ -856,11 +856,11 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
- $summary_data[] = array(anchor('sales/edit/'.$row['sale_id'], 'POS '.$row['sale_id'], array('class' => 'modal-dlg modal-btn-submit')), $row['sale_date'], to_quantity($row['items_purchased']), $row['employee_name'], $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[] = array(anchor('sales/edit/'.$row['sale_id'], 'POS '.$row['sale_id'], array('class' => 'modal-dlg modal-btn-submit')), $row['sale_date'], to_quantity_decimals($row['items_purchased']), $row['employee_name'], $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']);
foreach($report_data['details'][$key] as $drow)
{
- $quantity_purchased = to_quantity($drow['quantity_purchased']);
+ $quantity_purchased = to_quantity_decimals($drow['quantity_purchased']);
if ($show_locations)
{
$quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
@@ -899,11 +899,11 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
- $summary_data[] = array(anchor('receivings/edit/'.$row['receiving_id'], 'RECV '.$row['receiving_id'], array('class' => 'modal-dlg modal-btn-delete modal-btn-submit')), $row['receiving_date'], to_quantity($row['items_purchased']), $row['employee_name'], $row['supplier_name'], to_currency($row['total']), $row['payment_type'], $row['invoice_number'], $row['comment']);
+ $summary_data[] = array(anchor('receivings/edit/'.$row['receiving_id'], 'RECV '.$row['receiving_id'], array('class' => 'modal-dlg modal-btn-delete modal-btn-submit')), $row['receiving_date'], to_quantity_decimals($row['items_purchased']), $row['employee_name'], $row['supplier_name'], to_currency($row['total']), $row['payment_type'], $row['invoice_number'], $row['comment']);
foreach($report_data['details'][$key] as $drow)
{
- $quantity_purchased = $drow['receiving_quantity'] > 1 ? to_quantity($drow['quantity_purchased']) . ' x ' . to_quantity($drow['receiving_quantity']) : to_quantity($drow['quantity_purchased']);
+ $quantity_purchased = $drow['receiving_quantity'] > 1 ? to_quantity_decimals($drow['quantity_purchased']) . ' x ' . to_quantity_decimals($drow['receiving_quantity']) : to_quantity_decimals($drow['quantity_purchased']);
if ($show_locations)
{
$quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
diff --git a/application/helpers/locale_helper.php b/application/helpers/locale_helper.php
index 48bec9a41..c13044b73 100644
--- a/application/helpers/locale_helper.php
+++ b/application/helpers/locale_helper.php
@@ -13,6 +13,12 @@ function to_currency($number, $escape=FALSE)
$thousands_separator = $CI->config->item('thousands_separator') ? $CI->config->item('thousands_separator') : '';
$decimal_point = $CI->config->item('decimal_point') ? $CI->config->item('decimal_point') : '.';
$decimals = $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 0;
+
+ // in case of taxation with 3 decimals, force the currency decimal to be 3 and not max 2 as per db table (this is only used at UI level)
+ if( $CI->config->item('tax_decimals') > $CI->config->item('currency_decimals') )
+ {
+ $decimals = $CI->config->item('tax_decimals');
+ }
if($number >= 0)
{
@@ -42,14 +48,57 @@ function to_currency_no_money($number)
$decimals = $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 0;
+ // in case of taxation with 3 decimals, force the currency decimal to be 3 and not max 2 as per db table (this is only used at UI level)
+ if( $CI->config->item('tax_decimals') > $CI->config->item('currency_decimals') )
+ {
+ $decimals = $CI->config->item('tax_decimals');
+ }
+
return number_format($number, $decimals, '.', '');
}
+function totals_decimals()
+{
+ $CI =& get_instance();
+
+ $decimals = $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 0;
+
+ // in case of taxation with 3 decimals, force the tatals decimal to be 3 so roundings are correct
+ if( $CI->config->item('tax_decimals') > $CI->config->item('currency_decimals') )
+ {
+ $decimals = $CI->config->item('tax_decimals');
+ }
+
+ return $decimals;
+}
+
+
+/*
+ * Tax locale
+ */
+
+function to_tax_decimals($number)
+{
+ // ignore empty strings as they are just for empty input
+ if( empty($number) )
+ {
+ return $number;
+ }
+
+ $CI =& get_instance();
+
+ $decimal_point = $CI->config->item('decimal_point') ? $CI->config->item('decimal_point') : '.';
+ $decimals = $CI->config->item('tax_decimals') ? $CI->config->item('tax_decimals') : 0;
+
+ return number_format($number, $decimals, $decimal_point, '');
+}
+
+
/*
* Quantity decimals
*/
-function to_quantity($number)
+function to_quantity_decimals($number)
{
$CI =& get_instance();
diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php
index c60278005..5f74365ca 100644
--- a/application/helpers/table_helper.php
+++ b/application/helpers/table_helper.php
@@ -326,8 +326,9 @@ function get_item_data_row($item,$controller)
$tax_percents = '';
foreach($item_tax_info as $tax_info)
{
- $tax_percents.=$tax_info['percent']. '%, ';
+ $tax_percents.=to_tax_decimals($tax_info['percent']) . '%, ';
}
+ // remove ', ' from last item
$tax_percents=substr($tax_percents, 0, -2);
$controller_name=strtolower(get_class($CI));
@@ -341,7 +342,7 @@ function get_item_data_row($item,$controller)
$table_data_row.='
'.$item->company_name.' | ';
$table_data_row.=''.to_currency($item->cost_price).' | ';
$table_data_row.=''.to_currency($item->unit_price).' | ';
- $table_data_row.=''.to_quantity($item->quantity).' | ';
+ $table_data_row.=''.to_quantity_decimals($item->quantity).' | ';
$table_data_row.=''.$tax_percents.' | ';
$image = '';
if (!empty($item->pic_id))
diff --git a/application/language/de-CH/config_lang.php b/application/language/de-CH/config_lang.php
index df87bf318..aa87f8965 100644
--- a/application/language/de-CH/config_lang.php
+++ b/application/language/de-CH/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Bitte verwenden Sie einen eindeutige
$lang["config_stock_location_invalid_chars"] = "Der Lagerort kann keine Unterstriche enthalten";
$lang["config_stock_location_required"] = "Lagerort Nummer ist erforderlich";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "MWSt inbegriffen";
$lang["config_thousands_separator"] = "Tausendertrennzeichen";
$lang["config_timezone"] = "Zeitzone";
diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php
index 77dc77147..03317c156 100644
--- a/application/language/en/config_lang.php
+++ b/application/language/en/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Please use an unique location name";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "Stock location is a required field";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Tax Included";
$lang["config_thousands_separator"] = "Thousands Separator";
$lang["config_timezone"] = "Timezone";
diff --git a/application/language/es/config_lang.php b/application/language/es/config_lang.php
index d68612d76..b29dee48f 100644
--- a/application/language/es/config_lang.php
+++ b/application/language/es/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Por favor use un nombre de inventari
$lang["config_stock_location_invalid_chars"] = "Nombre de la Ubicación de Inventario no debe contener '_'";
$lang["config_stock_location_required"] = "Número de Ubicación de Inventario es requerido";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Impuestos incluidos";
$lang["config_thousands_separator"] = "Separador de miles";
$lang["config_timezone"] = "Zona Horaria";
diff --git a/application/language/fr/config_lang.php b/application/language/fr/config_lang.php
index 576fcee7d..37e8699f8 100644
--- a/application/language/fr/config_lang.php
+++ b/application/language/fr/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Please use an unique location name";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "Stock location number is a required field";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Tax Included";
$lang["config_thousands_separator"] = "Thousands Separator";
$lang["config_timezone"] = "Fuseau Horaire";
diff --git a/application/language/hu-HU/config_lang.php b/application/language/hu-HU/config_lang.php
index d88e4ba18..f38547f68 100644
--- a/application/language/hu-HU/config_lang.php
+++ b/application/language/hu-HU/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Kérem egyedi helyszin nevet haszná
$lang["config_stock_location_invalid_chars"] = "A bolt helyének neve nem tartalmazhat '_' karaktert";
$lang["config_stock_location_required"] = "Bolt helyszín szám kötelező mező";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Adókat tartalmaz";
$lang["config_thousands_separator"] = "Ezres elválasztó";
$lang["config_timezone"] = "Időzóna";
diff --git a/application/language/id/config_lang.php b/application/language/id/config_lang.php
index 04c8a070f..5aff04fe1 100644
--- a/application/language/id/config_lang.php
+++ b/application/language/id/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Please use an unique location name";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "Stock location number is a required field";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Dikenakan Pajak";
$lang["config_thousands_separator"] = "Pemisah Ribuan";
$lang["config_timezone"] = "Zona Waktu";
diff --git a/application/language/nl-BE/config_lang.php b/application/language/nl-BE/config_lang.php
index 4589224bb..6ce09e09f 100755
--- a/application/language/nl-BE/config_lang.php
+++ b/application/language/nl-BE/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Vul een unieke naam in";
$lang["config_stock_location_invalid_chars"] = "De bedrijfsnaam moet ingevuld worden";
$lang["config_stock_location_required"] = "Naam van de stock locatie is een verplicht veld";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "VAT Inbegrepen";
$lang["config_thousands_separator"] = "Thousands Separator";
$lang["config_timezone"] = "Tijdzone";
diff --git a/application/language/ru/config_lang.php b/application/language/ru/config_lang.php
index a2900e81d..f6a464db6 100644
--- a/application/language/ru/config_lang.php
+++ b/application/language/ru/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Please use an unique location name";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "Stock location number is a required field";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Tax Included";
$lang["config_thousands_separator"] = "Thousands Separator";
$lang["config_timezone"] = "Часовой пояс";
diff --git a/application/language/th/config_lang.php b/application/language/th/config_lang.php
index 32da3918b..65fcb5ef6 100644
--- a/application/language/th/config_lang.php
+++ b/application/language/th/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "จำเป็นต้องระบุสถานที่เก็บ";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "รวมภาษีแล้ว";
$lang["config_thousands_separator"] = "ตัวคั่นหลักพัน";
$lang["config_timezone"] = "โซนเวลา";
diff --git a/application/language/tr/config_lang.php b/application/language/tr/config_lang.php
index 35dbc6056..9333f19cf 100644
--- a/application/language/tr/config_lang.php
+++ b/application/language/tr/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Please use an unique location name";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "Mağaza Yeri numarası zorunlu alandır";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Tax Included";
$lang["config_thousands_separator"] = "Thousands Separator";
$lang["config_timezone"] = "Saat Dilimi";
diff --git a/application/language/zh/config_lang.php b/application/language/zh/config_lang.php
index 2e37cf52f..4f2f6015a 100755
--- a/application/language/zh/config_lang.php
+++ b/application/language/zh/config_lang.php
@@ -118,6 +118,7 @@ $lang["config_stock_location_duplicate"] = "Please use an unique location name";
$lang["config_stock_location_invalid_chars"] = "The stock location name can not contain '_'";
$lang["config_stock_location_required"] = "Stock location number is a required field";
$lang["config_takings_printer"] = "Takings Printer";
+$lang["config_tax_decimals"] = "Tax Decimals";
$lang["config_tax_included"] = "Tax Included";
$lang["config_thousands_separator"] = "Thousands Separator";
$lang["config_timezone"] = "時區";
diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php
index fa21d14f2..e0c6af192 100644
--- a/application/libraries/Sale_lib.php
+++ b/application/libraries/Sale_lib.php
@@ -565,14 +565,14 @@ class Sale_lib
foreach($tax_info as $tax)
{
- $name = $tax['percent'].'% ' . $tax['name'];
- $tax_percentage = $tax['percent'];
- $tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $tax_percentage);
+ $name = to_tax_decimals($tax['percent']) . '% ' . $tax['name'];
+ $tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $tax['percent']);
if (!isset($taxes[$name]))
{
$taxes[$name] = 0;
}
+
$taxes[$name] = bcadd($taxes[$name], $tax_amount, PRECISION);
}
}
diff --git a/application/models/Sale.php b/application/models/Sale.php
index c5bd1788f..5f5d2eb92 100644
--- a/application/models/Sale.php
+++ b/application/models/Sale.php
@@ -5,8 +5,8 @@ class Sale extends CI_Model
{
$this->db->select('first_name, last_name, email, comment, sale_payment_amount AS amount_tendered, payment_type,
invoice_number, sale_time, employee_id, customer_id, comments, sale_id, (sale_payment_amount - total) AS change_due', FALSE);
- $this->db->select('DATE_FORMAT( sale_time, "%d-%m-%Y" ) AS sale_date', FALSE);
- $this->db->select('CONCAT(first_name," ", last_name) AS customer_name', FALSE);
+ $this->db->select('DATE_FORMAT(sale_time, "%d-%m-%Y") AS sale_date', FALSE);
+ $this->db->select('CONCAT(first_name, " ", last_name) AS customer_name', FALSE);
$this->db->select('SUM(item_unit_price * quantity_purchased * (1 - discount_percent / 100)) AS amount_due');
$this->db->from('sales_items_temp');
$this->db->join('people', 'people.person_id = sales_items_temp.customer_id', 'left');
@@ -32,7 +32,7 @@ class Sale extends CI_Model
public function search($search, $filters, $rows=0, $limit_from=0)
{
$this->db->select('sale_id, sale_date, sale_time, SUM(quantity_purchased) AS items_purchased,
- CONCAT(customer.first_name," ",customer.last_name) AS customer_name,
+ CONCAT(customer.first_name, " ", customer.last_name) AS customer_name,
SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit,
sale_payment_amount AS amount_tendered, SUM(total) AS amount_due, (sale_payment_amount - SUM(total)) AS change_due,
payment_type, invoice_number', FALSE);
@@ -264,7 +264,7 @@ class Sale extends CI_Model
'invoice_number'=>$invoice_number
);
- //Run these queries as a transaction, we want to make sure we do all or nothing
+ // Run these queries as a transaction, we want to make sure we do all or nothing
$this->db->trans_start();
$this->db->insert('sales',$sales_data);
@@ -274,7 +274,7 @@ class Sale extends CI_Model
{
if ( substr( $payment['payment_type'], 0, strlen( $this->lang->line('sales_giftcard') ) ) == $this->lang->line('sales_giftcard') )
{
- /* We have a gift card and we have to deduct the used value from the total value of the card. */
+ // We have a gift card and we have to deduct the used value from the total value of the card.
$splitpayment = explode( ':', $payment['payment_type'] );
$cur_giftcard_value = $this->Giftcard->get_giftcard_value( $splitpayment[1] );
$this->Giftcard->update_giftcard_value( $splitpayment[1], $cur_giftcard_value - $payment['payment_amount'] );
@@ -389,7 +389,6 @@ class Sale extends CI_Model
'trans_comment'=>'Deleting sale ' . $sale_id,
'trans_location'=>$item['item_location'],
'trans_inventory'=>$item['quantity_purchased']
-
);
// update inventory
$this->Inventory->insert($inv_data);
@@ -448,7 +447,7 @@ class Sale extends CI_Model
public function get_giftcard_value( $giftcardNumber )
{
- if ( !$this->Giftcard->exists( $this->Giftcard->get_giftcard_id($giftcardNumber) ) )
+ if ( !$this->Giftcard->exists($this->Giftcard->get_giftcard_id($giftcardNumber)) )
{
return 0;
}
@@ -474,20 +473,22 @@ class Sale extends CI_Model
$total = "(1+(SUM(percent/100)))";
$subtotal = "1";
}
+
+ $decimals = totals_decimals();
$this->db->query("CREATE TEMPORARY TABLE IF NOT EXISTS ".$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, payments.sale_payment_amount, item_location, 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, ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$subtotal,2) as subtotal,
+ discount_percent, ROUND((item_unit_price * quantity_purchased-item_unit_price * quantity_purchased * discount_percent / 100) * $subtotal, $decimals) as subtotal,
".$this->db->dbprefix('sales_items').".line as line, serialnumber, ".$this->db->dbprefix('sales_items').".description as description,
- 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,
- (item_cost_price*quantity_purchased) as cost,
+ ROUND((item_unit_price * quantity_purchased-item_unit_price * quantity_purchased * discount_percent / 100) * $total, $decimals) as total,
+ ROUND((item_unit_price * quantity_purchased-item_unit_price * quantity_purchased * discount_percent / 100) * $tax, $decimals) as tax,
+ ROUND((item_unit_price * quantity_purchased-item_unit_price * quantity_purchased * discount_percent / 100)- (item_cost_price*quantity_purchased), $decimals) as profit,
+ (item_cost_price * quantity_purchased) as cost,
invoice_number
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'."
+ 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'."
INNER JOIN (SELECT sale_id, SUM(payment_amount) AS sale_payment_amount,
GROUP_CONCAT(CONCAT(payment_type,' ',payment_amount) SEPARATOR ', ') AS payment_type FROM " . $this->db->dbprefix('sales_payments') . " GROUP BY sale_id) AS payments
ON " . $this->db->dbprefix('sales_items') . '.sale_id'. "=" . "payments.sale_id
diff --git a/application/models/reports/Summary_taxes.php b/application/models/reports/Summary_taxes.php
index 7322e6ea2..3ab456747 100644
--- a/application/models/reports/Summary_taxes.php
+++ b/application/models/reports/Summary_taxes.php
@@ -36,12 +36,14 @@ class Summary_taxes extends Report
$total = "(1+(percent/100))";
$subtotal = "1";
}
+
+ $decimals = totals_decimals();
$query = $this->db->query("SELECT percent, count(*) as count, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax
- FROM (SELECT name, CONCAT( percent, '%' ) AS percent,
- 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 (SELECT name, CONCAT(ROUND(percent, $decimals), '%') AS percent,
+ ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $subtotal, $decimals) AS subtotal,
+ ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $total, $decimals) AS total,
+ ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $tax, $decimals) 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 "
diff --git a/application/views/configs/general_config.php b/application/views/configs/general_config.php
index 0f0508bc5..4db3d6658 100644
--- a/application/views/configs/general_config.php
+++ b/application/views/configs/general_config.php
@@ -118,7 +118,7 @@
'name'=>'default_tax_1_rate',
'id'=>'default_tax_1_rate',
'class'=>'form-control input-sm required',
- 'value'=>$this->config->item('default_tax_1_rate')));?>
+ 'value'=>to_tax_decimals($this->config->item('default_tax_1_rate'))));?>
%
@@ -137,7 +137,7 @@
'name'=>'default_tax_2_rate',
'id'=>'default_tax_2_rate',
'class'=>'form-control input-sm',
- 'value'=>$this->config->item('default_tax_2_rate')));?>
+ 'value'=>to_tax_decimals($this->config->item('default_tax_2_rate'))));?>
%
diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php
index dbfd74b35..ca4d912f0 100644
--- a/application/views/configs/locale_config.php
+++ b/application/views/configs/locale_config.php
@@ -38,6 +38,20 @@
+
+
diff --git a/application/views/items/form.php b/application/views/items/form.php
index 35bc7e2ff..6d57c189f 100644
--- a/application/views/items/form.php
+++ b/application/views/items/form.php
@@ -99,7 +99,7 @@
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_1',
'class'=>'form-control input-sm',
- 'value'=>isset($item_tax_info[0]['percent']) ? $item_tax_info[0]['percent'] : $default_tax_1_rate)
+ 'value'=>isset($item_tax_info[0]['percent']) ? to_tax_decimals($item_tax_info[0]['percent']) : to_tax_decimals($default_tax_1_rate))
);?>
%
@@ -122,7 +122,7 @@
'name'=>'tax_percents[]',
'class'=>'form-control input-sm',
'id'=>'tax_percent_name_2',
- 'value'=>isset($item_tax_info[1]['percent']) ? $item_tax_info[1]['percent'] : $default_tax_2_rate)
+ 'value'=>isset($item_tax_info[1]['percent']) ? to_tax_decimals($item_tax_info[1]['percent']) : to_tax_decimals($default_tax_2_rate))
);?>
%
@@ -140,7 +140,7 @@
'name'=>'quantity_' . $key,
'id'=>'quantity_' . $key,
'class'=>'required quantity form-control',
- 'value'=>isset($item_info->item_id) ? to_quantity($location_detail['quantity']) : to_quantity(0))
+ 'value'=>isset($item_info->item_id) ? to_quantity_decimals($location_detail['quantity']) : to_quantity_decimals(0))
);?>
@@ -155,7 +155,7 @@
'name'=>'receiving_quantity',
'id'=>'receiving_quantity',
'class'=>'required form-control input-sm',
- 'value'=>isset($item_info->item_id) ? to_quantity($item_info->receiving_quantity) : to_quantity(0))
+ 'value'=>isset($item_info->item_id) ? to_quantity_decimals($item_info->receiving_quantity) : to_quantity_decimals(0))
);?>
@@ -167,7 +167,7 @@
'name'=>'reorder_level',
'id'=>'reorder_level',
'class'=>'form-control input-sm',
- 'value'=>isset($item_info->item_id) ? to_quantity($item_info->reorder_level) : to_quantity(0))
+ 'value'=>isset($item_info->item_id) ? to_quantity_decimals($item_info->reorder_level) : to_quantity_decimals(0))
);?>
diff --git a/application/views/items/form_bulk.php b/application/views/items/form_bulk.php
index faafc45f3..677b08832 100644
--- a/application/views/items/form_bulk.php
+++ b/application/views/items/form_bulk.php
@@ -80,7 +80,7 @@
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_1',
'class'=>'form-control input-sm',
- 'value'=>$this->config->item('default_tax_1_rate'))
+ 'value'=>to_tax_decimals($this->config->item('default_tax_1_rate')))
);?>
%
@@ -103,7 +103,7 @@
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_2',
'class'=>'form-control input-sm',
- 'value'=>$this->config->item('default_tax_2_rate'))
+ 'value'=>to_tax_decimals($this->config->item('default_tax_2_rate')))
);?>
%
diff --git a/application/views/items/inventory.php b/application/views/items/inventory.php
index bca48e1d6..908676f3b 100644
--- a/application/views/items/inventory.php
+++ b/application/views/items/inventory.php
@@ -64,7 +64,7 @@
'id'=>'quantity',
'class'=>'form-control input-sm',
'disabled'=>'',
- 'value'=>to_quantity(current($item_quantities)))
+ 'value'=>to_quantity_decimals(current($item_quantities)))
); ?>
diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php
index 44e2da0c3..668c4264d 100644
--- a/application/views/receivings/receipt.php
+++ b/application/views/receivings/receipt.php
@@ -73,8 +73,8 @@ if (isset($error_message))
|
|
- x |
+ x |
|
diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php
index 53851a3a3..f7b517ee2 100644
--- a/application/views/receivings/receiving.php
+++ b/application/views/receivings/receiving.php
@@ -119,7 +119,7 @@ if (isset($error))
| ');?> |
-
+
|
@@ -141,12 +141,12 @@ if (isset($error))
}
?>
- 'quantity', 'class'=>'form-control input-sm', 'value'=>to_quantity($item['quantity']))); ?> |
+ 'quantity', 'class'=>'form-control input-sm', 'value'=>to_quantity_decimals($item['quantity']))); ?> |
1)
{
?>
- |
+ |
|
|
- |
+ |
|
|
|
diff --git a/application/views/sales/invoice_email.php b/application/views/sales/invoice_email.php
index 8c7faec72..89c6c156e 100644
--- a/application/views/sales/invoice_email.php
+++ b/application/views/sales/invoice_email.php
@@ -86,7 +86,7 @@ if (isset($error_message))
|
|
- |
+ |
|
|
|
diff --git a/application/views/sales/receipt.php b/application/views/sales/receipt.php
index 5c288ec85..955d45854 100644
--- a/application/views/sales/receipt.php
+++ b/application/views/sales/receipt.php
@@ -76,7 +76,7 @@ if (isset($error_message))
|
|
- |
+ |
Appconfig->get('show_total_discount') ? 'total' : 'discounted_total')]); ?> |
diff --git a/application/views/sales/receipt_email.php b/application/views/sales/receipt_email.php
index dd695050a..5e81d263b 100644
--- a/application/views/sales/receipt_email.php
+++ b/application/views/sales/receipt_email.php
@@ -36,7 +36,7 @@
|
|
|
- |
+ |
|
|
diff --git a/application/views/sales/register.php b/application/views/sales/register.php
index f00edd1b2..2699b4223 100644
--- a/application/views/sales/register.php
+++ b/application/views/sales/register.php
@@ -126,7 +126,7 @@ if (isset($success))
');?> |
|
-
+
|
@@ -152,12 +152,12 @@ if (isset($success))
'quantity', 'class'=>'form-control input-sm', 'value'=>to_quantity($item['quantity']), 'tabindex'=>$tabindex));
+ echo form_input(array('name'=>'quantity', 'class'=>'form-control input-sm', 'value'=>to_quantity_decimals($item['quantity']), 'tabindex'=>$tabindex));
}
?>
diff --git a/database/2.4_to_3.0.sql b/database/2.4_to_3.0.sql
index 7ac6841ef..a7909ccc7 100644
--- a/database/2.4_to_3.0.sql
+++ b/database/2.4_to_3.0.sql
@@ -18,4 +18,15 @@ ALTER TABLE `ospos_sales_items`
MODIFY COLUMN `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0';
ALTER TABLE `ospos_sales_suspended_items`
- MODIFY COLUMN `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0';
\ No newline at end of file
+ MODIFY COLUMN `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0';
+
+ALTER TABLE `ospos_sales_items_taxes`
+ MODIFY COLUMN `percent` decimal(15,3) NOT NULL;
+
+ALTER TABLE `ospos_sales_suspended_items_taxes`
+ MODIFY COLUMN `percent` decimal(15,3) NOT NULL;
+
+ALTER TABLE `ospos_items_taxes`
+ MODIFY COLUMN `percent` decimal(15,3) NOT NULL;
+
+
\ No newline at end of file
diff --git a/database/tables.sql b/database/tables.sql
index 9fbabfa73..99f094c8a 100644
--- a/database/tables.sql
+++ b/database/tables.sql
@@ -203,7 +203,7 @@ CREATE TABLE `ospos_items` (
CREATE TABLE `ospos_items_taxes` (
`item_id` int(10) NOT NULL,
`name` varchar(255) NOT NULL,
- `percent` decimal(15,2) NOT NULL,
+ `percent` decimal(15,3) NOT NULL,
PRIMARY KEY (`item_id`,`name`,`percent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -528,7 +528,7 @@ CREATE TABLE `ospos_sales_items_taxes` (
`item_id` int(10) NOT NULL,
`line` int(3) NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL,
- `percent` decimal(15,2) NOT NULL,
+ `percent` decimal(15,3) NOT NULL,
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
KEY `sale_id` (`sale_id`),
KEY `item_id` (`item_id`)
@@ -619,7 +619,7 @@ CREATE TABLE `ospos_sales_suspended_items_taxes` (
`item_id` int(10) NOT NULL,
`line` int(3) NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL,
- `percent` decimal(15,2) NOT NULL,
+ `percent` decimal(15,3) NOT NULL,
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
KEY `item_id` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/translations/config_lang.csv b/translations/config_lang.csv
index cc170848a..154fbebcf 100644
--- a/translations/config_lang.csv
+++ b/translations/config_lang.csv
@@ -117,6 +117,7 @@ config_stock_location_duplicate,Kérem egyedi helyszin nevet használjon,Bitte v
config_stock_location_invalid_chars,A bolt helyének neve nem tartalmazhat '_' karaktert,Der Lagerort kann keine Unterstriche enthalten,De bedrijfsnaam moet ingevuld worden,Nombre de la Ubicación de Inventario no debe contener '_',The stock location name can not contain '_',The stock location name can not contain '_',The stock location name can not contain '_',The stock location name can not contain '_',The stock location name can not contain '_',The stock location name can not contain '_',The stock location name can not contain '_'
config_stock_location_required,Bolt helyszín szám kötelező mező,Lagerort Nummer ist erforderlich,Naam van de stock locatie is een verplicht veld,Número de Ubicación de Inventario es requerido,Stock location is a required field,Stock location number is a required field,Stock location number is a required field,Stock location number is a required field,จำเป็นต้องระบุสถานที่เก็บ,Mağaza Yeri numarası zorunlu alandır,Stock location number is a required field
config_takings_printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer,Takings Printer
+config_tax_decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals,Tax Decimals
config_tax_included,Adókat tartalmaz,MWSt inbegriffen,VAT Inbegrepen,Impuestos incluidos,Tax Included,Tax Included,Tax Included,Tax Included,รวมภาษีแล้ว,Tax Included,Dikenakan Pajak
config_thousands_separator,Ezres elválasztó,Tausendertrennzeichen,Thousands Separator,Separador de miles,Thousands Separator,Thousands Separator,Thousands Separator,Thousands Separator,ตัวคั่นหลักพัน,Thousands Separator,Pemisah Ribuan
config_timezone,Időzóna,Zeitzone,Tijdzone,Zona Horaria,Timezone,Fuseau Horaire,時區,Часовой пояс,โซนเวลา,Saat Dilimi,Zona Waktu