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

This commit is contained in:
Aung Myo
2018-03-19 18:14:04 +06:30
39 changed files with 4403 additions and 159 deletions

17
app/controllers/oqs/edit_controller.rb Executable file → Normal file
View File

@@ -6,6 +6,11 @@ class Oqs::EditController < BaseOqsController
if params[:type] == 'oqs'
assigned_item = AssignedOrderItem.find(assigned_item_id)
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'")
elsif
assigned_item = OrderItem.find(assigned_item_id)
@booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id")
.where("bko.order_id = '#{assigned_item.order_id}'").first()
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
else
assigned_item = OrderItem.find(assigned_item_id)
dining = DiningFacility.find_by_id(params[:type])
@@ -25,13 +30,6 @@ class Oqs::EditController < BaseOqsController
order_item.item_order_by = current_user.name
order_item.qty = qty_weight
order_item.remark = remarks
if !order_item.set_menu_items.nil?
instance_item_sets = JSON.parse(order_item.set_menu_items)
instance_item_sets.each_with_index do |instance_item, instance_index|
instance_item_sets[instance_index]["quantity"] = qty_weight
end
order_item.set_menu_items = instance_item_sets.to_json
end
order_item.save
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
@@ -67,4 +65,9 @@ class Oqs::EditController < BaseOqsController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -0,0 +1,70 @@
class Origami::JunctionPayController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
@cashier_type = params[:type]
# limit jcb_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@junction_pay_count = 0
others = 0
@cashier_id = current_user.emp_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)
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 == "JunctionPay"
@junction_pay_count = @junction_pay_count + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_junction_pay = total - @junction_pay_count - 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
def create
gift_amount = params[:gift_amount]
voucher_amount = params[:voucher_amount]
voucher_no = params[:voucher_no]
sale_id = params[:sale_id]
# Gift card or Voucher classified and add for payment_reference
remarks = ''
cash = (gift_amount.to_f + voucher_amount.to_f)
if gift_amount.to_f > 0
remarks = "Junciton Gift Card Payment. RefNo-" + voucher_no
else
remarks = "Junciton Voucher Payment. RefNo-" + voucher_no
end
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, "JunctionPay", remarks)
end
end
end

View File

@@ -27,7 +27,7 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
@@ -79,8 +79,17 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
end
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
end
def create
@@ -131,7 +140,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
# For Print
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
if !receipt_bill_a5_pdf.empty?
@@ -195,7 +204,20 @@ class Origami::PaymentsController < BaseOrigamiController
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
end
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id)
end
# end
end
end
end
@@ -213,6 +235,7 @@ class Origami::PaymentsController < BaseOrigamiController
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@junctionpaycount = 0.0
@credit = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0.00
@@ -325,6 +348,8 @@ class Origami::PaymentsController < BaseOrigamiController
@mastercount += spay.payment_amount
elsif spay.payment_method == "unionpay"
@unionpaycount += spay.payment_amount
elsif spay.payment_method == "JunctionPay"
@junctionpaycount += spay.payment_amount
elsif spay.payment_method == "creditnote"
@credit += spay.payment_amount
end

View File

@@ -64,6 +64,17 @@ class PrintSettingsController < ApplicationController
end
end
def get_printer_options
printer_name = params[:printer_name]
printer_options = Printer::PrinterWorker.printer_options(printer_name)
options = {
:url => printer_options['device-uri'],
:model => printer_options['printer-info'],
}
render :json => options.to_json
end
private
# Use callbacks to share common setup or constraints between actions.
def set_print_setting
@@ -72,7 +83,7 @@ class PrintSettingsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def print_setting_params
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :brand_name, :printer_type, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
end
#Shop Name in Navbor

View File

@@ -6,6 +6,18 @@ class Settings::TaxProfilesController < ApplicationController
# GET /settings/tax_profiles.json
def index
@settings_tax_profiles = TaxProfile.all
tax_profiles = Lookup.collection_of("tax_profiles")
if !@settings_tax_profiles.nil?
@settings_tax_profiles.each_with_index do |setting_tax_profile, tax_index|
if !tax_profiles.nil?
tax_profiles.each do |group|
if setting_tax_profile.group_type == group[1]
@settings_tax_profiles[tax_index].group_type = group[0]
end
end
end
end
end
end
# GET /settings/tax_profiles/1
@@ -15,11 +27,19 @@ class Settings::TaxProfilesController < ApplicationController
# GET /settings/tax_profiles/new
def new
@name = nil
@settings_tax_profile = TaxProfile.new
@tax_profiles = TaxProfile.all
end
# GET /settings/tax_profiles/1/edit
def edit
@settings_tax_profile = TaxProfile.find(params[:id])
@name = nil
if !@settings_tax_profile.nil?
@name = @settings_tax_profile.name
end
@tax_profiles = TaxProfile.all
end
# POST /settings/tax_profiles
@@ -69,10 +89,20 @@ class Settings::TaxProfilesController < ApplicationController
# Use callbacks to share common setup or constraints between actions.
def set_settings_tax_profile
@settings_tax_profile = TaxProfile.find(params[:id])
tax_profiles = Lookup.collection_of("tax_profiles")
if !@settings_tax_profile.nil?
if !tax_profiles.nil?
tax_profiles.each do |group|
if @settings_tax_profile.group_type == group[1]
@settings_tax_profile.group_type = group[0]
end
end
end
end
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_tax_profile_params
params.require(:tax_profile).permit(:name, :rate, :inclusive, :order_by, :created_by)
params.require(:tax_profile).permit(:name, :group_type, :rate, :inclusive, :order_by, :created_by)
end
end