Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-12-22 16:37:09 +06:30
43 changed files with 955 additions and 202 deletions

View File

@@ -31,7 +31,7 @@ ruby 2.4.1p111
Campaign Id => {"campaign_type_id": 1}
java -jar ~/Documents/Jade.jar http://192.168.1.88:3002
* ToDo list

View File

@@ -61,7 +61,7 @@ $(document).on('turbolinks:load', function() {
if (data[field]["options"] == "[]" || data[field]["options"] == "") {
var options = "";
}else{
var options = data.options;
var options = data[field]["options"];
}
var date = new Date(data[field]["created_at"]);
@@ -80,7 +80,7 @@ $(document).on('turbolinks:load', function() {
+'<span class="order-qty"> [x'+ data[field]["qty"] +'] </span>'
+'</p>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<br/><p class="card-text item-options">'+ options +'</p>'
+'<span class="card-text">'
+'<span class="text-muted">Order at - '
@@ -223,8 +223,9 @@ $(document).on('turbolinks:load', function() {
var params = { 'options':options };
$.ajax({
type: 'GET',
type: 'POST',
url: '/oqs/print/print/'+assigned_item_id,
data: params,
success: function(data){ }
});
});

View File

@@ -5,10 +5,12 @@ App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', {
disconnected: function() {},
received: function(data) {
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
$('.new_text_'+data.table.id).removeClass('hide')
received: function(data) {
if($('.table_'+data.table.id).hasClass('green')){
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
}
$('.new_text_'+data.table.id).removeClass('hide');
}
});

View File

@@ -6,21 +6,21 @@ App.order = App.cable.subscriptions.create('CheckinChannel', {
disconnected: function() {},
received: function(data) {
$.each(data.table,function(key,value){
if($('.table_'+value.table_id).hasClass('blue')){
$('.table_'+value.table_id).removeClass('blue');
$('.table_'+value.table_id).addClass('orange');
}
else if($('.table_'+value.table_id).hasClass('red')){
$('.table_'+value.table_id).removeClass('red');
$('.table_'+value.table_id).addClass('orange');
}
else {
$('.table_'+value.table_id).removeClass('green');
$('.table_'+value.table_id).addClass('orange');
}
$('.new_text_'+value.table_id).removeClass('hide');
});
$.each(data.table,function(key,value){
if($('.table_'+value.table_id).hasClass('blue')){
$('.table_'+value.table_id).removeClass('blue');
$('.table_'+value.table_id).addClass('orange');
}
else if($('.table_'+value.table_id).hasClass('red')){
$('.table_'+value.table_id).removeClass('red');
$('.table_'+value.table_id).addClass('orange');
}
else {
$('.table_'+value.table_id).removeClass('green');
$('.table_'+value.table_id).addClass('orange');
}
$('.new_text_'+value.table_id).removeClass('hide');
});
}
});

View File

@@ -14,7 +14,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
var options = "";
}else{
var options = items.options;
var options = items[field]["options"];
}
//for count
test = document.getElementsByClassName("oqs_count");
@@ -49,7 +49,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
+'<span class="order-qty"> [x'+ items[field]["qty"] +'] </span>'
+'</p>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<br/><p class="card-text item-options">'+ options +'</p>'
+'<span class="card-text">'
+'<span class="text-muted">Order at - '

View File

@@ -143,3 +143,41 @@ $(document).on('turbolinks:load', function() {
return false;
});
});
/* start check first bill or not funs: */
function checkReceiptNoInFirstBillData(receipt_no) {
var status = false;
if((receipt_no!=undefined) && (receipt_no!="")){
if(localStorage.hasOwnProperty("receipt_lists")===true){
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
if((arr_data.length) > (json_data.length)){
status = true;
}
}
}
return status;
}
function createReceiptNoInFirstBillData(receipt_no) {
var arr_data = [];
var json_data = [];
if(localStorage.hasOwnProperty("receipt_lists")===true){
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
}
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
arr_data.push({'receipt_no':receipt_no});
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
}
}
function deleteReceiptNoInFirstBillData(receipt_no) {
if(localStorage.hasOwnProperty("receipt_lists")===true){
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
}
}
/* end check first bill or not funs: */

