From 3b659526f39423be9201813e49157362c52c74c3 Mon Sep 17 00:00:00 2001 From: Erastus Date: Sun, 2 Sep 2018 17:58:41 -0500 Subject: [PATCH] cleaning spaces --- application/controllers/Sales.php | 2 +- application/libraries/Receiving_lib.php | 7 +++--- application/libraries/Sale_lib.php | 3 ++- .../20180820100000_discount_on_sales.php | 20 ---------------- ...hp => 20180830100000_upgrade_to_3_3_0.php} | 0 .../migrations/sqlscripts/3.2.1_to_3.3.0.sql | 23 ++++++++++++++++++- .../sqlscripts/discount_on_sales.sql | 23 ------------------- .../models/reports/Specific_discount.php | 1 - application/views/item_kits/form.php | 3 +-- application/views/receivings/receiving.php | 1 - application/views/sales/register.php | 1 - 11 files changed, 30 insertions(+), 54 deletions(-) delete mode 100644 application/migrations/20180820100000_discount_on_sales.php rename application/migrations/{20180610100000_upgrade_to_3_3_0.php => 20180830100000_upgrade_to_3_3_0.php} (100%) delete mode 100644 application/migrations/sqlscripts/discount_on_sales.sql diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index f157f45c0..dffb26d81 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -385,7 +385,7 @@ class Sales extends Secure_Controller } // 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'); } diff --git a/application/libraries/Receiving_lib.php b/application/libraries/Receiving_lib.php index 218cc1242..53ba67bfd 100644 --- a/application/libraries/Receiving_lib.php +++ b/application/libraries/Receiving_lib.php @@ -226,7 +226,8 @@ class Receiving_lib 1 => 'x1'); } - if(is_null($receiving_quantity)){ + if(is_null($receiving_quantity)) + { $receiving_quantity = $item_info->receiving_quantity; } @@ -279,7 +280,8 @@ class Receiving_lib $line['quantity'] = $quantity; $line['receiving_quantity'] = $receiving_quantity; $line['discount'] = $discount; - if(!is_null($discount_type)){ + if(!is_null($discount_type)) + { $line['discount_type'] = $discount_type; } $line['price'] = $price; @@ -367,7 +369,6 @@ class Receiving_lib $discount_fraction = bcdiv($discount, 100); $discount_amount = bcmul($total, $discount_fraction); } - return bcsub($total, $discount_amount); } diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php index 528459fa6..6e98c0918 100644 --- a/application/libraries/Sale_lib.php +++ b/application/libraries/Sale_lib.php @@ -949,7 +949,8 @@ class Sale_lib $line['serialnumber'] = $serialnumber; $line['quantity'] = $quantity; $line['discount'] = $discount; - if(!is_null($discount_type)){ + if(!is_null($discount_type)) + { $line['discount_type'] = $discount_type; } $line['price'] = $price; diff --git a/application/migrations/20180820100000_discount_on_sales.php b/application/migrations/20180820100000_discount_on_sales.php deleted file mode 100644 index d0c6e401a..000000000 --- a/application/migrations/20180820100000_discount_on_sales.php +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/application/migrations/20180610100000_upgrade_to_3_3_0.php b/application/migrations/20180830100000_upgrade_to_3_3_0.php similarity index 100% rename from application/migrations/20180610100000_upgrade_to_3_3_0.php rename to application/migrations/20180830100000_upgrade_to_3_3_0.php diff --git a/application/migrations/sqlscripts/3.2.1_to_3.3.0.sql b/application/migrations/sqlscripts/3.2.1_to_3.3.0.sql index 0cc3bd68d..8f32dbb51 100644 --- a/application/migrations/sqlscripts/3.2.1_to_3.3.0.sql +++ b/application/migrations/sqlscripts/3.2.1_to_3.3.0.sql @@ -3,7 +3,8 @@ -- INSERT INTO `ospos_app_config` (`key`, `value`) VALUES -('multi_pack_enabled', '0'); +('multi_pack_enabled', '0'), +('default_sales_discount_type', '0'); ALTER TABLE `ospos_items` ADD COLUMN `qty_per_pack` decimal(15,3) NOT NULL DEFAULT 1, @@ -13,3 +14,23 @@ ALTER TABLE `ospos_items` UPDATE `ospos_items` SET `low_sell_item_id` = `item_id` WHERE `low_sell_item_id` = 0; + +-- +-- Add support for Discount on Sales Fixed +-- + +ALTER TABLE `ospos_item_kits` + CHANGE COLUMN `kit_discount_percent` `kit_discount` DECIMAL(15,2) NOT NULL DEFAULT 0 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 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 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 AFTER `item_unit_price`, + ADD COLUMN `discount_type` TINYINT(2) NOT NULL DEFAULT '0' AFTER `discount`; diff --git a/application/migrations/sqlscripts/discount_on_sales.sql b/application/migrations/sqlscripts/discount_on_sales.sql deleted file mode 100644 index 05d61f922..000000000 --- a/application/migrations/sqlscripts/discount_on_sales.sql +++ /dev/null @@ -1,23 +0,0 @@ --- --- Add support for Discount on Sales Fixed --- - -INSERT INTO `ospos_app_config` (`key`, `value`) VALUES -('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`; diff --git a/application/models/reports/Specific_discount.php b/application/models/reports/Specific_discount.php index d46e6f037..03f05623d 100755 --- a/application/models/reports/Specific_discount.php +++ b/application/models/reports/Specific_discount.php @@ -141,7 +141,6 @@ class Specific_discount extends Report $this->db->where('discount >=', $inputs['discount']); $this->db->where('discount_type',$inputs['discount_type']); - if($inputs['sale_type'] == 'complete') { diff --git a/application/views/item_kits/form.php b/application/views/item_kits/form.php index e767346a7..711c35350 100644 --- a/application/views/item_kits/form.php +++ b/application/views/item_kits/form.php @@ -59,8 +59,7 @@ 'id'=>'kit_discount_fixed', 'class'=>'form-control input-sm', 'value'=>$item_kit_info->kit_discount_fixed) - );?> - + );?> diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php index f4d6946f7..5c2b934e7 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -516,7 +516,6 @@ $(document).ready(function() }); $('[name="discount_toggle"]').change(function() { - var 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(); diff --git a/application/views/sales/register.php b/application/views/sales/register.php index 8c20bd4d1..7fde2d58c 100644 --- a/application/views/sales/register.php +++ b/application/views/sales/register.php @@ -906,7 +906,6 @@ $(document).ready(function() }); $('[name="discount_toggle"]').change(function() { - var 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();