Pull from master

This commit is contained in:
San Wai Lwin
2018-06-08 10:31:02 +06:30
parent b3e85ff25e
commit ce3ab0b0eb
8 changed files with 177 additions and 93 deletions

View File

@@ -219,3 +219,13 @@ function export_to(path)
var form_params = $("#frm_report").serialize();
window.location = path+"?"+ form_params;
}
/* chartkick js YAxis value override */
Chart.scaleService.updateScaleDefaults('linear', {
ticks: {
callback: function (value, index, values) {
return value/1000 + 'k';
}
}
});
/* chartkick js YAxis value override */

View File

@@ -13,7 +13,11 @@ App.order = App.cable.subscriptions.create('OrderChannel', {
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
$('.new_text_'+data.table.id).removeClass('hide')
}else{
}else if(data.type == 'move'){
$('.table_'+data.table).removeClass('blue');
$('.table_'+data.table).addClass('green');
$('.table_'+data.change_to).addClass('blue');
}else{
$('.table_'+data.table.id).removeClass('red');
$('.table_'+data.table.id).addClass('green');
$('.new_text_'+data.table.id).html('');

View File

@@ -7,8 +7,8 @@ class Origami::MoveroomController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@orders = Order.all.order('date desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@status_order = ""
@status_sale = ""
@@ -34,25 +34,25 @@ class Origami::MoveroomController < BaseOrigamiController
end
end
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != "waste" && sale.sale_status != "spoile"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end
@booking= booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
# else
# sale = Sale.find(booking.sale_id)
# if sale.sale_status != "completed" && sale.sale_status != "waste" && sale.sale_status != "spoile"
# @sale_array.push(sale)
# if @status_order == 'order'
# @status_order = 'sale'
# end
# @booking= booking
# @date = sale.created_at
# @status_sale = 'sale'
# @obj_sale = sale
# @customer = sale.customer
# accounts = @customer.tax_profiles
# @account_arr =[]
# accounts.each do |acc|
# account = TaxProfile.find(acc)
# @account_arr.push(account)
# end
# end
end
end
end

View File

@@ -7,52 +7,74 @@ class Origami::MovetableController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@orders = Order.all.order('date desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@dining = DiningFacility.find(params[:dining_id])
@status_order = ""
@status_sale = ""
@sale_array = Array.new
# if !bookings.nil?
# bookings.each do | booking |
# if booking.sale_id.nil? && booking.booking_status != 'moved'
# booking_array.push(booking)
# end
# booking.booking_orders.each do |booking_order|
# order = Order.find(booking_order.order_id)
# if order.status == 'new'
# order.order_items.each do |order_item|
# order_items.push(order_item)
# end
# end
# end
# end
# end
@dining.bookings.each do |booking|
if booking.sale_id.nil?
@order_items = Array.new
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
@obj_order = order
@customer = order.customer
@date = order.created_at
@booking= booking
order.order_items.each do |item|
@order_items.push(item)
end
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
if booking.booking_status != 'moved'
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
@obj_order = order
@customer = order.customer
@date = order.created_at
@booking= booking
if order.status == 'new'
order.order_items.each do |item|
@order_items.push(item)
end
end
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
end
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != "waste" && sale.sale_status != "spoile"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end
@booking= booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
# else
# sale = Sale.find(booking.sale_id)
# if sale.sale_status != "completed" && sale.sale_status != "waste" && sale.sale_status != "spoile"
# @sale_array.push(sale)
# if @status_order == 'order'
# @status_order = 'sale'
# end
# @booking= booking
# @date = sale.created_at
# @status_sale = 'sale'
# @obj_sale = sale
# @customer = sale.customer
# accounts = @customer.tax_profiles
# @account_arr =[]
# accounts.each do |acc|
# account = TaxProfile.find(acc)
# @account_arr.push(account)
# end
# end
end
end
end
@@ -104,6 +126,20 @@ class Origami::MovetableController < BaseOrigamiController
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items)
end
end
end
end
type = 'move'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: change_from,type:type,from:from ,change_to:change_to
end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
end
return from
end
end

View File

@@ -139,11 +139,10 @@ class Promotion < ApplicationRecord
# item = OrderItem.find_by_item_code(promo_product)
item = OrderItem.where("item_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
end
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion", item.price,source)
puts "Charged - " + charge_qty.to_s
puts "FOC - " + foc_qty.to_s
if !item.nil?
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion", item.price,source)
end
end
# AA - 10 # 3 # BB # orderList, #S34345
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id)
@@ -155,9 +154,10 @@ class Promotion < ApplicationRecord
end
# item = OrderItem.find_by_item_instance_code(promo_product)
item = OrderItem.where("item_instance_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
source = Order.find(item.order_id).source
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
if !item.nil?
source = Order.find(item.order_id).source
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
end
end
@@ -190,15 +190,21 @@ class Promotion < ApplicationRecord
foc_qty = orderitem[1].to_i / foc_min_qty
# item = OrderItem.find_by_item_instance_code(orderitem[0][0])
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
if !item.nil?
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
end
else
foc_qty = orderitem[1].to_i / foc_min_qty
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
if !item.nil?
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
end
end
end
@@ -208,9 +214,12 @@ class Promotion < ApplicationRecord
foc_qty = orderitem[1].to_i / foc_min_qty
# item = OrderItem.find_by_item_instance_code(orderitem[0][0]) # need to specify with menu item instance
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
price = item.price.to_i - promo_product.net_price.to_i
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
if !item.nil?
price = item.price.to_i - promo_product.net_price.to_i
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
end
else
order_qty = find_second_item_qty(sale_id, promo_product.item_code)# need to check for qty
foc_qty = orderitem[1].to_i / foc_min_qty
@@ -220,9 +229,12 @@ class Promotion < ApplicationRecord
end
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
price = item.price - promo_product.net_price
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
if !item.nil?
price = item.price - promo_product.net_price
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
end
end
end
@@ -233,10 +245,13 @@ class Promotion < ApplicationRecord
# item = OrderItem.find_by_item_instance_code(orderitem[0][0])
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
# total = orderitem[1].to_i * item.price
total = item.price
price = calculate_discount(total, promo_product.percentage)
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
if !item.nil?
total = item.price
price = calculate_discount(total, promo_product.percentage)
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
end
else
order_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check
foc_qty = orderitem[1].to_i / foc_min_qty
@@ -248,10 +263,12 @@ class Promotion < ApplicationRecord
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
# total = item.price * foc_qty
total = item.price
price = calculate_discount(total, promo_product.percentage)
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
if !item.nil?
total = item.price
price = calculate_discount(total, promo_product.percentage)
source = Order.find(item.order_id).source
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
end
end
end

View File

@@ -36,6 +36,7 @@ if (@booking)
end
json.order_items order_items do |item|
total_set_menu = 0
# For YGN BBQ
if item.item_code.include? ("PSA_")
adult_count += item.qty
@@ -46,6 +47,7 @@ if (@booking)
child_spent += (item.price * item.qty)
end
# End YGN BBQ
json.order_items_id item.order_items_id
json.order_id item.order_id
json.item_code item.item_code
@@ -57,7 +59,16 @@ if (@booking)
json.options item.options
json.remark item.remark
json.item_status item.order_item_status
@total_amount = @total_amount + (item.price * item.qty)
#start set menu item price
if !item.set_menu_items.nil? && item.set_menu_items != '[]'
JSON.parse(item.set_menu_items).each do |item_instance|
total_set_menu += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
end
end
#end set menu item price
@total_amount = @total_amount + (item.price * item.qty) + total_set_menu
end
end

View File

@@ -284,6 +284,7 @@
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item|
set_item_prices = 0
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
@@ -301,7 +302,8 @@
<% end %>
<% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]'
JSON.parse(order_item.set_menu_items).each do |item_instance| %>
JSON.parse(order_item.set_menu_items).each do |item_instance|
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && !item_instance["options"].empty? %>
@@ -313,10 +315,11 @@
<% end %>
</span>
<% end
sub_total += set_item_prices
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
<td class='item-attr'><%= (order_item.qty*order_item.price).to_f + set_item_prices %></td>
</tr>
<%

View File

@@ -269,8 +269,9 @@
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item |
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
set_item_prices = 0
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
@@ -286,7 +287,8 @@
<% end %>
<% if !order_item.set_menu_items.nil?
JSON.parse(order_item.set_menu_items).each do |item_instance| %>
JSON.parse(order_item.set_menu_items).each do |item_instance|
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
@@ -298,10 +300,11 @@
<% end %>
</span>
<% end
sub_total += set_item_prices
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
<td class='item-attr'><%= (order_item.qty*order_item.price).to_f + set_item_prices %></td>
</tr>
<%