Wip bon de reception achat
This commit is contained in:
parent
5f7b79139c
commit
04d2bbd60a
@ -662,7 +662,7 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
price_line_block = PriceLineBlock.new(p_fournisseur: @final_consult.price_line_block.p_fournisseur)
|
price_line_block = PriceLineBlock.new(p_fournisseur: @final_consult.price_line_block.p_fournisseur)
|
||||||
price_lines = PriceLine.where(price_line_block: @final_consult.price_line_block)
|
price_lines = PriceLine.where(price_line_block: @final_consult.price_line_block)
|
||||||
|
|
||||||
@price_document = PriceDocument.new(date: Date.today, price_line_block: price_line_block, doc_ref_id: @final_consult.id, :price_document_type => PriceDocumentType.find_by_label("Commande achat"))
|
@price_document = PriceDocument.new(date: Date.today, price_line_block: price_line_block, doc_ref_id: @final_consult.id, demande_de_prix_id: @final_consult.id ,:price_document_type => PriceDocumentType.find_by_label("Commande achat"))
|
||||||
price_lines.each do |pl|
|
price_lines.each do |pl|
|
||||||
@price_document.price_line_block.price_lines << PriceLine.new(p_product_ref: pl.p_product_ref, qte: pl.qte, ct_u_price_ht: pl.price_u_ht)
|
@price_document.price_line_block.price_lines << PriceLine.new(p_product_ref: pl.p_product_ref, qte: pl.qte, ct_u_price_ht: pl.price_u_ht)
|
||||||
end
|
end
|
||||||
@ -671,6 +671,7 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def bon_de_reception
|
def bon_de_reception
|
||||||
@past_price_document = PriceDocument.find(params[:id])
|
@past_price_document = PriceDocument.find(params[:id])
|
||||||
|
|
||||||
@ -678,31 +679,22 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
|
|
||||||
if @p_customer_sheet
|
if @p_customer_sheet
|
||||||
price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today)
|
price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today)
|
||||||
|
|
||||||
else
|
else
|
||||||
price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :date => Date.today)
|
price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :date => Date.today)
|
||||||
end
|
end
|
||||||
|
|
||||||
price_document.doc_ref_id = @past_price_document.id
|
price_document.doc_ref_id = @past_price_document.id
|
||||||
|
|
||||||
price_document.p_fournisseur = @past_price_document.p_fournisseur
|
price_document.p_fournisseur = @past_price_document.p_fournisseur
|
||||||
|
|
||||||
|
|
||||||
price_document.price_line_block = @past_price_document.price_line_block.dup
|
price_document.price_line_block = @past_price_document.price_line_block.dup
|
||||||
|
|
||||||
if @past_price_document.cc_label == "Commande achat"
|
if @past_price_document.cc_label == "Commande achat"
|
||||||
price_document.bon_de_commande_achat_id = @past_price_document.id
|
price_document.bon_de_commande_achat_id = @past_price_document.id
|
||||||
price_document.reliquat = true if PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type_id => [5]).count > 0
|
price_document.reliquat = true if PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat")).count > 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if @past_price_document.cc_label == "Facture achat"
|
if @past_price_document.cc_label == "Facture achat"
|
||||||
price_document.facture_achat_id = @past_price_document.id
|
price_document.facture_achat_id = @past_price_document.id
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -719,9 +711,9 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
new_pl = pl.dup
|
new_pl = pl.dup
|
||||||
new_pl.price_line_ref_id = pl.id
|
new_pl.price_line_ref_id = pl.id
|
||||||
new_pl.ac_block_type = nil
|
new_pl.ac_block_type = nil
|
||||||
|
raise
|
||||||
if price_document.reliquat and @p_customer_sheet
|
if price_document.reliquat and @p_customer_sheet
|
||||||
bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type_id => [5])
|
bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"))
|
||||||
|
|
||||||
qte_ok = PriceLine.where(:price_line_ref_id => new_pl.price_line_ref_id).where(:price_line_block_id => PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bls.ids)).sum(:qte)
|
qte_ok = PriceLine.where(:price_line_ref_id => new_pl.price_line_ref_id).where(:price_line_block_id => PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bls.ids)).sum(:qte)
|
||||||
|
|
||||||
@ -744,8 +736,6 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
else
|
else
|
||||||
redirect_to [:admin, price_document]
|
redirect_to [:admin, price_document]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
render :inline => price_document.errors.messages.to_s
|
render :inline => price_document.errors.messages.to_s
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,8 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
|
|
||||||
belongs_to :p_payment_type
|
belongs_to :p_payment_type
|
||||||
|
|
||||||
PURCHASE_BLOCKS = [ "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"]
|
PURCHASE_BLOCKS = ["Réponse fournisseur", "Consultation fournisseur", "Facture d'achat", "Commande achat", "Demande de prix", "Bon de commande achat", "Bon de réception achat", "Facture achat", "Avoir achat"]
|
||||||
|
|
||||||
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
|
||||||
@ -261,7 +262,9 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def wish_date_needed?
|
def wish_date_needed?
|
||||||
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Réponse fournisseur"
|
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type)
|
||||||
|
false
|
||||||
|
elsif self.block_type == "Devis"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
@ -270,7 +273,9 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
|
|
||||||
def particular_bill_needed?
|
def particular_bill_needed?
|
||||||
if !self.imported
|
if !self.imported
|
||||||
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur"
|
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type)
|
||||||
|
false
|
||||||
|
elsif self.block_type == "Devis"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
@ -280,7 +285,9 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
|
|
||||||
def particular_send_needed?
|
def particular_send_needed?
|
||||||
if !self.imported
|
if !self.imported
|
||||||
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur"
|
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type)
|
||||||
|
false
|
||||||
|
elsif self.block_type == "Devis"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
@ -297,9 +304,11 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def p_customer_needed?
|
def p_customer_needed?
|
||||||
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur"
|
if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type)
|
||||||
false
|
false
|
||||||
elsif !self.imported
|
elsif self.block_type == "Devis"
|
||||||
|
false
|
||||||
|
else
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
62
app/views/admin/price_documents/_relicats.html.haml
Normal file
62
app/views/admin/price_documents/_relicats.html.haml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
#bills
|
||||||
|
|
||||||
|
.qi_tab_header
|
||||||
|
%h3 Bons de réception associés
|
||||||
|
.right
|
||||||
|
|
||||||
|
|
||||||
|
-params[:search][:per_page] = params[:search][:per_page] || 50
|
||||||
|
-per_page = params[:search][:per_page]
|
||||||
|
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||||
|
|
||||||
|
-@price_documents = PriceDocument.where(:bon_de_commande_achat_id => bca.id, :price_document_type_id => [5]).order("date DESC, created_at DESC")
|
||||||
|
|
||||||
|
-@price_documents = sort_by_sorting(@price_documents, "created_at DESC")
|
||||||
|
-@all_price_documents = @price_documents
|
||||||
|
-@price_documents = @price_documents.page(page).per(per_page)
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "projet-factures"}
|
||||||
|
|
||||||
|
|
||||||
|
%h3 Etat des réceptions par articles
|
||||||
|
|
||||||
|
- bca_price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bca.id)
|
||||||
|
|
||||||
|
- bra_price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => @all_price_documents.ids)
|
||||||
|
|
||||||
|
%table.table.table-striped.table-hover.table-bordered.data_table
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
Code produit
|
||||||
|
%th
|
||||||
|
Produit
|
||||||
|
%th Quantité commandée
|
||||||
|
|
||||||
|
%th Quantité réceptionnée
|
||||||
|
|
||||||
|
%th Différence
|
||||||
|
%tbody
|
||||||
|
- PriceLine.where(:price_line_block_id => (bca_price_line_blocks.ids + bra_price_line_blocks.ids)).map {|pl| pl.p_product_ref_id}.uniq.each do |p_product_ref_id|
|
||||||
|
-if p_product_ref = PProductRef.where(:id => p_product_ref_id).first
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
=link_to [:admin, p_product_ref] do
|
||||||
|
=p_product_ref.ref
|
||||||
|
%td
|
||||||
|
=link_to [:admin, p_product_ref] do
|
||||||
|
=p_product_ref.cc_name
|
||||||
|
|
||||||
|
%td
|
||||||
|
=a = PriceLine.where(:p_product_ref_id => p_product_ref_id, :price_line_block_id => bca_price_line_blocks).sum(:qte)
|
||||||
|
|
||||||
|
|
||||||
|
%td
|
||||||
|
=b = PriceLine.where(:p_product_ref_id => p_product_ref_id, :price_line_block_id => bra_price_line_blocks).sum(:qte)
|
||||||
|
|
||||||
|
%td
|
||||||
|
= a -b
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -255,7 +255,8 @@
|
|||||||
-if @price_document.d_number
|
-if @price_document.d_number
|
||||||
-if @price_document.cc_label == "Commande achat"
|
-if @price_document.cc_label == "Commande achat"
|
||||||
%p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary"
|
%p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary"
|
||||||
|
-if @price_document.cc_label == "Commande achat"
|
||||||
|
=render :partial => "admin/price_documents/relicats", :locals => {:bca => @price_document}
|
||||||
-if false
|
-if false
|
||||||
|
|
||||||
-if @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 and !@price_document.cost_ok
|
-if @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 and !@price_document.cost_ok
|
||||||
@ -380,7 +381,13 @@
|
|||||||
= semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form|
|
= semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form|
|
||||||
= form.button "Valider modifications)", type: :submit, class: "btn btn-primary m-2"
|
= form.button "Valider modifications)", type: :submit, class: "btn btn-primary m-2"
|
||||||
= link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)'
|
= link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)'
|
||||||
= link_to "Generer la commande", buy_order_create_admin_price_document_path(price_document_consult)
|
- existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id)
|
||||||
|
- if existing_order.present?
|
||||||
|
= link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary"
|
||||||
|
- else
|
||||||
|
= link_to "Generer la commande", buy_order_create_admin_price_document_path(price_document_consult), class: "btn btn-primary"
|
||||||
|
|
||||||
|
|
||||||
.price-lines{"data-document" => price_document_consult.id}
|
.price-lines{"data-document" => price_document_consult.id}
|
||||||
=form.semantic_fields_for :price_line_block do |f|
|
=form.semantic_fields_for :price_line_block do |f|
|
||||||
.mx-2
|
.mx-2
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
=f.inputs do
|
||||||
|
|
||||||
|
|
||||||
|
-if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande")
|
||||||
|
.qi_pannel.qi_plain.padding{:style => "margin:20px 0;"}
|
||||||
|
|
||||||
|
%table{:style => "width:100%;"}
|
||||||
|
%tr
|
||||||
|
%td{:style => "width:50%;"}
|
||||||
|
= f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date
|
||||||
|
|
||||||
|
|
||||||
|
-if @price_document.label != "Demande prix"
|
||||||
|
= f.input :customer_ref, :label => "Référence commande client :"
|
||||||
|
-if current_admin.has_permission?("customer-sheets-bl")
|
||||||
|
= f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"}
|
||||||
|
|
||||||
|
|
||||||
|
.price_lines_form
|
||||||
|
=f.semantic_fields_for :price_lines do |f|
|
||||||
|
=render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f}
|
||||||
|
|
||||||
|
%p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {slug: f.object.block_type_slug , :class => "btn btn-primary", tabindex: 2}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
|
||||||
|
- price_line = form.object
|
||||||
|
.row
|
||||||
|
.col-6.row
|
||||||
|
.col-2.d-flex
|
||||||
|
.take.mx-3
|
||||||
|
=ic :arrows
|
||||||
|
%label
|
||||||
|
ref :
|
||||||
|
%input.p_product_ref_autocomplete_input.form-control.col{:type => "text", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)}
|
||||||
|
|
||||||
|
.col-3.ml-2
|
||||||
|
.form-inline
|
||||||
|
= form.input :qte, :label => "qte :", :input_html => { class: "mx-2", tabindex: 1}
|
||||||
|
.col-2
|
||||||
|
.form-inline
|
||||||
|
= form.input :ct_u_price_ht, :label => "PU :", :input_html => { class: "mx-2"}
|
||||||
|
.col-1.ml-2
|
||||||
|
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
|
||||||
|
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
|
||||||
|
|
||||||
|
= form.hidden_field :position, :class => "price_line_position_input"
|
||||||
|
|
Reference in New Issue
Block a user