updated for food and beverage bugs

This commit is contained in:
Yan
2017-06-12 14:11:13 +06:30
parent ca2dc181d6
commit 4212ad45b3
4 changed files with 24 additions and 30 deletions

View File

@@ -64,12 +64,6 @@ $(document).ready(function(){
url: "/origami/" + unique_id,
data: { 'booking_id' : unique_id },
success:function(result){
// =======
// type: "GET",
// url: "origami/" + unique_id,
// data: { 'id' : unique_id },
// success:function(result){
// >>>>>>> 5ee3ae257a59269b651dcc5c0232b95d7f41fb77
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
@@ -191,20 +185,20 @@ $(document).ready(function(){
});
function show_customer_details(customer_id){
$('.customer_detail').removeClass('hide');
//Start Ajax
$.ajax({
type: "GET",
url: "origami/"+customer_id+"/get_customer/",
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data.name);
$("#customer_name").text(data.name);
}
});
//End Ajax
}
$('.customer_detail').removeClass('hide');
//Start Ajax
$.ajax({
type: "GET",
url: "origami/"+customer_id+"/get_customer/",
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data.name);
$("#customer_name").text(data.name);
}
});
//End Ajax
}
/* For Receipt - Calculate discount or tax */
$('.cashier_number').on('click', function(event){

View File

@@ -36,24 +36,25 @@ class SaleItem < ApplicationRecord
sale_items.each do |si|
food_price = self.get_food_price(si.sale_item_id)
beverage_price = self.get_beverage_price(si.sale_item_id)
puts food_price
# food_prices = food_prices + food_price.price
# beverage_prices = beverage_prices + beverage_price.price
beverage_price = self.get_beverage_price(si.sale_item_id)
food_prices = food_prices + food_price
beverage_prices = beverage_prices + beverage_price
end
return food_prices, beverage_prices
end
def self.get_food_price(sale_item_id)
food_price=SaleItem.select("sale_items.price")
food=SaleItem.select("sale_items.price")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
.where("sale_items.sale_item_id=? and menu_items.account_id=0", sale_item_id)
.where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id.to_s)
food_price = food[0].price rescue 0
end
def self.get_beverage_price(sale_item_id)
beverage_price=SaleItem.select("sale_items.price")
beverage=SaleItem.select("sale_items.price")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
.where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id)
.where("sale_items.sale_item_id=? and menu_items.account_id=2", sale_item_id.to_s)
beverage_price = beverage[0].price rescue 0
end
private

View File

@@ -216,7 +216,6 @@ $( document ).ready(function() {
});
$('#pay').click(function() {
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
}else{

View File

@@ -72,7 +72,7 @@ Rails.application.routes.draw do
#--------- Cashier ------------#
namespace :origami do
root "home#index"
get "/:booking_id" => "home#show" do #origami/:booking_id will show
get "/:booking_id" => "home#index" do #origami/:booking_id will show
# resources :discounts, only: [:index,:new, :create ] #add discount type
resources :customers #add customer type
end