merge with master

This commit is contained in:
phyusin
2018-03-30 15:36:41 +06:30
220 changed files with 6716 additions and 1947 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]
@@ -226,9 +226,4 @@ class Origami::AddordersController < BaseOrigamiController
# @dining = DiningFacility.find(params[:id])
# end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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

@@ -96,9 +96,4 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon
render json: response
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -24,9 +24,4 @@ class Origami::CardPaymentsController < BaseOrigamiController
def create
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -14,10 +14,5 @@ class Origami::CashInsController < BaseOrigamiController
shift.cash_in = shift.cash_in + amount.to_i
shift.save
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -8,9 +8,4 @@ class Origami::CashMgmtController < ApplicationController
def create
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -13,9 +13,4 @@ class Origami::CashOutsController < BaseOrigamiController
shift.save
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -36,9 +36,4 @@ class Origami::CheckInProcessController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -47,10 +47,4 @@ class Origami::CreditPaymentsController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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,16 +135,11 @@ 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"})
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -58,8 +58,4 @@ class Origami::DashboardController < BaseOrigamiController
@current_user = current_user
end
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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]
@@ -273,7 +277,7 @@ class Origami::DiscountsController < BaseOrigamiController
auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=2'
'Accept' => 'application/json; version=3'
}, :timeout => 10)
rescue HTTParty::Error
response = {"status": false, "message": "Can't open membership server " }
@@ -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 }
@@ -355,9 +359,5 @@ class Origami::DiscountsController < BaseOrigamiController
# redirect_to origami_path(sale_id)
# end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -74,16 +74,6 @@ class Origami::HomeController < BaseOrigamiController
@date = order.created_at
@booking= booking
order.order_items.each do |item|
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
item.price = item.price.to_f + instance_item["price"].to_f
end
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item)
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil?
@@ -105,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'
@@ -136,12 +126,6 @@ class Origami::HomeController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
private
def set_dining

View File

@@ -81,9 +81,4 @@ class Origami::HomeController < ApplicationController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -169,9 +169,4 @@ class Origami::InDutiesController < BaseOrigamiController
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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

@@ -5,32 +5,43 @@ 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
@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 == "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
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -41,6 +52,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
@@ -54,7 +66,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

@@ -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

57
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?
@@ -40,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
@@ -53,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

@@ -35,11 +35,5 @@ class Origami::MoveroomController < BaseOrigamiController
end
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -70,10 +70,5 @@ class Origami::MovetableController < BaseOrigamiController
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

60
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?
@@ -40,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
@@ -53,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

@@ -80,10 +80,5 @@ class Origami::OrdersController < BaseOrigamiController
end
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 }
@@ -76,10 +77,5 @@ class Origami::OtherChargesController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -37,9 +37,4 @@ class Origami::OthersPaymentsController < BaseOrigamiController
def create
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
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"
@@ -63,9 +63,9 @@ class Origami::PaymentsController < BaseOrigamiController
# 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 = 0
# member_info = Customer.get_member_account(customer)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -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
@@ -104,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
#end rounding adjustment
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
@@ -129,7 +138,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?
@@ -156,6 +165,23 @@ class Origami::PaymentsController < BaseOrigamiController
current_balance = SaleAudit.paymal_search(sale_id)
end
#orders print out
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)
oqs = OrderQueueStation.new
oqs.pay_process_order_queue(order.order_id, table_id)
end
end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
@@ -180,19 +206,7 @@ class Origami::PaymentsController < BaseOrigamiController
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})
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
end
@@ -210,16 +224,20 @@ 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.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
@@ -269,10 +287,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
@@ -283,7 +302,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
@@ -323,10 +342,14 @@ 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
elsif spay.payment_method == "paymal"
@paymalcount += spay.payment_amount
elsif spay.payment_method == "alipay"
@alipaycount += spay.payment_amount
end
end
end
@@ -402,19 +425,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
@@ -436,7 +459,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)
@@ -450,7 +473,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)
@@ -464,7 +497,7 @@ class Origami::PaymentsController < BaseOrigamiController
Order.pay_process_order_queue(order.order_id,table_id)
end
end
end
# end
end
end
@@ -510,12 +543,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}
end
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
# Mobile Print
render :json => result.to_json
# render :json => {status: true}
end
end

View File

@@ -29,9 +29,4 @@ class Origami::PayparPaymentsController < BaseOrigamiController
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -41,9 +41,4 @@ class Origami::PendingOrderController < BaseOrigamiController
end
end
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -137,9 +137,4 @@ class Origami::ProductCommissionsController < BaseOrigamiController
params.fetch(:product_commission, {})
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
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

