shop code

This commit is contained in:
Myat Zin Wai Maw
2019-11-22 18:24:02 +06:30
parent 5a3f328789
commit d1ab2c194d
106 changed files with 834 additions and 895 deletions

View File

@@ -40,8 +40,8 @@ class OrderReservation < ApplicationRecord
# unless customer.valid?
# render json: {
# status: 422,
# message: "Validation error",
# errors: customer.errors
# message: "Validation error",
# errors: customer.errors
# }.to_json
# return
# end
@@ -53,7 +53,7 @@ class OrderReservation < ApplicationRecord
Rails.logger.debug order_reserve.to_s
check_order_reservation = OrderReservation.where("transaction_ref = ?",order_reserve[:reference])
if check_order_reservation.empty?
OrderReservation.transaction do
OrderReservation.transaction do
begin
order_reservation = OrderReservation.new
order_reservation.order_reservation_type = order_reserve[:order_type]
@@ -84,7 +84,7 @@ class OrderReservation < ApplicationRecord
end
order_reservation.save!
if order_reserve[:order_info][:items]
order_reserve[:order_info][:items].each do |oritem|
order_reserve[:order_info][:items].each do |oritem|
OrderReservationItem.process_order_reservation_item(oritem[:product_code],oritem[:item_instance_code],oritem[:product_name],oritem[:product_alt_name],
oritem[:account_id],oritem[:qty],oritem[:price],oritem[:unit_price],
oritem[:options],nil,order_reservation.id)
@@ -93,13 +93,13 @@ class OrderReservation < ApplicationRecord
if order_reserve[:delivery_info]
Delivery.addDeliveryInfo(order_reserve[:delivery_info],order_reservation.id)
end
return order_reservation.id, true
rescue ActiveRecord::StatementInvalid
raise ActiveRecord::Rollback
return nil, false
end
end
end
else
return check_order_reservation[0].id, false
@@ -112,14 +112,14 @@ class OrderReservation < ApplicationRecord
items_arr = []
count = 1
order.order_reservation_items.each { |i|
order.order_reservation_items.each { |i|
i.item_instance_code = i.item_instance_code.downcase.to_s
items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": i.options}
count += 1
items_arr.push(items)
}
customer_id = order.customer_id
@order = Order.new
@order.source = "doemal_order"
@order.order_type = "delivery"
@@ -138,7 +138,7 @@ class OrderReservation < ApplicationRecord
# Order.send_customer_view(@booking)
if @status && @booking
@status, @sale = Sale.request_bill(@order,current_user,current_user)
#order status send to doemal
@@ -157,7 +157,7 @@ class OrderReservation < ApplicationRecord
def self.update_doemal_payment(order,current_user,receipt_bill)
if(Sale.exists?(order.sale_id))
saleObj = Sale.find(order.sale_id)
shop_details = Shop.first
shop_details = Shop.find_by_shop_code(order.shop_code)
# rounding adjustment
if shop_details.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
@@ -167,11 +167,11 @@ class OrderReservation < ApplicationRecord
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
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)
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end
end
#end rounding adjustment
sale_payment = SalePayment.new
if(order.payment_type == "cash_on_delivery")
sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash")
@@ -183,9 +183,9 @@ class OrderReservation < ApplicationRecord
callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,DELIVERED)
#order reservation status updated
update_order_reservation(order.id, saleObj.sale_id, DELIVERED)
Rails.logger.debug "@@@@ receipt_bill :: "
Rails.logger.debug "@@@@ receipt_bill :: "
Rails.logger.debug receipt_bill
if receipt_bill == 1
#receipt bill pdf setting
# get printer info
@@ -194,7 +194,7 @@ class OrderReservation < ApplicationRecord
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
shop_detail = Shop.first
# shop_detail = Shop.first
order_reservation = OrderReservation.get_order_reservation_info(saleObj.sale_id)
if !cashier_terminal.nil?
# Calculate Food and Beverage Total
@@ -203,16 +203,16 @@ class OrderReservation < ApplicationRecord
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
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,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_details, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
#receipt bill pdf setting
result = {:status=> true,
:filepath => filename,
:sale_id => saleObj.sale_id,
:receipt_no => sale_receipt_no,
:printer_name => printer_name,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings ,
result = {:status=> true,
:filepath => filename,
:sale_id => saleObj.sale_id,
:receipt_no => sale_receipt_no,
:printer_name => printer_name,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings ,
:message => DELIVERED }
else
result = {:status=> true, :message => DELIVERED }
@@ -223,7 +223,7 @@ class OrderReservation < ApplicationRecord
result = {:status=> true, :message => DELIVERED }
end
return result
end
end
end
def self.send_status_to_ordering(url,ref_no,status,waiting_time=nil,min_type=nil,reason=nil)
@@ -349,12 +349,12 @@ class OrderReservation < ApplicationRecord
shift.save
end
end
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
# For Sale Audit
# For Sale Audit
if !current_user.nil?
action_by = current_user.name
else
@@ -363,7 +363,7 @@ class OrderReservation < ApplicationRecord
approved_name = nil
approved_by = Employee.find_by_emp_id(access_code)
if !approved_by.nil?
approved_name = approved_by.name
end
@@ -372,7 +372,7 @@ class OrderReservation < ApplicationRecord
sale_audit = SaleAudit.record_audit_for_edit(sale_id,cashier_name, approved_name,remark,"SALEVOID" )
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
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
@@ -410,7 +410,7 @@ class OrderReservation < ApplicationRecord
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
else
from = ""
end
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code,from:from
@@ -428,7 +428,7 @@ class OrderReservation < ApplicationRecord
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
else
from = ""
end
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code,from:from
@@ -446,7 +446,7 @@ class OrderReservation < ApplicationRecord
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
else
from = ""
end
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code,from:from