This commit is contained in:
Myat Zin Wai Maw
2020-01-14 13:31:54 +06:30
226 changed files with 3427 additions and 3740 deletions

View File

@@ -10,121 +10,73 @@ class Origami::PaymentsController < BaseOrigamiController
member_info = nil
# For Cashier by Zone
booking = Booking.find_by_sale_id(sale_id)
# if bookings.count > 1
# # for Multiple Booking
# table = DiningFacility.find(bookings[0].dining_facility_id)
# else
# table = DiningFacility.find(bookings[0].dining_facility_id)
# end
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if booking.dining_facility_id.to_i > 0
table = DiningFacility.find(booking.dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(sale_data.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
booking = sale_data.booking
if current_user.role == 'cashier'
cashier_terminal = current_user.cashier_terminal
elsif booking.dining_facility
cashier_terminal = booking.cashier_terminal_by_dining_facility
end
cashier_terminal ||= sale_data.cashier_terminal_by_shift_sale
customer = sale_data.customer
#record for sale audit
action_by = current_user.name
type = "FIRST_BILL"
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
# 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
end
# find order id by sale id
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
print_settings = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first
printer = Printer::ReceiptPrinter.new(print_settings)
#TODO :: KBZPAY ( QR )
# On/Off setting ( show or not qr )
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
status = false
qr = nil
if !kbz_pay_method.nil?
if kbz_pay_method.is_active == true
sale_payment = SalePayment.new
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
status, qr = KbzPay.pay(sale_data.grand_total.to_i, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
end
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, nil, current_shop, "Frt", current_balance, nil, other_amount, nil, nil, nil)
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = unique_code#{}"ReceiptBillPdf"
end
end
end
end
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
#shop detail
## shop_detail = @shop
# customer= Customer.where('customer_id=' +.customer_id)
customer = Customer.find(sale_data.customer_id)
# rounding adjustment
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = new_total - sale_data.grand_total
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
end
#end rounding adjustment
#record for sale audit
action_by = current_user.name
type = "FIRST_BILL"
# status, qr = KbzPay.query(sale_payment.sale_payment_id)
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
if customer.membership_id != nil && rebate
# 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_and_shop_code(unique_code,@shop.shop_code)
# find order id by sale id
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
#TODO :: KBZPAY ( QR )
# On/Off setting ( show or not qr )
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => @shop.shop_code).last
status = false
qr = nil
if !kbz_pay_method.nil?
if kbz_pay_method.is_active == true
sale_payment = SalePayment.new
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
status, qr = KbzPay.pay(sale_data.grand_total.to_i, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
end
end
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# status, qr = KbzPay.query(sale_payment.sale_payment_id)
# Mobile Print
render :json => result.to_json
# Mobile Print
render :json => result.to_json
# end
end
@@ -138,25 +90,9 @@ class Origami::PaymentsController < BaseOrigamiController
latest_order_no = nil
is_kbz = params[:is_kbz]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
if saleObj = Sale.find(sale_id)
sale_items = SaleItem.get_all_sale_items(sale_id)
#shop_detail = @shop
# rounding adjustment
if !path.include? ("credit_payment")
if @shop.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) if rounding_adj > 0
end
end
#end rounding adjustment
# if pay_from = 'kbzpay'
# salePayment = SalePayment.find(sale_payment_id)
# salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid')
# else
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
if is_kbz == 'false'
Rails.logger.info '################ CASH PAYMENT #################'
sale_payment = SalePayment.new
@@ -166,134 +102,110 @@ class Origami::PaymentsController < BaseOrigamiController
sale_payment.process_payment(saleObj, current_user, cash, "cash")
end
else
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
end
# end
if !path.include? ("credit_payment")
rebate_amount = nil
# For Cashier by Zone
# bookings = Booking.where("sale_id='#{sale_id}'")
bookings = saleObj.bookings[0]
booking = saleObj.booking
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings.dining_facility_id.to_i > 0
table = bookings.dining_facility
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
if current_user.role == 'cashier'
cashier_terminal = current_user.cashier_terminal
elsif booking.dining_facility
cashier_terminal = booking.cashier_terminal_by_dining_facility
end
type = 'payment'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
else
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
cashier_terminal ||= saleObj.cashier_terminal_by_shift_sale
if booking.dining_facility
ActionCable.server.broadcast(
"order_channel",
table: booking.dining_facility,
type: 'payment',
from: getCloudDomain
)
end
# For Print
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillA5Pdf"
else
unique_code = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code
end
customer = saleObj.customer
# get member information
rebate = MembershipSetting.find_by_rebate(1)
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
if customer.membership_id != nil && rebate && credit_data.nil?
member_info = Customer.get_member_account(customer)
if member_info["status"] == true
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
end
#orders print out
if type == "quick_service"
if booking.dining_facility_id.present?
table_id = booking.dining_facility_id
else
table_id = 0
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
# else
end
end
end
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
if !latest_order.nil?
latest_order_no = latest_order.order_id
end
customer= Customer.find(saleObj.customer_id)
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)
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
if customer.membership_id != nil && rebate && credit_data.nil?
member_info = Customer.get_member_account(customer)
if member_info["status"] == true
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
end
#orders print out
if 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
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
if !latest_order.nil?
latest_order_no = latest_order.order_id
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)
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
end
end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#card_balance amount for Paymal payment
card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
#card_balance amount for Paymal payment
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
# 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(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, current_shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil)
#end
end
logger.debug 'saleObj++++++++++++++++++++++++++'
logger.debug saleObj.to_json
if !saleObj.nil?
# InventoryJob.perform_now(self.id)
# InventoryDefinition.calculate_product_count(saleObj)
@@ -313,7 +225,7 @@ class Origami::PaymentsController < BaseOrigamiController
# end
def show
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value
else
@@ -330,10 +242,10 @@ class Origami::PaymentsController < BaseOrigamiController
end
if path.include? ("credit_payment")
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
end
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
@member_discount = MembershipSetting.find_by_discount(1)
@membership_rebate_balance=0
if Sale.exists?(sale_id)
@@ -358,17 +270,17 @@ class Origami::PaymentsController < BaseOrigamiController
@dining = ''
@other_payment = 0.0
@pdf_view = nil
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value
end
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
@kbz_pay_amount += amount.to_f
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
@@ -381,7 +293,7 @@ class Origami::PaymentsController < BaseOrigamiController
# @shop = shop_detail #show shop info
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
saleObj = Sale.find(sale_id)
@@ -410,7 +322,7 @@ class Origami::PaymentsController < BaseOrigamiController
#end rounding adjustment
# rounding adjustment
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
@@ -436,7 +348,7 @@ class Origami::PaymentsController < BaseOrigamiController
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
# accounts = @customer.tax_profiles
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
@account_arr =[]
@tax_arr =[]
accounts.each do |acc|
@@ -450,7 +362,7 @@ class Origami::PaymentsController < BaseOrigamiController
@account_arr.push(sale_tax)
end
end
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
rebate = MembershipSetting.find_by_rebate(1)
# get member information
if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer)
@@ -612,7 +524,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount, current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
result = {
:status => true,
@@ -636,11 +548,14 @@ class Origami::PaymentsController < BaseOrigamiController
current_balance = nil
order_source = params[:type]
if(Sale.exists?(sale_id))
if Sale.exists?(sale_id)
saleObj = Sale.find(sale_id)
#calculate cash acmount
cash = saleObj.total_amount
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
if saleObj.discount_type == "member_discount"
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
saleObj.compute_by_sale_items(0, nil, order_source)
@@ -648,9 +563,6 @@ class Origami::PaymentsController < BaseOrigamiController
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id)
@@ -659,8 +571,6 @@ class Origami::PaymentsController < BaseOrigamiController
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
@@ -703,7 +613,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
@@ -712,7 +622,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
result = {
:status => true,
:filepath => filename,
@@ -747,7 +657,7 @@ class Origami::PaymentsController < BaseOrigamiController
saleObj = Sale.find(params[:sale_id])
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
@@ -770,9 +680,9 @@ class Origami::PaymentsController < BaseOrigamiController
if cashier_type.strip.downcase == "doemal_order"
unique_code = "ReceiptBillOrderPdf"
else
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
@@ -795,7 +705,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
@@ -817,8 +727,10 @@ class Origami::PaymentsController < BaseOrigamiController
sale_id = params[:sale_id]
order_source = params[:cashier_type]
tax_type = params[:tax_type]
remark = "Change tax to #{tax_type.upcase} for Sale ID #{sale_id} By #{current_login_employee.name}"
sale = Sale.find(sale_id)
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
SaleAudit.record_audit_change_tax(sale_id,remark,current_login_employee.name)
render json: JSON.generate({:status => true})
end