update rounding adj

This commit is contained in:
Aung Myo
2017-11-30 12:05:01 +06:30
parent 7ce71a1960
commit 6cb7c1e0c4
3 changed files with 32 additions and 17 deletions

View File

@@ -54,6 +54,15 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop.find(1)
if shop_details.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)
#end rounding adjment
end
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
@@ -75,9 +84,7 @@ class Origami::PaymentsController < BaseOrigamiController
# For Print
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
#shop detail
shop_details = Shop.find(1)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
@@ -114,6 +121,14 @@ class Origami::PaymentsController < BaseOrigamiController
@accountable_type = ''
@table_no = ''
@shop = Shop.find_by_id(1)
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
else
new_total = @sale_data.grand_total
end
@rounding_adj = new_total-@sale_data.grand_total
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
accounts = @customer.tax_profiles
@@ -127,7 +142,6 @@ class Origami::PaymentsController < BaseOrigamiController
# get member information
if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer)
puts response.to_json
if response["status"]==true
response["account_data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"