From a9070ebe0dde64c6eddbafdb398eb49f351f68b8 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 30 May 2018 10:20:36 +0630 Subject: [PATCH] add override sale tax for member discount --- app/controllers/origami/discounts_controller.rb | 3 ++- app/models/sale_payment.rb | 2 +- app/views/origami/others_payments/index.html.erb | 4 ++-- app/views/origami/payments/show.html.erb | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 8bbba963..380c2c47 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -231,6 +231,7 @@ class Origami::DiscountsController < BaseOrigamiController sale_id = params[:sale_id] is_card = params[:is_card] sub_total = params[:sub_total] + tax_type = params[:tax_type] sale = Sale.find(sale_id) if is_card == 'true' is_card = true @@ -306,7 +307,7 @@ class Origami::DiscountsController < BaseOrigamiController if response["discount_bonus_earned"] discount_amount = discount_amount + response["discount_bonus_earned"] end - sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source) + sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source, tax_type) result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type } elsif response["status"] == "500" result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type } diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 34926548..3933aa2c 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -270,7 +270,7 @@ class SalePayment < ApplicationRecord def self.get_sale_payments_by_card(sale_payments) # Check for Card Payment sale_payments.each do |sp| - if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" + if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay" return true; end end diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index b77e607e..65961556 100755 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -39,7 +39,7 @@ if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ receipt_no = ($("#receipt_no").html()).trim(); } - if ($("#server_mode").val() != "cloud") { // first bill not used in cloud + // if ($("#server_mode").val() != "cloud") { // first bill not used in cloud payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment"); if(payment_type) { $(".others-payment").hide(); @@ -47,7 +47,7 @@ $("."+payment_type[i]).show(); }); } - } + // } /* end check first bill or not*/ $('.others-payment').on('click',function(){ diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 2137d99e..f16fc42d 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -762,7 +762,7 @@ var customer_name = "<%= @customer.name %>"; var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : ''; if (credit <= 0) { - calculate_member_discount(sale_id); + calculate_member_discount(sale_id,tax_type); } $("#pdfModal").on('shown.bs.modal', function () { @@ -1049,7 +1049,7 @@ var customer_name = "<%= @customer.name %>"; }); } - function calculate_member_discount(sale_id) { + function calculate_member_discount(sale_id,tax_type) { var sub_total = $('#sub-total').text(); var member_id = $('#membership_id').text(); var member_discount = $('#member_discount').text(); @@ -1064,7 +1064,7 @@ var customer_name = "<%= @customer.name %>"; $.ajax({ type: "POST", url: "/origami/" + sale_id + "/member_discount", - data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':cashier_type }, + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':cashier_type, 'tax_type':tax_type }, async: false, success:function(result){ }