tax profiles

This commit is contained in:
Myat Zin Wai Maw
2020-01-16 10:05:45 +06:30
parent bad510c6b4
commit 676251a12c
14 changed files with 79 additions and 66 deletions

View File

@@ -1,5 +1,5 @@
class Api::OrdersController < Api::ApiController
skip_before_action :authenticate
# skip_before_action :authenticate
#Description
# This API show current order details
# Input Params - order_id
@@ -72,7 +72,6 @@ class Api::OrdersController < Api::ApiController
@status = false
@message = "No Current Open Shift for This Employee"
else
current_user = Employee.find(current_shift.employee_id)
if checkin_checkout_time(params[:booking_id])
table = DiningFacility.find(params[:table_id]) if params[:table_id].present?
@@ -95,6 +94,24 @@ class Api::OrdersController < Api::ApiController
end
end
}
items_arr = []
params[:order_items].each { |i|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
if i["parent_order_item_id"]
items = {"order_item_id": i,"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,"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
end
items_arr.push(items)
}
#end extra time
Order.transaction do
# begin
@@ -102,12 +119,12 @@ class Api::OrdersController < Api::ApiController
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
@order.items = params[:order_items]
@order.items = items_arr
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.waiters = @user.name
@order.employee_name = @user.name
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
@@ -125,7 +142,7 @@ class Api::OrdersController < Api::ApiController
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
if @order.source == 'app'
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
@status, @sale = Sale.request_bill(@order,@user,@user)
end
end
if @order.table_id.to_i > 0

View File

@@ -1,5 +1,4 @@
class Api::PaymentsController < Api::ApiController
skip_before_action :authenticate
#Payment by Invoice ID
# Payment Method - [Cash | CreditNote | VISA | MASTER | etc..]
@@ -28,23 +27,22 @@ class Api::PaymentsController < Api::ApiController
if !sale.nil?
@paid_amount = sale.grand_total
current_shift = ShiftSale.current_shift
current_login_employee =Employee.find(current_shift.employee_id)
@shop =Shop.find_by_shop_code(sale.shop_code)
@shop =Shop.current_shop
@status,@message,@balance =check_security_code(sale,params)
sale_items = SaleItem.get_all_sale_items(sale_id)
if @status
sale_payment = SalePayment.new
@status, @sale, @membership_data = sale_payment.process_payment(sale, current_login_employee, sale.grand_total, "paymal",params[:account_no])
@status, @sale, @membership_data = sale_payment.process_payment(sale, @user, sale.grand_total, "paymal",params[:account_no])
if @status && @membership_data["status"] == true
sale_payment = SalePayment.new
status = sale_payment.process_payment(sale, current_login_employee, 0, "cash")
status = sale_payment.process_payment(sale, @user, 0, "cash")
#card_balance amount for Paymal payment
card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(params[:sale_id])
rebate_amount = nil
# For Cashier by Zone
bookings = Booking.find_by_sale_id(sale_id)
shift = ShiftSale.current_open_shift(current_login_employee)
shift = ShiftSale.current_open_shift(@user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
@@ -165,10 +163,10 @@ class Api::PaymentsController < Api::ApiController
end
end
def send_account_paymal(amount, account_no, receipt_no,current_login_employee)
def send_account_paymal(amount, account_no, receipt_no)
sale = Sale.find_by_receipt_no(receipt_no)
@out = []
action_by = current_login_employee.name
action_by = @user.name
@status = true
@message = ""
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
@@ -182,10 +180,10 @@ class Api::PaymentsController < Api::ApiController
membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no)
if membership_data["status"]==true
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,current_login_employee.name, current_login_employee.name,remark,"PAYBYACCOUNT" )
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,@user.name, @user.name,remark,"PAYBYACCOUNT" )
else
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Remark : #{membership_data[:message]}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,current_login_employee.name, current_login_employee.name,remark,"PAYBYACCOUNT" )
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,@user.name, @user.name,remark,"PAYBYACCOUNT" )
end
@out = membership_data
@@ -237,11 +235,9 @@ class Api::PaymentsController < Api::ApiController
end
def check_security_code(sale,params)
current_shift = ShiftSale.current_shift
current_login_employee =Employee.find(current_shift.employee_id)
@shop =Shop.find_by_shop_code(sale.shop_code)
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sale.shop_code)
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",Shop.current_shop.shop_code)
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type_and_shop_code("search_paypar_security_code",sale.shop_code)
member_actions =MembershipAction.find_by_membership_type_and_shop_code("search_paypar_security_code",Shop.current_shop.shop_code)
if member_actions.gateway_url
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
@@ -292,68 +288,68 @@ class Api::PaymentsController < Api::ApiController
when "cash"
sale_payment.payment_method = "cash"
sale_payment.received_amount = params[:amount]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "creditnote"
sale_payment.payment_method = "creditnote"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "visa"
sale_payment.payment_method = "visa"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "master"
sale_payment.payment_method = "master"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "jcb"
sale_payment.payment_method = "jcb"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "mpu"
sale_payment.payment_method = "mpu"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "unionpay"
sale_payment.payment_method = "unionpay"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "vochure"
sale_payment.payment_method = "vochure"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
sale_payment.payment_reference = params[:vochure_no]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "giftcard"
sale_payment.payment_method = "giftcard"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
sale_payment.payment_reference = params[:giftcard_no]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "paypar"
sale_payment.payment_method = "paypar"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
#TODO: implement paypar implementation
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "JunctionPay"
sale_payment.payment_method = "JunctionPay"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
sale_payment.payment_reference = params[:vochure_no]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
when "alipay"
sale_payment.payment_method = "alipay"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
@status, @invoice = sale_payment.process_payment(sale_payment, @user)
end
end
#get cloud domain

View File

@@ -1,6 +1,4 @@
class Api::Restaurant::MenuController < Api::ApiController
skip_before_action :authenticate
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id

View File

@@ -1,6 +1,4 @@
class Api::Restaurant::MenuItemsController < Api::ApiController
skip_before_action :authenticate
def index
end

View File

@@ -1,7 +1,5 @@
class Api::ShopsController < Api::ApiController
skip_before_action :authenticate
def index
@shops = Shop.select('id,logo,name,shop_code,address,phone_no').all
end
@@ -9,4 +7,7 @@ class Api::ShopsController < Api::ApiController
def show
@shop = Shop.find_by_shop_code(params[:id])
end
def get_tax_profiles
@inclusive_tax,@exclusive_tax =TaxProfile.calculate_tax("online_order")
end
end

View File

@@ -1,5 +1,4 @@
class Api::VerificationsController < Api::ApiController
skip_before_action :authenticate
def new
phone_number = params[:phone_number]