facture achat
This commit is contained in:
parent
d28ad68e99
commit
084e71905f
@ -731,8 +731,8 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
@p_customer_sheet.save
|
@p_customer_sheet.save
|
||||||
end
|
end
|
||||||
|
|
||||||
if price_document.ref_element
|
if price_document.doc_ref_id
|
||||||
redirect_to [:admin, price_document.ref_element]
|
redirect_to [:admin, @past_price_document]
|
||||||
else
|
else
|
||||||
redirect_to [:admin, price_document]
|
redirect_to [:admin, price_document]
|
||||||
end
|
end
|
||||||
@ -740,4 +740,60 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
render :inline => price_document.errors.messages.to_s
|
render :inline => price_document.errors.messages.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def facture_achat
|
||||||
|
@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("Facture achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today)
|
||||||
|
|
||||||
|
else
|
||||||
|
price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Facture 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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
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 = "Facture"
|
||||||
|
@p_customer_sheet.save
|
||||||
|
end
|
||||||
|
|
||||||
|
if price_document.doc_ref_id
|
||||||
|
redirect_to [:admin, @past_price_document]
|
||||||
|
else
|
||||||
|
redirect_to [:admin, price_document]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render :inline => price_document.errors.messages.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -54,6 +54,8 @@ class PriceLine < ApplicationRecord
|
|||||||
|
|
||||||
FACTURE_DACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht 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)
|
FACTURE_DACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht 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)
|
||||||
|
|
||||||
|
BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht 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)
|
||||||
|
|
||||||
COMMANDE_ACHAT_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)
|
COMMANDE_ACHAT_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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,6 +326,8 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
|
|
||||||
FACTURE_DACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship)
|
FACTURE_DACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship)
|
||||||
|
|
||||||
|
BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship)
|
||||||
|
|
||||||
COMMANDE_ACHAT_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship)
|
COMMANDE_ACHAT_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship)
|
||||||
|
|
||||||
def reset_for_update
|
def reset_for_update
|
||||||
@ -346,12 +348,12 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
eval("self.ac_#{qid} = nil")
|
eval("self.ac_#{qid} = nil")
|
||||||
end
|
end
|
||||||
|
|
||||||
self.archive_now(:skip_personalised_archive => true)
|
self.archive_now()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.price_lines.each do |pl|
|
self.price_lines.each do |pl|
|
||||||
pl.archive_now(:skip_personalised_archive => true)
|
pl.archive_now()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
=hidden_field_tag :public_edit, params[:public_edit]
|
=hidden_field_tag :public_edit, params[:public_edit]
|
||||||
|
%h3
|
||||||
= @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"
|
||||||
|
@ -186,7 +186,6 @@
|
|||||||
|
|
||||||
=# link_to i(:eye), admin_price_document_path(price_document), :remote => true
|
=# link_to i(:eye), admin_price_document_path(price_document), :remote => true
|
||||||
|
|
||||||
|
|
||||||
= link_to i(:eye), admin_price_document_path(price_document.id), :remote => false
|
= link_to i(:eye), admin_price_document_path(price_document.id), :remote => false
|
||||||
-if PriceLineBlock::PURCHASE_BLOCKS.include?(price_document.block_type)
|
-if PriceLineBlock::PURCHASE_BLOCKS.include?(price_document.block_type)
|
||||||
=# link_to i(:eye), admin_price_document_path(price_document.id), :remote => false
|
=# link_to i(:eye), admin_price_document_path(price_document.id), :remote => false
|
||||||
@ -201,6 +200,9 @@
|
|||||||
= link_to i(:pencil), edit_admin_price_document_path(price_document)
|
= link_to i(:pencil), edit_admin_price_document_path(price_document)
|
||||||
= link_to i(:eye), admin_price_document_path(price_document.id), :remote => false, :target => "_blank"
|
= link_to i(:eye), admin_price_document_path(price_document.id), :remote => false, :target => "_blank"
|
||||||
|
|
||||||
|
-if price_document.cc_label == "Bon de réception achat"
|
||||||
|
%br
|
||||||
|
=link_to "Générer la facture", facture_achat_admin_price_document_path(price_document)
|
||||||
|
|
||||||
=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}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@
|
|||||||
=number_to_currency @price_document.marge_ht
|
=number_to_currency @price_document.marge_ht
|
||||||
|
|
||||||
-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.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"
|
||||||
@ -304,6 +304,7 @@
|
|||||||
|
|
||||||
|
|
||||||
-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
|
||||||
|
-if @price_document.price_line_block.stock_ok
|
||||||
%h3 Stocks générés
|
%h3 Stocks générés
|
||||||
#bills
|
#bills
|
||||||
-params[:search][:per_page] = params[:search][:per_page] || 5000
|
-params[:search][:per_page] = params[:search][:per_page] || 5000
|
||||||
@ -379,7 +380,7 @@
|
|||||||
%h4.ml-2= price_document_consult.p_fournisseur.name
|
%h4.ml-2= price_document_consult.p_fournisseur.name
|
||||||
|
|
||||||
= 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)'
|
||||||
- existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id)
|
- existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id)
|
||||||
- if existing_order.present?
|
- if existing_order.present?
|
||||||
@ -398,7 +399,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
const copyPriceLines = (event) => {
|
const copyPriceLines = (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@ -436,3 +436,4 @@
|
|||||||
// Remove temporary element
|
// Remove temporary element
|
||||||
document.body.removeChild(el);
|
document.body.removeChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user