tax calculation for view order api
This commit is contained in:
@@ -36,6 +36,17 @@ class Api::OrdersController < Api::ApiController
|
|||||||
table = DiningFacility.find(table_id)
|
table = DiningFacility.find(table_id)
|
||||||
@booking = table.get_booking
|
@booking = table.get_booking
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@tax_profile = nil
|
||||||
|
# arr_tax = []
|
||||||
|
|
||||||
|
# if !arr_tax.empty?
|
||||||
|
# @tax_profile = TaxProfile.where(:id => arr_tax)
|
||||||
|
# else
|
||||||
|
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||||
|
# end
|
||||||
|
|
||||||
|
@shop = Shop.first
|
||||||
end
|
end
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
|||||||
@@ -86,9 +86,29 @@ if (@booking)
|
|||||||
# end
|
# end
|
||||||
# End YGN BBQ
|
# End YGN BBQ
|
||||||
|
|
||||||
|
#total tax calculation
|
||||||
|
@total_tax_amount = 0
|
||||||
|
@total_taxable = @total_amount
|
||||||
|
if !@tax_profile.nil?
|
||||||
|
@tax_profile.each do |tax|
|
||||||
|
# total_tax_amount = 0
|
||||||
|
if tax.inclusive
|
||||||
|
total_tax_amount = (@total_taxable / ((100 + tax.rate)/ tax.rate))
|
||||||
|
else
|
||||||
|
total_tax_amount = (@total_taxable * tax.rate / 100)
|
||||||
|
end
|
||||||
|
if @shop.calc_tax_order
|
||||||
|
@total_taxable = @total_taxable + total_tax_amount
|
||||||
|
end
|
||||||
|
|
||||||
|
@total_tax_amount += total_tax_amount
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#total tax calculation
|
||||||
json.sub_total @total_amount
|
json.sub_total @total_amount
|
||||||
json.commerical_tax @total_amount * 0.05
|
json.total_tax @total_tax_amount
|
||||||
json.total @total_amount + (@total_amount * 0.05)
|
json.total @total_amount + @total_tax_amount
|
||||||
else
|
else
|
||||||
json.success false
|
json.success false
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user