View File

@@ -6,6 +6,14 @@ class Api::CallWaitersController < ActionController::API
@time = params[:time]
@table = DiningFacility.find(@table_id)
CallWaiterJob.perform_later(@table,@time)
# get printer info
# @shop = Shop::ShopDetail
# unique_code = "CallWaiterPdf"
# print_settings = PrintSetting.find_by_unique_code(unique_code)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_call_waiter(print_settings,@table,@time,@shop)
end

View File

@@ -157,7 +157,11 @@ class Origami::DiscountsController < BaseOrigamiController
is_card = params[:is_card]
sub_total = params[:sub_total]
sale = Sale.find(sale_id)
if is_card == 'true'
is_card = true
else is_card.to_s == 'false'
is_card = false
end
# Check for Card Payment
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
@@ -178,9 +182,7 @@ class Origami::DiscountsController < BaseOrigamiController
end
end
end
generic_customer_id = sale.customer.membership_id
account_no = sale.customer.paypar_account_no
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
@@ -188,12 +190,13 @@ class Origami::DiscountsController < BaseOrigamiController
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
account_no = sale.customer.paypar_account_no rescue nil
# Check for items for Paypar Cloud
if acc_prices.length > 0
begin
response = HTTParty.post(url,
:body => { account_no: nil,
:body => { account_no: account_no,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
@@ -220,8 +223,8 @@ class Origami::DiscountsController < BaseOrigamiController
else
response = {"status": false, "message": "You have no selected discount item" }
end
puts "discountttttttttttt"
puts response.to_json
Rails.logger.debug "-------------- Member Discount Osaka ---------"
Rails.logger.debug response.to_json
# Re-calc All Amount in Sale
if response["status"] == true
discount_amount = response["discount_earned"]

View File

@@ -22,6 +22,10 @@ class Origami::HomeController < BaseOrigamiController
@status_sale = ""
@sale_array = Array.new
@shop = Shop::ShopDetail
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@dining.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new

View File

@@ -26,12 +26,28 @@ class Origami::PaymentsController < BaseOrigamiController
#shop detail
shop_details = Shop::ShopDetail
# customer= Customer.where('customer_id=' +.customer_id)
customer= Customer.find(sale_data.customer_id)
customer = Customer.find(sale_data.customer_id)
# rounding adjustment
if shop_details.is_rounding_adj
a = sale_data.grand_total % 25 # Modulus
b = sale_data.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = new_total-sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj)
end
end
#end rounding adjustment
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
current_balance = SaleAudit.paymal_search(sale_id)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -59,9 +75,15 @@ class Origami::PaymentsController < BaseOrigamiController
# rounding adjustment
if shop_details.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
end
#end rounding adjustment
@@ -89,7 +111,9 @@ class Origami::PaymentsController < BaseOrigamiController
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
if customer.membership_id != nil && rebate && credit_data.nil?
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
@@ -278,14 +302,15 @@ class Origami::PaymentsController < BaseOrigamiController
@shop = Shop.find_by_id(1)
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
else
new_total = saleObj.grand_total
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
end
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
end
end

View File

@@ -19,6 +19,10 @@ class Origami::RoomsController < BaseOrigamiController
@status_sale = ""
@sale_array = Array.new
@shop = Shop::ShopDetail
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@room.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new

View File

@@ -147,7 +147,7 @@ class Customer < ApplicationRecord
response = self.rebat(Sale.find(sale.sale_id))
#record an payment in sale-audit
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.received_amount} "
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, "CronJob")
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
if response["status"] == true
status = sale.update_attributes(rebate_status: "true")

View File

