diff --git a/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c b/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c new file mode 100644 index 0000000..e13aa03 Binary files /dev/null and b/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c differ diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index f99ea9f..5729f1c 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -174,12 +174,14 @@ class Admin::PCustomerSheetsController < ApplicationController @p_customer_sheet.admin = current_admin - @p_customer = @p_customer_sheet.p_customer + if @p_customer_sheet.save - @p_customer_sheets = PCustomerSheet.order(:id).all + redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else + @p_customer = @p_customer_sheet.price_line_block.p_customer + render action: "new" end @@ -189,13 +191,14 @@ class Admin::PCustomerSheetsController < ApplicationController def update @p_customer_sheet = PCustomerSheet.find(params[:id]) - @p_customer = @p_customer_sheet.p_customer + if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) - @p_customer_sheets = PCustomerSheet.order(:id).all - + @p_customer = @p_customer_sheet.price_line_block.p_customer + + redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else render action: "edit" diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index c72e779..5648846 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -138,27 +138,29 @@ class Admin::PProductRefsController < ApplicationController def get_infos + @p_product_ref = PProductRef.find(params[:id]) if params[:type] == "price" price = @p_product_ref.get_price(:p_customer_id => params[:p_customer_id], :qte => params[:qte]) - puts params[:p_fournisseur_id] - + + if params[:p_customer_id].to_s != "" p_customer = PCustomer.find(params[:p_customer_id]) accounting_zone_id = p_customer.accounting_zone_id + if p_customer.tva_rate tva_account_id = p_customer.tva_rate.id tva_account_value = p_customer.tva_rate.rate - + else tva_account_id = @p_product_ref.p_product.tva_rate(accounting_zone_id).id if @p_product_ref.p_product.tva_rate(accounting_zone_id) tva_account_value = @p_product_ref.p_product.tva_rate(accounting_zone_id).rate if @p_product_ref.p_product.tva_rate(accounting_zone_id) - - + + end - + elsif params[:p_fournisseur_id].to_s != "" p_fournisseur = PFournisseur.find(params[:p_fournisseur_id]) accounting_zone_id = p_fournisseur.accounting_zone_id diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 3fd7005..e1ee85d 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -192,6 +192,15 @@ class PCustomer < ApplicationRecord end + def tva_rate + if tva = TvaRate.where(:accounting_zone_id => self.accounting_zone_id).first + return tva + else + return nil + end + end + + def update_caches diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 9920ecb..67bd84d 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -118,7 +118,7 @@ -else %label Taux de TVA : %br - =select_tag :tva_account_id, options_from_collection_for_select(TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, "id", "member_label", form.object.tva_account_id), :class => "input_price_line_tva_account_id", :disabled => true + =select_tag :tva_account_id, options_from_collection_for_select(TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, "id", "member_label", form.object.tva_account_id), :class => "input_price_line_tva_account_id" #, :disabled => true