Pull from master

This commit is contained in:
San Wai Lwin
2018-03-29 18:17:10 +06:30
122 changed files with 4008 additions and 1115 deletions

View File

@@ -1,6 +1,6 @@
class Origami::AddordersController < BaseOrigamiController
# before_action :set_dining, only: [:detail]
def index
@tables = Table.all.active.order('zone_id asc').group("zone_id")
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
@@ -94,20 +94,20 @@ class Origami::AddordersController < BaseOrigamiController
extra_time = Time.at(time)
end
end
if i["parent_order_item_id"]
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
if i["parent_order_item_id"];
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
else
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
end
items_arr.push(items)
}
# begin
if params[:order_source] == "quick_service"
customer_id = "CUS-000000000002" # for no customer id from mobile
else
# if params[:order_source] == "quick_service"
# customer_id = "CUS-000000000002" # for no customer id from mobile
# else
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
end
# end
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]

View File

@@ -98,10 +98,10 @@ class Origami::CustomersController < BaseOrigamiController
def update_sale_by_customer
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
order_source = params[:type]
# Check and find with card no
# if(!customer_id.include? "CUS")
# customer = Customer.find_by_paypar_account_no(customer_id)
@@ -135,7 +135,7 @@ class Origami::CustomersController < BaseOrigamiController
if status == true
render json: JSON.generate({:status => true})
if(id == "SAL")
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
end
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})

View File

@@ -20,10 +20,12 @@ class Origami::DiscountsController < BaseOrigamiController
#discount page show from origami index with selected order
def create
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
overall_discount = params[:overall_discount]
sub_total = params[:sub_total]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -82,7 +84,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
end
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
if !table.nil?
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
@@ -102,6 +104,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Remove selected discount Items
def remove_discount_items
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
if Sale.exists?(sale_id)
@@ -136,7 +139,7 @@ class Origami::DiscountsController < BaseOrigamiController
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
@@ -158,6 +161,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Remove all discount Items
def remove_all_discount
sale_id = params[:id]
order_source = params[:type]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -197,7 +201,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
@@ -218,7 +222,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Member Discount
def member_discount
order_source = params[:cashier_type]
sale_id = params[:sale_id]
is_card = params[:is_card]
sub_total = params[:sub_total]
@@ -297,7 +301,7 @@ class Origami::DiscountsController < BaseOrigamiController
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
end
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source)
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
elsif response["status"] == "500"
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }

63
app/controllers/origami/jcb_controller.rb Executable file → Normal file
View File

@@ -5,32 +5,44 @@ class Origami::JcbController < BaseOrigamiController
@cashier_type = params[:type]
# limit jcb_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@jcbcount = 0
others = 0
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_jcb = 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 == "jcb"
@jcbcount = @jcbcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_jcb = total - @jcbcount - others
@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 == "jcb"
@jcbcount = @jcbcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
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
#for bank integration
@receipt_no = sale_data.receipt_no
@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?
@@ -58,4 +70,9 @@ class Origami::JcbController < BaseOrigamiController
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

59
app/controllers/origami/master_controller.rb Executable file → Normal file
View File

@@ -5,31 +5,41 @@ class Origami::MasterController < BaseOrigamiController
@cashier_type = params[:type]
# limit master_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@mastercount = 0
others = 0
@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
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_master = 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 == "master"
@mastercount = @mastercount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "master"
@mastercount = @mastercount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_master = total - @mastercount - 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
@can_master = total - @mastercount - 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
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +67,9 @@ class Origami::MasterController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

62
app/controllers/origami/mpu_controller.rb Executable file → Normal file
View File

@@ -4,32 +4,43 @@ class Origami::MpuController < BaseOrigamiController
@cashier_type = params[:type]
# limit mpu_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@mpucount = 0
others = 0
@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 == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_mpu = total - @mpucount - others
@rounding_adj = 0
@can_mpu = 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 == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_mpu = total - @mpucount - 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
@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
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +68,9 @@ class Origami::MpuController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -19,6 +19,7 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_id = params[:sale_id]
other_charges_items = JSON.parse(params[:other_charges_items])
sub_total = params[:sub_total]
cashier_type = params[:cashier_type]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -68,7 +69,7 @@ class Origami::OtherChargesController < BaseOrigamiController
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type)
end
if !table.nil?
dining = {:table_id => table_id, :table_type => table.type }

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?
@@ -170,8 +179,11 @@ class Origami::PaymentsController < BaseOrigamiController
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id)
# Order.pay_process_order_queue(order.order_id, table_id)
oqs = OrderQueueStation.new
oqs.pay_process_order_queue(order.order_id, table_id)
end
end
#for card sale data
@@ -197,7 +209,8 @@ 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
#end
end
end
@@ -215,15 +228,18 @@ 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
@balance = 0
@accountable_type = ''
@table_no = ''
@dining = ''
@shop = Shop::ShopDetail #show shop info
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
saleObj = Sale.find(sale_id)
#total customer with individual total amount
@@ -273,10 +289,11 @@ class Origami::PaymentsController < BaseOrigamiController
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
accounts = @customer.tax_profiles
# accounts = @customer.tax_profiles
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
account = TaxProfile.find(acc.id)
@account_arr.push(account)
end
@@ -287,7 +304,7 @@ class Origami::PaymentsController < BaseOrigamiController
if response["status"]==true
response["account_data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
@balance += res["balance"]
@balance = @balance.to_f + res["balance"].to_f
# @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end
@@ -327,6 +344,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
@@ -404,19 +423,19 @@ class Origami::PaymentsController < BaseOrigamiController
member_info = nil
rebate_amount = nil
current_balance = nil
order_source = params[:type]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
if saleObj.discount_type == "member_discount"
saleObj.update_attributes(rounding_adjustment: 0)
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source)
end
saleObj.update_attributes(rounding_adjustment: 0)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
# if bookings.count > 1
@@ -438,7 +457,7 @@ class Origami::PaymentsController < BaseOrigamiController
# Re-call Sale Data
saleObj = Sale.find(sale_id)
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
@@ -452,7 +471,17 @@ class Origami::PaymentsController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
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, "FOC",nil,nil)
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, "FOC",nil,nil)
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
@@ -466,7 +495,7 @@ class Origami::PaymentsController < BaseOrigamiController
Order.pay_process_order_queue(order.order_id,table_id)
end
end
end
# end
end
end
@@ -512,6 +541,15 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
render :json => {status: true}
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# render :json => {status: true}
end
end

