From edf213d6d621a4a00d5882cc7525b9fcfccc6168 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 10 Aug 2017 14:49:00 +0630 Subject: [PATCH] fix for tax inclusive --- app/controllers/crm/customers_controller.rb | 6 ++++-- app/models/sale.rb | 10 ++++------ app/views/reports/void_sale/index.html.erb | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index fe490abb..ffa714a2 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -196,10 +196,12 @@ end # PATCH/PUT /crm/customers/1 # PATCH/PUT /crm/customers/1.json def update - + # Remove "" default first + params[:customer][:tax_profiles].delete_at(0) respond_to do |format| if @crm_customer.update(customer_params) - + # update tax profile + @crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles]) name = customer_params[:name] phone = customer_params[:contact_no] email = customer_params[:email] diff --git a/app/models/sale.rb b/app/models/sale.rb index b252fdf1..56f52b74 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -290,14 +290,13 @@ class Sale < ApplicationRecord sale_tax.tax_payable_amount = total_tax / 21 else sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount end #new taxable amount is standard rule for step by step # total_taxable = total_taxable + sale_tax.tax_payable_amount sale_tax.inclusive = tax.inclusive - sale_tax.save - - total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + sale_tax.save end end end @@ -334,15 +333,14 @@ class Sale < ApplicationRecord sale_tax.tax_payable_amount = total_tax / 21 else sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount end #new taxable amount is standard rule for step by step # total_taxable = total_taxable + sale_tax.tax_payable_amount sale_tax.inclusive = tax.inclusive - sale_tax.save - - total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + sale_tax.save end end end diff --git a/app/views/reports/void_sale/index.html.erb b/app/views/reports/void_sale/index.html.erb index e85a0974..53f8ff46 100644 --- a/app/views/reports/void_sale/index.html.erb +++ b/app/views/reports/void_sale/index.html.erb @@ -1,7 +1,7 @@