mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-15 12:32:33 -04:00
Discount on Sales
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
|
||||
|
|
||||
*/
|
||||
$config['application_version'] = '3.3.0';
|
||||
$config['application_version'] = '3.4.0';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -60,6 +60,7 @@ $route['sales/index/([^/]+)/([^/]+)/([^/]+)'] = 'sales/manage/$1/$2/$3';
|
||||
|
||||
$route['reports/(summary_:any)/([^/]+)/([^/]+)'] = 'reports/$1/$2/$3/$4';
|
||||
$route['reports/summary_expenses_categories'] = 'reports/date_input_only';
|
||||
$route['reports/summary_discounts'] = 'reports/summary_discounts_input';
|
||||
$route['reports/summary_:any'] = 'reports/date_input';
|
||||
|
||||
$route['reports/(graphical_:any)/([^/]+)/([^/]+)'] = 'reports/$1/$2/$3/$4';
|
||||
|
||||
@@ -285,7 +285,9 @@ class Config extends Secure_Controller
|
||||
{
|
||||
$batch_save_data = array(
|
||||
'theme' => $this->input->post('theme'),
|
||||
'default_sales_discount_type' => $this->input->post('default_sales_discount_type') != NULL,
|
||||
'default_sales_discount' => $this->input->post('default_sales_discount'),
|
||||
'default_sales_discount_fixed' => $this->input->post('default_sales_discount_fixed'),
|
||||
'enforce_privacy' => $this->input->post('enforce_privacy'),
|
||||
'receiving_calculate_average_price' => $this->input->post('receiving_calculate_average_price') != NULL,
|
||||
'lines_per_page' => $this->input->post('lines_per_page'),
|
||||
|
||||
@@ -249,6 +249,7 @@ class Customers extends Persons
|
||||
'account_number' => $this->input->post('account_number') == '' ? NULL : $this->input->post('account_number'),
|
||||
'company_name' => $this->input->post('company_name') == '' ? NULL : $this->input->post('company_name'),
|
||||
'discount_percent' => $this->input->post('discount_percent') == '' ? 0.00 : $this->input->post('discount_percent'),
|
||||
'discount_fixed' => $this->input->post('discount_fixed') == '' ? 0.00 : $this->input->post('discount_fixed'),
|
||||
'package_id' => $this->input->post('package_id') == '' ? NULL : $this->input->post('package_id'),
|
||||
'taxable' => $this->input->post('taxable') != NULL,
|
||||
'date' => $date_formatter->format('Y-m-d H:i:s'),
|
||||
@@ -404,7 +405,8 @@ class Customers extends Persons
|
||||
'consent' => $consent,
|
||||
'company_name' => $data[13],
|
||||
'discount_percent' => $data[15],
|
||||
'taxable' => $data[16] == '' ? 0 : 1,
|
||||
'discount_fixed' => $data[16],
|
||||
'taxable' => $data[17] == '' ? 0 : 1,
|
||||
'date' => date('Y-m-d H:i:s'),
|
||||
'employee_id' => $this->Employee->get_logged_in_employee_info()->person_id
|
||||
);
|
||||
|
||||
@@ -18,6 +18,7 @@ class Item_kits extends Secure_Controller
|
||||
|
||||
$item_kit->total_cost_price = 0;
|
||||
$item_kit->total_unit_price = (float)$kit_item_info->unit_price;
|
||||
$total_quantity = 0;
|
||||
|
||||
foreach($this->Item_kit_items->get_info($item_kit->item_kit_id) as $item_kit_item)
|
||||
{
|
||||
@@ -32,11 +33,12 @@ class Item_kits extends Secure_Controller
|
||||
if($item_kit->price_option == PRICE_OPTION_ALL || ($item_kit->price_option == PRICE_OPTION_KIT_STOCK && $item_info->stock_type == HAS_STOCK ))
|
||||
{
|
||||
$item_kit->total_unit_price += $item_info->unit_price * $item_kit_item['quantity'];
|
||||
$total_quantity += $item_kit_item['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
$discount_fraction = bcdiv($item_kit->kit_discount_percent, 100);
|
||||
$item_kit->total_unit_price = $item_kit->total_unit_price - round(bcmul($item_kit->total_unit_price, $discount_fraction), totals_decimals(), PHP_ROUND_HALF_UP);
|
||||
$item_kit->total_unit_price = $item_kit->total_unit_price - round(bcadd(bcmul($item_kit->total_unit_price, $discount_fraction),bcmul($item_kit->kit_discount_fixed,$total_quantity)), totals_decimals(), PHP_ROUND_HALF_UP);
|
||||
|
||||
return $item_kit;
|
||||
}
|
||||
@@ -130,6 +132,7 @@ class Item_kits extends Secure_Controller
|
||||
'name' => $this->input->post('name'),
|
||||
'item_id' => $this->input->post('kit_item_id'),
|
||||
'kit_discount_percent' => $this->input->post('kit_discount_percent'),
|
||||
'kit_discount_fixed' => $this->input->post('kit_discount_fixed'),
|
||||
'price_option' => $this->input->post('price_option'),
|
||||
'print_option' => $this->input->post('print_option'),
|
||||
'description' => $this->input->post('description')
|
||||
|
||||
@@ -93,6 +93,7 @@ class Receivings extends Secure_Controller
|
||||
$this->barcode_lib->parse_barcode_fields($quantity, $item_id_or_number_or_item_kit_or_receipt);
|
||||
$quantity = ($mode == 'receive' || $mode == 'requisition') ? $quantity : -$quantity;
|
||||
$item_location = $this->receiving_lib->get_stock_source();
|
||||
$discount_type = $this->config->item('default_sales_discount_type');
|
||||
|
||||
if($mode == 'return' && $this->Receiving->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
|
||||
{
|
||||
@@ -100,9 +101,9 @@ class Receivings extends Secure_Controller
|
||||
}
|
||||
elseif($this->Item_kit->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
|
||||
{
|
||||
$this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location);
|
||||
$this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount_type);
|
||||
}
|
||||
elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location))
|
||||
elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount_type))
|
||||
{
|
||||
$data['error'] = $this->lang->line('receivings_unable_to_add_item');
|
||||
}
|
||||
@@ -123,12 +124,14 @@ class Receivings extends Secure_Controller
|
||||
$price = parse_decimals($this->input->post('price'));
|
||||
$quantity = parse_decimals($this->input->post('quantity'));
|
||||
$discount = parse_decimals($this->input->post('discount'));
|
||||
$discount_fixed = parse_decimals($this->input->post('discount_fixed'));
|
||||
$discount_type = parse_decimals($this->input->post('discount_type'));
|
||||
$item_location = $this->input->post('location');
|
||||
$receiving_quantity = $this->input->post('receiving_quantity');
|
||||
|
||||
if($this->form_validation->run() != FALSE)
|
||||
{
|
||||
$this->receiving_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $price, $receiving_quantity);
|
||||
$this->receiving_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $discount_fixed, $discount_type, $price, $receiving_quantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -264,8 +267,8 @@ class Receivings extends Secure_Controller
|
||||
foreach($this->receiving_lib->get_cart() as $item)
|
||||
{
|
||||
$this->receiving_lib->delete_item($item['line']);
|
||||
$this->receiving_lib->add_item($item['item_id'], $item['quantity'], $this->receiving_lib->get_stock_destination());
|
||||
$this->receiving_lib->add_item($item['item_id'], -$item['quantity'], $this->receiving_lib->get_stock_source());
|
||||
$this->receiving_lib->add_item($item['item_id'], $item['quantity'], $this->receiving_lib->get_stock_destination(), $item['discount_type']);
|
||||
$this->receiving_lib->add_item($item['item_id'], -$item['quantity'], $this->receiving_lib->get_stock_source(), $item['discount_type']);
|
||||
}
|
||||
|
||||
$this->complete();
|
||||
|
||||
@@ -318,10 +318,25 @@ class Reports extends Secure_Controller
|
||||
$this->load->view('reports/tabular', $data);
|
||||
}
|
||||
|
||||
//Summary Discounts report
|
||||
public function summary_discounts($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
public function summary_discounts_input()
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
$data = array();
|
||||
$stock_locations = $data = $this->xss_clean($this->Stock_location->get_allowed_locations('sales'));
|
||||
$stock_locations['all'] = $this->lang->line('reports_all');
|
||||
$data['stock_locations'] = array_reverse($stock_locations, TRUE);
|
||||
$data['mode'] = 'sale';
|
||||
$data['discount_type_options'] = array(
|
||||
'0' => $this->lang->line('reports_discount_percent'),
|
||||
'1'=> $this->lang->line('reports_discount_fixed'));
|
||||
$data['sale_type_options'] = $this->get_sale_type_options();
|
||||
|
||||
$this->load->view('reports/date_input', $data);
|
||||
}
|
||||
|
||||
//Summary Discounts report
|
||||
public function 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,'discount_type'=>$discount_type);
|
||||
|
||||
$this->load->model('reports/Summary_discounts');
|
||||
$model = $this->Summary_discounts;
|
||||
@@ -333,7 +348,7 @@ class Reports extends Secure_Controller
|
||||
foreach($report_data as $row)
|
||||
{
|
||||
$tabular_data[] = $this->xss_clean(array(
|
||||
'discount' => $row['discount_percent'],
|
||||
'discount' => $row['discount'],
|
||||
'count' => $row['count']
|
||||
));
|
||||
}
|
||||
@@ -869,7 +884,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'%'));
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -980,7 +995,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'%'));
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -1018,6 +1033,9 @@ class Reports extends Secure_Controller
|
||||
$discounts[$i] = $i . '%';
|
||||
}
|
||||
$data['specific_input_data'] = $discounts;
|
||||
$data['discount_type_options'] = array(
|
||||
'0' => $this->lang->line('reports_discount_percent'),
|
||||
'1'=> $this->lang->line('reports_discount_fixed'));
|
||||
$data['sale_type_options'] = $this->get_sale_type_options();
|
||||
|
||||
$data = $this->xss_clean($data);
|
||||
@@ -1025,9 +1043,9 @@ class Reports extends Secure_Controller
|
||||
$this->load->view('reports/specific_input', $data);
|
||||
}
|
||||
|
||||
public function specific_discount($start_date, $end_date, $discount, $sale_type)
|
||||
public function specific_discount($start_date, $end_date, $discount, $sale_type, $discount_type)
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type);
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type, 'discount_type' => $discount_type);
|
||||
|
||||
$this->load->model('reports/Specific_discount');
|
||||
$model = $this->Specific_discount;
|
||||
@@ -1085,7 +1103,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'%'));
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -1238,7 +1256,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'%'));
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -1340,7 +1358,7 @@ class Reports extends Secure_Controller
|
||||
$drow['category'],
|
||||
$quantity_purchased,
|
||||
to_currency($drow['total']),
|
||||
$drow['discount_percent'].'%'));
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,11 +137,12 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$this->sale_lib->set_customer($customer_id);
|
||||
$discount_percent = $this->Customer->get_info($customer_id)->discount_percent;
|
||||
$discount_fixed = $this->Customer->get_info($customer_id)->discount_fixed;
|
||||
|
||||
// apply customer default discount to items that have 0 discount
|
||||
if($discount_percent != '')
|
||||
if($discount_percent != '' OR $discount_fixed != '')
|
||||
{
|
||||
$this->sale_lib->apply_customer_discount($discount_percent);
|
||||
$this->sale_lib->apply_customer_discount($discount_percent, $discount_fixed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +368,8 @@ class Sales extends Secure_Controller
|
||||
$data = array();
|
||||
|
||||
$discount = 0;
|
||||
$discount_fixed = 0;
|
||||
$discount_type = $this->config->item('default_sales_discount_type');
|
||||
|
||||
// check if any discount is assigned to the selected customer
|
||||
$customer_id = $this->sale_lib->get_customer();
|
||||
@@ -374,18 +377,31 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
// load the customer discount if any
|
||||
$discount_percent = $this->Customer->get_info($customer_id)->discount_percent;
|
||||
$discount_cash = $this->Customer->get_info($customer_id)->discount_fixed;
|
||||
if($discount_percent != '')
|
||||
{
|
||||
$discount = $discount_percent;
|
||||
$discount_type = 0;
|
||||
}
|
||||
|
||||
if($discount_cash != '')
|
||||
{
|
||||
$discount_fixed = $discount_cash;
|
||||
$discount_type = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// if the customer discount is 0 or no customer is selected apply the default sales discount
|
||||
if($discount == 0)
|
||||
if($discount == 0 )
|
||||
{
|
||||
$discount = $this->config->item('default_sales_discount');
|
||||
}
|
||||
|
||||
if($discount_fixed == 0)
|
||||
{
|
||||
$discount_fixed = $this->config->item('default_sales_discount_fixed');
|
||||
}
|
||||
|
||||
$item_id_or_number_or_item_kit_or_receipt = $this->input->post('item');
|
||||
$this->barcode_lib->parse_barcode_fields($quantity, $item_id_or_number_or_item_kit_or_receipt);
|
||||
$mode = $this->sale_lib->get_mode();
|
||||
@@ -411,12 +427,17 @@ class Sales extends Secure_Controller
|
||||
$discount = $item_kit_info->kit_discount_percent;
|
||||
}
|
||||
|
||||
if($item_kit_info->kit_discount_fixed != 0 && $item_kit_info->kit_discount_fixed > $discount_fixed)
|
||||
{
|
||||
$discount_fixed = $item_kit_info->kit_discount_fixed;
|
||||
}
|
||||
|
||||
$price = NULL;
|
||||
$print_option = PRINT_ALL; // Always include in list of items on invoice
|
||||
|
||||
if(!empty($kit_item_id))
|
||||
{
|
||||
if(!$this->sale_lib->add_item($kit_item_id, $quantity, $item_location, $discount, PRICE_MODE_STANDARD))
|
||||
if(!$this->sale_lib->add_item($kit_item_id, $quantity, $item_location, $discount, $discount_fixed, $discount_type, PRICE_MODE_STANDARD))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
@@ -428,7 +449,7 @@ class Sales extends Secure_Controller
|
||||
|
||||
// Add item kit items to order
|
||||
$stock_warning = NULL;
|
||||
if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $kit_price_option, $kit_print_option, $stock_warning))
|
||||
if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $discount_fixed, $discount_type, $kit_price_option, $kit_print_option, $stock_warning))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
@@ -439,7 +460,7 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$this->sale_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount, PRICE_MODE_STANDARD))
|
||||
if(!$this->sale_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount, $discount_fixed, $discount_type, PRICE_MODE_STANDARD))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
@@ -458,18 +479,22 @@ class Sales extends Secure_Controller
|
||||
$this->form_validation->set_rules('price', 'lang:sales_price', 'required|callback_numeric');
|
||||
$this->form_validation->set_rules('quantity', 'lang:sales_quantity', 'required|callback_numeric');
|
||||
$this->form_validation->set_rules('discount', 'lang:sales_discount', 'required|callback_numeric');
|
||||
$this->form_validation->set_rules('discount_fixed', 'lang:sales_discount', 'required|callback_numeric');
|
||||
|
||||
$description = $this->input->post('description');
|
||||
$serialnumber = $this->input->post('serialnumber');
|
||||
$price = parse_decimals($this->input->post('price'));
|
||||
$quantity = parse_decimals($this->input->post('quantity'));
|
||||
$discount = parse_decimals($this->input->post('discount'));
|
||||
$discount_fixed = parse_decimals($this->input->post('discount_fixed'));
|
||||
$discount_type = $this->input->post('discount_type');
|
||||
|
||||
$item_location = $this->input->post('location');
|
||||
$discounted_total = $this->input->post('discounted_total') != '' ? $this->input->post('discounted_total') : NULL;
|
||||
|
||||
if($this->form_validation->run() != FALSE)
|
||||
{
|
||||
$this->sale_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $price, $discounted_total);
|
||||
$this->sale_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $discount_fixed, $discount_type, $price, $discounted_total);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ $lang["sales_delete_unsuccessful"] = "Sale delete failed.";
|
||||
$lang["sales_description_abbrv"] = "Desc.";
|
||||
$lang["sales_discard"] = "Discard";
|
||||
$lang["sales_discard_quote"] = "";
|
||||
$lang["sales_discount"] = "Disc %";
|
||||
$lang["sales_discount"] = "Disc";
|
||||
$lang["sales_discount_included"] = "% Discount";
|
||||
$lang["sales_discount_short"] = "%";
|
||||
$lang["sales_due"] = "Due";
|
||||
|
||||
@@ -271,3 +271,4 @@ $lang["config_top"] = "Arriba";
|
||||
$lang["config_website"] = "Sitio Web";
|
||||
$lang["config_work_order_enable"] = "Soporte Ordenes de Trabajo";
|
||||
$lang["config_work_order_format"] = "Formato Ordenes de trabajo";
|
||||
$lang["config_default_sales_discount_type"] = "Descuento Fijo en Ventas predeterminado";
|
||||
@@ -121,3 +121,5 @@ $lang["reports_unit_price"] = "Precio de Venta";
|
||||
$lang["reports_used"] = "Puntos usados";
|
||||
$lang["reports_work_orders"] = "Ordenes";
|
||||
$lang["reports_zero_and_less"] = "Cero y negativos";
|
||||
$lang["reports_discount_type"] = "Tipo de Descuento";
|
||||
$lang["reports_discount_fixed"] = "Descuento Fijo";
|
||||
|
||||
@@ -44,7 +44,7 @@ $lang["sales_delete_unsuccessful"] = "Venta no borrada, fallida.";
|
||||
$lang["sales_description_abbrv"] = "Descrp.";
|
||||
$lang["sales_discard"] = "Descartar";
|
||||
$lang["sales_discard_quote"] = "Descartar";
|
||||
$lang["sales_discount"] = "% Descuento";
|
||||
$lang["sales_discount"] = "Descuento";
|
||||
$lang["sales_discount_included"] = "% Descuento";
|
||||
$lang["sales_discount_short"] = "%";
|
||||
$lang["sales_due"] = "Deudado";
|
||||
|
||||
@@ -159,7 +159,7 @@ class Receiving_lib
|
||||
$this->CI->session->unset_userdata('recv_stock_destination');
|
||||
}
|
||||
|
||||
public function add_item($item_id, $quantity = 1, $item_location = NULL, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $include_deleted = FALSE)
|
||||
public function add_item($item_id, $quantity = 1, $item_location = NULL, $discount_type = 0, $discount = 0, $discount_fixed = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $include_deleted = FALSE)
|
||||
{
|
||||
//make sure item exists in database.
|
||||
if(!$this->CI->Item->exists($item_id, $include_deleted))
|
||||
@@ -226,6 +226,10 @@ class Receiving_lib
|
||||
1 => 'x1');
|
||||
}
|
||||
|
||||
if(is_null($receiving_quantity)){
|
||||
$receiving_quantity = $item_info->receiving_quantity;
|
||||
}
|
||||
|
||||
$item = array($insertkey => array(
|
||||
'item_id' => $item_id,
|
||||
'item_location' => $item_location,
|
||||
@@ -238,11 +242,13 @@ class Receiving_lib
|
||||
'is_serialized' => $item_info->is_serialized,
|
||||
'quantity' => $quantity,
|
||||
'discount' => $discount,
|
||||
'discount_fixed' => $discount_fixed,
|
||||
'discount_type' => $discount_type,
|
||||
'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
|
||||
'price' => $price,
|
||||
'receiving_quantity' => $item_info->receiving_quantity,
|
||||
'receiving_quantity' => $receiving_quantity,
|
||||
'receiving_quantity_choices' => $receiving_quantity_choices,
|
||||
'total' => $this->get_item_total($quantity, $price, $discount, $item_info->receiving_quantity)
|
||||
'total' => $this->get_item_total($quantity, $price, $discount, $discount_fixed, $receiving_quantity)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -250,7 +256,7 @@ class Receiving_lib
|
||||
if($itemalreadyinsale)
|
||||
{
|
||||
$items[$updatekey]['quantity'] += $quantity;
|
||||
$items[$updatekey]['total'] = $this->get_item_total($items[$updatekey]['quantity'], $price, $discount, $items[$updatekey]['receiving_quantity']);
|
||||
$items[$updatekey]['total'] = $this->get_item_total($items[$updatekey]['quantity'], $price, $discount, $discount_fixed, $items[$updatekey]['receiving_quantity']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -263,7 +269,7 @@ class Receiving_lib
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $price, $receiving_quantity)
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $discount_fixed, $discount_type, $price, $receiving_quantity)
|
||||
{
|
||||
$items = $this->get_cart();
|
||||
if(isset($items[$line]))
|
||||
@@ -274,8 +280,12 @@ class Receiving_lib
|
||||
$line['quantity'] = $quantity;
|
||||
$line['receiving_quantity'] = $receiving_quantity;
|
||||
$line['discount'] = $discount;
|
||||
$line['discount_fixed'] = $discount_fixed;
|
||||
if(!is_null($discount_type)){
|
||||
$line['discount_type'] = $discount_type;
|
||||
}
|
||||
$line['price'] = $price;
|
||||
$line['total'] = $this->get_item_total($quantity, $price, $discount, $receiving_quantity);
|
||||
$line['total'] = $this->get_item_total($quantity, $price, $discount, $discount_fixed, $receiving_quantity);
|
||||
$this->set_cart($items);
|
||||
}
|
||||
|
||||
@@ -308,13 +318,13 @@ class Receiving_lib
|
||||
|
||||
foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
|
||||
$this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_type, $row->discount_percent, $row->discount_fixed, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
|
||||
}
|
||||
|
||||
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
|
||||
}
|
||||
|
||||
public function add_item_kit($external_item_kit_id, $item_location)
|
||||
public function add_item_kit($external_item_kit_id, $item_location, $discount_type)
|
||||
{
|
||||
//KIT #
|
||||
$pieces = explode(' ',$external_item_kit_id);
|
||||
@@ -322,7 +332,7 @@ class Receiving_lib
|
||||
|
||||
foreach($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
|
||||
{
|
||||
$this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'], $item_location);
|
||||
$this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'], $item_location, $discount_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +343,7 @@ class Receiving_lib
|
||||
|
||||
foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_type, $row->discount_percent, $row->discount_fixed, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
|
||||
}
|
||||
|
||||
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
|
||||
@@ -349,12 +359,12 @@ class Receiving_lib
|
||||
$this->clear_reference();
|
||||
}
|
||||
|
||||
public function get_item_total($quantity, $price, $discount_percentage, $receiving_quantity)
|
||||
public function get_item_total($quantity, $price, $discount_percentage, $discount_fixed, $receiving_quantity)
|
||||
{
|
||||
$extended_quantity = bcmul($quantity, $receiving_quantity);
|
||||
$total = bcmul($extended_quantity, $price);
|
||||
$discount_fraction = bcdiv($discount_percentage, 100);
|
||||
$discount_amount = bcmul($total, $discount_fraction);
|
||||
$discount_amount = bcadd(bcmul($total, $discount_fraction), $discount_fixed);
|
||||
|
||||
return bcsub($total, $discount_amount);
|
||||
}
|
||||
@@ -364,7 +374,7 @@ class Receiving_lib
|
||||
$total = 0;
|
||||
foreach($this->get_cart() as $item)
|
||||
{
|
||||
$total = bcadd($total, $this->get_item_total(($item['quantity']), $item['price'], $item['discount'], $item['receiving_quantity']));
|
||||
$total = bcadd($total, $this->get_item_total(($item['quantity']), $item['price'], $item['discount'], $item['discount_fixed'], $item['receiving_quantity']));
|
||||
}
|
||||
|
||||
return $total;
|
||||
|
||||
@@ -450,7 +450,7 @@ class Sale_lib
|
||||
$item_count++;
|
||||
$total_units += $item['quantity'];
|
||||
}
|
||||
$discount_amount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount']);
|
||||
$discount_amount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed']);
|
||||
$total_discount = bcadd($total_discount, $discount_amount);
|
||||
|
||||
$extended_amount = $this->get_extended_amount($item['quantity'], $item['price']);
|
||||
@@ -460,7 +460,7 @@ class Sale_lib
|
||||
|
||||
if($this->CI->config->item('tax_included'))
|
||||
{
|
||||
$subtotal = bcadd($subtotal, $this->get_extended_total_tax_exclusive($item['item_id'], $extended_discounted_amount, $item['quantity'], $item['price'], $item['discount']));
|
||||
$subtotal = bcadd($subtotal, $this->get_extended_total_tax_exclusive($item['item_id'], $extended_discounted_amount, $item['quantity'], $item['price'], $item['discount'],$item['discount_fixed']));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -696,7 +696,7 @@ class Sale_lib
|
||||
$this->CI->session->unset_userdata('sales_rewards_remainder');
|
||||
}
|
||||
|
||||
public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 0, $price_mode = PRICE_MODE_STANDARD, $kit_price_option = NULL, $kit_print_option = NULL, $price_override = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = NULL )
|
||||
public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 0, $discount_fixed = 0, $discount_type = 0, $price_mode = PRICE_MODE_STANDARD, $kit_price_option = NULL, $kit_print_option = NULL, $price_override = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = NULL )
|
||||
{
|
||||
$item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
|
||||
|
||||
@@ -753,6 +753,7 @@ class Sale_lib
|
||||
if($price == 0.00)
|
||||
{
|
||||
$discount = 0.00;
|
||||
$discount_fixed = 0.00;
|
||||
}
|
||||
|
||||
// Serialization and Description
|
||||
@@ -825,8 +826,8 @@ class Sale_lib
|
||||
}
|
||||
}
|
||||
|
||||
$total = $this->get_item_total($quantity, $price, $discount);
|
||||
$discounted_total = $this->get_item_total($quantity, $price, $discount, TRUE);
|
||||
$total = $this->get_item_total($quantity, $price, $discount, $discount_fixed);
|
||||
$discounted_total = $this->get_item_total($quantity, $price, $discount, $discount_fixed, TRUE);
|
||||
|
||||
if($this->CI->config->item('multi_pack_enabled') == '1')
|
||||
{
|
||||
@@ -850,6 +851,8 @@ class Sale_lib
|
||||
'is_serialized' => $item_info->is_serialized,
|
||||
'quantity' => $quantity,
|
||||
'discount' => $discount,
|
||||
'discount_fixed' => $discount_fixed,
|
||||
'discount_type' => $discount_type,
|
||||
'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
|
||||
'price' => $price,
|
||||
'cost_price' => $cost_price,
|
||||
@@ -933,7 +936,7 @@ class Sale_lib
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $price, $discounted_total=NULL)
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $discount_fixed, $discount_type, $price, $discounted_total=NULL)
|
||||
{
|
||||
$items = $this->get_cart();
|
||||
if(isset($items[$line]))
|
||||
@@ -948,9 +951,13 @@ class Sale_lib
|
||||
$line['serialnumber'] = $serialnumber;
|
||||
$line['quantity'] = $quantity;
|
||||
$line['discount'] = $discount;
|
||||
$line['discount_fixed'] = $discount_fixed;
|
||||
if(!is_null($discount_type)){
|
||||
$line['discount_type'] = $discount_type;
|
||||
}
|
||||
$line['price'] = $price;
|
||||
$line['total'] = $this->get_item_total($quantity, $price, $discount);
|
||||
$line['discounted_total'] = $this->get_item_total($quantity, $price, $discount, TRUE);
|
||||
$line['total'] = $this->get_item_total($quantity, $price, $discount, $discount_fixed);
|
||||
$line['discounted_total'] = $this->get_item_total($quantity, $price, $discount, $discount_fixed, TRUE);
|
||||
$this->set_cart($items);
|
||||
}
|
||||
|
||||
@@ -981,13 +988,13 @@ class Sale_lib
|
||||
|
||||
foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, PRICE_MODE_STANDARD, NULL, NULL, $row->item_unit_price, $row->description, $row->serialnumber, TRUE);
|
||||
$this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->discount_fixed, $row->discount_type, PRICE_MODE_STANDARD, NULL, NULL, $row->item_unit_price, $row->description, $row->serialnumber, TRUE);
|
||||
}
|
||||
|
||||
$this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
|
||||
}
|
||||
|
||||
public function add_item_kit($external_item_kit_id, $item_location, $discount, $kit_price_option, $kit_print_option, &$stock_warning)
|
||||
public function add_item_kit($external_item_kit_id, $item_location, $discount, $discount_fixed, $discount_type, $kit_price_option, $kit_print_option, &$stock_warning)
|
||||
{
|
||||
//KIT #
|
||||
$pieces = explode(' ', $external_item_kit_id);
|
||||
@@ -996,7 +1003,7 @@ class Sale_lib
|
||||
|
||||
foreach($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
|
||||
{
|
||||
$result &= $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount, PRICE_MODE_KIT, $kit_price_option, $kit_print_option, NULL, NULL, NULL, NULL);
|
||||
$result &= $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount, $discount_fixed, $discount_type, PRICE_MODE_KIT, $kit_price_option, $kit_print_option, NULL, NULL, NULL, NULL);
|
||||
|
||||
if($stock_warning == NULL)
|
||||
{
|
||||
@@ -1014,7 +1021,7 @@ class Sale_lib
|
||||
|
||||
foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, PRICE_MODE_STANDARD, NULL, NULL, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->discount_fixed, $row->discount_type, PRICE_MODE_STANDARD, NULL, NULL, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
}
|
||||
|
||||
foreach($this->CI->Sale->get_sale_payments($sale_id)->result() as $row)
|
||||
@@ -1042,7 +1049,7 @@ class Sale_lib
|
||||
$this->empty_cart();
|
||||
foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
|
||||
{
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, PRICE_MODE_STANDARD, NULL, NULL, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->discount_fixed, $row->discount_type, PRICE_MODE_STANDARD, NULL, NULL, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
|
||||
}
|
||||
|
||||
return $this->CI->session->userdata('sales_cart');
|
||||
@@ -1127,12 +1134,12 @@ class Sale_lib
|
||||
// This computes tax for each line item and adds it to the tax type total
|
||||
$tax_group = (float)$tax['percent'] . '% ' . $tax['name'];
|
||||
$tax_type = Tax_lib::TAX_TYPE_VAT;
|
||||
$tax_basis = $this->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
|
||||
$tax_basis = $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed'], TRUE);
|
||||
$tax_amount = 0;
|
||||
|
||||
if($this->CI->config->item('tax_included'))
|
||||
{
|
||||
$tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $tax['percent']);
|
||||
$tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed'], $tax['percent']);
|
||||
}
|
||||
elseif($this->CI->config->item('customer_sales_tax_support') == '0')
|
||||
{
|
||||
@@ -1166,7 +1173,7 @@ class Sale_lib
|
||||
return $sales_taxes;
|
||||
}
|
||||
|
||||
public function apply_customer_discount($discount_percent)
|
||||
public function apply_customer_discount($discount_percent, $discount_fixed)
|
||||
{
|
||||
// Get all items in the cart so far...
|
||||
$items = $this->get_cart();
|
||||
@@ -1180,8 +1187,17 @@ class Sale_lib
|
||||
if($item['discount'] == 0)
|
||||
{
|
||||
$item['discount'] = $discount_percent;
|
||||
$item['total'] = $this->get_item_total($quantity, $price, $discount_percent);
|
||||
$item['discounted_total'] = $this->get_item_total($quantity, $price, $discount_percent, TRUE);
|
||||
$item['discount_fixed'] = $discount_fixed;
|
||||
$item['total'] = $this->get_item_total($quantity, $price, $discount_percent, $discount_fixed);
|
||||
$item['discounted_total'] = $this->get_item_total($quantity, $price, $discount_percent, $discount_fixed, TRUE);
|
||||
}
|
||||
|
||||
if($item['discount_fixed'] == 0)
|
||||
{
|
||||
$item['discount'] = $discount_percent;
|
||||
$item['discount_fixed'] = $discount_fixed;
|
||||
$item['total'] = $this->get_item_total($quantity, $price, $discount_percent, $discount_fixed);
|
||||
$item['discounted_total'] = $this->get_item_total($quantity, $price, $discount_percent, $discount_fixed, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1195,7 +1211,7 @@ class Sale_lib
|
||||
{
|
||||
if($item['discount'] > 0)
|
||||
{
|
||||
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount']);
|
||||
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed']);
|
||||
$discount = bcadd($discount, $item_discount);
|
||||
}
|
||||
}
|
||||
@@ -1208,39 +1224,39 @@ class Sale_lib
|
||||
return $this->calculate_subtotal($include_discount, $exclude_tax);
|
||||
}
|
||||
|
||||
public function get_item_total_tax_exclusive($item_id, $quantity, $price, $discount_percentage, $include_discount = FALSE)
|
||||
public function get_item_total_tax_exclusive($item_id, $quantity, $price, $discount_percentage, $discount_fixed, $include_discount = FALSE)
|
||||
{
|
||||
$tax_info = $this->CI->Item_taxes->get_info($item_id);
|
||||
$item_total = $this->get_item_total($quantity, $price, $discount_percentage, $include_discount);
|
||||
$item_total = $this->get_item_total($quantity, $price, $discount_percentage, $discount_fixed, $include_discount);
|
||||
// only additive tax here
|
||||
foreach($tax_info as $tax)
|
||||
{
|
||||
$tax_percentage = $tax['percent'];
|
||||
$item_total = bcsub($item_total, $this->get_item_tax($quantity, $price, $discount_percentage, $tax_percentage));
|
||||
$item_total = bcsub($item_total, $this->get_item_tax($quantity, $price, $discount_percentage, $discount_fixed, $tax_percentage));
|
||||
}
|
||||
|
||||
return $item_total;
|
||||
}
|
||||
|
||||
public function get_extended_total_tax_exclusive($item_id, $discounted_extended_amount, $quantity, $price, $discount_percentage = 0)
|
||||
public function get_extended_total_tax_exclusive($item_id, $discounted_extended_amount, $quantity, $price, $discount_percentage = 0, $discount_fixed = 0)
|
||||
{
|
||||
$tax_info = $this->CI->Item_taxes->get_info($item_id);
|
||||
// only additive tax here
|
||||
foreach($tax_info as $tax)
|
||||
{
|
||||
$tax_percentage = $tax['percent'];
|
||||
$discounted_extended_amount = bcsub($discounted_extended_amount, $this->get_item_tax($quantity, $price, $discount_percentage, $tax_percentage));
|
||||
$discounted_extended_amount = bcsub($discounted_extended_amount, $this->get_item_tax($quantity, $price, $discount_percentage, $discount_fixed, $tax_percentage));
|
||||
}
|
||||
|
||||
return $discounted_extended_amount;
|
||||
}
|
||||
|
||||
public function get_item_total($quantity, $price, $discount_percentage, $include_discount = FALSE)
|
||||
public function get_item_total($quantity, $price, $discount_percentage, $discount_fixed, $include_discount = FALSE)
|
||||
{
|
||||
$total = bcmul($quantity, $price);
|
||||
if($include_discount)
|
||||
{
|
||||
$discount_amount = $this->get_item_discount($quantity, $price, $discount_percentage);
|
||||
$discount_amount = $this->get_item_discount($quantity, $price, $discount_percentage, $discount_fixed);
|
||||
|
||||
return bcsub($total, $discount_amount);
|
||||
}
|
||||
@@ -1269,17 +1285,20 @@ class Sale_lib
|
||||
return bcsub($extended_amount, $discount_amount);
|
||||
}
|
||||
|
||||
public function get_item_discount($quantity, $price, $discount_percentage)
|
||||
public function get_item_discount($quantity, $price, $discount_percentage, $discount_fixed)
|
||||
{
|
||||
$total = bcmul($quantity, $price);
|
||||
$discount_fraction = bcdiv($discount_percentage, 100);
|
||||
|
||||
return round(bcmul($total, $discount_fraction), totals_decimals(), PHP_ROUND_HALF_UP);
|
||||
$discount_amount=bcadd(bcmul($total, $discount_fraction), $discount_fixed);
|
||||
|
||||
return round($discount_amount, totals_decimals(), PHP_ROUND_HALF_UP);
|
||||
|
||||
}
|
||||
|
||||
public function get_item_tax($quantity, $price, $discount_percentage, $tax_percentage)
|
||||
public function get_item_tax($quantity, $price, $discount_percentage, $discount_fixed, $tax_percentage)
|
||||
{
|
||||
$price = $this->get_item_total($quantity, $price, $discount_percentage, TRUE);
|
||||
$price = $this->get_item_total($quantity, $price, $discount_percentage, $discount_fixed, TRUE);
|
||||
if($this->CI->config->item('tax_included'))
|
||||
{
|
||||
$tax_fraction = bcadd(100, $tax_percentage);
|
||||
@@ -1300,11 +1319,11 @@ class Sale_lib
|
||||
{
|
||||
if($exclude_tax && $this->CI->config->item('tax_included'))
|
||||
{
|
||||
$subtotal = bcadd($subtotal, $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount'], $include_discount));
|
||||
$subtotal = bcadd($subtotal, $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount'], $item['discount_fixed'], $include_discount));
|
||||
}
|
||||
else
|
||||
{
|
||||
$subtotal = bcadd($subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $include_discount));
|
||||
$subtotal = bcadd($subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed'], $include_discount));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
application/migrations/20180820100000_upgrade_to_3_4_0.php
Normal file
20
application/migrations/20180820100000_upgrade_to_3_4_0.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Migration_Upgrade_To_3_4_0 extends CI_Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
execute_script(APPPATH . 'migrations/sqlscripts/3.3.0_to_3.4.0.sql');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
22
application/migrations/sqlscripts/3.3.0_to_3.4.0.sql
Normal file
22
application/migrations/sqlscripts/3.3.0_to_3.4.0.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
--
|
||||
-- Add support for Discount on Sales Fixed
|
||||
--
|
||||
|
||||
INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
|
||||
('default_sales_discount_fixed', '0'),
|
||||
('default_sales_discount_type', '0');
|
||||
|
||||
ALTER TABLE `ospos_item_kits`
|
||||
ADD COLUMN `kit_discount_fixed` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `kit_discount_percent`;
|
||||
|
||||
ALTER TABLE `ospos_customers`
|
||||
ADD COLUMN `discount_fixed` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `discount_percent`;
|
||||
|
||||
|
||||
ALTER TABLE `ospos_sales_items`
|
||||
ADD COLUMN `discount_fixed` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `discount_percent`,
|
||||
ADD COLUMN `discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `discount_fixed`;
|
||||
|
||||
ALTER TABLE `ospos_receivings_items`
|
||||
ADD COLUMN `discount_fixed` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `discount_percent`,
|
||||
ADD COLUMN `discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `discount_fixed`;
|
||||
@@ -59,6 +59,7 @@ class Item_kit extends CI_Model
|
||||
items.description as item_description,
|
||||
item_kits.item_id as kit_item_id,
|
||||
kit_discount_percent,
|
||||
kit_discount_fixed,
|
||||
price_option,
|
||||
print_option,
|
||||
category,
|
||||
|
||||
@@ -94,6 +94,8 @@ class Receiving extends CI_Model
|
||||
'quantity_purchased' => $item['quantity'],
|
||||
'receiving_quantity' => $item['receiving_quantity'],
|
||||
'discount_percent' => $item['discount'],
|
||||
'discount_fixed' => $item['discount_fixed'],
|
||||
'discount_type' => $item['discount_type'],
|
||||
'item_cost_price' => $cur_item_info->cost_price,
|
||||
'item_unit_price' => $item['price'],
|
||||
'item_location' => $item['item_location']
|
||||
@@ -266,12 +268,13 @@ class Receiving extends CI_Model
|
||||
MAX(item_cost_price) AS item_cost_price,
|
||||
MAX(item_unit_price) AS item_unit_price,
|
||||
MAX(discount_percent) AS discount_percent,
|
||||
MAX(discount_fixed) AS discount_fixed,
|
||||
receivings_items.line,
|
||||
MAX(serialnumber) AS serialnumber,
|
||||
MAX(receivings_items.description) AS description,
|
||||
MAX(item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) AS subtotal,
|
||||
MAX(item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) AS total,
|
||||
MAX((item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit,
|
||||
MAX(item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) - discount_fixed AS subtotal,
|
||||
MAX(item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) - discount_fixed AS total,
|
||||
MAX((item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) - discount_fixed - (item_cost_price * quantity_purchased)) AS profit,
|
||||
MAX(item_cost_price * quantity_purchased * receivings_items.receiving_quantity ) AS cost
|
||||
FROM ' . $this->db->dbprefix('receivings_items') . ' AS receivings_items
|
||||
INNER JOIN ' . $this->db->dbprefix('receivings') . ' AS receivings
|
||||
|
||||
@@ -38,7 +38,7 @@ class Sale extends CI_Model
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)-sales_items.discount_fixed';
|
||||
$tax = 'ROUND(IFNULL(SUM(sales_items_taxes.tax), 0), ' . $decimals . ')';
|
||||
|
||||
if($this->config->item('tax_included'))
|
||||
@@ -152,7 +152,7 @@ class Sale extends CI_Model
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)-sales_items.discount_fixed';
|
||||
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
|
||||
|
||||
@@ -653,6 +653,8 @@ class Sale extends CI_Model
|
||||
'serialnumber' => character_limiter($item['serialnumber'], 30),
|
||||
'quantity_purchased'=> $item['quantity'],
|
||||
'discount_percent' => $item['discount'],
|
||||
'discount_fixed' => $item['discount_fixed'],
|
||||
'discount_type' => $item['discount_type'],
|
||||
'item_cost_price' => $item['cost_price'],
|
||||
'item_unit_price' => $item['price'],
|
||||
'item_location' => $item['item_location'],
|
||||
@@ -928,6 +930,8 @@ class Sale extends CI_Model
|
||||
item_cost_price,
|
||||
item_unit_price,
|
||||
discount_percent,
|
||||
discount_fixed,
|
||||
discount_type,
|
||||
item_location,
|
||||
print_option,
|
||||
' . $this->Item->get_item_name('name') . ',
|
||||
@@ -1113,7 +1117,7 @@ class Sale extends CI_Model
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)-sales_items.discount_fixed';
|
||||
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
|
||||
|
||||
@@ -1191,6 +1195,7 @@ class Sale extends CI_Model
|
||||
MAX(sales_items.item_cost_price) AS item_cost_price,
|
||||
MAX(sales_items.item_unit_price) AS item_unit_price,
|
||||
MAX(sales_items.discount_percent) AS discount_percent,
|
||||
MAX(sales_items.discount_fixed) AS discount_fixed,
|
||||
sales_items.line AS line,
|
||||
MAX(sales_items.serialnumber) AS serialnumber,
|
||||
MAX(sales_items.item_location) AS item_location,
|
||||
|
||||
@@ -97,7 +97,7 @@ class Detailed_receivings extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, item_location, receivings_items_temp.receiving_quantity');
|
||||
$this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, discount_fixed, item_location, receivings_items_temp.receiving_quantity');
|
||||
$this->db->from('receivings_items_temp');
|
||||
$this->db->join('items', 'receivings_items_temp.item_id = items.item_id');
|
||||
$this->db->where('receiving_id = '.$value['receiving_id']);
|
||||
|
||||
@@ -144,7 +144,7 @@ class Detailed_sales extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, tax, total, cost, profit, discount_percent, sale_status');
|
||||
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, tax, total, cost, profit, discount_percent, discount_fixed, sale_status');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
|
||||
@@ -127,7 +127,7 @@ class Specific_customer extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent, discount_fixed');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
|
||||
@@ -70,7 +70,12 @@ class Specific_discount extends Report
|
||||
MAX(payment_type) AS payment_type,
|
||||
MAX(comment) AS comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
|
||||
if($inputs['discount_type']==1){
|
||||
$this->db->where('discount_fixed >=', $inputs['discount']);
|
||||
}else{
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
}
|
||||
|
||||
if($inputs['sale_type'] == 'complete')
|
||||
{
|
||||
@@ -119,7 +124,7 @@ class Specific_discount extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent, discount_fixed');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
@@ -136,7 +141,12 @@ class Specific_discount extends Report
|
||||
{
|
||||
$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']);
|
||||
|
||||
if($inputs['discount_type']==1){
|
||||
$this->db->where('discount_fixed >=', $inputs['discount']);
|
||||
}else{
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
}
|
||||
|
||||
if($inputs['sale_type'] == 'complete')
|
||||
{
|
||||
|
||||
@@ -117,7 +117,7 @@ class Specific_employee extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent, discount_fixed');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
|
||||
@@ -13,17 +13,23 @@ class Summary_discounts extends Summary_report
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('MAX(CONCAT(sales_items.discount_percent, "%")) AS discount_percent, count(*) AS count');
|
||||
if($inputs['discount_type']==1){
|
||||
$this->db->select('MAX(CONCAT("'.$this->config->item('currency_symbol').'",sales_items.discount_fixed)) AS discount, count(*) AS count');
|
||||
$this->db->where('discount_fixed > 0');
|
||||
$this->db->group_by('sales_items.discount_fixed');
|
||||
$this->db->order_by('sales_items.discount_fixed');
|
||||
}else{
|
||||
$this->db->select('MAX(CONCAT(sales_items.discount_percent, "%")) AS discount, count(*) AS count');
|
||||
$this->db->where('discount_percent > 0');
|
||||
$this->db->group_by('sales_items.discount_percent');
|
||||
$this->db->order_by('sales_items.discount_percent');
|
||||
}
|
||||
|
||||
$this->db->from('sales_items AS sales_items');
|
||||
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
|
||||
|
||||
$this->db->where('discount_percent > 0');
|
||||
|
||||
$this->_where($inputs);
|
||||
|
||||
$this->db->group_by('sales_items.discount_percent');
|
||||
$this->db->order_by('sales_items.discount_percent');
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class Summary_payments extends Summary_report
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('sales_payments.payment_type, COUNT(DISTINCT sales_payments.sale_id) AS count, SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)) AS payment_amount');
|
||||
$this->db->select('sales_payments.payment_type, COUNT(DISTINCT sales_payments.sale_id) AS count, SUM(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)-sales_items.discount_fixed) AS payment_amount');
|
||||
$this->db->from('sales_payments AS sales_payments');
|
||||
$this->db->join('sales AS sales', 'sales.sale_id = sales_payments.sale_id');
|
||||
$this->db->join('sales_items AS sales_items', 'sales_items.sale_id = sales_payments.sale_id', 'left');
|
||||
|
||||
@@ -23,7 +23,7 @@ abstract class Summary_report extends Report
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
|
||||
$sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)-sales_items.discount_fixed';
|
||||
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
|
||||
|
||||
|
||||
@@ -11,6 +11,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_default_sales_discount_type'), 'default_sales_discount_type', array('class' => 'control-label col-xs-2')); ?>
|
||||
<div class='col-xs-1'>
|
||||
<?php echo form_checkbox(array(
|
||||
'name' => 'default_sales_discount_type',
|
||||
'id' => 'default_sales_discount_type',
|
||||
'value' => 'default_sales_discount_type',
|
||||
'checked' => $this->config->item('default_sales_discount_type'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('config_default_sales_discount'), 'default_sales_discount', array('class' => 'control-label col-xs-2 required')); ?>
|
||||
<div class='col-xs-2'>
|
||||
@@ -26,6 +37,18 @@
|
||||
<span class="input-group-addon input-sm">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-xs-2'>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon input-sm"><?php echo$this->config->item('currency_symbol'); ?></span>
|
||||
<?php echo form_input(array(
|
||||
'name' => 'default_sales_discount_fixed',
|
||||
'id' => 'default_sales_discount_fixed',
|
||||
'class' => 'form-control input-sm required',
|
||||
'type' => 'number',
|
||||
'min' => 0,
|
||||
'value' => $this->config->item('default_sales_discount_fixed'))); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
|
||||
@@ -53,6 +53,21 @@
|
||||
); ?>
|
||||
<span class="input-group-addon input-sm"><b>%</b></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='col-xs-3'>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon input-sm"><b><?php echo $this->config->item('currency_symbol'); ?></b></span>
|
||||
<?php echo form_input(array(
|
||||
'name'=>'discount_fixed',
|
||||
'size'=>'5',
|
||||
'maxlength'=>'5',
|
||||
'id'=>'discount_fixed',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>$person_info->discount_fixed)
|
||||
);?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -48,6 +48,21 @@
|
||||
<span class="input-group-addon input-sm"><b>%</b></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='col-xs-3'>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon input-sm"><b><?php echo $this->config->item('currency_symbol'); ?></b></span>
|
||||
<?php echo form_input(array(
|
||||
'name'=>'kit_discount_fixed',
|
||||
'size'=>'5',
|
||||
'maxlength'=>'5',
|
||||
'id'=>'kit_discount_fixed',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>$item_kit_info->kit_discount_fixed)
|
||||
);?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<link rel="stylesheet" href="bower_components/chartist/dist/chartist.min.css" />
|
||||
<link rel="stylesheet" href="bower_components/chartist-plugin-tooltip/dist/chartist-plugin-tooltip.css" />
|
||||
<link rel="stylesheet" href="bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.css" />
|
||||
<link rel="stylesheet" href="bower_components/bootstrap-toggle/css/bootstrap-toggle.min.css" />
|
||||
<!-- endbower -->
|
||||
<!-- start css template tags -->
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.autocomplete.css"/>
|
||||
@@ -60,6 +61,7 @@
|
||||
<script src="bower_components/remarkable-bootstrap-notify/bootstrap-notify.js"></script>
|
||||
<script src="bower_components/js-cookie/src/js.cookie.js"></script>
|
||||
<script src="bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.js"></script>
|
||||
<script src="bower_components/bootstrap-toggle/js/bootstrap-toggle.min.js"></script>
|
||||
<!-- endbower -->
|
||||
<!-- start js template tags -->
|
||||
<script type="text/javascript" src="js/imgpreview.full.jquery.js"></script>
|
||||
@@ -72,10 +74,10 @@
|
||||
<![endif]-->
|
||||
<!-- start mincss template tags -->
|
||||
<link rel="stylesheet" type="text/css" href="dist/jquery-ui/jquery-ui.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=84371241b2"/>
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=88039333a5"/>
|
||||
<!-- end mincss template tags -->
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=c206fd4a9f"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=11c54984ca"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -97,6 +97,16 @@
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ($item['discount_fixed'] > 0 )
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" style="font-weight: bold;"> <?php echo to_currency($item['discount_fixed']) . " " . $this->lang->line("sales_discount")?> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -103,11 +103,11 @@ if (isset($success))
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:5%;"><?php echo $this->lang->line('common_delete'); ?></th>
|
||||
<th style="width:40%;"><?php echo $this->lang->line('receivings_item_name'); ?></th>
|
||||
<th style="width:35%;"><?php echo $this->lang->line('receivings_item_name'); ?></th>
|
||||
<th style="width:10%;"><?php echo $this->lang->line('receivings_cost'); ?></th>
|
||||
<th style="width:10%;"><?php echo $this->lang->line('receivings_quantity'); ?></th>
|
||||
<th style="width:10%;"><?php echo $this->lang->line('receivings_ship_pack'); ?></th>
|
||||
<th style="width:10%;"><?php echo $this->lang->line('receivings_discount'); ?></th>
|
||||
<th style="width:15%;"><?php echo $this->lang->line('receivings_discount'); ?></th>
|
||||
<th style="width:10%;"><?php echo $this->lang->line('receivings_total'); ?></th>
|
||||
<th style="width:5%;"><?php echo $this->lang->line('receivings_update'); ?></th>
|
||||
</tr>
|
||||
@@ -163,18 +163,46 @@ if (isset($success))
|
||||
if ($items_module_allowed && $mode!='requisition')
|
||||
{
|
||||
?>
|
||||
<td><?php echo form_input(array('name'=>'discount', 'class'=>'form-control input-sm', 'value'=>$item['discount']));?></td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<?php
|
||||
if($item['discount_type'])
|
||||
{
|
||||
echo form_input(array('name'=>'discount_fixed', 'class'=>'form-control input-sm', 'value'=>to_decimals($item['discount_fixed'], 0), 'onClick'=>'this.select();'));
|
||||
echo form_hidden('discount', $item['discount']);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo form_input(array('name'=>'discount', 'class'=>'form-control input-sm', 'value'=>to_decimals($item['discount'], 0), 'onClick'=>'this.select();'));
|
||||
echo form_hidden('discount_fixed', $item['discount_fixed']);
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<td><?php echo $item['discount']; ?></td>
|
||||
<td><?php
|
||||
if($item['discount_type'])
|
||||
{
|
||||
echo $item['discount_fixed'];
|
||||
}else{
|
||||
echo $item['discount'];
|
||||
}
|
||||
?></td>
|
||||
<?php echo form_hidden('discount',$item['discount']); ?>
|
||||
<?php echo form_hidden('discount_fixed',$item['discount_fixed']); ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td><?php echo to_currency($item['price']*$item['quantity']*$item['receiving_quantity']-$item['price']*$item['quantity']*$item['receiving_quantity']*$item['discount']/100); ?></td>
|
||||
<td><?php echo to_currency($item['price']*$item['quantity']*$item['receiving_quantity']-$item['price']*$item['quantity']*$item['receiving_quantity']*$item['discount']/100-$item['discount_fixed']); ?></td>
|
||||
<td><a href="javascript:$('#<?php echo 'cart_'.$line ?>').submit();" title=<?php echo $this->lang->line('receivings_update')?> ><span class="glyphicon glyphicon-refresh"></span></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -503,10 +531,17 @@ $(document).ready(function()
|
||||
}
|
||||
}
|
||||
|
||||
$('[name="price"],[name="quantity"],[name="receiving_quantity"],[name="discount"],[name="description"],[name="serialnumber"]').change(function() {
|
||||
$('[name="price"],[name="quantity"],[name="receiving_quantity"],[name="discount"],[name="discount_fixed"],[name="description"],[name="serialnumber"]').change(function() {
|
||||
$(this).parents("tr").prevAll("form:first").submit()
|
||||
});
|
||||
|
||||
$('[name="discount_toggle"]').change(function() {
|
||||
|
||||
var input = $("<input>").attr("type", "hidden").attr("name", "discount_type").val(($(this).prop('checked'))?1:0);
|
||||
$('#cart_'+ $(this).attr('data-line')).append($(input));
|
||||
$('#cart_'+ $(this).attr('data-line')).submit();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -55,6 +55,20 @@ if(isset($error))
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (isset($discount_type_options))
|
||||
{
|
||||
?>
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('reports_discount_type'), 'reports_discount_type_label', array('class'=>'required control-label col-xs-2')); ?>
|
||||
<div id='report_discount_type' class="col-xs-3">
|
||||
<?php echo form_dropdown('discount_type', $discount_type_options, $this->config->item('default_sales_discount_type'), array('id'=>'discount_type_id', 'class'=>'form-control')); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (!empty($stock_locations) && count($stock_locations) > 1)
|
||||
{
|
||||
@@ -88,7 +102,7 @@ $(document).ready(function()
|
||||
|
||||
$("#generate_report").click(function()
|
||||
{
|
||||
window.location = [window.location, start_date, end_date, $("#input_type").val() || 0, $("#location_id").val()].join("/");
|
||||
window.location = [window.location, start_date, end_date, $("#input_type").val() || 0, $("#location_id").val(), $("#discount_type_id").val() || 0 ].join("/");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -22,11 +22,42 @@ if(isset($error))
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (isset($discount_type_options))
|
||||
{
|
||||
?>
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('reports_discount_type'), 'reports_discount_type_label', array('class'=>'required control-label col-xs-2')); ?>
|
||||
<div id='report_discount_type' class="col-xs-3">
|
||||
<?php echo form_dropdown('discount_type', $discount_type_options, $this->config->item('default_sales_discount_type'), array('id'=>'discount_type_id', 'class'=>'form-control')); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="form-group form-group-sm" id="report_specific_input_data">
|
||||
<?php echo form_label($specific_input_name, 'specific_input_name_label', array('class'=>'required control-label col-xs-2')); ?>
|
||||
<div class="col-xs-3">
|
||||
<div class="col-xs-3 discount_percent">
|
||||
<?php echo form_dropdown('specific_input_data', $specific_input_data, '', 'id="specific_input_data" class="form-control"'); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (isset($discount_type_options))
|
||||
{
|
||||
?>
|
||||
<div class="col-xs-3 discount_fixed">
|
||||
<?php echo form_input(array(
|
||||
'name' => 'discount_fixed',
|
||||
'id' => 'discount_fixed',
|
||||
'class' => 'form-control input-sm required',
|
||||
'type' => 'number',
|
||||
'min' => 0,
|
||||
'value' => $this->config->item('default_sales_discount_fixed'))); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
@@ -51,11 +82,38 @@ if(isset($error))
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
<?php
|
||||
if (isset($discount_type_options))
|
||||
{
|
||||
?>
|
||||
$("#discount_type_id").change(check_discount_type).ready(check_discount_type);
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php $this->load->view('partial/daterangepicker'); ?>
|
||||
|
||||
$("#generate_report").click(function()
|
||||
{
|
||||
window.location = [window.location, start_date, end_date, $('#specific_input_data').val(), $("#input_type").val() || 0].join("/");
|
||||
var specific_input_data = $('#specific_input_data').val();
|
||||
if(!$(".discount_percent").is(":visible")){
|
||||
specific_input_data = $('#discount_fixed').val();
|
||||
}
|
||||
|
||||
window.location = [window.location, start_date, end_date, specific_input_data, $("#input_type").val() || 0, $("#discount_type_id").val() || 0].join("/");
|
||||
});
|
||||
});
|
||||
|
||||
function check_discount_type()
|
||||
{
|
||||
var discount_type = $("#discount_type_id").val();
|
||||
|
||||
if(discount_type==1){
|
||||
$(".discount_percent").hide();
|
||||
$(".discount_fixed").show();
|
||||
}else{
|
||||
$(".discount_percent").show();
|
||||
$(".discount_fixed").hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -133,7 +133,7 @@ $(document).ready(function()
|
||||
<td style='text-align:center;'><textarea rows="5" cols="6"><?php echo to_quantity_decimals($item['quantity']); ?></textarea>
|
||||
</td>
|
||||
<td><textarea rows="4" cols="6"><?php echo to_currency($item['price']); ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo $item['discount'] . '%'; ?></textarea>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo $item['discount'] . '% | ' .to_currency($item['discount_fixed']); ?></textarea>
|
||||
</td>
|
||||
<?php if($discount > 0): ?>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo to_currency($item['discounted_total'] / $item['quantity']); ?></textarea>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
<td class="item-name"><?php echo $item['name']; ?></td>
|
||||
<td><?php echo to_quantity_decimals($item['quantity']); ?></td>
|
||||
<td><?php echo to_currency($item['price']); ?></td>
|
||||
<td><?php echo $item['discount'] . '%'; ?></td>
|
||||
<td><?php echo $item['discount'] . '% | ' .to_currency($item['discount_fixed']); ?></td>
|
||||
<?php if ($item['discount'] > 0): ?>
|
||||
<td><?php echo to_currency($item['discounted_total'] / $item['quantity']); ?></td>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -135,7 +135,7 @@ if (isset($error_message))
|
||||
</td>
|
||||
<td><textarea rows="4" cols="6"><?php echo to_currency($item['price']); ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="4"
|
||||
cols="6"><?php echo $item['discount'] . '%'; ?></textarea></td>
|
||||
cols="6"><?php echo $item['discount'] . '% | ' .to_currency($item['discount_fixed']); ?></textarea></td>
|
||||
<?php if($discount > 0): ?>
|
||||
<td style='text-align:center;'><textarea rows="4"
|
||||
cols="6"><?php echo to_currency($item['discounted_total'] / $item['quantity']); ?></textarea>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
<td class="item-name"><?php echo $item['name']; ?></td>
|
||||
<td><?php echo to_quantity_decimals($item['quantity']); ?></td>
|
||||
<td><?php echo to_currency($item['price']); ?></td>
|
||||
<td><?php echo $item['discount'] . '%'; ?></td>
|
||||
<td><?php echo $item['discount'] . '% | ' .to_currency($item['discount_fixed']); ?></td>
|
||||
<?php if($discount > 0): ?>
|
||||
<td><?php echo to_currency($item['discounted_total'] / $item['quantity']); ?></td>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -102,6 +102,17 @@
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if($item['discount_fixed'] > 0)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3"
|
||||
class="discount"><?php echo to_currency($item['discount_fixed']) . " " . $this->lang->line("sales_discount") ?></td>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -96,6 +96,17 @@
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if($item['discount_fixed'] > 0)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3"
|
||||
class="discount"><?php echo to_currency($item['discount_fixed']) . " " . $this->lang->line("sales_discount") ?></td>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,19 @@
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if($item['discount_fixed'] > 0)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3"
|
||||
class="discount"><?php echo to_currency($item['discount_fixed']) . " " . $this->lang->line("sales_discount") ?></td>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -107,10 +107,10 @@ if(isset($success))
|
||||
<tr>
|
||||
<th style="width: 5%;"><?php echo $this->lang->line('common_delete'); ?></th>
|
||||
<th style="width: 15%;"><?php echo $this->lang->line('sales_item_number'); ?></th>
|
||||
<th style="width: 35%;"><?php echo $this->lang->line('sales_item_name'); ?></th>
|
||||
<th style="width: 30%;"><?php echo $this->lang->line('sales_item_name'); ?></th>
|
||||
<th style="width: 10%;"><?php echo $this->lang->line('sales_price'); ?></th>
|
||||
<th style="width: 10%;"><?php echo $this->lang->line('sales_quantity'); ?></th>
|
||||
<th style="width: 10%;"><?php echo $this->lang->line('sales_discount'); ?></th>
|
||||
<th style="width: 15%;"><?php echo $this->lang->line('sales_discount'); ?></th>
|
||||
<th style="width: 10%;"><?php echo $this->lang->line('sales_total'); ?></th>
|
||||
<th style="width: 5%;"><?php echo $this->lang->line('sales_update'); ?></th>
|
||||
</tr>
|
||||
@@ -195,7 +195,27 @@ if(isset($success))
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td><?php echo form_input(array('name'=>'discount', 'class'=>'form-control input-sm', 'value'=>to_decimals($item['discount'], 0), 'tabindex'=>++$tabindex, 'onClick'=>'this.select();'));?></td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<?php
|
||||
if($item['discount_type'])
|
||||
{
|
||||
echo form_input(array('name'=>'discount_fixed', 'class'=>'form-control input-sm', 'value'=>to_decimals($item['discount_fixed'], 0), 'tabindex'=>++$tabindex, 'onClick'=>'this.select();'));
|
||||
echo form_hidden('discount', $item['discount']);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo form_input(array('name'=>'discount', 'class'=>'form-control input-sm', 'value'=>to_decimals($item['discount'], 0), 'tabindex'=>++$tabindex, 'onClick'=>'this.select();'));
|
||||
echo form_hidden('discount_fixed', $item['discount_fixed']);
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
<td>
|
||||
<?php
|
||||
if($item['item_type'] == ITEM_AMOUNT_ENTRY)
|
||||
@@ -208,7 +228,7 @@ if(isset($success))
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><a href="javascript:document.getElementById("<?php echo 'cart_'.$line ?>").submit();" title=<?php echo $this->lang->line('sales_update')?> ><span class="glyphicon glyphicon-refresh"></span></a></td>
|
||||
<td><a href="javascript:document.getElementById('<?php echo 'cart_'.$line ?>').submit();" title=<?php echo $this->lang->line('sales_update')?> ><span class="glyphicon glyphicon-refresh"></span></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php
|
||||
@@ -892,9 +912,16 @@ $(document).ready(function()
|
||||
}
|
||||
}
|
||||
|
||||
$('[name="price"],[name="quantity"],[name="discount"],[name="description"],[name="serialnumber"],[name="discounted_total"]').change(function() {
|
||||
$('[name="price"],[name="quantity"],[name="discount"],[name="discount_fixed"],[name="description"],[name="serialnumber"],[name="discounted_total"]').change(function() {
|
||||
$(this).parents("tr").prevAll("form:first").submit()
|
||||
});
|
||||
|
||||
$('[name="discount_toggle"]').change(function() {
|
||||
|
||||
var input = $("<input>").attr("type", "hidden").attr("name", "discount_type").val(($(this).prop('checked'))?1:0);
|
||||
$('#cart_'+ $(this).attr('data-line')).append($(input));
|
||||
$('#cart_'+ $(this).attr('data-line')).submit();
|
||||
});
|
||||
});
|
||||
|
||||
function check_payment_type()
|
||||
|
||||
@@ -123,7 +123,7 @@ if(isset($error_message))
|
||||
<td class="item-name"><textarea rows="4" cols="6"><?php echo $item['name']; ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="5" cols="6"><?php echo to_quantity_decimals($item['quantity']); ?></textarea></td>
|
||||
<td><textarea rows="4" cols="6"><?php if($print_price_info) echo to_currency($item['price']); ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo $item['discount'] . '%'; ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo $item['discount'] . '% | ' .to_currency($item['discount_fixed']); ?></textarea></td>
|
||||
<td style='border-right: solid 1px; text-align:right;'><textarea rows="4" cols="6"><?php if($print_price_info) echo to_currency($item['discounted_total']); ?></textarea></td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<td class="item-name"><?php echo $item['name']; ?></td>
|
||||
<td><?php echo to_quantity_decimals($item['quantity']); ?></td>
|
||||
<td><?php echo to_currency($item['price']); ?></td>
|
||||
<td><?php echo $item['discount'] . '%'; ?></td>
|
||||
<td><?php echo $item['discount'] . '% | ' .to_currency($item['discount_fixed']); ?></td>
|
||||
<td class="total-line"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
"chartist-plugin-barlabels": "https://github.com/mtgibbs/chartist-plugin-barlabels.git#~0.0.5",
|
||||
"remarkable-bootstrap-notify": "~3.1.3",
|
||||
"js-cookie": "~2.1.4",
|
||||
"bootstrap-tagsinput": "~0.8.0"
|
||||
"bootstrap-tagsinput": "~0.8.0",
|
||||
"bootstrap-toggle": "^2.2.2"
|
||||
},
|
||||
"overrides": {
|
||||
"jquery-ui": {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
First Name,Last Name,Gender,Consent,Email,Phone Number,Address 1,Address2,City,State,Zip,Country,Comments,Company,Account Number,Discount,Taxable
|
||||
Bob,Smith,1,y,bsmith@nowhere.com,585-555-1111,123 Nowhere Street,Apt 4,Awesome,NY,11111,USA,Awesome guy,,,5,y
|
||||
First Name,Last Name,Gender,Consent,Email,Phone Number,Address 1,Address2,City,State,Zip,Country,Comments,Company,Account Number,Discount,Discount Fixed,Taxable
|
||||
Bob,Smith,1,y,bsmith@nowhere.com,585-555-1111,123 Nowhere Street,Apt 4,Awesome,NY,11111,USA,Awesome guy,,,5,0,y
|
||||
|
||||
|
@@ -18,6 +18,8 @@ Copyright (c) 2017 Deep Shah (aka deepshah)
|
||||
Copyright (c) 2017 Joshua Fernandez (aka joshua1234511)
|
||||
Copyright (c) 2017 odiea
|
||||
Copyright (c) 2017 asadjaved63
|
||||
Copyright (c) 2018 Erasto Marroquín (aka Erastus)
|
||||
Copyright (c) 2018 WebShells/Shady Sh
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
Reference in New Issue
Block a user