change tax profile structure

This commit is contained in:
phyusin
2018-07-25 17:19:00 +06:30
parent 2be9ff0613
commit 94a65a749f
6 changed files with 85 additions and 69 deletions

View File

@@ -76,9 +76,15 @@ class Settings::TaxProfilesController < ApplicationController
# DELETE /settings/tax_profiles/1
# DELETE /settings/tax_profiles/1.json
def destroy
@settings_tax_profile.destroy
flash[:notice] = 'Tax profile was successfully destroyed.'
render :json => {:status=> "Success", :url => settings_tax_profiles_url }.to_json
customers = Customer.where("tax_profiles LIKE '%#{@settings_tax_profile.id}%'")
if customers.nil? || customers.empty?
@settings_tax_profile.destroy
flash[:notice] = 'Tax profile was successfully destroyed.'
render :json => {:status=> "Success", :url => settings_tax_profiles_url }.to_json
else
flash[:error] = 'Tax profile could not destroy! This record is using in somewhere.'
render :json => {:status=> "Error", :url => settings_tax_profiles_url }.to_json
end
# respond_to do |format|
# format.html { redirect_to settings_tax_profiles_url, notice: 'Tax profile was successfully destroyed.' }
# format.json { head :no_content }