View File

@@ -1,6 +1,12 @@
class Origami::QuickServiceController < ApplicationController
# before_action :set_dining, only: [:detail]
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
def index
today = DateTime.now
day = Date.today.wday
@@ -211,6 +217,11 @@ class Origami::QuickServiceController < ApplicationController
end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
# this can always true
def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"

View File

@@ -1,5 +1,11 @@
class Origami::RequestBillsController < ApplicationController
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
# Print Request Bill and add to sale tables
def print
@sale = Sale.new
@@ -13,7 +19,7 @@ class Origami::RequestBillsController < ApplicationController
if check_booking.sale_id.nil?
# Create Sale if it doesn't exist
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user)
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
else

View File

@@ -76,11 +76,14 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
order = Order.find(order_id)
action_by = current_user.id
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -141,7 +144,7 @@ class Origami::SaleEditController < BaseOrigamiController
end
end
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
ProductCommission.edit_product_commission(saleitemObj)
end
@@ -162,17 +165,21 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
order = Order.find(order_id)
action_by = current_user.id
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount, order.source)
ProductCommission.remove_product_commission(saleitemObj)
end
# remove all void items
def cancel_all_void
sale_id = params[:sale_id]
order_source = params[:type]
saleObj = Sale.find(sale_id)
saleObj.sale_items.each do |item|
if item.qty.to_i < 0
@@ -185,13 +192,14 @@ class Origami::SaleEditController < BaseOrigamiController
end
# re-calc tax
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
end
def apply_void
sale_id = params[:sale_id]
order_source = params[:type]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void
saleObj.compute_without_void(order_source)
saleObj.sale_items.each do |item|
ProductCommission.remove_product_commission(item)
end

View File

@@ -3,7 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController
end
def show
@type = params[:type]
@cashier_type = params[:type]
@shift = ShiftSale.current_open_shift(current_user.id)
#for bank integration
bank_integration = Lookup.collection_of('bank_integration')

View File

@@ -3,6 +3,7 @@ class Origami::SplitBillController < BaseOrigamiController
def index
dining_id = params[:dining_id]
@cashier_type = params[:type]
@table = DiningFacility.find(dining_id)
@booking = @table.get_booking
@orders = Array.new
@@ -76,6 +77,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
def create
cashier_type = params[:cashier_type]
order_ids = params[:order_ids]
arr_order_ids = nil
if !params[:arr_order_ids].nil?
@@ -111,7 +113,7 @@ class Origami::SplitBillController < BaseOrigamiController
if booking
if booking.sale_id.nil?
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user)
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type)
sale_data = Sale.find_by_sale_id(sale_id)
else
status = true
@@ -233,7 +235,7 @@ class Origami::SplitBillController < BaseOrigamiController
puts "order_id_count < 1"
new_order_status = true
order_items.each do |order_item|
orderItem = OrderItem.find_by_order_id(order_id)
orderItem = OrderItem.find(order_item["id"])
if !orderItem.nil?
if order_item["id"] == orderItem.order_items_id
if orderItem.qty.to_f != order_item['qty'].to_f
@@ -324,7 +326,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user)
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type)
end
Promotion.promo_activate(sale)

View File

@@ -31,6 +31,8 @@ class Origami::TableInvoicesController < BaseOrigamiController
def show
@table = DiningFacility.find(params[:table_id])
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
shop = Shop::ShopDetail
@sale_array = Array.new
@table.bookings.each do |booking|

View File

@@ -4,31 +4,40 @@ class Origami::UnionpayController < BaseOrigamiController
@cashier_type = params[:type]
# limit unionpay_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@unionpaycount = 0
others = 0
@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
@rounding_adj = 0
@can_unionpay = 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 == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_unionpay = total - @unionpaycount - 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
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_unionpay = total - @unionpaycount - 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
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +66,9 @@ class Origami::UnionpayController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

58
app/controllers/origami/visa_controller.rb Executable file → Normal file
View File

@@ -4,31 +4,40 @@ class Origami::VisaController < BaseOrigamiController
@cashier_type = params[:type]
# limit visa_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@visacount = 0
others = 0
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_visa = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
@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
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 == "visa"
@visacount = @visacount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_visa = total - @visacount - 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
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "visa"
@visacount = @visacount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_visa = total - @visacount - 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
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +66,9 @@ class Origami::VisaController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -4,12 +4,13 @@ class Origami::VoidController < BaseOrigamiController
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)
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
end
# update count for shift sale
@@ -86,8 +87,6 @@ class Origami::VoidController < BaseOrigamiController
if bookings[0].dining_facility_id.to_i>0
table = DiningFacility.find(bookings[0].dining_facility_id)
end
end
if bookings[0].dining_facility_id.to_i > 0
@@ -99,7 +98,7 @@ class Origami::VoidController < BaseOrigamiController
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
@@ -119,9 +118,17 @@ class Origami::VoidController < BaseOrigamiController
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
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)
end
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)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print