From 6236e06558618d2eabe3e27c168e8f40b43469d6 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 23 May 2018 16:33:20 +0630 Subject: [PATCH 1/3] update commitssion --- .../origami/product_commissions_controller.rb | 11 +++++++---- app/models/commission.rb | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb index 1156827a..7872573b 100755 --- a/app/controllers/origami/product_commissions_controller.rb +++ b/app/controllers/origami/product_commissions_controller.rb @@ -90,10 +90,13 @@ class Origami::ProductCommissionsController < BaseOrigamiController @menu_item = MenuItem.find_by_item_code(@sale_item.product_code) # @commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.item_code, true).take - Commission.all.each do |com| - if com.product_code.include? @menu_item.item_code && com.is_active == true - @commission = Commission.find(com.id) - break + Commission.all.active.each do |com| + puts com.product_code != "[]" + if com.product_code != "[]" + if com.product_code.to_s.include? @menu_item.item_code + @commission = Commission.find(com.id) + break + end end end @commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take diff --git a/app/models/commission.rb b/app/models/commission.rb index e331eb59..32aa8a04 100755 --- a/app/models/commission.rb +++ b/app/models/commission.rb @@ -10,7 +10,7 @@ class Commission < ApplicationRecord # validations validates_presence_of :name, :commission_type, :amount - + scope :active, -> {where(is_active: true)} private def generate_custom_id self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM') From 0ec4b6cb1259582a1272a7c1fcd996c8728dcc00 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 23 May 2018 17:50:13 +0630 Subject: [PATCH 2/3] update addorder --- app/assets/javascripts/addorder.js | 5 +++++ app/controllers/origami/product_commissions_controller.rb | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 3be2f34d..db1dab63 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1012,12 +1012,14 @@ $(function() { //calculate subtotal function calculate_sub_total(){ var total_price = 0; + var total_qty = 0; var taxable_amount = 0; var item_row = $('.summary-items tbody tr'); $(item_row).each(function(i){ var unit_price = parseFloat($(item_row[i]).attr('data-price')); var qty = parseFloat($(item_row[i]).children('#item_qty').text()); + total_qty += qty; total_price += qty*unit_price; }); var fixed_total_price = parseFloat(total_price).toFixed(2); @@ -1026,6 +1028,9 @@ $(function() { $('#sub_total').empty(); $('#sub_total').append(fixed_total_price); + $('#total_qty').empty(); + $('#total_qty').append(fixed_total_price); + if (item_row.length > 0) { $('.create').removeAttr("disabled", false); }else{ diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb index 7872573b..b452cffe 100755 --- a/app/controllers/origami/product_commissions_controller.rb +++ b/app/controllers/origami/product_commissions_controller.rb @@ -91,7 +91,6 @@ class Origami::ProductCommissionsController < BaseOrigamiController # @commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.item_code, true).take Commission.all.active.each do |com| - puts com.product_code != "[]" if com.product_code != "[]" if com.product_code.to_s.include? @menu_item.item_code @commission = Commission.find(com.id) From 295615a9fc956dc1a8f17ba3f53c6910513b1793 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 23 May 2018 17:59:20 +0630 Subject: [PATCH 3/3] update addorder for qty toatal --- app/assets/javascripts/addorder.js | 2 +- app/views/origami/addorders/detail.html.erb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index db1dab63..6d9782e3 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1029,7 +1029,7 @@ $(function() { $('#sub_total').append(fixed_total_price); $('#total_qty').empty(); - $('#total_qty').append(fixed_total_price); + $('#total_qty').append(total_qty); if (item_row.length > 0) { $('.create').removeAttr("disabled", false); diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 0ba7f60b..7aeb6342 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -255,9 +255,9 @@ - - - + + +
Total:Total:00.00