diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 93ec79c1..ca5a6932 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1097,16 +1097,28 @@ $(function() { var total_price = 0; var total_qty = 0; var taxable_amount = 0; + var exclusive_total =0; + var inclusive_total =0; + var inclusive_tax =$('#inclusive_tax').val(); + var exclusive_tax =$('#exclusive_tax').val(); 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; }); + if (inclusive_tax >0){ + inclusive_total = total_price / inclusive_tax; + } + if (exclusive_tax >0){ + exclusive_total = total_price * exclusive_tax; + } + total_price = total_price + exclusive_total + inclusive_total; var fixed_total_price = parseFloat(total_price).toFixed(2); var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2); + $('#total_tax').empty(); + $('#total_tax').append(exclusive_total + inclusive_total); $('#sub_total').empty(); $('#sub_total').append(fixed_total_price); diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index b6664050..12837add 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -81,7 +81,8 @@ class Crm::CustomersController < BaseCrmController @membership_types = Lookup.collection_of("member_group_type") - # @taxes = TaxProfile.where(:group_type => 'cashier') + # @taxes = TaxProfile.all + # @taxes =TaxProfile.unscoped.select("id,(SELECT name from lookups where lookup_type='tax_profiles') as name") @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") .order("group_type ASC,order_by ASC") diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index 3e69485a..f61da475 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -32,8 +32,8 @@ class Origami::QuickServiceController < ApplicationController #checked quick_service only @quick_service_only = false lookup_dine_in = Lookup.collection_of('quickservice_add_order') - puts 'lookup_dine_in!!!!' - puts lookup_dine_in + # puts 'lookup_dine_in!!!!' + # puts lookup_dine_in if !lookup_dine_in.empty? lookup_dine_in.each do |dine_in| if dine_in[0].downcase == "quickserviceaddorder" @@ -43,7 +43,23 @@ class Origami::QuickServiceController < ApplicationController end end end - + divided_value =0 + exclusive =0 + tax_profiles = TaxProfile.where(group_type: "quick_service") + if !tax_profiles.empty? + tax_profiles.each do |tax| + #include or execulive + if tax.inclusive + tax_incl_exec = "inclusive" + rate = tax.rate + divided_value += (100 + rate)/rate + else + exclusive +=tax.rate / 100 + end + end + end + @inclusive_tax =divided_value + @exclusive_tax =exclusive render "origami/addorders/detail" end @@ -121,7 +137,7 @@ class Origami::QuickServiceController < ApplicationController order.table_id = params[:table_id] # this is dining facilities's id order.waiters = current_login_employee.name order.employee_name = current_login_employee.name - + order.is_extra_time = is_extra_time order.extra_time = extra_time diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index e7abb58b..ce3d709d 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -10,6 +10,8 @@ + +