@@ -1,2 +1,3 @@
class MembershipSetting < ApplicationRecord
MembershipSetting = MembershipSetting.find_by_id(1)
end

View File

@@ -12,7 +12,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
filename = "tmp/order_item.pdf"
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
# check for item not to show
# if order_item[0].price != 0
@@ -47,7 +47,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Per Item
if oqs.cut_per_item
order.each do|odi|
filename = "tmp/order_item.pdf"
filename = "tmp/order_item_#{order_id}" + ".pdf"
# For Item Options
options = odi.options == "[]"? "" : odi.options
@@ -68,7 +68,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# For Print Order Summary
else
filename = "tmp/order_summary.pdf"
filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy
@@ -96,7 +96,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Per Item
if oqs.cut_per_item
order.each do|odi|
filename = "tmp/order_item.pdf"
filename = "tmp/order_item_#{booking_id}" + ".pdf"
# For Item Options
options = odi.options == "[]"? "" : odi.options
@@ -120,7 +120,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# For Print Order Summary
else
filename = "tmp/booking_summary.pdf"
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy

View File

@@ -117,4 +117,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
pdf.render_file "tmp/print_crm_order.pdf"
self.print("tmp/print_crm_order.pdf")
end
#Queue No Print
def print_call_waiter(printer_settings,table,time,shop_detail)
#Use CUPS service
#Generate PDF
#Print
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
pdf.render_file "tmp/print_call_waiter.pdf"
self.print("tmp/print_call_waiter.pdf")
end
end

View File

@@ -659,7 +659,7 @@ def self.get_item_query()
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
# query = query.where("i.item_instance_code IS NOT NULL")
query = query.group("i.product_name").order("mi.account_id asc","mi.menu_category_id asc")
query = query.group("i.product_name").order("mi.account_id desc")
end
def self.get_other_charges()
@@ -1107,7 +1107,7 @@ end
def self.top_items(today)
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.group("a.product_code")
.order("SUM(a.qty) DESC")
.first()

View File

@@ -173,13 +173,20 @@ class SalePayment < ApplicationRecord
private
def cash_payment
status = false
sale_payments_data = SalePayment.find_by_sale_id(self.sale_id)
if sale_payments_data.nil?
status = true
end
payment_status = false
self.payment_method = "cash"
self.payment_amount = self.received_amount
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
sale_update_payment_status(self.received_amount,status)
return payment_status
end
@@ -187,7 +194,7 @@ class SalePayment < ApplicationRecord
payment_status = false
# add to sale item with foc
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null")
sale_items.each do|item|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
@@ -271,7 +278,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier")
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
if membership_data["status"]==true
self.payment_method = "paypar"
@@ -290,7 +297,7 @@ class SalePayment < ApplicationRecord
end
def sale_update_payment_status(paid_amount)
def sale_update_payment_status(paid_amount,check_foc = false)
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.save!
@@ -328,7 +335,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier")
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
if !response.nil?
if response["status"] == true
@@ -349,8 +356,10 @@ class SalePayment < ApplicationRecord
self.sale.save!
table_update_status(sObj)
if paid_amount != "0.0"
if check_foc
update_shift
elsif paid_amount != "0.0"
update_shift
end
end

View File

@@ -0,0 +1,71 @@
class CallWaiterPdf < 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
def initialize(printer_settings, table,time,shop_detail)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 35
self.qty_width = 20
self.total_width = 35
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
self.header_font_size = 10
self.item_font_size = 8
header( shop_detail.name, printer_settings.name)
call_waiter(table)
stroke_horizontal_rule
# date_info(queue)
end
def header (shop_name, name)
text "#{shop_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
text "#{name}", :size => self.header_font_size,:align => :center
# move_down self.item_height
move_down 5
stroke_horizontal_rule
move_down 5
end
def call_waiter (table)
move_down 3
text "Table Name : #{table.name}",:align => :center
end
# def date_info(queue)
# move_down 5
# y_position = cursor
# bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
# text "Date:", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.label_width,y_position], :width => self.item_width) do
# text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
# end
# move_down 5
# end
end

