diff --git a/app/models/sale.rb b/app/models/sale.rb index 1edd835e..3714c21e 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -23,6 +23,8 @@ class Sale < ApplicationRecord if (booking) Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s #get all order attached to this booking and combine into 1 invoice + + puts booking.booking_orders.length booking.booking_orders.each do |order| if booking.sale_id status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) @@ -195,28 +197,28 @@ class Sale < ApplicationRecord existing_tax.delete end - # total_tax_amount = 0 - # #tax_profile - list by order_by - # tax_profiles = TaxProfile.all.order("order_by asc") + total_tax_amount = 0 + #tax_profile - list by order_by + tax_profiles = TaxProfile.all.order("order_by asc") # #Creat new tax records - # tax_profiles.each do |tax| - # sale_tax = SaleTax.new(:sale => self) - # sale_tax.tax_name = tax.name - # sale_tax.tax_rate = tax.rate - # #include or execulive - # # sale_tax.tax_payable_amount = total_taxable * tax.rate - # sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 - # #new taxable amount - # total_taxable = total_taxable + sale_tax.tax_payable_amount + tax_profiles.each do |tax| + sale_tax = SaleTax.new(:sale => self) + sale_tax.tax_name = tax.name + sale_tax.tax_rate = tax.rate + #include or execulive + # sale_tax.tax_payable_amount = total_taxable * tax.rate + sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 + #new taxable amount + total_taxable = total_taxable + sale_tax.tax_payable_amount - # sale_tax.inclusive = tax.inclusive - # sale_tax.save + sale_tax.inclusive = tax.inclusive + sale_tax.save - # total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount - # end + total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + end - # self.total_tax = total_tax_amount + self.total_tax = total_tax_amount end