@@ -6,6 +6,7 @@ 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)
@@ -68,10 +69,5 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
end
@out = false, 0
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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
@@ -8,14 +14,12 @@ class Origami::RequestBillsController < ApplicationController
if !ShiftSale.current_shift.nil?
order_id = params[:id] # order_id
bk_order = BookingOrder.find_by_order_id(order_id)
puts params[:id]
puts bk_order
puts bk_order.booking_id
order = Order.find(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
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
@@ -29,6 +33,10 @@ class Origami::RequestBillsController < ApplicationController
# Promotion Activation
Promotion.promo_activate(@sale)
if order.source == "quick_service"
result = {:status=> @status, :data => @sale.sale_id }
render :json => result.to_json
end
else
@status = false
@error_message = "No Current Open Shift for This Employee"
@@ -56,10 +64,5 @@ class Origami::RequestBillsController < ApplicationController
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -37,9 +37,4 @@ class Origami::RoomInvoicesController < BaseOrigamiController
@customer = @sale.customer
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -68,16 +68,6 @@ class Origami::RoomsController < BaseOrigamiController
@date = order.created_at
@booking = booking
order.order_items.each do |item|
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
item.price = item.price.to_f + instance_item["price"].to_f
end
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item)
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil?
@@ -89,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'
@@ -136,9 +125,4 @@ class Origami::RoomsController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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,21 +192,17 @@ 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
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -56,9 +56,4 @@ class Origami::SalesController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -3,6 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController
end
def show
@cashier_type = params[:type]
@shift = ShiftSale.current_open_shift(current_user.id)
#for bank integration
bank_integration = Lookup.collection_of('bank_integration')
@@ -125,9 +126,4 @@ class Origami::ShiftsController < BaseOrigamiController
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

71
app/controllers/origami/split_bill_controller.rb Normal file → Executable file
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,7 +77,12 @@ 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?
arr_order_ids = JSON.parse(params[:arr_order_ids])
end
orders = nil
if !params[:orders].empty?
orders = JSON.parse(params[:orders])
@@ -107,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
@@ -136,14 +142,15 @@ class Origami::SplitBillController < BaseOrigamiController
order_id_count = 0
order_id = nil
order_items.each do |order_item|
order_item_count = 0
order = Order.find(order_item["order_id"])
if order.order_items.count == 1
order_id = order.id
order_id_count += 1
else
order_item_count += 1
arr_order_ids.each do |order|
order.each do |odr|
data = Order.find(odr[0])
if data.order_items.count == odr[1]
order_id = odr[0]
order_id_count += 1
else
order_item_count += 1
end
end
end
@@ -158,10 +165,12 @@ class Origami::SplitBillController < BaseOrigamiController
puts "order_id_count > 1"
updated_order_id = Array.new
order_ids.each do |odr_id|
odr = Order.find(odr_id)
if odr.order_items.count > 1
updated_order_id.push(odr_id)
arr_order_ids.each do |order|
order.each do |odr|
data = Order.find(odr[0])
if data.order_items.count != odr[1]
updated_order_id.push(odr[0])
end
end
end
@@ -226,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
@@ -266,12 +275,32 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
else
# puts order_ids
if order_ids.count == 1 && order_id_count == 0 && order_item_count == 1
BookingOrder.find_by_order_id(order_ids[0]).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
order_items.each do |order_item|
update_order_item(order_ids[0], order_item)
if order_ids.count == 1 && order_item_count == 1
if order_id_count == 0
customer = Customer.find(params[:customer_id])
order_type = "dine_in"
if !customer.nil?
if customer.customer_type == "Takeaway"
order_type = "takeaway"
elsif customer.customer_type == "Delivery"
order_type = "delivery"
end
end
# begin
order = create_order(params,order_type,order_items.count,current_user)
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
order_items.each do |order_item|
update_order_item(order.order_id, order_item)
end
else
BookingOrder.find_by_order_id(order_ids[0]).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
order_items.each do |order_item|
update_order_item(order_ids[0], order_item)
end
end
else
customer = Customer.find(params[:customer_id])
@@ -297,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

@@ -90,10 +90,5 @@ class Origami::SurveysController < BaseOrigamiController
def survey_params
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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|
@@ -70,9 +72,4 @@ class Origami::TableInvoicesController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter()
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

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?
@@ -39,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
@@ -53,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

56
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
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_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
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?
@@ -39,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
@@ -53,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

@@ -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
@@ -47,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
@@ -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
@@ -134,10 +141,5 @@ class Origami::VoidController < BaseOrigamiController
end
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -54,7 +54,7 @@ class Origami::VoucherController < BaseOrigamiController
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=2'
'Accept' => 'application/json; version=3'
}, :timeout => 10
)
rescue Net::OpenTimeout
@@ -78,9 +78,4 @@ class Origami::VoucherController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -0,0 +1,128 @@
class Origami::WasteSpoileController < BaseOrigamiController
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)
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.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
table_avaliable = true
table_count = 0
table = sale.bookings[0].dining_facility
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' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
table_avaliable = true
end
else
table_avaliable = false
table_count += 1
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
end
else
table = nil
end
# FOr Sale Audit
action_by = current_user.name
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,remark )
# For Print
member_info = nil
rebate_amount = nil
current_balance = nil
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
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
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.find(1)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
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)
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,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
aoi.delivery_status = 1
aoi.save
end
end
end
end
end