View File

@@ -40,7 +40,7 @@ class OrderItemPdf < Prawn::Document
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 5
move_down 3
#order_info
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
@@ -56,13 +56,13 @@ class OrderItemPdf < Prawn::Document
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 5
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 5
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
@@ -105,18 +105,22 @@ class OrderItemPdf < Prawn::Document
end
if alt_name
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
if !(order_item.alt_name).empty?
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
end
move_down 5
if !options.empty?
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
end
move_down 5

View File

@@ -0,0 +1,129 @@
class OrderItemSlimPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
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
def initialize(print_settings,order_item_slim, print_status, options, alt_name)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
# db font setup
if print_settings.font != ""
font_families.update("#{print_settings.font}" => {
:normal => "public/fonts/#{print_settings.font}.ttf",
:italic => "public/fonts/#{print_settings.font}.ttf",
:bold => "public/fonts/#{print_settings.font}.ttf",
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
})
font "#{print_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
self.header_font_size = 11
self.item_font_size = 9
else
self.header_font_size = 12
self.item_font_size = 10
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 1
#order_info
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
# order items slim
order_items_slim(order_item_slim, options, alt_name, print_settings.precision)
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 3
end
# Write Order items to PDF
def order_items_slim(order_item_slim, options, alt_name, precision)
y_position = cursor
#Add Order Item
add_order_items_slim(order_item_slim, options, alt_name, precision)
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 1
end
# Add order items slim under order info
def add_order_items_slim(order_item_slim, options, alt_name, precision)
y_position = cursor
move_down 1
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
end
# if alt_name
# if !(order_item_slim.alt_name).empty?
# move_down 1
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
# text "(#{order_item_slim.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
# end
# end
if !options.empty?
move_down 1
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
end
move_down 1
end
end

View File

@@ -122,19 +122,21 @@ class OrderSummaryPdf < Prawn::Document
end
if alt_name
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
if !(odi.alt_name).empty?
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
end
move_down 5
# add option
options = odi.options == "[]"? "" : odi.options
if options != ""
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{options}", :size => self.item_font_size,:align => :left

View File

@@ -0,0 +1,155 @@
class OrderSummarySlimPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
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
def initialize(print_settings,order, print_status, order_items = nil,alt_name)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if print_settings.font != ""
font_families.update("#{print_settings.font}" => {
:normal => "public/fonts/#{print_settings.font}.ttf",
:italic => "public/fonts/#{print_settings.font}.ttf",
:bold => "public/fonts/#{print_settings.font}.ttf",
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
})
font "#{print_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
self.header_font_size = 11
self.item_font_size = 9
else
self.header_font_size = 12
self.item_font_size = 10
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 1
#order_info
order_info(order[0].order_id, order[0].order_by,order[0].order_at)
# order items
if order_items == nil
order_items(order, alt_name, print_settings.precision)
else
order_items(order_items, alt_name, print_settings.precision)
end
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 1
end
# Write Order items to PDF
def order_items(order_item, alt_name, precision)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Item", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
text "Qty", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 1
#Add Order Item
add_order_items(order_item, alt_name, precision)
end
# Add order items under order info
def add_order_items(order_item, alt_name, precision)
y_position = cursor
move_down 1
order_item.each do|odi|
# check for item not to show
# if odi.price != 0
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
if alt_name
if !(odi.alt_name).empty?
move_down 1
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
end
# add option
options = odi.options == "[]"? "" : odi.options
if options != ""
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "#{options}", :size => self.item_font_size,:align => :left
end
move_down 1
end
move_down 1
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 1
# end
end
end
end

View File

