Suite consultation fournisseurs

This commit is contained in:
Nicolas Bally 2021-09-08 22:23:06 +02:00
parent 455dc38ad8
commit 26e36e8c38
7 changed files with 138 additions and 75 deletions

View File

@ -611,27 +611,60 @@ class Admin::PriceDocumentsController < ApplicationController
def analyse_reponses def analyse_reponses
@price_document = PriceDocument.find(params[:id]) @price_document = PriceDocument.find(params[:id])
@price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id ) @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id )
end end
def generate_final_consult def generate_final_consult
# price_line_to_add ={id_fournisseur {price_line_resp_id: id, ||||| id priceline resp => id price line selectionné, prix} } # price_line_to_add ={id_fournisseur {price_line_resp_id: id, ||||| id priceline resp => id price line selectionné, prix} }
price_lines_to_add = {p_fournisseur_id: 0} price_lines_to_add = {}
@price_document_demand = PriceDocument.find(params[:id]) @price_document_demand = PriceDocument.find(params[:id])
@price_document_responses = PriceDocument.where(doc_ref_id: price_document_demand) #@price_document_responses = PriceDocument.where(doc_ref_id: price_document_demand)
@result = [] #@result = []
@price_document_demand.price_line_block.price_lines.each do |pl_demand| @price_document_demand.price_line_block.price_lines.each do |pl_demand|
pl_response = pl_demand.price_line_resps.first
@p_fournisseur = PFournisseur.find(pl_response)
@final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!)
@price_document = PriceDocument.new(:p_fournisseur_id => params[:p_fournisseur_id])
PriceDocument.new() pl_demand.price_line_resps.all.each do |price_line_resp|
@result << pl_demand
price_lines_to_add[price_line_resp.p_fournisseur.id] = price_lines_to_add[price_line_resp.p_fournisseur.id] || {:p_fournisseur => price_line_resp.p_fournisseur, :price_lines => [] }
price_lines_to_add[price_line_resp.p_fournisseur.id][:price_lines] << price_line_resp
end
end
price_lines_to_add.each do |k,v|
new_final_consult = PriceDocument.new(:doc_ref_id => @price_document_demand.id,:date => Date.today, :price_document_type => PriceDocumentType.find_by_label("Consultation fournisseur"))
new_final_consult.price_line_block = PriceLineBlock.new(:p_fournisseur => v[:p_fournisseur])
v[:price_lines].each do |price_line_resp|
new_final_consult.price_line_block.price_lines << PriceLine.new(:p_product_ref => price_line_resp.p_product_ref, :qte => price_line_resp.qte_available, :ct_u_price_ht => price_line_resp.price_u_ht )
end
new_final_consult.save
end
#pl_response = pl_demand.price_line_resps.first
#@p_fournisseur = PFournisseur.find(pl_response)
#@final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!)
#@price_document = PriceDocument.new(:p_fournisseur_id => params[:p_fournisseur_id])
#PriceDocument.new()
#@result << pl_demand
#end
render :consult_index render :consult_index

View File

@ -25,7 +25,7 @@ class PriceDocument < ApplicationRecord
has_many :avoir_p_payment_documents, :dependent => :destroy, :foreign_key => :avoir_id, :class_name => "PPaymentDocument" has_many :avoir_p_payment_documents, :dependent => :destroy, :foreign_key => :avoir_id, :class_name => "PPaymentDocument"
accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true
PURCHASES = ["Demande de prix", "Commande achat", "Facture d'achat"] PURCHASES = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"]
SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"]
# AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"] # AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] AVANCEMENT = ["0%", "25%", "50%", "75%", "100"]

View File

@ -7,6 +7,8 @@ class PriceLine < ApplicationRecord
has_many :price_line_resps, through: :price_line_resp_selects, :source => :price_line_resp has_many :price_line_resps, through: :price_line_resp_selects, :source => :price_line_resp
has_one :p_fournisseur, :through => :price_line_block
#has_many :price_line_demands, through: :price_line_resp_selects #has_many :price_line_demands, through: :price_line_resp_selects
default_scope { order('position ASC') } default_scope { order('position ASC') }

