mobile payment

This commit is contained in:
Nweni
2019-06-21 10:47:48 +06:30
parent c06f0aade8
commit 2a71794529

View File

@@ -15,26 +15,27 @@ class Api::Payment::MobilepaymentController < Api::ApiController
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
sale_items = SaleItem.get_all_sale_items(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id)
shop_detail = Shop.first shop_detail = Shop.first
# rounding adjustment
if !path.include? ("credit_payment") # # rounding adjustment
if shop_detail.is_rounding_adj # if !path.include? ("credit_payment")
a = saleObj.grand_total % 25 # Modulus # if shop_detail.is_rounding_adj
b = saleObj.grand_total / 25 # Division # a = saleObj.grand_total % 25 # Modulus
#not calculate rounding if modulus is 0 and division is even # b = saleObj.grand_total / 25 # Division
#calculate rounding if modulus is zero or not zero and division are not even # #not calculate rounding if modulus is 0 and division is even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) # #calculate rounding if modulus is zero or not zero and division are not even
new_total = Sale.get_rounding_adjustment(saleObj.grand_total) # if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
rounding_adj = new_total-saleObj.grand_total # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) # rounding_adj = new_total-saleObj.grand_total
end # saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
end # end
end # end
# end rounding adjustment # end
# # end rounding adjustment
sale_payment = SalePayment.new sale_payment = SalePayment.new
sale_payment =sale_payment.process_payment(saleObj, current_user, cash, "cash") sale_payment = sale_payment.process_payment(saleObj, current_user, cash, "cash")
if sale_payment[0] if sale_payment[0]
@cash ={"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''} @cash = {"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''}
end end
@out = true,@cash @out = true,@cash
# if !path.include? ("credit_payment") # if !path.include? ("credit_payment")