@@ -4,13 +4,13 @@ class ReceiptBillPdf < Prawn::Document
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 40
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.margin = 0
self.price_width = 60
self.qty_width = 25
self.total_width = 60
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.item_description_width = (self.page_width-5) / 2
self.label_width = 100
self.description_width = 150
@@ -22,6 +22,11 @@ class ReceiptBillPdf < Prawn::Document
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
@@ -74,7 +79,7 @@ class ReceiptBillPdf < Prawn::Document
end
def header (shop_details)
move_down 7
move_down 5
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
@@ -124,15 +129,27 @@ class ReceiptBillPdf < Prawn::Document
end
def line_items(sale_items,precision,delimiter)
if precision.to_i > 0
item_label_qty_front_width = (self.item_width+self.price_width) + 5
item_label_qty_end_width = self.qty_width + 4
item_label_total_front_width = (self.item_width+self.price_width) + 10
item_label_total_end_width = self.total_width + 9
else
self.item_width = self.item_width.to_i + 8
item_label_qty_front_width = (self.item_width+self.price_width) + 8
item_label_qty_end_width = self.qty_width + 7
item_label_total_front_width = (self.item_width+self.price_width) + 5
item_label_total_end_width = self.total_width + 4
end
move_down 5
y_position = cursor
move_down 5
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down -5
stroke_horizontal_rule
@@ -140,7 +157,19 @@ class ReceiptBillPdf < Prawn::Document
end
def add_line_item_row(sale_items,precision,delimiter)
item_name_width = (self.item_width+self.price_width)
if precision.to_i > 0
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = (self.item_width+self.price_width) + 5
item_qty_end_width = self.qty_width + 4
item_total_front_width = item_name_width + 10
item_total_end_width = self.total_width + 9
else
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = item_name_width + 8
item_qty_end_width = self.qty_width + 7
item_total_front_width = item_name_width + 5
item_total_end_width = self.total_width + 4
end
y_position = cursor
move_down 5
sub_total = 0.0
@@ -162,8 +191,8 @@ class ReceiptBillPdf < Prawn::Document
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_name_width,y_position], :width => self.qty_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 5
end
@@ -469,7 +498,7 @@ class ReceiptBillPdf < Prawn::Document
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
end
move_down 5

View File

@@ -7,6 +7,8 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M")
if (menu.menu_categories)
json.categories menu.menu_categories do |category|
json.id category.id
json.code category.code
json.order_by category.order_by
json.name category.name
json.alt_name category.alt_name
json.order_by category.order_by

View File

@@ -84,8 +84,8 @@
<%= qid.qty %>
</span> ]
</p>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<span class="card-text">
<span class="text-muted">Order at -

View File

