demade de prix

This commit is contained in:
Barnabé 2021-08-31 19:12:25 +02:00
parent fa354b1366
commit e9e0f009a6
7 changed files with 89 additions and 59 deletions

View File

@ -235,12 +235,18 @@ 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])
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
# @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

View File

@ -27,6 +27,8 @@ class PriceDocument < ApplicationRecord
PURCHASES = ["Demande prix", "Commande achat", "Facture d'achat"]
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?
@ -291,7 +293,7 @@ class PriceDocument < ApplicationRecord
:cc_cost_ht => {:name => "Coût 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},
:f_token => {:name => "Liens consultation"},

View File

@ -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)
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

View File

@ -24,11 +24,20 @@
= @price_document.price_line_block.block_type
-if @price_document.label == "Demande prix"
=f.input :avancement, :label => "Avancement (%) :"
=f.input :list_designaton, :label => "Désignation de la liste :"
.row
.col-4
.row
.col
=f.input :end_date, :label => "Fin de consultation :", :as => :date
=f.input :dp_comment, :label => "Commentaire demande de prix :"
=f.input :acheteur_text, :label => "Envoyé à :"
.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}

View File

@ -50,7 +50,14 @@
-if price_document.label == "Avoir"
=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

View File

@ -13,7 +13,7 @@
-else
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes"
%h1
Documents comptables
Documents
%span
Liste
@ -33,50 +33,50 @@
%table.qi_search_row_top
%tr
%tr.form-inline
%td
Début
%td
.input-group
%td.input-group
=text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début"
%span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
.input-group-append
%span.input-group-text{:onclick => "$(this).prev('input').val('');"}
=ic(:times)
%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
%td.pl-4
Fin
%td
.input-group
%td.input-group
=text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin"
%span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
.input-group-append
%span.input-group-text{:onclick => "$(this).prev('input').val('');"}
=ic(:times)
%br
%tr.form-inline
%td.right.ml-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-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] || []
%tr.form-inline
%td
Type de document :
%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|
%p
= 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
%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}", class: "my-auto"}
= label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label, class: "ml-3 my-auto"
-else
-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}"}
= 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
%tr
%td
@ -95,6 +95,7 @@
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])
-if [6].include?(params[:price_document_type_id].to_i)
%td
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])

View File

@ -1,7 +1,7 @@
.qi_header
%h1
Documents comptables
Documents
%span
Ajouter un document