View File

@ -23,7 +23,7 @@ class PriceLineBlock < ApplicationRecord
belongs_to :p_payment_type belongs_to :p_payment_type
PURCHASE_BLOCKS = ["Facture d'achat", "Commande achat"] PURCHASE_BLOCKS = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"]
SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"]
belongs_to :p_fournisseur belongs_to :p_fournisseur

View File

@ -69,12 +69,15 @@
%td %td
- if price_document.avancement - if price_document.avancement
= price_document.avancement.to_s + " %" = price_document.avancement.to_s + " %"
- elsif parent_doc.avancement - elsif parent_doc and parent_doc.avancement
= parent_doc.avancement.to_s + " %" = parent_doc.avancement.to_s + " %"
-tr[:list_designaton] = capture do -tr[:list_designaton] = capture do
%td %td
= price_document.list_designaton || parent_doc.list_designaton -if price_document.list_designaton
= price_document.list_designaton
-elsif parent_doc
=parent_doc.list_designaton
-tr[:end_date] = capture do -tr[:end_date] = capture do
%td %td
@ -87,11 +90,17 @@
-tr[:dp_comment] = capture do -tr[:dp_comment] = capture do
%td %td
= price_document.dp_comment || parent_doc.dp_comment -if price_document.dp_comment
= price_document.dp_comment
-elsif parent_doc
=parent_doc.dp_comment
-tr[:acheteur_text] = capture do -tr[:acheteur_text] = capture do
%td %td
= price_document.acheteur_text || parent_doc.acheteur_text -if price_document.acheteur_text
= price_document.acheteur_text
-elsif parent_doc
=parent_doc.acheteur_text
-tr[:customer_ref] = capture do -tr[:customer_ref] = capture do
%td %td

View File

@ -197,8 +197,8 @@
-#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id -#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id
-if line.price_line_ref_id.to_s != "" -if line.price_line_ref_id.to_s != ""
%input.category-selector{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ %input.category-selectornico{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/
%label.p-2.m-auto{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} %label.p-2.m-autonico{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"}
=sanitize(cell.join('<br>')) =sanitize(cell.join('<br>'))

View File

@ -25,16 +25,18 @@
=@price_document.d_number =@price_document.d_number
-if @price_document.label == "Réponse fournisseur"
.qi_row .qi_row
.qi_pannel.padding
%table.table.table-striped %table.table.table-striped
-if @price_document.label == "Réponse fournisseur"
%tr %tr
%td %td
Nom fournisseur saisi Nom fournisseur saisi
%td %td
=@price_document.public_fournisseur_name =@price_document.public_fournisseur_name
-if @price_document.p_fournisseur
%tr %tr
%td %td
Fournisseur Fournisseur
@ -43,11 +45,8 @@
-if @price_document.label == "Demande prix"
.qi_row
.qi_pannel.padding
%table.table.table-striped -if @price_document.label == "Demande prix"
%tr %tr
%td %td
Avancement (%) Avancement (%)
@ -90,12 +89,12 @@
-if false -if true
-price_line_block = @price_document.price_line_block -price_line_block = @price_document.price_line_block
=render price_line_block =#render price_line_block
-else -else
-params[:search][:per_page] = params[:search][:per_page] || 5000 -params[:search][:per_page] = params[:search][:per_page] || 5000
@ -321,14 +320,34 @@
-if @price_document.label == "Demande prix" -if @price_document.label == "Demande prix"
%h3 Réponses fournisseur %h3 Réponses fournisseur
#bills #bills
-params[:search][:per_page] = params[:search][:per_page] || 5000 -params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page] -per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1 -page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id ) -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id)
-@price_documents = sort_by_sorting(@price_documents, "created_at DESC")
-@price_documents = @price_documents.page(page).per(per_page)
%br
.clear
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"}
%h3 Consultations fournisseur
#bills
-params[:search][:per_page] = params[:search][:per_page] || 5000
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id)