@@ -32,7 +32,7 @@
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12">
<input type="hidden" name="type" id="type" value="<%= @dining_facility.type %>">
<!-- <input type="hidden" name="type" id="type" value="<%= @dining_facility.type %>"> -->
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
@@ -423,13 +423,13 @@
success: function(data) {
if(data.status == true)
{
var id = $("#table_id").val()
var type = $("#type").val()
var id = $("#table_id").val();
var type = $("#type").val();
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
window.location.href = '/origami/room/'+id
}
}else{
swal("Alert!", "Record not found!", "error");
location.reload();

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class="row clearfix">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
@@ -153,8 +156,7 @@
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Receipt No: <span id="receipt_no">
<% if @status_sale == 'sale' %>
<%= @sale_array[0].receipt_no rescue '' %>
<%= @sale_array[0].receipt_no rescue '' %>
<% end %>
</span>
<br>
@@ -264,7 +266,7 @@
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
<td class="item-attr"><strong id="sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<% if @obj_sale != nil && @obj_sale.discount_type == 'member_discount' %>
@@ -291,7 +293,8 @@
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr">
<strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0 %></strong></td>
<strong id="order-round-adj"><%= @obj_sale.rounding_adjustment
%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
@@ -387,8 +390,12 @@
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%if @membership.discount && @obj_sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" active="<%= can? :overall_void, :void %>"> Void</button>
<% end %>
@@ -398,11 +405,51 @@
<% else %>
<button type="button" id="check_in" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.check_in") %></button>
<% end %>
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" id="payment_method" >
<option value="Cash">Cash</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
// console.log(checkReceiptNoInFirstBillData(receipt_no));
if(checkReceiptNoInFirstBillData(receipt_no)){
$("#pay").show();
}else{
$("#pay").hide();
}
/* end check first bill or not*/
$('.invoicedetails').on('click', function () {
var dining_id = "<%= @dining.id %>";
@@ -491,7 +538,7 @@
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -510,13 +557,12 @@
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
});
});
// Print for first bill
$("#first_bill").on('click', function () {
var sale_id = $('#sale_id').val();
@@ -526,10 +572,53 @@
type: "GET",
url: ajax_url,
success: function (result) {
location.reload();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no);
location.reload();
}
});
});
});
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
calculate_member_discount(sale_id,type);
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no);
location.reload();
}
});
});
function calculate_member_discount(sale_id,type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
async: false,
success:function(result){
}
});
}
// $('#pay').on('click', function () {
// var sale_id = $('#sale_id').val();
@@ -556,11 +645,12 @@
url: ajax_url,
// data: 'order_id='+ order_id,
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
location.reload();
else {
location.reload();
}
}
});
@@ -584,8 +674,16 @@
url: ajax_url,
data: 'dining_id=' + dining_id + "&sale_id=" + sale_id,
success: function (result) {
alert("Invoice updated")
swal({
title: "Information!",
text: "Invoice updated",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.reload();
});
}
});
})

View File

