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

This commit is contained in:
Yan
2018-04-02 16:13:46 +06:30
98 changed files with 1742 additions and 325 deletions

View File

@@ -84,6 +84,17 @@ class Api::PaymentsController < ActionController::API
sale_payment.payment_reference = params[:payment_reference]
#TODO: implement paypar implementation
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
when "JunctionPay"
sale_payment.payment_method = "JunctionPay"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
sale_payment.payment_reference = params[:vochure_no]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
when "alipay"
sale_payment.payment_method = "alipay"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
end
end
end

View File

@@ -36,33 +36,39 @@ class Oqs::EditController < BaseOqsController
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# print
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
# order queue stations
oqs = assigned_item.order_queue_station
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'")
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
order_slim_pdf.each do |order_item_slim|
if order_item_slim[0] == 'OrderSlimPdf'
if order_item_slim[1] == '1'
unique_code="OrderItemSlimPdf"
else
unique_code="OrderItemPdf"
end
elsif order_item_slim[0] == 'OrderSetPdf'
if order_item_slim[1] == '1'
unique_code="OrderSetItemPdf"
else
unique_code="OrderItemPdf"
if !assigned_items.nil?
assigned_items.each do |assign_item|
# order queue stations
oqs = assign_item.order_queue_station
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
order_slim_pdf.each do |order_item_slim|
if order_item_slim[0] == 'OrderSlimPdf'
if order_item_slim[1] == '1'
unique_code="OrderItemSlimPdf"
else
unique_code="OrderItemPdf"
end
elsif order_item_slim[0] == 'OrderSetPdf'
if order_item_slim[1] == '1'
unique_code="OrderSetItemPdf"
else
unique_code="OrderItemPdf"
end
end
end
end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end
end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end
end

View File

@@ -26,7 +26,7 @@ class Oqs::PrintController < ApplicationController
assigned_item_id = params[:id]
options = params[:options]
assigned_item = AssignedOrderItem.find(assigned_item_id)
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'")
# order queue stations
oqs = assigned_item.order_queue_station

View File

@@ -0,0 +1,77 @@
class Origami::AlipayController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
@cashier_type = params[:type]
# limit alipay_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = 0
@alipaycount = 0
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_alipay = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "alipay"
@alipaycount = @alipaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_alipay = total - @alipaycount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
# 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)
# end
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -95,7 +95,7 @@ class Origami::HomeController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -35,6 +35,7 @@ class Origami::JcbController < BaseOrigamiController
end
@can_jcb = total - @jcbcount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
@@ -52,6 +53,7 @@ class Origami::JcbController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -65,7 +67,7 @@ class Origami::JcbController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb",ref_no)
end
end

View File

@@ -24,7 +24,7 @@ class Origami::MasterController < BaseOrigamiController
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "master"
@@ -50,6 +50,7 @@ class Origami::MasterController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -63,7 +64,7 @@ class Origami::MasterController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master",ref_no)
end
end

View File

@@ -69,6 +69,18 @@ class Origami::MovetableController < BaseOrigamiController
end
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
# get printer info
@from = (DiningFacility.find(change_from)).name
@to = (DiningFacility.find(change_to)).name
@type = (DiningFacility.find(change_to)).type
@moved_by = @current_user.name
@date = DateTime.now
@shop = Shop::ShopDetail
unique_code = "MoveTablePdf"
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by)
end
end

View File

@@ -51,6 +51,7 @@ class Origami::MpuController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -64,7 +65,7 @@ class Origami::MpuController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
end
end

View File

