fix discount with selected

This commit is contained in:
Yan
2017-07-20 17:42:02 +06:30
parent e45bc7964c
commit 30e1854969
3 changed files with 54 additions and 50 deletions

View File

@@ -124,7 +124,8 @@ class Origami::DiscountsController < BaseOrigamiController
# Member Discount # Member Discount
def member_discount def member_discount
sale_id = params[:sale_id] sale_id = params[:sale_id]
account_types = JSON.parse(params[:account_types]) # account_types = JSON.parse(params[:account_types])
account_types = Account.where("discount=?",true)
sub_total = params[:sub_total] sub_total = params[:sub_total]
sale = Sale.find(sale_id) sale = Sale.find(sale_id)
price = SaleItem.calculate_price_by_accounts(sale.sale_items) price = SaleItem.calculate_price_by_accounts(sale.sale_items)
@@ -133,7 +134,7 @@ class Origami::DiscountsController < BaseOrigamiController
account_types.each do |at| account_types.each do |at|
price.each do |pc| price.each do |pc|
if pc[:name].to_s == at["name"].to_s && pc[:price]>0 if pc[:name] == at.title && pc[:price]>0
str={type:pc[:name],amount:pc[:price]} str={type:pc[:name],amount:pc[:price]}
arr.push(str) arr.push(str)
end end

View File

@@ -497,60 +497,63 @@ $(document).ready(function(){
var ajax_url = "/origami/" + sale_id + "/member_discount"; var ajax_url = "/origami/" + sale_id + "/member_discount";
// Selected Account // Selected Account
var account_types = JSON.stringify(get_selected_account_types()); //var account_types = JSON.stringify(get_selected_account_types());
if($('.accounts-type').hasClass('selected-account') == true){ // if($('.accounts-type').hasClass('selected-account') == true){
var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types }; // var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
$.ajax({ var params = {'sale_id':sale_id, 'sub_total':sub_total };
type: "POST",
url: ajax_url,
data: params,
success:function(result){
if (result.status == "Success") { $.ajax({
type = 'green' type: "POST",
btn_color = 'btn-green' url: ajax_url,
}else{ data: params,
type = 'red' success:function(result){
btn_color = 'btn-red'
} if (result.status == "Success") {
type = 'green'
$.confirm({ btn_color = 'btn-green'
title: result.title, }else{
content: result.status, type = 'red'
columnClass: 'small', btn_color = 'btn-red'
type: type,
buttons: { }
confirm: {
text: 'Ok', $.confirm({
btnClass: btn_color, title: result.title,
action: function(){ content: result.status,
if(result.table_type == "Table"){ columnClass: 'small',
window.location.href = "/origami/table/" + result.table_id type: type,
} buttons: {
else { confirm: {
window.location.href = "/origami/room/" + result.table_id text: 'Ok',
} btnClass: btn_color,
} action: function(){
} if(result.table_type == "Table"){
} window.location.href = "/origami/table/" + result.table_id
}); }
else {
} window.location.href = "/origami/room/" + result.table_id
}); }
}else{ }
$.alert({ }
title: 'Alert!', }
content: 'Please Select Account', });
type: 'red',
typeAnimated: true, }
btnClass: 'btn-danger', });
}); // }
// else{
// $.alert({
// title: 'Alert!',
// content: 'Please Select Account',
// type: 'red',
// typeAnimated: true,
// btnClass: 'btn-danger',
// });
} // }
});//end member discount });//end member discount
}); });

BIN
dump.rdb

Binary file not shown.