Wip bon de livraison
This commit is contained in:
parent
2a540f292a
commit
6751e34f29
@ -670,4 +670,84 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
redirect_to admin_price_document_path(@price_document)
|
redirect_to admin_price_document_path(@price_document)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bon_de_reception
|
||||||
|
@past_price_document = PriceDocument.find(params[:id])
|
||||||
|
|
||||||
|
@p_customer_sheet = @past_price_document.ref_element
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
else
|
||||||
|
price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :date => Date.today)
|
||||||
|
end
|
||||||
|
|
||||||
|
price_document.doc_ref_id = @past_price_document.id
|
||||||
|
|
||||||
|
price_document.p_fournisseur = @past_price_document.p_fournisseur
|
||||||
|
|
||||||
|
|
||||||
|
price_document.price_line_block = @past_price_document.price_line_block.dup
|
||||||
|
|
||||||
|
if @past_price_document.cc_label == "Commande achat"
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if @past_price_document.cc_label == "Facture achat"
|
||||||
|
price_document.facture_achat_id = @past_price_document.id
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
price_document.price_line_block.ac_bon_de_commande_id = nil
|
||||||
|
price_document.price_line_block.ac_bon_de_livraison_id = nil
|
||||||
|
price_document.price_line_block.ac_facture_id = nil
|
||||||
|
price_document.price_line_block.ac_block_type = nil
|
||||||
|
price_document.price_line_block.ac_reliquat = nil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@past_price_document.price_line_block.price_lines.each do |pl|
|
||||||
|
new_pl = pl.dup
|
||||||
|
new_pl.price_line_ref_id = pl.id
|
||||||
|
new_pl.ac_block_type = nil
|
||||||
|
|
||||||
|
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])
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
new_pl.qte = new_pl.qte - qte_ok
|
||||||
|
|
||||||
|
end
|
||||||
|
price_document.price_line_block.price_lines << new_pl
|
||||||
|
end
|
||||||
|
|
||||||
|
if price_document.save
|
||||||
|
#price_document.reset_for_update
|
||||||
|
#price_document.archive_now
|
||||||
|
if @p_customer_sheet
|
||||||
|
@p_customer_sheet.state = "Bon de réception achat"
|
||||||
|
@p_customer_sheet.save
|
||||||
|
end
|
||||||
|
|
||||||
|
if price_document.ref_element
|
||||||
|
redirect_to [:admin, price_document.ref_element]
|
||||||
|
else
|
||||||
|
redirect_to [:admin, price_document]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
render :inline => price_document.errors.messages.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -43,8 +43,13 @@
|
|||||||
%td
|
%td
|
||||||
=link_to @price_document.p_fournisseur.name, [:admin, @price_document.p_fournisseur] if @price_document.p_fournisseur
|
=link_to @price_document.p_fournisseur.name, [:admin, @price_document.p_fournisseur] if @price_document.p_fournisseur
|
||||||
|
|
||||||
|
-if @price_document.d_number?
|
||||||
|
%tr
|
||||||
|
%td Numéro
|
||||||
|
%td=@price_document.d_number
|
||||||
|
%tr
|
||||||
|
%td Date
|
||||||
|
%td=l @price_document.date, :format => :date
|
||||||
|
|
||||||
-if @price_document.label == "Demande prix"
|
-if @price_document.label == "Demande prix"
|
||||||
%tr
|
%tr
|
||||||
@ -119,8 +124,9 @@
|
|||||||
|
|
||||||
-if @price_document.label != "Demande prix" and @price_document.label != "Réponse fournisseur"
|
-if @price_document.label != "Demande prix" and @price_document.label != "Réponse fournisseur"
|
||||||
|
|
||||||
|
|
||||||
-if current_admin and current_admin.id == 1
|
-if current_admin and current_admin.id == 1
|
||||||
|
-enable_stat = false
|
||||||
|
-if enable_stat
|
||||||
%table.table
|
%table.table
|
||||||
%tr
|
%tr
|
||||||
%th Archivé ?
|
%th Archivé ?
|
||||||
@ -184,13 +190,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%h3 Lignes de produits
|
||||||
%table.table
|
%table.table
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th
|
%th
|
||||||
%th Référence
|
%th Référence
|
||||||
%th Produit
|
%th Marque
|
||||||
%th Désignation
|
%th Désignation
|
||||||
%th Qté
|
%th Qté
|
||||||
%th P.U. HT
|
%th P.U. HT
|
||||||
@ -208,11 +214,10 @@
|
|||||||
|
|
||||||
|
|
||||||
%td
|
%td
|
||||||
=link_to price_line.p_product_ref.p_product.name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product
|
=price_line.p_product_ref.p_product.s_brand.name
|
||||||
|
|
||||||
|
|
||||||
%td
|
%td
|
||||||
=price_line.title
|
=link_to price_line.p_product_ref.cc_name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product
|
||||||
|
|
||||||
%td.numeraire
|
%td.numeraire
|
||||||
=price_line.qte
|
=price_line.qte
|
||||||
@ -230,12 +235,10 @@
|
|||||||
%td.numeraire
|
%td.numeraire
|
||||||
=number_to_currency price_line.tot_amount_ht
|
=number_to_currency price_line.tot_amount_ht
|
||||||
|
|
||||||
%td
|
/ %td=# price_line.line_stocks.sum(:price_ht)
|
||||||
= price_line.line_stocks.sum(:price_ht)
|
|
||||||
|
|
||||||
|
.qi_row
|
||||||
-if current_admin.has_permission?("show-costs")
|
-if current_admin.has_permission?("show-costs")
|
||||||
%br
|
|
||||||
%br
|
|
||||||
%p
|
%p
|
||||||
-if @price_document.price_document_type_id == 6
|
-if @price_document.price_document_type_id == 6
|
||||||
=link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok
|
=link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok
|
||||||
@ -249,6 +252,9 @@
|
|||||||
|
|
||||||
-if !@price_document.cost_ok
|
-if !@price_document.cost_ok
|
||||||
=link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary"
|
=link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary"
|
||||||
|
-if @price_document.d_number
|
||||||
|
-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"
|
||||||
|
|
||||||
-if false
|
-if false
|
||||||
|
|
||||||
@ -296,7 +302,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5
|
-if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5
|
||||||
%h3 Stocks générés
|
%h3 Stocks générés
|
||||||
#bills
|
#bills
|
||||||
|
@ -632,6 +632,8 @@ Rails.application.routes.draw do
|
|||||||
post :analyse_reponses_save
|
post :analyse_reponses_save
|
||||||
get :generate_final_consult
|
get :generate_final_consult
|
||||||
get :buy_order_create
|
get :buy_order_create
|
||||||
|
get :bon_de_reception
|
||||||
|
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :search_to_affect
|
get :search_to_affect
|
||||||
|
Reference in New Issue
Block a user