mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2025-12-24 01:57:51 -05:00
new discount on sales
This commit is contained in:
@@ -287,7 +287,6 @@ class Config extends Secure_Controller
|
||||
'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'),
|
||||
|
||||
@@ -248,8 +248,8 @@ class Customers extends Persons
|
||||
'consent' => $this->input->post('consent') != NULL,
|
||||
'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'),
|
||||
'discount' => $this->input->post('discount') == '' ? 0.00 : $this->input->post('discount'),
|
||||
'discount_type' => $this->input->post('discount_type') == NULL ? PERCENT : $this->input->post('discount_type'),
|
||||
'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,8 +404,8 @@ class Customers extends Persons
|
||||
$customer_data = array(
|
||||
'consent' => $consent,
|
||||
'company_name' => $data[13],
|
||||
'discount_percent' => $data[15],
|
||||
'discount_fixed' => $data[16],
|
||||
'discount' => $data[15],
|
||||
'discount_type' => $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
|
||||
|
||||
@@ -124,14 +124,13 @@ 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, $discount_fixed, $discount_type, $price, $receiving_quantity);
|
||||
$this->receiving_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $discount_type, $price, $receiving_quantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -884,7 +884,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -995,7 +995,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -1103,7 +1103,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -1256,7 +1256,7 @@ class Reports extends Secure_Controller
|
||||
to_currency($drow['total']),
|
||||
to_currency($drow['cost']),
|
||||
to_currency($drow['profit']),
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])));
|
||||
}
|
||||
|
||||
if(isset($report_data['rewards'][$key]))
|
||||
@@ -1358,7 +1358,7 @@ class Reports extends Secure_Controller
|
||||
$drow['category'],
|
||||
$quantity_purchased,
|
||||
to_currency($drow['total']),
|
||||
$drow['discount_percent'].'% | '.to_currency($drow['discount_fixed'])));
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,13 +136,13 @@ class Sales extends Secure_Controller
|
||||
if($this->Customer->exists($customer_id))
|
||||
{
|
||||
$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;
|
||||
$discount = $this->Customer->get_info($customer_id)->discount;
|
||||
$discount_type = $this->Customer->get_info($customer_id)->discount_type;
|
||||
|
||||
// apply customer default discount to items that have 0 discount
|
||||
if($discount_percent != '' OR $discount_fixed != '')
|
||||
if($discount != '')
|
||||
{
|
||||
$this->sale_lib->apply_customer_discount($discount_percent, $discount_fixed);
|
||||
$this->sale_lib->apply_customer_discount($discount, $discount_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +368,6 @@ 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
|
||||
@@ -376,18 +375,12 @@ class Sales extends Secure_Controller
|
||||
if($customer_id != -1)
|
||||
{
|
||||
// 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 != '')
|
||||
$customer_discount = $this->Customer->get_info($customer_id)->discount;
|
||||
$customer_discount_type = $this->Customer->get_info($customer_id)->discount_type;
|
||||
if($customer_discount != '')
|
||||
{
|
||||
$discount = $discount_percent;
|
||||
$discount_type = 0;
|
||||
}
|
||||
|
||||
if($discount_cash != '')
|
||||
{
|
||||
$discount_fixed = $discount_cash;
|
||||
$discount_type = 1;
|
||||
$discount = $customer_discount;
|
||||
$discount_type = $customer_discount_type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,11 +390,6 @@ class Sales extends Secure_Controller
|
||||
$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();
|
||||
@@ -422,14 +410,10 @@ class Sales extends Secure_Controller
|
||||
$kit_price_option = $item_kit_info->price_option;
|
||||
$kit_print_option = $item_kit_info->print_option; // 0-all, 1-priced, 2-kit-only
|
||||
|
||||
if($item_kit_info->kit_discount_percent != 0 && $item_kit_info->kit_discount_percent > $discount)
|
||||
if($item_kit_info->kit_discount != 0 && $item_kit_info->kit_discount > $discount)
|
||||
{
|
||||
$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;
|
||||
$discount = $item_kit_info->kit_discount;
|
||||
$discount_type = $item_kit_info->discount_type;
|
||||
}
|
||||
|
||||
$price = NULL;
|
||||
@@ -437,7 +421,7 @@ class Sales extends Secure_Controller
|
||||
|
||||
if(!empty($kit_item_id))
|
||||
{
|
||||
if(!$this->sale_lib->add_item($kit_item_id, $quantity, $item_location, $discount, $discount_fixed, $discount_type, PRICE_MODE_STANDARD))
|
||||
if(!$this->sale_lib->add_item($kit_item_id, $quantity, $item_location, $discount, $discount_type, PRICE_MODE_STANDARD))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
@@ -449,7 +433,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, $discount_fixed, $discount_type, $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_type, $kit_price_option, $kit_print_option, $stock_warning))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
@@ -460,7 +444,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, $discount_fixed, $discount_type, PRICE_MODE_STANDARD))
|
||||
if(!$this->sale_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount, $discount_type, PRICE_MODE_STANDARD))
|
||||
{
|
||||
$data['error'] = $this->lang->line('sales_unable_to_add_item');
|
||||
}
|
||||
@@ -479,14 +463,12 @@ 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');
|
||||
@@ -494,7 +476,7 @@ class Sales extends Secure_Controller
|
||||
|
||||
if($this->form_validation->run() != FALSE)
|
||||
{
|
||||
$this->sale_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $discount_fixed, $discount_type, $price, $discounted_total);
|
||||
$this->sale_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $discount_type, $price, $discounted_total);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -886,7 +868,8 @@ class Sales extends Secure_Controller
|
||||
$data['customer_location'] = '';
|
||||
}
|
||||
$data['customer_account_number'] = $customer_info->account_number;
|
||||
$data['customer_discount_percent'] = $customer_info->discount_percent;
|
||||
$data['customer_discount'] = $customer_info->discount;
|
||||
$data['customer_discount_type'] = $customer_info->discount_type;
|
||||
$package_id = $this->Customer->get_info($customer_id)->package_id;
|
||||
if($package_id != NULL)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ $lang["config_default_barcode_page_width_required"] = "Default Barcode Page Widt
|
||||
$lang["config_default_barcode_width_number"] = "Default Barcode Width must be a number.";
|
||||
$lang["config_default_barcode_width_required"] = "Default Barcode Width is a required field.";
|
||||
$lang["config_default_origin_tax_code"] = "Default Origin Tax Code";
|
||||
$lang["config_default_sales_discount"] = "Default Sales Discount %";
|
||||
$lang["config_default_sales_discount"] = "Default Sales Discount";
|
||||
$lang["config_default_sales_discount_number"] = "Default Sales Discount must be a number.";
|
||||
$lang["config_default_sales_discount_required"] = "Default Sales Discount is a required field.";
|
||||
$lang["config_default_tax_name_number"] = "Default Tax Name must be a string.";
|
||||
|
||||
@@ -48,3 +48,6 @@ $lang["customers_taxable"] = "Taxable";
|
||||
$lang["customers_total"] = "Total spent";
|
||||
$lang["customers_update"] = "Update Customer";
|
||||
$lang["rewards_package"] = "Rewards Package";
|
||||
$lang["customers_discount_type"] = "Discount Type";
|
||||
$lang["customers_discount_fixed"] = "Fixed Discount";
|
||||
$lang["customers_discount_percent"] = "Percentage Discount";
|
||||
@@ -12,7 +12,7 @@ $lang["receivings_date"] = "Receiving Date";
|
||||
$lang["receivings_date_required"] = "A correct date must be entered.";
|
||||
$lang["receivings_date_type"] = "Date is a required field.";
|
||||
$lang["receivings_delete_entire_sale"] = "Delete Entire Sale";
|
||||
$lang["receivings_discount"] = "Discount %";
|
||||
$lang["receivings_discount"] = "Discount";
|
||||
$lang["receivings_edit"] = "Edit";
|
||||
$lang["receivings_edit_sale"] = "Edit Receiving";
|
||||
$lang["receivings_employee"] = "Employee";
|
||||
|
||||
@@ -123,3 +123,5 @@ $lang["reports_unit_price"] = "Retail Price";
|
||||
$lang["reports_used"] = "Points Used";
|
||||
$lang["reports_work_orders"] = "Work Orders";
|
||||
$lang["reports_zero_and_less"] = "Zero and less";
|
||||
$lang["reports_discount_type"] = "Discount Type";
|
||||
$lang["reports_discount_fixed"] = "Fixed Discount";
|
||||
@@ -78,7 +78,7 @@ $lang["config_default_barcode_page_width_required"] = "Ancho de página del cód
|
||||
$lang["config_default_barcode_width_number"] = "Ancho del código de barras debe ser número.";
|
||||
$lang["config_default_barcode_width_required"] = "Ancho del código de barras es requerido.";
|
||||
$lang["config_default_origin_tax_code"] = "Código de impuesto por defecto";
|
||||
$lang["config_default_sales_discount"] = "% de Descuento en Ventas predeterminado";
|
||||
$lang["config_default_sales_discount"] = "Descuento en Ventas predeterminado";
|
||||
$lang["config_default_sales_discount_number"] = "Descuento en ventas predeterminado debe ser un número.";
|
||||
$lang["config_default_sales_discount_required"] = "Descuento en ventas predeterminado es requerido.";
|
||||
$lang["config_default_tax_name_number"] = "El nombre de el impuesto debe ser letras.";
|
||||
@@ -271,4 +271,3 @@ $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";
|
||||
@@ -48,3 +48,6 @@ $lang["customers_taxable"] = "Gravable";
|
||||
$lang["customers_total"] = "Total";
|
||||
$lang["customers_update"] = "Actualizar Cliente";
|
||||
$lang["rewards_package"] = "Paquete de premios";
|
||||
$lang["customers_discount_type"] = "Tipo de Descuento";
|
||||
$lang["customers_discount_fixed"] = "Descuento Fijo";
|
||||
$lang["customers_discount_percent"] = "Descuento en Porcentaje";
|
||||
|
||||
@@ -12,7 +12,7 @@ $lang["receivings_date"] = "Fecha de Recepción";
|
||||
$lang["receivings_date_required"] = "Una fecha correcta debe ser ingresada.";
|
||||
$lang["receivings_date_type"] = "Campo Fecha es requerido.";
|
||||
$lang["receivings_delete_entire_sale"] = "Borrar venta completa";
|
||||
$lang["receivings_discount"] = "Descuento %";
|
||||
$lang["receivings_discount"] = "Descuento";
|
||||
$lang["receivings_edit"] = "Editar";
|
||||
$lang["receivings_edit_sale"] = "Editar Recepción";
|
||||
$lang["receivings_employee"] = "Empleado";
|
||||
|
||||
@@ -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_type = 0, $discount = 0, $discount_fixed = 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, $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))
|
||||
@@ -242,13 +242,12 @@ 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' => $receiving_quantity,
|
||||
'receiving_quantity_choices' => $receiving_quantity_choices,
|
||||
'total' => $this->get_item_total($quantity, $price, $discount, $discount_fixed, $receiving_quantity)
|
||||
'total' => $this->get_item_total($quantity, $price, $discount, $discount_type, $receiving_quantity)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -256,7 +255,7 @@ class Receiving_lib
|
||||
if($itemalreadyinsale)
|
||||
{
|
||||
$items[$updatekey]['quantity'] += $quantity;
|
||||
$items[$updatekey]['total'] = $this->get_item_total($items[$updatekey]['quantity'], $price, $discount, $discount_fixed, $items[$updatekey]['receiving_quantity']);
|
||||
$items[$updatekey]['total'] = $this->get_item_total($items[$updatekey]['quantity'], $price, $discount, $discount_type, $items[$updatekey]['receiving_quantity']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -269,7 +268,7 @@ class Receiving_lib
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $discount_fixed, $discount_type, $price, $receiving_quantity)
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $discount_type, $price, $receiving_quantity)
|
||||
{
|
||||
$items = $this->get_cart();
|
||||
if(isset($items[$line]))
|
||||
@@ -280,12 +279,11 @@ 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, $discount_fixed, $receiving_quantity);
|
||||
$line['total'] = $this->get_item_total($quantity, $price, $discount, $discount_type, $receiving_quantity);
|
||||
$this->set_cart($items);
|
||||
}
|
||||
|
||||
@@ -318,7 +316,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_type, $row->discount_percent, $row->discount_fixed, $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, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
|
||||
}
|
||||
|
||||
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
|
||||
@@ -343,7 +341,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_type, $row->discount_percent, $row->discount_fixed, $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, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
|
||||
}
|
||||
|
||||
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
|
||||
@@ -359,12 +357,17 @@ class Receiving_lib
|
||||
$this->clear_reference();
|
||||
}
|
||||
|
||||
public function get_item_total($quantity, $price, $discount_percentage, $discount_fixed, $receiving_quantity)
|
||||
public function get_item_total($quantity, $price, $discount, $discount_type, $receiving_quantity)
|
||||
{
|
||||
$extended_quantity = bcmul($quantity, $receiving_quantity);
|
||||
$total = bcmul($extended_quantity, $price);
|
||||
$discount_fraction = bcdiv($discount_percentage, 100);
|
||||
$discount_amount = bcadd(bcmul($total, $discount_fraction), $discount_fixed);
|
||||
$discount_amount = $discount;
|
||||
if($discount_type == PERCENT)
|
||||
{
|
||||
$discount_fraction = bcdiv($discount, 100);
|
||||
$discount_amount = bcmul($total, $discount_fraction);
|
||||
}
|
||||
|
||||
|
||||
return bcsub($total, $discount_amount);
|
||||
}
|
||||
@@ -374,7 +377,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['discount_fixed'], $item['receiving_quantity']));
|
||||
$total = bcadd($total, $this->get_item_total(($item['quantity']), $item['price'], $item['discount'], $item['discount_type'], $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'], $item['discount_fixed']);
|
||||
$discount_amount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_type']);
|
||||
$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'],$item['discount_fixed']));
|
||||
$subtotal = bcadd($subtotal, $this->get_extended_total_tax_exclusive($item['item_id'], $extended_discounted_amount, $item['quantity'], $item['price'], $item['discount'],$item['discount_type']));
|
||||
}
|
||||
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, $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 )
|
||||
public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 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,7 +753,6 @@ class Sale_lib
|
||||
if($price == 0.00)
|
||||
{
|
||||
$discount = 0.00;
|
||||
$discount_fixed = 0.00;
|
||||
}
|
||||
|
||||
// Serialization and Description
|
||||
@@ -826,8 +825,8 @@ class Sale_lib
|
||||
}
|
||||
}
|
||||
|
||||
$total = $this->get_item_total($quantity, $price, $discount, $discount_fixed);
|
||||
$discounted_total = $this->get_item_total($quantity, $price, $discount, $discount_fixed, TRUE);
|
||||
$total = $this->get_item_total($quantity, $price, $discount, $discount_type);
|
||||
$discounted_total = $this->get_item_total($quantity, $price, $discount, $discount_type, TRUE);
|
||||
|
||||
if($this->CI->config->item('multi_pack_enabled') == '1')
|
||||
{
|
||||
@@ -851,7 +850,6 @@ 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,
|
||||
@@ -936,7 +934,7 @@ class Sale_lib
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $discount_fixed, $discount_type, $price, $discounted_total=NULL)
|
||||
public function edit_item($line, $description, $serialnumber, $quantity, $discount, $discount_type, $price, $discounted_total=NULL)
|
||||
{
|
||||
$items = $this->get_cart();
|
||||
if(isset($items[$line]))
|
||||
@@ -951,13 +949,12 @@ 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, $discount_fixed);
|
||||
$line['discounted_total'] = $this->get_item_total($quantity, $price, $discount, $discount_fixed, TRUE);
|
||||
$line['total'] = $this->get_item_total($quantity, $price, $discount, $line['discount_type']);
|
||||
$line['discounted_total'] = $this->get_item_total($quantity, $price, $discount, $line['discount_type'], TRUE);
|
||||
$this->set_cart($items);
|
||||
}
|
||||
|
||||
@@ -988,13 +985,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, $row->discount_fixed, $row->discount_type, 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, $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, $discount_fixed, $discount_type, $kit_price_option, $kit_print_option, &$stock_warning)
|
||||
public function add_item_kit($external_item_kit_id, $item_location, $discount, $discount_type, $kit_price_option, $kit_print_option, &$stock_warning)
|
||||
{
|
||||
//KIT #
|
||||
$pieces = explode(' ', $external_item_kit_id);
|
||||
@@ -1003,7 +1000,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, $discount_fixed, $discount_type, 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_type, PRICE_MODE_KIT, $kit_price_option, $kit_print_option, NULL, NULL, NULL, NULL);
|
||||
|
||||
if($stock_warning == NULL)
|
||||
{
|
||||
@@ -1021,7 +1018,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, $row->discount_fixed, $row->discount_type, 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, $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)
|
||||
@@ -1049,7 +1046,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, $row->discount_fixed, $row->discount_type, 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, $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');
|
||||
@@ -1134,12 +1131,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'], $item['discount_fixed'], TRUE);
|
||||
$tax_basis = $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_type'], TRUE);
|
||||
$tax_amount = 0;
|
||||
|
||||
if($this->CI->config->item('tax_included'))
|
||||
{
|
||||
$tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed'], $tax['percent']);
|
||||
$tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $item['discount_type'], $tax['percent']);
|
||||
}
|
||||
elseif($this->CI->config->item('customer_sales_tax_support') == '0')
|
||||
{
|
||||
@@ -1173,7 +1170,7 @@ class Sale_lib
|
||||
return $sales_taxes;
|
||||
}
|
||||
|
||||
public function apply_customer_discount($discount_percent, $discount_fixed)
|
||||
public function apply_customer_discount($discount, $discount_type)
|
||||
{
|
||||
// Get all items in the cart so far...
|
||||
$items = $this->get_cart();
|
||||
@@ -1186,18 +1183,9 @@ class Sale_lib
|
||||
// set a new discount only if the current one is 0
|
||||
if($item['discount'] == 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);
|
||||
}
|
||||
|
||||
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);
|
||||
$item['discount'] = $discount;
|
||||
$item['total'] = $this->get_item_total($quantity, $price, $discount, $discount_type);
|
||||
$item['discounted_total'] = $this->get_item_total($quantity, $price, $discount, $discount_type, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,13 +1199,7 @@ class Sale_lib
|
||||
{
|
||||
if($item['discount'] > 0)
|
||||
{
|
||||
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed']);
|
||||
$discount = bcadd($discount, $item_discount);
|
||||
}
|
||||
|
||||
if($item['discount_fixed'] > 0)
|
||||
{
|
||||
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed']);
|
||||
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_type']);
|
||||
$discount = bcadd($discount, $item_discount);
|
||||
}
|
||||
}
|
||||
@@ -1230,39 +1212,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, $discount_fixed, $include_discount = FALSE)
|
||||
public function get_item_total_tax_exclusive($item_id, $quantity, $price, $discount, $discount_type, $include_discount = FALSE)
|
||||
{
|
||||
$tax_info = $this->CI->Item_taxes->get_info($item_id);
|
||||
$item_total = $this->get_item_total($quantity, $price, $discount_percentage, $discount_fixed, $include_discount);
|
||||
$item_total = $this->get_item_total($quantity, $price, $discount, $discount_type, $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, $discount_fixed, $tax_percentage));
|
||||
$item_total = bcsub($item_total, $this->get_item_tax($quantity, $price, $discount, $discount_type, $tax_percentage));
|
||||
}
|
||||
|
||||
return $item_total;
|
||||
}
|
||||
|
||||
public function get_extended_total_tax_exclusive($item_id, $discounted_extended_amount, $quantity, $price, $discount_percentage = 0, $discount_fixed = 0)
|
||||
public function get_extended_total_tax_exclusive($item_id, $discounted_extended_amount, $quantity, $price, $discount = 0, $discount_type = 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, $discount_fixed, $tax_percentage));
|
||||
$discounted_extended_amount = bcsub($discounted_extended_amount, $this->get_item_tax($quantity, $price, $discount, $discount_type, $tax_percentage));
|
||||
}
|
||||
|
||||
return $discounted_extended_amount;
|
||||
}
|
||||
|
||||
public function get_item_total($quantity, $price, $discount_percentage, $discount_fixed, $include_discount = FALSE)
|
||||
public function get_item_total($quantity, $price, $discount, $discount_type, $include_discount = FALSE)
|
||||
{
|
||||
$total = bcmul($quantity, $price);
|
||||
if($include_discount)
|
||||
{
|
||||
$discount_amount = $this->get_item_discount($quantity, $price, $discount_percentage, $discount_fixed);
|
||||
$discount_amount = $this->get_item_discount($quantity, $price, $discount, $discount_type);
|
||||
|
||||
return bcsub($total, $discount_amount);
|
||||
}
|
||||
@@ -1291,17 +1273,21 @@ class Sale_lib
|
||||
return bcsub($extended_amount, $discount_amount);
|
||||
}
|
||||
|
||||
public function get_item_discount($quantity, $price, $discount_percentage, $discount_fixed)
|
||||
public function get_item_discount($quantity, $price, $discount, $discount_type)
|
||||
{
|
||||
$total = bcmul($quantity, $price);
|
||||
$discount_fraction = bcdiv($discount_percentage, 100);
|
||||
|
||||
return round(bcadd(bcmul($total, $discount_fraction),$discount_fixed), totals_decimals(), PHP_ROUND_HALF_UP);
|
||||
if($discount_type == PERCENT)
|
||||
{
|
||||
$discount_fraction = bcdiv($discount, 100);
|
||||
$discount=bcmul($total,$discount_fraction);
|
||||
}
|
||||
|
||||
return round($discount, totals_decimals(), PHP_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
public function get_item_tax($quantity, $price, $discount_percentage, $discount_fixed, $tax_percentage)
|
||||
public function get_item_tax($quantity, $price, $discount, $discount_type, $tax_percentage)
|
||||
{
|
||||
$price = $this->get_item_total($quantity, $price, $discount_percentage, $discount_fixed, TRUE);
|
||||
$price = $this->get_item_total($quantity, $price, $discount, $discount_type, TRUE);
|
||||
if($this->CI->config->item('tax_included'))
|
||||
{
|
||||
$tax_fraction = bcadd(100, $tax_percentage);
|
||||
@@ -1322,11 +1308,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'], $item['discount_fixed'], $include_discount));
|
||||
$subtotal = bcadd($subtotal, $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount'], $item['discount_type'], $include_discount));
|
||||
}
|
||||
else
|
||||
{
|
||||
$subtotal = bcadd($subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed'], $include_discount));
|
||||
$subtotal = bcadd($subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_type'], $include_discount));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ class Tax_lib
|
||||
/*
|
||||
* Compute the tax basis and returns the tax amount
|
||||
*/
|
||||
public function get_item_sales_tax($quantity, $price, $discount_percentage, $discount_fixed, $tax_percentage, $rounding_code)
|
||||
public function get_item_sales_tax($quantity, $price, $discount, $discount_type, $tax_percentage, $rounding_code)
|
||||
{
|
||||
$decimals = tax_decimals();
|
||||
|
||||
// The tax basis should be returned at the currency scale
|
||||
$tax_basis = $this->CI->sale_lib->get_item_total($quantity, $price, $discount_percentage, $discount_fixed, TRUE);
|
||||
$tax_basis = $this->CI->sale_lib->get_item_total($quantity, $price, $discount, $discount_type, TRUE);
|
||||
|
||||
return $this->get_sales_tax_for_amount($tax_basis, $tax_percentage, $rounding_code, $decimals);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ class Tax_lib
|
||||
$decimals = tax_decimals();
|
||||
|
||||
// The tax basis should be returned at the currency scale
|
||||
$tax_basis = $this->CI->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_fixed'], TRUE);
|
||||
$tax_basis = $this->CI->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_type'], TRUE);
|
||||
$tax_amount = $this->get_sales_tax_for_amount($tax_basis, $tax_rate, $rounding_code, $decimals);
|
||||
|
||||
$tax_group = (float)$tax_rate . '% ' . $tax_category;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Migration_Upgrade_To_3_4_0 extends CI_Migration
|
||||
class Migration_Discount_on_sales extends CI_Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@@ -9,7 +9,7 @@ class Migration_Upgrade_To_3_4_0 extends CI_Migration
|
||||
|
||||
public function up()
|
||||
{
|
||||
execute_script(APPPATH . 'migrations/sqlscripts/3.3.0_to_3.4.0.sql');
|
||||
execute_script(APPPATH . 'migrations/sqlscripts/discount_on_sales.sql');
|
||||
}
|
||||
|
||||
public function down()
|
||||
@@ -1,22 +0,0 @@
|
||||
--
|
||||
-- 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`;
|
||||
24
application/migrations/sqlscripts/discount_on_sales.sql
Normal file
24
application/migrations/sqlscripts/discount_on_sales.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
--
|
||||
-- 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`
|
||||
CHANGE COLUMN `kit_discount_percent` `kit_discount` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `item_id`,
|
||||
ADD COLUMN `kit_discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `kit_discount`;
|
||||
|
||||
ALTER TABLE `ospos_customers`
|
||||
CHANGE COLUMN `discount_percent` `discount` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `sales_tax_code`,
|
||||
ADD COLUMN `discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `discount`;
|
||||
|
||||
|
||||
ALTER TABLE `ospos_sales_items`
|
||||
CHANGE COLUMN `discount_percent` `discount` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `item_unit_price`,
|
||||
ADD COLUMN `discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `discount`;
|
||||
|
||||
ALTER TABLE `ospos_receivings_items`
|
||||
CHANGE COLUMN `discount_percent` `discount` DECIMAL(15,2) NOT NULL DEFAULT '0.00' AFTER `item_unit_price`,
|
||||
ADD COLUMN `discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `discount`;
|
||||
@@ -104,7 +104,7 @@ class Customer extends Person
|
||||
(
|
||||
SELECT
|
||||
sales.sale_id AS sale_id,
|
||||
AVG(sales_items.discount_percent) AS avg_discount,
|
||||
AVG(sales_items.discount) AS avg_discount,
|
||||
SUM(sales_items.quantity_purchased) AS quantity
|
||||
FROM ' . $this->db->dbprefix('sales') . ' AS sales
|
||||
INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
|
||||
@@ -252,7 +252,8 @@ class Customer extends Person
|
||||
'company_name' => NULL,
|
||||
'account_number' => NULL,
|
||||
'taxable' => 0,
|
||||
'discount_percent' => 0.00,
|
||||
'discount' => 0.00,
|
||||
'discount_type' => 0,
|
||||
'package_id' => NULL,
|
||||
'points' => NULL,
|
||||
'sales_tax_code' => 1,
|
||||
|
||||
@@ -93,8 +93,7 @@ class Receiving extends CI_Model
|
||||
'serialnumber' => $item['serialnumber'],
|
||||
'quantity_purchased' => $item['quantity'],
|
||||
'receiving_quantity' => $item['receiving_quantity'],
|
||||
'discount_percent' => $item['discount'],
|
||||
'discount_fixed' => $item['discount_fixed'],
|
||||
'discount' => $item['discount'],
|
||||
'discount_type' => $item['discount_type'],
|
||||
'item_cost_price' => $cur_item_info->cost_price,
|
||||
'item_unit_price' => $item['price'],
|
||||
@@ -267,14 +266,14 @@ class Receiving extends CI_Model
|
||||
MAX(receivings_items.receiving_quantity) AS receiving_quantity,
|
||||
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,
|
||||
MAX(discount) AS discount,
|
||||
discount_type as discount_type,
|
||||
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) - 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(CASE WHEN receivings_items.discount_type = ' . PERCENT . ' THEN item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount / 100 ELSE item_unit_price * quantity_purchased * receivings_items.receiving_quantity - discount END) AS subtotal,
|
||||
MAX(CASE WHEN receivings_items.discount_type = ' . PERCENT . ' THEN item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount / 100 ELSE item_unit_price * quantity_purchased * receivings_items.receiving_quantity - discount END) AS total,
|
||||
MAX((CASE WHEN receivings_items.discount_type = ' . PERCENT . ' THEN item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount / 100 ELSE item_unit_price * quantity_purchased * receivings_items.receiving_quantity - discount END) - (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
|
||||
|
||||
@@ -10,6 +10,8 @@ define('SALE_TYPE_WORK_ORDER', 2);
|
||||
define('SALE_TYPE_QUOTE', 3);
|
||||
define('SALE_TYPE_RETURN', 4);
|
||||
|
||||
define('PERCENT', 0);
|
||||
define('FIXED', 1);
|
||||
/**
|
||||
* Sale class
|
||||
*/
|
||||
@@ -38,7 +40,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)-sales_items.discount_fixed';
|
||||
$sale_price = 'CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END';
|
||||
$tax = 'ROUND(IFNULL(SUM(sales_items_taxes.tax), 0), ' . $decimals . ')';
|
||||
|
||||
if($this->config->item('tax_included'))
|
||||
@@ -152,7 +154,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)-sales_items.discount_fixed';
|
||||
$sale_price = 'CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END';
|
||||
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
|
||||
|
||||
@@ -652,8 +654,7 @@ class Sale extends CI_Model
|
||||
'description' => character_limiter($item['description'], 255),
|
||||
'serialnumber' => character_limiter($item['serialnumber'], 30),
|
||||
'quantity_purchased'=> $item['quantity'],
|
||||
'discount_percent' => $item['discount'],
|
||||
'discount_fixed' => $item['discount_fixed'],
|
||||
'discount' => $item['discount'],
|
||||
'discount_type' => $item['discount_type'],
|
||||
'item_cost_price' => $item['cost_price'],
|
||||
'item_unit_price' => $item['price'],
|
||||
@@ -705,7 +706,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
$rounding_code = Rounding_mode::HALF_UP; // half adjust
|
||||
$tax_group_sequence = 0;
|
||||
$item_total = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
|
||||
$item_total = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_type'], TRUE);
|
||||
$tax_basis = $item_total;
|
||||
$item_tax_amount = 0;
|
||||
|
||||
@@ -727,12 +728,12 @@ class Sale extends CI_Model
|
||||
|
||||
// This computes tax for each line item and adds it to the tax type total
|
||||
$tax_group = (float)$row['percent'] . '% ' . $row['name'];
|
||||
$tax_basis = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
|
||||
$tax_basis = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], $item['discount_type'], TRUE);
|
||||
|
||||
if($this->config->item('tax_included'))
|
||||
{
|
||||
$tax_type = Tax_lib::TAX_TYPE_VAT;
|
||||
$item_tax_amount = $this->sale_lib->get_item_tax($item['quantity'], $item['price'], $item['discount'],$row['percent']);
|
||||
$item_tax_amount = $this->sale_lib->get_item_tax($item['quantity'], $item['price'], $item['discount'], $item['discount_type'], $row['percent']);
|
||||
}
|
||||
elseif($this->config->item('customer_sales_tax_support') == '0')
|
||||
{
|
||||
@@ -929,8 +930,7 @@ class Sale extends CI_Model
|
||||
quantity_purchased,
|
||||
item_cost_price,
|
||||
item_unit_price,
|
||||
discount_percent,
|
||||
discount_fixed,
|
||||
discount,
|
||||
discount_type,
|
||||
item_location,
|
||||
print_option,
|
||||
@@ -1117,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)-sales_items.discount_fixed';
|
||||
$sale_price = 'CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END';
|
||||
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
|
||||
|
||||
@@ -1194,8 +1194,8 @@ class Sale extends CI_Model
|
||||
MAX(sales_items.quantity_purchased) AS quantity_purchased,
|
||||
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,
|
||||
MAX(sales_items.discount) AS discount,
|
||||
sales_items.discount_type AS discount_type,
|
||||
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, discount_fixed, item_location, receivings_items_temp.receiving_quantity');
|
||||
$this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount, discount_type, 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, discount_fixed, sale_status');
|
||||
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, tax, total, cost, profit, discount, discount_type, sale_status');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
|
||||
@@ -71,11 +71,8 @@ class Specific_discount extends Report
|
||||
MAX(comment) AS comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
|
||||
if($inputs['discount_type']==1){
|
||||
$this->db->where('discount_fixed >=', $inputs['discount']);
|
||||
}else{
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
}
|
||||
$this->db->where('discount >=', $inputs['discount']);
|
||||
$this->db->where('discount_type',$inputs['discount_type']);
|
||||
|
||||
if($inputs['sale_type'] == 'complete')
|
||||
{
|
||||
@@ -124,7 +121,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, discount_fixed');
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount, discount_type');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
@@ -142,11 +139,9 @@ 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');
|
||||
|
||||
if($inputs['discount_type']==1){
|
||||
$this->db->where('discount_fixed >=', $inputs['discount']);
|
||||
}else{
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
}
|
||||
$this->db->where('discount >=', $inputs['discount']);
|
||||
$this->db->where('discount_type',$inputs['discount_type']);
|
||||
|
||||
|
||||
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, discount_fixed');
|
||||
$this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount, discount_type');
|
||||
$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,21 @@ class Summary_discounts extends Summary_report
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
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');
|
||||
if($inputs['discount_type'] == FIXED)
|
||||
{
|
||||
$this->db->select('MAX(CONCAT("'.$this->config->item('currency_symbol').'",sales_items.discount)) AS discount, count(*) AS count');
|
||||
$this->db->where('discount_type',FIXED);
|
||||
}
|
||||
elseif($inputs['discount_type'] == PERCENT)
|
||||
{
|
||||
$this->db->select('MAX(CONCAT(sales_items.discount, "%")) AS discount, count(*) AS count');
|
||||
$this->db->where('discount_type',PERCENT);
|
||||
}
|
||||
|
||||
$this->db->where('discount > 0');
|
||||
$this->db->group_by('sales_items.discount');
|
||||
$this->db->order_by('sales_items.discount');
|
||||
|
||||
|
||||
$this->db->from('sales_items AS sales_items');
|
||||
$this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
|
||||
|
||||
@@ -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)-sales_items.discount_fixed) AS payment_amount');
|
||||
$this->db->select('sales_payments.payment_type, COUNT(DISTINCT sales_payments.sale_id) AS count, SUM(CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END) 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)-sales_items.discount_fixed';
|
||||
$sale_price = 'CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END';
|
||||
$sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
$tax = 'IFNULL(SUM(sales_items_taxes.tax), 0)';
|
||||
|
||||
|
||||
@@ -41,13 +41,13 @@ class Summary_taxes extends Summary_report
|
||||
|
||||
if($this->config->item('tax_included'))
|
||||
{
|
||||
$sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
|
||||
$sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (100 / (100 + sales_items_taxes.percent)))';
|
||||
$sale_total = '(CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END)';
|
||||
$sale_subtotal = '(CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END * (100 / (100 + sales_items_taxes.percent)))';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 + (sales_items_taxes.percent / 100)))';
|
||||
$sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
|
||||
$sale_total = '(CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END * (1 + (sales_items_taxes.percent / 100)))';
|
||||
$sale_subtotal = '(CASE WHEN sales_items.discount_type = ' . PERCENT . ' THEN sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount / 100) ELSE sales_items.item_unit_price * sales_items.quantity_purchased - sales_items.discount END)';
|
||||
}
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
@@ -11,17 +11,6 @@
|
||||
</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'>
|
||||
@@ -34,19 +23,19 @@
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
'value' => $this->config->item('default_sales_discount'))); ?>
|
||||
<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'))); ?>
|
||||
<span class="input-group-btn">
|
||||
<?php echo form_checkbox(array(
|
||||
'id'=>'default_sales_discount_type',
|
||||
'name'=>'default_sales_discount_type',
|
||||
'value'=>1,
|
||||
'data-toggle'=>"toggle",
|
||||
'data-size'=>'small',
|
||||
'data-onstyle'=>'success',
|
||||
'data-on'=>'<b>'.$this->config->item('currency_symbol').'</b>',
|
||||
'data-off'=>'<b>%</b>',
|
||||
'checked'=>$this->config->item('default_sales_discount_type'))
|
||||
); ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -40,33 +40,41 @@
|
||||
</div>
|
||||
|
||||
<?php $this->load->view("people/form_basic_info"); ?>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('customers_discount_type'), 'discount_type', array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class="col-xs-8">
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'discount_type',
|
||||
'type'=>'radio',
|
||||
'id'=>'discount_type',
|
||||
'value'=>0,
|
||||
'checked'=>$person_info->discount_type == PERCENT)
|
||||
); ?> <?php echo $this->lang->line('customers_discount_percent'); ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<?php echo form_radio(array(
|
||||
'name'=>'discount_type',
|
||||
'type'=>'radio',
|
||||
'id'=>'discount_type',
|
||||
'value'=>1,
|
||||
'checked'=>$person_info->discount_type == FIXED)
|
||||
); ?> <?php echo $this->lang->line('customers_discount_fixed'); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('customers_discount'), 'discount_percent', array('class' => 'control-label col-xs-3')); ?>
|
||||
<?php echo form_label($this->lang->line('customers_discount'), 'discount', array('class' => 'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-3'>
|
||||
<div class="input-group input-group-sm">
|
||||
<?php echo form_input(array(
|
||||
'name'=>'discount_percent',
|
||||
'id'=>'discount_percent',
|
||||
'name'=>'discount',
|
||||
'id'=>'discount',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>$person_info->discount_percent)
|
||||
'value'=>$person_info->discount)
|
||||
); ?>
|
||||
<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>
|
||||
|
||||
@@ -92,17 +92,20 @@
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" style="font-weight: bold;"> <?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included")?> </td>
|
||||
</tr>
|
||||
<?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>
|
||||
<?php
|
||||
if($item['discount_type'] == FIXED)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo to_currency($item['discount']) . " " . $this->lang->line("sales_discount") ?></td>
|
||||
<?php
|
||||
}
|
||||
elseif($item['discount_type'] == PERCENT)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included") ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -165,22 +165,9 @@ if (isset($success))
|
||||
?>
|
||||
<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']);
|
||||
}
|
||||
?>
|
||||
<?php echo form_input(array('name'=>'discount', 'class'=>'form-control input-sm', 'value'=>to_decimals($item['discount'], 0), 'onClick'=>'this.select();')); ?>
|
||||
<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>
|
||||
@@ -189,20 +176,13 @@ if (isset($success))
|
||||
else
|
||||
{
|
||||
?>
|
||||
<td><?php
|
||||
if($item['discount_type'])
|
||||
{
|
||||
echo $item['discount_fixed'];
|
||||
}else{
|
||||
echo $item['discount'];
|
||||
}
|
||||
?></td>
|
||||
<td><?php 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-$item['discount_fixed']); ?></td>
|
||||
<td>
|
||||
<?php echo to_currency(($item['discount_type'] == PERCENT) ? $item['price']*$item['quantity']*$item['receiving_quantity'] - $item['price'] * $item['quantity'] * $item['receiving_quantity'] * $item['discount'] / 100 : $item['price']*$item['quantity']*$item['receiving_quantity'] - $item['discount']); ?></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>
|
||||
@@ -531,7 +511,7 @@ $(document).ready(function()
|
||||
}
|
||||
}
|
||||
|
||||
$('[name="price"],[name="quantity"],[name="receiving_quantity"],[name="discount"],[name="discount_fixed"],[name="description"],[name="serialnumber"]').change(function() {
|
||||
$('[name="price"],[name="quantity"],[name="receiving_quantity"],[name="discount"],[name="description"],[name="serialnumber"]').change(function() {
|
||||
$(this).parents("tr").prevAll("form:first").submit()
|
||||
});
|
||||
|
||||
|
||||
@@ -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'] . '% | ' .to_currency($item['discount_fixed']); ?></textarea>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo ($item['discount_type']==FIXED)?to_currency($item['discount']):$item['discount'] . '%';?></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'] . '% | ' .to_currency($item['discount_fixed']); ?></td>
|
||||
<td><?php echo ($item['discount_type']==FIXED)?to_currency($item['discount']):$item['discount'] . '%';?></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'] . '% | ' .to_currency($item['discount_fixed']); ?></textarea></td>
|
||||
cols="6"><?php echo ($item['discount_type']==FIXED)?to_currency($item['discount']):$item['discount'] . '%';?></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'] . '% | ' .to_currency($item['discount_fixed']); ?></td>
|
||||
<td><?php echo ($item['discount_type']==FIXED)?to_currency($item['discount']):$item['discount'] . '%';?></td>
|
||||
<?php if($discount > 0): ?>
|
||||
<td><?php echo to_currency($item['discounted_total'] / $item['quantity']); ?></td>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -96,19 +96,20 @@
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3"
|
||||
class="discount"><?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included") ?></td>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</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>
|
||||
<?php
|
||||
if($item['discount_type'] == FIXED)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo to_currency($item['discount']) . " " . $this->lang->line("sales_discount") ?></td>
|
||||
<?php
|
||||
}
|
||||
elseif($item['discount_type'] == PERCENT)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included") ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -91,18 +91,20 @@
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" style="font-weight: bold;"><?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included") ?></td>
|
||||
<td style="text-align:right;"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</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>
|
||||
<?php
|
||||
if($item['discount_type'] == FIXED)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo to_currency($item['discount']) . " " . $this->lang->line("sales_discount") ?></td>
|
||||
<?php
|
||||
}
|
||||
elseif($item['discount_type'] == PERCENT)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included") ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -93,18 +93,20 @@
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="2" class="discount"><?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included")?></td>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']) ; ?></td>
|
||||
</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>
|
||||
<?php
|
||||
if($item['discount_type'] == FIXED)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo to_currency($item['discount']) . " " . $this->lang->line("sales_discount") ?></td>
|
||||
<?php
|
||||
}
|
||||
elseif($item['discount_type'] == PERCENT)
|
||||
{
|
||||
?>
|
||||
<td colspan="3" class="discount"><?php echo number_format($item['discount'], 0) . " " . $this->lang->line("sales_discount_included") ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td class="total-value"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -197,23 +197,13 @@ if(isset($success))
|
||||
|
||||
<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']);
|
||||
}
|
||||
?>
|
||||
<?php echo form_input(array('name'=>'discount', 'class'=>'form-control input-sm', 'value'=>to_decimals($item['discount'], 0), 'tabindex'=>++$tabindex, 'onClick'=>'this.select();')); ?>
|
||||
<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)
|
||||
@@ -226,6 +216,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>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -358,7 +349,7 @@ if(isset($success))
|
||||
?>
|
||||
<tr>
|
||||
<th style='width: 55%;'><?php echo $this->lang->line("sales_customer_discount"); ?></th>
|
||||
<th style="width: 45%; text-align: right;"><?php echo $customer_discount_percent . ' %'; ?></th>
|
||||
<th style="width: 45%; text-align: right;"><?php echo ($customer_discount_type == FIXED)?to_currency($customer_discount):$customer_discount . '%'; ?></th>
|
||||
</tr>
|
||||
<?php if($this->config->item('customer_reward_enable') == TRUE): ?>
|
||||
<?php
|
||||
@@ -910,7 +901,7 @@ $(document).ready(function()
|
||||
}
|
||||
}
|
||||
|
||||
$('[name="price"],[name="quantity"],[name="discount"],[name="discount_fixed"],[name="description"],[name="serialnumber"],[name="discounted_total"]').change(function() {
|
||||
$('[name="price"],[name="quantity"],[name="discount"],[name="description"],[name="serialnumber"],[name="discounted_total"]').change(function() {
|
||||
$(this).parents("tr").prevAll("form:first").submit()
|
||||
});
|
||||
|
||||
|
||||
@@ -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'] . '% | ' .to_currency($item['discount_fixed']); ?></textarea></td>
|
||||
<td style='text-align:center;'><textarea rows="4" cols="6"><?php echo ($item['discount_type']==FIXED)?to_currency($item['discount']):$item['discount'] . '%';?></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'] . '% | ' .to_currency($item['discount_fixed']); ?></td>
|
||||
<td><?php echo ($item['discount_type']==FIXED)?to_currency($item['discount']):$item['discount'] . '%';?></td>
|
||||
<td class="total-line"><?php echo to_currency($item['discounted_total']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -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,Discount Fixed,Taxable
|
||||
First Name,Last Name,Gender,Consent,Email,Phone Number,Address 1,Address2,City,State,Zip,Country,Comments,Company,Account Number,Discount,Discount_Type,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
|
||||
|
||||
|
Reference in New Issue
Block a user