diff --git a/app/views/api/orders/view_orders.json.jbuilder b/app/views/api/orders/view_orders.json.jbuilder index 8bfb3b65..ce8eac1d 100755 --- a/app/views/api/orders/view_orders.json.jbuilder +++ b/app/views/api/orders/view_orders.json.jbuilder @@ -88,26 +88,44 @@ if (@booking) #total tax calculation @total_tax_amount = 0 + @service_rate = 0 + @commercial_rate = 0 + @service_charges = 0.00 + @commercial_tax = 0.00 @total_taxable = @total_amount if !@tax_profile.nil? @tax_profile.each do |tax| - # total_tax_amount = 0 + 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 + if tax.name.strip.downcase.include? ("service") + @service_rate = tax.rate.to_i + @service_charges = total_tax_amount + else + @commercial_rate = tax.rate.to_i + @commercial_tax = total_tax_amount + end end + @total_tax_amount = @service_charges + @commercial_tax end #total tax calculation json.sub_total @total_amount - json.total_tax @total_tax_amount + if @service_rate.to_i > 0 + json.service_rate @service_rate + json.service_charges @service_charges + end + if @commercial_rate.to_i > 0 + json.commercial_rate @commercial_rate + json.commercial_tax @commercial_tax + end json.total @total_amount + @total_tax_amount else json.success false