Add config item for default order discount

This commit is contained in:
jekkos
2019-01-10 19:19:04 +01:00
committed by jekkos
parent 74f5bb17bb
commit 02d7588e59
10 changed files with 61 additions and 23 deletions

View File

@@ -276,6 +276,8 @@ 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_receivings_discount_type' => $this->input->post('default_receivings_discount_type') != NULL,
'default_receivings_discount' => $this->input->post('default_receivings_discount'),
'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'),

View File

@@ -93,7 +93,8 @@ 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');
$discount = $this->config->item('default_receivings_discount');
$discount_type = $this->config->item('default_receivings_discount_type');
if($mode == 'return' && $this->Receiving->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
{
@@ -101,9 +102,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, $discount_type);
$this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $discount_type);
}
elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount_type))
elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount, $discount_type))
{
$data['error'] = $this->lang->line('receivings_unable_to_add_item');
}

View File

@@ -367,7 +367,7 @@ class Sales extends Secure_Controller
{
$data = array();
$discount = 0.0;
$discount = $this->config->item('default_sales_discount');
$discount_type = $this->config->item('default_sales_discount_type');
// check if any discount is assigned to the selected customer
@@ -384,12 +384,6 @@ class Sales extends Secure_Controller
}
}
// if the customer discount is 0 or no customer is selected apply the default sales discount
if($discount == 0)
{
$discount = $this->config->item('default_sales_discount');
}
$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();

View File

@@ -68,7 +68,10 @@ $lang["config_default_barcode_width_number"] = "Default Barcode Width must be a
$lang["config_default_barcode_width_required"] = "Default Barcode Width is a required field";
$lang["config_default_item_columns"] = "Default Visible Item Columns";
$lang["config_default_origin_tax_code"] = "Default Origin Tax Code";
$lang["config_default_sales_discount"] = "Default Sales Discount %";
$lang["config_default_receivings_discount"] = "Default Receivings Discount";
$lang["config_default_receivings_discount_number"] = "Default Receivings Discount must be a number";
$lang["config_default_receivings_discount_required"] = "Default Receivings Discount is a required field";
$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_category"] = "Default Tax Category";

View File

@@ -42,7 +42,7 @@ $lang["common_logout"] = "Logout";
$lang["common_migration_needed"] = "A database migration to %1 will start after login.";
$lang["common_new"] = "New";
$lang["common_no_persons_to_display"] = "There are no people to display.";
$lang["common_none_selected_text"] = "[Select]";
$lang["common_none_selected_text"] = "Nothing selected";
$lang["common_or"] = "OR";
$lang["common_phone_number"] = "Phone Number";
$lang["common_phone_number_required"] = "";

View File

@@ -69,7 +69,10 @@ $lang["config_default_barcode_width_number"] = "Default Barcode Width must be a
$lang["config_default_barcode_width_required"] = "Default Barcode Width is a required field.";
$lang["config_default_item_columns"] = "Default Visible Item Columns";
$lang["config_default_origin_tax_code"] = "Default Origin Tax Code";
$lang["config_default_sales_discount"] = "Default Sales Discount %";
$lang["config_default_receivings_discount"] = "Default Receivings Discount";
$lang["config_default_receivings_discount_number"] = "Default Receivings Discount must be a number.";
$lang["config_default_receivings_discount_required"] = "Default Receivings Discount is a required field.";
$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_category"] = "Default Tax Category";

View File

@@ -68,7 +68,10 @@ $lang["config_default_barcode_width_number"] = "De breedte van de barcode moet e
$lang["config_default_barcode_width_required"] = "De breedte van de barcode is een verplicht veld.";
$lang["config_default_item_columns"] = "Standaard Zichtbaarheid Kolommen";
$lang["config_default_origin_tax_code"] = "Standaard VAT code";
$lang["config_default_sales_discount"] = "Standaard Korting %";
$lang["config_default_receivings_discount"] = "Standaard Korting Orders";
$lang["config_default_receivings_discount_number"] = "De korting moet een getal zijn.";
$lang["config_default_receivings_discount_required"] = "De korting is een verplicht veld.";
$lang["config_default_sales_discount"] = "Standaard Korting Verkoop";
$lang["config_default_sales_discount_number"] = "De korting moet een getal zijn.";
$lang["config_default_sales_discount_required"] = "De korting is een verplicht veld.";
$lang["config_default_tax_category"] = "Standaard Tax Categorie";

View File

@@ -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, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $receiving_id = NULL, $include_deleted = FALSE)
public function add_item($item_id, $quantity = 1, $item_location = NULL, $discount = 0, $discount_type = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $receiving_id = NULL, $include_deleted = FALSE)
{
//make sure item exists in database.
if(!$this->CI->Item->exists($item_id, $include_deleted))
@@ -320,13 +320,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_type, $row->discount, $row->item_unit_price, $row->description, $row->serialnumber, $receiving_id, $row->receiving_quantity, TRUE);
$this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount, $row->discount_type, $row->item_unit_price, $row->description, $row->serialnumber, $receiving_id, $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, $discount_type)
public function add_item_kit($external_item_kit_id, $item_location, $discount, $discount_type)
{
//KIT #
$pieces = explode(' ',$external_item_kit_id);
@@ -334,7 +334,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, $discount_type);
$this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount, $discount_type);
}
}
@@ -345,7 +345,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, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, $receiving_id, TRUE);
$this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount, $row->discount_type, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, $receiving_id, TRUE);
}
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);

View File

@@ -132,15 +132,19 @@ SET `ospos_expenses`.`supplier_id` = `ospos_suppliers`.`person_id`;
-- Save name in description for those expenses whose supplier isn't registered
UPDATE `ospos_expenses`
SET `description` = CONCAT(`description`, CONCAT('\nSupplier name: ', `supplier_name`))
WHERE `supplier_id` is NULL;
SET `description` = CONCAT(`description`, CONCAT('\nSupplier name: ', `supplier_name`))
WHERE `supplier_id` is NULL;
-- Add foreign key
ALTER TABLE `ospos_expenses`
ADD CONSTRAINT `ospos_expenses_ibfk_3` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`);
ADD CONSTRAINT `ospos_expenses_ibfk_3` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`);
-- Delete supplier name
ALTER TABLE `ospos_expenses`
DROP COLUMN `supplier_name`;
DROP COLUMN `supplier_name`;
INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('default_receivings_discount_type', '0'),
('default_receivings_discount', '0');

View File

@@ -39,6 +39,34 @@
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_default_receivings_discount'), 'default_receivings_discount', array('class' => 'control-label col-xs-2 required')); ?>
<div class='col-xs-2'>
<div class="input-group">
<?php echo form_input(array(
'name' => 'default_receivings_discount',
'id' => 'default_receivings_discount',
'class' => 'form-control input-sm required',
'type' => 'number',
'min' => 0,
'max' => 100,
'value' => $this->config->item('default_receivings_discount'))); ?>
<span class="input-group-btn">
<?php echo form_checkbox(array(
'id' => 'default_receivings_discount_type',
'name' => 'default_receivings_discount_type',
'value' => 1,
'data-toggle' => 'toggle',
'data-size' => 'normal',
'data-onstyle' => 'success',
'data-on' => '<b>'.$this->config->item('currency_symbol').'</b>',
'data-off' => '<b>%</b>',
'checked' => $this->config->item('default_receivings_discount_type'))); ?>
</span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_enforce_privacy'), 'enforce_privacy', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-1'>