@@ -0,0 +1,101 @@
class Origami::PaymalController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
payment_method = params[:payment_method]
@cashier_type = params[:type]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@shop = Shop::ShopDetail
# if @shop.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
# else
# new_total = sale_data.grand_total
# end
# @rounding_adj = new_total-sale_data.grand_total
@rounding_adj = sale_data.rounding_adjustment
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "paypar"
@payparcount = @payparcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@payment_prices = sale_data.grand_total - @payparcount -others
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
end
else
@out =false,0
end
else
@out = false,0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
@out = false, 0
end
def create
cash = params[:payment_amount]
sale_id = params[:sale_id]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
# 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)
# end
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "paymal")
if status == true
@out = true, "Success!"
else
@out =false, "Please try again payment!"
end
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -113,8 +113,6 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
#end rounding adjustment
puts "sale"
puts saleObj.to_json
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
@@ -163,8 +161,10 @@ class Origami::PaymentsController < BaseOrigamiController
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)
if member_info["status"] == true
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
end
#orders print out
@@ -226,8 +226,10 @@ class Origami::PaymentsController < BaseOrigamiController
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@alipaycount = 0.0
@junctionpaycount = 0.0
@credit = 0.0
@paymalcount = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0
@accountable_type = ''
@@ -346,6 +348,10 @@ class Origami::PaymentsController < BaseOrigamiController
@junctionpaycount += spay.payment_amount
elsif spay.payment_method == "creditnote"
@credit += spay.payment_amount
elsif spay.payment_method == "paymal"
@paymalcount += spay.payment_amount
elsif spay.payment_method == "alipay"
@alipaycount += spay.payment_amount
end
end
end

View File

@@ -12,7 +12,7 @@ class Origami::QuickServiceController < ApplicationController
day = Date.today.wday
@menus = Menu.all
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
@zone = Zone.all
@zone = Zone.all
@customer = Customer.all
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')

View File

@@ -6,7 +6,6 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@payment_method_setting_nav = PaymentMethodSetting.all
@shop = Shop::ShopDetail
# if @shop.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)

View File

@@ -79,8 +79,7 @@ class Origami::RoomsController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -1,7 +1,10 @@
class Origami::SecondDisplayController < BaseOrigamiController
def index
@display_images = DisplayImage.all
end
def show
end
def customer_view

View File

@@ -5,7 +5,6 @@ class Origami::SurveysController < BaseOrigamiController
@id = params[:id]
@cashier_type = params[:type]
if(@id[0,3] == "SAL")
@sale = Sale.find(@id)
@receipt_no = @sale.receipt_no

View File

@@ -48,6 +48,7 @@ class Origami::UnionpayController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -62,7 +63,7 @@ class Origami::UnionpayController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
#end rounding adjustment
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no)
end
end

View File

@@ -6,7 +6,7 @@ class Origami::VisaController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(@sale_id)
total = 0
@visacount = 0
@shop = Shop::ShopDetail
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_visa = 0
@member_discount = 0
@@ -48,6 +48,7 @@ class Origami::VisaController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
ref_no = params[:ref_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
@@ -62,7 +63,7 @@ class Origami::VisaController < BaseOrigamiController
# saleObj = Sale.find(sale_id)
#end rounding adjustment
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa")
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa",ref_no)
end
end

View File

@@ -48,7 +48,7 @@ class Origami::VoidController < BaseOrigamiController
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else

View File

@@ -1,29 +1,28 @@
class Origami::WasteSpoileController < BaseOrigamiController
def index
end
def waste_and_spoile
def waste_and_spoilage
sale_id = params[:sale_id]
remark = params[:remark]
order_source = params[:type] #tax profile source
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
existing_tax.delete
end
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
sale.payment_status = remark
sale.sale_status = remark
sale.save
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
# add to sale item with foc
sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
sale_items.each do|item|
SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
sale.sale_items.each do|item|
# SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
item.status = remark
item.remark = remark
item.save
end
if sale.bookings[0].dining_facility_id.to_i > 0
@@ -33,7 +32,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
@@ -45,7 +44,6 @@ class Origami::WasteSpoileController < BaseOrigamiController
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
@@ -104,7 +102,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -0,0 +1,19 @@
class Reports::WasteAndSpoilageController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
@sale_type = params[:sale_type]
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls
end
end
end

View File

@@ -47,11 +47,13 @@ class Settings::ShopsController < ApplicationController
# PATCH/PUT /settings/shops/1
# PATCH/PUT /settings/shops/1.json
def update
respond_to do |format|
if @settings_shop.update(shop_params)
if params[:display_images].present?
params[:display_images]['image'].each do |a|
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a)
params[:display_images][:image].each do |a|
@aa = Base64.encode64(a.read)
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => "data:image/jpeg;base64,"+@aa)
end
end
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully updated.' }