This commit is contained in:
Aung Myo
2017-07-11 16:50:41 +06:30
24 changed files with 726 additions and 102 deletions

View File

@@ -42,6 +42,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.unit_price = di["price"]
sale_item.taxable_price = di["price"]
sale_item.is_taxable = 0
sale_item.account_id = origin_sale_item.account_id
sale_item.price = di["price"]
sale_item.save
@@ -120,6 +121,78 @@ class Origami::DiscountsController < BaseOrigamiController
render :json => result.to_json
end
# Member Discount
def member_discount
sale_id = params[:sale_id]
account_types = JSON.parse(params[:account_types])
sub_total = params[:sub_total]
sale = Sale.find(sale_id)
price = SaleItem.calculate_price_by_accounts(sale.sale_items)
arr = Array.new;
account_types.each do |at|
price.each do |pc|
if pc[:name].to_s == at["name"].to_s && pc[:price]>0
str={type:pc[:name],amount:pc[:price]}
arr.push(str)
end
end
end
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => { generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
merchant_uid:merchant_uid,
discount_method:arr.to_json,
total_sale_transaction_amount: sale.grand_total,
auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10)
rescue HTTParty::Error
response = {status: false, message: "Can't open membership server "}
rescue Net::OpenTimeout
response = { status: false , message: "Can't open membership server "}
rescue OpenURI::HTTPError
response = { status: false, message: "Can't open membership server "}
rescue SocketError
response = { status: false, message: "Can't open membership server "}
end
puts response.to_json
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
# Re-calc All Amount in Sale
if response["status"] == true
sale.compute_by_sale_items(sale_id, sale.sale_items, response["rebate_earned"].to_f,"member_discount")
end
result = {:status=> "Success", :table_id => table_id, :table_type => table_type,:table_type => table_type,:url_status => response[:status],:url_message => response[:message] }
render :json => result.to_json
end
#discount for selected order
# def create
# sale_id = params[:sale_id]

View File

@@ -67,10 +67,8 @@ 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,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
end
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
end
end
def show
@@ -87,6 +85,7 @@ class Origami::PaymentsController < BaseOrigamiController
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0.00
@accountable_type = ''
@table_no = ''
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
@@ -107,6 +106,12 @@ class Origami::PaymentsController < BaseOrigamiController
#end customer amount
@sale_data.bookings.each do |sbk|
df = DiningFacility.find(sbk.dining_facility_id)
@table_no = df.type + ' ' + df.name
break
end
@sale_data.sale_payments.each do |spay|
if spay.payment_method == "cash"
@cash = spay.payment_amount

View File

@@ -41,10 +41,8 @@ class Origami::ShiftsController < BaseOrigamiController
end
session[:session_token] = nil
redirect_to root_path
Employee.logout(session[:session_token])
session[:session_token] = nil
end
def edit