@@ -162,19 +162,19 @@ $('#jcb_pay').on('click',function(){
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
//start member discount 5% by pay card
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",

View File

@@ -160,18 +160,18 @@
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// // success:function(result){
// // }
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_master_path %>",

View File

@@ -163,18 +163,18 @@
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
//Mpu Payment
$.ajax({type: "POST",

View File

@@ -96,7 +96,8 @@
<div class="form-horizontal">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="bottom-5">
<input type="text" id="other-charges-amount" name="other-charges-amount" class="form-control" placeholder="Amount" />
<input type="text" id="other-charges-amount" name="other-charges-amount" class="form-control" placeholder="Amount" onkeypress="return isNumberKey(event);" />
<br><span id="other-charges-amountErr" style="color:red;"></span>
</div>
<div class="bottom-5">
<textarea id="reasons" name="reasons" rows="2" class="form-control" placeholder="Reasons"></textarea>
@@ -278,12 +279,19 @@
if ($("#is_taxable:checked").length > 0) {
is_taxable = 1
}
$("#other-charges-amountErr").html("");
if(charge_amount != ""){
$("#other-charges-amount").val("");
$("#reasons").val("");
// Update sub total
$('#order-sub-total').text(parseFloat(sub_total) + parseFloat(charge_amount));
// Update sub total
$('#order-sub-total').text(parseFloat(sub_total) + parseFloat(charge_amount));
var item_row = item_row_template(sale_id, charge_amount, reasons, is_taxable);
$("#order-items-table tbody").append(item_row);
var item_row = item_row_template(sale_id, charge_amount, reasons, is_taxable);
$("#order-items-table tbody").append(item_row);
}
else{
$("#other-charges-amountErr").html("can't be blank");
}
});
// Calculate Other Charges for Payment
@@ -361,4 +369,13 @@
return item_row;
}
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
</script>

View File

@@ -94,11 +94,11 @@
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong><span id="rounding_adj"><%=@rounding_adj rescue 0%></span></strong></td>
<td class="item-attr"><strong><%= @sale_data.rounding_adjustment rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total+ @rounding_adj rescue 0%></span></strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
@@ -124,7 +124,7 @@
<div class="col-md-4">
<strong>
<span id="grand_total" class="hidden"><%= @sale_data.grand_total rescue 0%></span>
<span id="amount_due"><%= @sale_data.grand_total + @rounding_adj rescue 0%></span></strong>
<span id="amount_due"><%= @sale_data.grand_total rescue 0%></span></strong>
</div>
</div>
@@ -223,7 +223,7 @@
<!-- <br> -->
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total+ @rounding_adj rescue 0 %></span></strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total rescue 0 %></span></strong></div>
</div>
<!-- <br> -->
</div>
@@ -389,11 +389,11 @@
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
var item_row = $('.is_card');
// var item_row = $('.is_card');
if (item_row.length < 1) {
// if (item_row.length < 1) {
calculate_member_discount(sale_id);
}
// }
// payment
var cash = $('#cash').text();
@@ -405,6 +405,12 @@
data: "cash="+ cash + "&sale_id=" + sale_id,
async: false,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
if (result.status) {
@@ -497,7 +503,7 @@
//$( "#loading_wrapper" ).hide();
if (cash > 0) {
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
@@ -517,15 +523,20 @@
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
var item_row = $('.is_card');
if (member_id && member_discount) {
if (item_row.length < 1) {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':false },
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
async: false,
success:function(result){
}
});
}

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
@@ -183,7 +186,7 @@
<div class="card-title row customer_detail p-l-5 p-r-5" >
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @obj_sale_sale.customer_id rescue '' %></p>
<p class="hidden customer-id"><%= @obj_sale.customer_id rescue '' %></p>
&nbsp; Customer : <%= @obj_sale.customer.name rescue '-' %>
<%else%>
<p class="hidden customer-id"><%= @obj_order.customer_id rescue "-" %></p>
@@ -260,7 +263,7 @@
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
<td class="item-attr"><strong id="sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
@@ -358,7 +361,8 @@
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
<!-- <button type="button" id="pay" class="btn bg-blue btn-block" disabled>Pay</button> -->
<!-- <button type="button" class="btn bg-blue btn-block" disabled=""> Void </button> -->
<% else %>
<% end %>
<% if @status_sale == 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<button type="button" class="btn bg-blue btn-block" id='edit'>Edit</button>
@@ -369,10 +373,43 @@
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- <button type="button" class="btn bg-blue btn-block" id='move' disabled="">Move</button> -->
<!-- <button type="button" id="request_bills" class="btn bg-blue btn-block" disabled> Req.Bill</button> -->
<button type="button" id="first_bill" class="btn bg-blue btn-block">First Bill</button>
<%if @membership.discount && @obj_sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn bg-blue btn-block" > Void </button>
<% end %>
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" id="payment_method" >
<option value="Cash">Cash</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
<!-- Cashier Buttons -->
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
@@ -411,6 +448,19 @@ $(document).ready(function(){
// window.location.href = '/origami/order/' + order_id;
// })
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
// console.log(checkReceiptNoInFirstBillData(receipt_no));
if(checkReceiptNoInFirstBillData(receipt_no)){
$("#pay").show();
}else{
$("#pay").hide();
}
/* end check first bill or not*/
$('.invoicedetails').on('click',function(){
var dining_id = "<%= @room.id %>";
var sale_id = this.id;
@@ -498,7 +548,7 @@ $(document).ready(function(){
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -517,7 +567,7 @@ $(document).ready(function(){
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -533,11 +583,54 @@ $("#first_bill").on('click', function(){
type: "GET",
url: ajax_url,
success:function(result){
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no);
location.reload();
}
});
});
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
calculate_member_discount(sale_id,type);
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no);
location.reload();
}
});
});
function calculate_member_discount(sale_id,type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
async: false,
success:function(result){
}
});
}
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
@@ -600,8 +693,16 @@ $('#add_invoice').on('click',function(){
url: ajax_url,
data: 'dining_id='+ dining_id + "&sale_id=" + sale_id,
success:function(result){
alert("Invoice updated")
window.location.reload();
swal({
title: "Information!",
text: "Invoice updated",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.reload();
});
}
});
});

