Merge branch 'staging' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -25,11 +25,12 @@ $(document).ready(function(){
|
||||
// }, 10000);
|
||||
$(".nav-completed").on("click", function(){
|
||||
$("#completed").removeClass('hide')
|
||||
|
||||
$(".oqs_append").addClass('hide')
|
||||
});
|
||||
|
||||
$(".oqs_click").on("click", function(){
|
||||
$("#completed").addClass('hide')
|
||||
$(".oqs_append").removeClass('hide')
|
||||
var oqs_id = $(this).find(".oqs-id").text();
|
||||
var url = 'oqs/get_items/'+oqs_id;
|
||||
show_details(url);
|
||||
@@ -46,7 +47,8 @@ $(document).ready(function(){
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
success: function(data) {
|
||||
|
||||
for(var field in data) {
|
||||
var price = parseFloat(data[field].price).toFixed(2);
|
||||
|
||||
@@ -62,7 +64,7 @@ $(document).ready(function(){
|
||||
row ='<div class="card queue_station">'
|
||||
+'<div class="card-block">'
|
||||
+'<h4 class="card-title">'
|
||||
+'<span class="order-zone-type">'+data[field]["type"]+'- </span>'
|
||||
+'<span class="order-zone-type">'+data[field]["table_type"]+'- </span>'
|
||||
+'<span class="order-zone">'+ data[field]["zone"] +'</span>'
|
||||
+'<small class="pull-right">'+ data[field]["order_id"] +'- </small>'
|
||||
+'</h4>'
|
||||
@@ -200,7 +202,8 @@ $(document).ready(function(){
|
||||
$(document).on('click', '#print_order_item', function(event){
|
||||
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
|
||||
var options = $('.selected-item').children('.card-block').find('.item-options').text();
|
||||
var params = { 'options':options };
|
||||
var params = { 'options':options };
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/oqs/print/print/'+assigned_item_id,
|
||||
|
||||
@@ -89,7 +89,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
|
||||
@@ -95,7 +95,6 @@ class Oqs::HomeController < BaseOqsController
|
||||
end
|
||||
|
||||
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status,oqs_id=nil)
|
||||
if oqs_id == nil
|
||||
@@ -103,7 +102,13 @@ class Oqs::HomeController < BaseOqsController
|
||||
else
|
||||
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
|
||||
end
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options,
|
||||
cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
@@ -114,7 +119,6 @@ class Oqs::HomeController < BaseOqsController
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs}")
|
||||
.group("assigned_order_items.assigned_order_item_id")
|
||||
.order("assigned_order_items.created_at")
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@complete = Sale.where("sale_status != 'new'")
|
||||
@orders = Order.all.order('date desc')
|
||||
@shop = Shop.find_by_id(1)
|
||||
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
@@ -39,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
puts "enter"
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
|
||||
@@ -39,13 +39,13 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account)
|
||||
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
|
||||
|
||||
|
||||
end
|
||||
@@ -72,6 +72,8 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -22,14 +22,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
# end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
|
||||
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
cashier = shift_sale.employee.name
|
||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
|
||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
pdf.render_file filename
|
||||
self.print(filename)
|
||||
|
||||
@@ -125,6 +125,12 @@ class ShiftSale < ApplicationRecord
|
||||
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
|
||||
.group("acc.title").order("acc.id")
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_total_member_discount(shift)
|
||||
query = Sale.select("SUM(sales.total_discount) as member_discount")
|
||||
.where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class CloseCashierPdf < Prawn::Document
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
|
||||
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
|
||||
self.page_width = 210
|
||||
self.page_height = 7000
|
||||
self.margin = 5
|
||||
@@ -32,7 +32,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
|
||||
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
|
||||
move_down 7
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
@@ -277,9 +277,32 @@ class CloseCashierPdf < Prawn::Document
|
||||
end
|
||||
#end total amount by Account
|
||||
|
||||
if total_member_discount[0].member_discount.present?
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@overall = shift_sale.total_discounts - @member_discount
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Member Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{@member_discount}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Overall Discount Amount :", :size => self.item_font_size, :align => :right
|
||||
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{@overall}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Discount Amount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{shift_sale.total_discounts}", :size => self.item_font_size, :align => :right
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
<p class="hidden oqs-id"><%= qsi.id %></p>
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab" <%= status %>>
|
||||
<%= qsi.station_name %>
|
||||
<span class="badge badge-pill badge-default" id=""><%= qsi.assigned_order_items.count(:delivery_status) %>
|
||||
<span class="badge badge-pill badge-default" id=""> <%= qsi.assigned_order_items.where("delivery_status=0").count %>
|
||||
</span>
|
||||
<% if qsi.auto_print %>
|
||||
<span>(ap)</span>
|
||||
<% end %>
|
||||
<%= qsi.assigned_order_items.where("delivery_status=0").count %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
|
||||
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
|
||||
<!-- Temporary Disabled -->
|
||||
<%if current_login_employee.role == "cashier" %>
|
||||
<%if current_login_employee.role == "cashier" && @shop.quick_sale_summary == true%>
|
||||
<button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Sammary</button>
|
||||
<%end%>
|
||||
<button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button>
|
||||
|
||||
@@ -55,11 +55,29 @@
|
||||
<td><%= amount.total_price.round(2) %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
|
||||
<% if !@total_member_discount[0].member_discount.nil?
|
||||
@member_discount = @total_member_discount[0].member_discount rescue 0.0
|
||||
@overall = @shift.total_discounts - @member_discount
|
||||
%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Overall Discount Amount</th>
|
||||
<th><%= @shift.total_discounts %></th>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Member Discount</th>
|
||||
<th><%= @member_discount %></th>
|
||||
</tr>
|
||||
<%else @overall = @shift.total_discounts %>
|
||||
|
||||
<%end%>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Overall Discount</th>
|
||||
<th><%= @overall %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th style="text-align: right;"> Total Discount</th>
|
||||
<th><%= @shift.total_discounts %></th>
|
||||
</tr>
|
||||
|
||||
<% @sale_taxes.each do |tax| %>
|
||||
<tr>
|
||||
@@ -98,6 +116,7 @@
|
||||
<th><%=@shift.credit_sales %></th>
|
||||
</tr>
|
||||
<% @total_amount = 0
|
||||
|
||||
@other_payment.each do |other| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
@@ -107,32 +126,32 @@
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">MPU Payment </td>
|
||||
<td><%=other.mpu_amount.round(2) %></td>
|
||||
<% @total_amount = @total_amount+other.mpu_amount %>
|
||||
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">VISA Payment </td>
|
||||
<td><%=other.visa_amount.round(2) %></td>
|
||||
<% @total_amount = @total_amount+other.visa_amount %>
|
||||
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">JCB Payment </td>
|
||||
<td><%=other.master_amount.round(2) %></td>
|
||||
<% @total_amount = @total_amount+other.master_amount %>
|
||||
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">Master Payment </td>
|
||||
<td><%=other.jcb_amount.round(2) %></td>
|
||||
<% @total_amount = @total_amount+other.jcb_amount %>
|
||||
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td style="text-align: right;">Reedem Payment </td>
|
||||
<td><%=other.paypar_amount.round(2) %></td>
|
||||
<% @total_amount = @total_amount+other.paypar_amount %>
|
||||
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
|
||||
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
|
||||
</tr>
|
||||
<%end%>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user