demade de prix
This commit is contained in:
parent
fa354b1366
commit
e9e0f009a6
@ -235,11 +235,17 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
@price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id])
|
@price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id])
|
||||||
|
|
||||||
if @price_document.price_document_type.label == "Demande prix"
|
if @price_document.price_document_type.label == "Demande prix"
|
||||||
@ref_price_lines = PriceLine.where(:id => params[:price_line_ids])
|
p_product_ref_id = params[:qte].keys
|
||||||
|
p_product_ref_qte = params[:qte].values
|
||||||
@ref_price_lines.group(:p_product_ref_id).each do |plr|
|
|
||||||
@price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte))
|
p_product_ref_id.each_with_index do |key, i|
|
||||||
|
@price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => key, :qte => p_product_ref_qte[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @ref_price_lines = PriceLine.where(:id => params[:price_line_ids])
|
||||||
|
# @ref_price_lines.group(:p_product_ref_id).each do |plr|
|
||||||
|
# @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte))
|
||||||
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ class PriceDocument < ApplicationRecord
|
|||||||
|
|
||||||
PURCHASES = ["Demande prix", "Commande achat", "Facture d'achat"]
|
PURCHASES = ["Demande prix", "Commande achat", "Facture d'achat"]
|
||||||
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%", "25%", "50%", "75%", "100"]
|
||||||
|
|
||||||
validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed?
|
validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed?
|
||||||
|
|
||||||
@ -291,7 +293,7 @@ class PriceDocument < ApplicationRecord
|
|||||||
:cc_cost_ht => {:name => "Coût HT", :reorder => true, :as => :currency},
|
:cc_cost_ht => {:name => "Coût HT", :reorder => true, :as => :currency},
|
||||||
:cc_marge_ht => {:name => "Marge HT", :reorder => true, :as => :currency},
|
:cc_marge_ht => {:name => "Marge HT", :reorder => true, :as => :currency},
|
||||||
:cost_ok => {:name => "Marge calculée", :reorder => true, :as => :boolean},
|
:cost_ok => {:name => "Marge calculée", :reorder => true, :as => :boolean},
|
||||||
|
:f_token => {:name => "Liens consultation"},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -597,7 +597,12 @@ class PriceLine < ApplicationRecord
|
|||||||
AVOIR_TO_RESET = %w(block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id)
|
AVOIR_TO_RESET = %w(block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id)
|
||||||
|
|
||||||
|
|
||||||
|
def self.asap_triage(limit)
|
||||||
|
total = self.sum(:qte).to_i
|
||||||
|
asap = self.where('cc_wish_date > ?', Date.today + limit).sum(:qte).to_i
|
||||||
|
non_asap = total - asap
|
||||||
|
return [asap, non_asap]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,14 +24,23 @@
|
|||||||
= @price_document.price_line_block.block_type
|
= @price_document.price_line_block.block_type
|
||||||
|
|
||||||
-if @price_document.label == "Demande prix"
|
-if @price_document.label == "Demande prix"
|
||||||
=f.input :avancement, :label => "Avancement (%) :"
|
.row
|
||||||
=f.input :list_designaton, :label => "Désignation de la liste :"
|
.col-4
|
||||||
=f.input :end_date, :label => "Fin de consultation :", :as => :date
|
.row
|
||||||
=f.input :dp_comment, :label => "Commentaire demande de prix :"
|
.col
|
||||||
=f.input :acheteur_text, :label => "Envoyé à :"
|
=f.input :end_date, :label => "Fin de consultation :", :as => :date
|
||||||
|
.col
|
||||||
|
=f.input :avancement, :label => "Avancement (%) :", as: :select, collection: PriceDocument::AVANCEMENT, selected: PriceDocument::AVANCEMENT.first
|
||||||
|
=f.input :list_designaton, as: :string, :label => "Désignation de la liste :"
|
||||||
|
.col
|
||||||
|
=f.input :acheteur_text, :label => "Envoyé à :", input_html: {rows: 5}
|
||||||
|
.col
|
||||||
|
=f.input :dp_comment, :label => "Commentaire demande de prix :", input_html: {rows: 5}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 7
|
-if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 7
|
||||||
= f.input :date, :label => "Date du document :", :as => :date
|
= f.input :date, :label => "Date du document :", :as => :date
|
||||||
.price_line_block_form
|
.price_line_block_form
|
||||||
@ -50,4 +59,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,8 +50,15 @@
|
|||||||
-if price_document.label == "Avoir"
|
-if price_document.label == "Avoir"
|
||||||
=number_to_currency price_document.cc_to_paid_ttc
|
=number_to_currency price_document.cc_to_paid_ttc
|
||||||
|
|
||||||
|
-tr[:f_token] = capture do
|
||||||
|
%td
|
||||||
|
= consult_admin_price_document_url(:id => price_document.f_token, :lang => nil)
|
||||||
|
|
||||||
|
-tr[:avancement] = capture do
|
||||||
|
%td
|
||||||
|
- if price_document.avancement
|
||||||
|
= price_document.avancement.to_s + " %"
|
||||||
|
|
||||||
|
|
||||||
-tr[:stock_ok] = capture do
|
-tr[:stock_ok] = capture do
|
||||||
%td
|
%td
|
||||||
@ -147,4 +154,4 @@
|
|||||||
|
|
||||||
|
|
||||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_document}
|
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_document}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
-else
|
-else
|
||||||
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes"
|
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes"
|
||||||
%h1
|
%h1
|
||||||
Documents comptables
|
Documents
|
||||||
%span
|
%span
|
||||||
Liste
|
Liste
|
||||||
|
|
||||||
@ -33,50 +33,50 @@
|
|||||||
|
|
||||||
|
|
||||||
%table.qi_search_row_top
|
%table.qi_search_row_top
|
||||||
%tr
|
%tr.form-inline
|
||||||
%td
|
%td
|
||||||
Début
|
Début
|
||||||
%td
|
%td.input-group
|
||||||
.input-group
|
=text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début"
|
||||||
=text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début"
|
.input-group-append
|
||||||
%span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
|
%span.input-group-text{:onclick => "$(this).prev('input').val('');"}
|
||||||
=ic(:times)
|
=ic(:times)
|
||||||
|
%td.pl-4
|
||||||
%br
|
|
||||||
-if @start and @stop
|
|
||||||
|
|
||||||
=link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-default"
|
|
||||||
|
|
||||||
|
|
||||||
%td
|
|
||||||
Fin
|
Fin
|
||||||
%td
|
%td.input-group
|
||||||
.input-group
|
=text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin"
|
||||||
=text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin"
|
.input-group-append
|
||||||
%span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
|
%span.input-group-text{:onclick => "$(this).prev('input').val('');"}
|
||||||
=ic(:times)
|
=ic(:times)
|
||||||
%br
|
|
||||||
|
%tr.form-inline
|
||||||
|
%td.right.ml-auto
|
||||||
-if @start and @stop
|
-if @start and @stop
|
||||||
=link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-default"
|
|
||||||
|
=link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary"
|
||||||
|
%td.mr-auto
|
||||||
|
-if @start and @stop
|
||||||
|
=link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary"
|
||||||
|
|
||||||
|
|
||||||
-params[:price_document_type_ids] = params[:price_document_type_ids] || []
|
-params[:price_document_type_ids] = params[:price_document_type_ids] || []
|
||||||
|
%tr.form-inline
|
||||||
%td
|
%td
|
||||||
Type de document :
|
Type de document :
|
||||||
%td
|
%td
|
||||||
|
|
||||||
-if [6,7].include?(params[:price_document_type_id].to_i)or (params[:price_document_type_ids] and (params[:price_document_type_ids].include?("6") or params[:price_document_type_ids].include?("7")))
|
-if [1,2,6,7].include?(params[:price_document_type_id].to_i)or (params[:price_document_type_ids] and (params[:price_document_type_ids].include?("6") or params[:price_document_type_ids].include?("7")))
|
||||||
-PriceDocumentType.where(:label => PriceDocument::PURCHASES, :enabled => true).order("id DESC").each do |pdt|
|
-PriceDocumentType.where(:label => PriceDocument::PURCHASES, :enabled => true).order("id DESC").each do |pdt|
|
||||||
%p
|
%p.d-inline-flex.ml-3
|
||||||
= check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}"}
|
= check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}", class: "my-auto"}
|
||||||
= label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label
|
= label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label, class: "ml-3 my-auto"
|
||||||
|
|
||||||
-else
|
-else
|
||||||
-PriceDocumentType.where(:label => PriceDocument::SALES, :enabled => true).order("id DESC").each do |pdt|
|
-PriceDocumentType.where(:label => PriceDocument::SALES, :enabled => true).order("id DESC").each do |pdt|
|
||||||
%p
|
%p.d-inline-flex
|
||||||
= check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}"}
|
= check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}"}
|
||||||
= label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label
|
= label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label, class: "ml-3"
|
||||||
|
%br
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
@ -95,18 +95,19 @@
|
|||||||
Commercial :
|
Commercial :
|
||||||
=select_tag "search[p_commercial_id]", options_for_select([["",""],["Aucun","null"]]+PCommercial.order(:name).all.map{|a| [a.member_label, a.id]}, params[:search][:p_commercial_id])
|
=select_tag "search[p_commercial_id]", options_for_select([["",""],["Aucun","null"]]+PCommercial.order(:name).all.map{|a| [a.member_label, a.id]}, params[:search][:p_commercial_id])
|
||||||
|
|
||||||
%td
|
-if [6].include?(params[:price_document_type_id].to_i)
|
||||||
Type de paiement :
|
%td
|
||||||
=select_tag "search[p_payment_type_id]", options_for_select([["",""]]+PPaymentType.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_payment_type_id])
|
Type de paiement :
|
||||||
|
=select_tag "search[p_payment_type_id]", options_for_select([["",""]]+PPaymentType.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_payment_type_id])
|
||||||
|
|
||||||
|
|
||||||
%td
|
%td
|
||||||
Soldé ?
|
Soldé ?
|
||||||
=select_tag "search[cc_solded]", options_for_select([[""], "Oui", "Non"], params[:search][:cc_solded])
|
=select_tag "search[cc_solded]", options_for_select([[""], "Oui", "Non"], params[:search][:cc_solded])
|
||||||
|
|
||||||
%td
|
%td
|
||||||
Importé ?
|
Importé ?
|
||||||
=select_tag "search[imported]", options_for_select([[""], "Oui", "Non"], params[:search][:imported])
|
=select_tag "search[imported]", options_for_select([[""], "Oui", "Non"], params[:search][:imported])
|
||||||
|
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
@ -155,4 +156,4 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
|
|
||||||
%h1
|
%h1
|
||||||
Documents comptables
|
Documents
|
||||||
%span
|
%span
|
||||||
Ajouter un document
|
Ajouter un document
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row=render :partial => "form"
|
.qi_row=render :partial => "form"
|
||||||
|
Reference in New Issue
Block a user