View File

@@ -162,18 +162,18 @@
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_visa_path %>",

View File

@@ -15,8 +15,8 @@
<%= f.input :api_settings %>
<%= f.input :page_width %>
<%= f.input :page_height %>
<%= f.input :print_copies, input_html: { min: '1', step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %>
<%= f.input :precision %>
<%= f.input :print_copies, input_html: { min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %>
<%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanTwo(this.value);" } %>
<%= f.input :delimiter %>
<%= f.input :heading_space %>
</div>
@@ -73,4 +73,8 @@
function greaterThanOne(val){
if(parseInt(val)==0) $("#print_setting_print_copies").val(1);
}
function greaterThanTwo(val){
if(parseInt(val)>2) $("#print_setting_precision").val(2);
}
</script>

View File

@@ -123,7 +123,10 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var str = '';

View File

@@ -189,7 +189,10 @@
var shift = $('#shift_name');
shift.empty();
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';

View File

@@ -196,7 +196,10 @@
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){

View File

@@ -49,6 +49,7 @@
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
<% other_sub_total = 0 %>
<% count = 0 %>
@@ -108,18 +109,23 @@
<td><%= sale.grand_total rescue '-' %></td>
</tr>
<!-- sub total -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.menu_category_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% sub_qty += sale.total_item %>
<% if count == value %>
<tr>
<td colspan="5">&nbsp;</td>
<td colspan="3">&nbsp;</td>
<td><b>Total <%= sale.account_name %> Qty </b> </td>
<td><b><%= sub_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span class="underline"><%= sub_total %></span></td>
</tr>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
<% count = 0%>
<% end %>
<% end %>
@@ -127,7 +133,7 @@
<!-- end sub total -->
<% end %>
<!--Other Charges -->
<% if @other_charges.present? %>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
@@ -157,7 +163,7 @@
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= other_sub_total %></span></td>
</tr>
<%end%>
<!-- End Other Charges -->
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
@@ -291,12 +297,15 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var selected = '';
var str = '';
var param_shift = '<%= params[:shift_name]%>';
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
console.log(data)

View File

@@ -191,7 +191,10 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var str = '';

View File

@@ -144,7 +144,10 @@
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var str = '';

View File

@@ -30,7 +30,7 @@
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.alt_name") %></th>
<th><%= t("views.right_panel.detail.is_available") %></th>
<th><%= t("views.right_panel.detail.order_by") %></th>
<!-- <th><%= t("views.right_panel.detail.order_by") %></th> -->
<th><%= t("views.right_panel.detail.parent") %></th>
<th><%= t("views.right_panel.detail.actions") %></th>
</tr>
@@ -43,7 +43,7 @@
<td><%= link_to settings_menu_category.name, settings_menu_category_path(settings_menu_category) %></td>
<td><%= settings_menu_category.alt_name rescue ''%></td>
<td><%= settings_menu_category.is_available rescue false%></td>
<td><%= settings_menu_category.order_by rescue ''%></td>
<!-- <td><%= settings_menu_category.order_by rescue ''%></td> -->
<td><%= settings_menu_category.parent.name rescue ''%></td>
<td><%= link_to t("views.btn.edit"), edit_settings_menu_category_path(settings_menu_category),:class => 'btn btn-info btn-sm waves-effect' %>
</td></td>
@@ -51,8 +51,8 @@
<% end %>
</tbody>
</table>
<%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
</div>
<%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">

View File

@@ -245,7 +245,7 @@ scope "(:locale)", locale: /en|mm/ do
post "/:id", to: "edit#update"
# Pass assigned_order_item_id
get 'print/print/:id', to: "print#print"
post 'print/print/:id', to: "print#print"
get 'print/print_order_summary/:id', to: "print#print_order_summary"
get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs"