fixing p_article_price_line mannel bug
This commit is contained in:
parent
e2ed7e5f22
commit
820bd03640
Binary file not shown.
@ -267,29 +267,25 @@ class PCustomerSheet < ApplicationRecord
|
||||
def generate_doc(label, state)
|
||||
self.archive_now if !self.archived
|
||||
self.block_price if !self.price_blocked
|
||||
price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today)
|
||||
#raise
|
||||
price_document.p_customer = self.p_customer
|
||||
|
||||
price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today)
|
||||
price_document.p_customer = self.p_customer
|
||||
price_document.price_line_block = self.price_line_block.dup
|
||||
price_document.tva_type = self.price_line_block.price_document.tva_type
|
||||
|
||||
price_document.price_line_block.ac_block_type = nil
|
||||
|
||||
self.price_line_block.price_lines.each do |pl|
|
||||
new_pl = pl.dup
|
||||
new_pl.ac_block_type = nil
|
||||
pl.p_articles.each { |p_article| new_pl.p_articles << p_article }
|
||||
price_document.price_line_block.price_lines << new_pl
|
||||
end
|
||||
|
||||
if price_document.save
|
||||
|
||||
price_document.archive_now
|
||||
self.state = state
|
||||
self.save
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def generate_d
|
||||
|
@ -19,4 +19,3 @@
|
||||
=link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn"
|
||||
=form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add"
|
||||
.clear
|
||||
|
||||
|
@ -51,34 +51,24 @@
|
||||
%br
|
||||
|
||||
|
||||
%div{:style=>"padding:0 30px;"}
|
||||
.row.qi_field_wrapper
|
||||
%table{:style => "width:100%;border-collapse:separate;"}
|
||||
%thead
|
||||
%tr
|
||||
%th
|
||||
%th Produit
|
||||
%th{:style => "width:200px;"} Prix
|
||||
%th
|
||||
%th{:style => "width:100px;"} Qté
|
||||
%th TVA
|
||||
%th
|
||||
%tbody.price_lines_form
|
||||
=f.semantic_fields_for :price_lines do |f|
|
||||
=render :partial => "admin/price_lines/form", :locals => {:form => f}
|
||||
|
||||
%p{:style=>"padding-top:10px;"}= link_to_add_fields ic("plus-circle") + " ligne", f, :price_lines, {:class => "btn btn-primary p-2", tabindex: 10, style: "position: sticky; top: 100px"}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-# %div{:style=>"padding:0 30px;"}
|
||||
-# .row.qi_field_wrapper
|
||||
-# %table{:style => "width:100%;border-collapse:separate;"}
|
||||
-# %thead
|
||||
-# %tr
|
||||
-# %th
|
||||
-# %th Produit
|
||||
-# %th{:style => "width:200px;"} Prix
|
||||
-# %th
|
||||
-# %th{:style => "width:100px;"} Qté
|
||||
-# %th TVA
|
||||
-# %th
|
||||
-# %tbody.price_lines_form
|
||||
.qi_row.price_lines_form
|
||||
=f.semantic_fields_for :price_lines do |f|
|
||||
=render :partial => "admin/price_lines/form", :locals => {:form => f}
|
||||
|
||||
%p{:style=>"padding-left:10px;"}= link_to_add_fields ic("plus-circle") + " Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary p-2 add_lines", tabindex: 10}
|
||||
|
||||
-if current_admin.has_permission?("payments")
|
||||
-if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande")
|
||||
@ -108,3 +98,12 @@
|
||||
-if false
|
||||
.col-6
|
||||
= f.input :ct_payment_month_end, :label => "Fin de mois ?"
|
||||
|
||||
:javascript
|
||||
$('.p_product_ref_select').select2();
|
||||
$('.add_lines').click(function() {
|
||||
$('.p_product_ref_select').last().select2({
|
||||
//theme: "bootstrap"
|
||||
});
|
||||
//$('.p_product_ref_select').last().removeClass('form-control');
|
||||
})
|
@ -1,4 +1,4 @@
|
||||
= form.input :p_article_id, as: :select, collection: PArticle.joins(:p_product_ref).where(p_product_ref: price_line.p_product_ref).map{|p_article| [p_article.serialized_name, p_article.id]}, label: "Article(s) associé(s)", input_html: {class:"p_article_select"}
|
||||
= form.input :p_article_id, as: :select, collection: PArticle.joins(:p_product_ref).where(p_product_ref: @price_line.p_product_ref).map{|p_article| [p_article.serialized_name, p_article.id]}, label: "Article(s) associé(s)", input_html: {class:"p_article_select"}
|
||||
|
||||
:javascript
|
||||
$('.p_article_select').select2({
|
||||
|
@ -3,6 +3,6 @@
|
||||
=f.inputs do
|
||||
.price_line_p_articles_form.col-3
|
||||
= f.semantic_fields_for :price_line_p_articles do |form|
|
||||
=render :partial => "admin/price_line_p_articles/form", :locals => {:form => form, price_line: @price_line}
|
||||
= render "admin/price_line_p_articles/form", form: form, price_line: @price_line
|
||||
%p= link_to_add_fields "Ajouter un article", f, :price_line_p_articles, {:class => "btn btn-primary"} if @price_line.p_articles.count < @price_line.qte
|
||||
=render :partial => "qi/actions", :locals => {:f => f}
|
||||
|
@ -1,7 +1,4 @@
|
||||
.row.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
|
||||
|
||||
|
||||
|
||||
.take.mr-1{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
|
||||
=ic :arrows
|
||||
.col-3
|
||||
@ -42,51 +39,3 @@
|
||||
%span.destroy{style: "font-size: 2rem;"}=link_to_remove_fields ic(:"trash-o"), form
|
||||
= qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
|
||||
= form.hidden_field :position, :class => "price_line_position_input"
|
||||
|
||||
:javascript
|
||||
-# $('.p_product_ref_autocomplete_input').focus()
|
||||
-# $( function() {
|
||||
-# $('.p_product_ref_autocomplete_input').autocomplete({
|
||||
-# source: function( request, response ) {
|
||||
-# $.ajax( {
|
||||
-# url: "/admin/p_product_refs/autocomplete.json",
|
||||
-# dataType: "json",
|
||||
-# data: {
|
||||
-# search: request.term,
|
||||
-# p_customer_id: $(".p_customer_id").val()
|
||||
-# },
|
||||
-# success: function(data){
|
||||
-# arr = jQuery.map( data, function( item ) {
|
||||
-# return {
|
||||
-# label: item.member_label,
|
||||
-# value: item.member_label,
|
||||
-# id: item.id
|
||||
-# }
|
||||
-# });
|
||||
-# response(arr)
|
||||
-# }
|
||||
-# });
|
||||
-# },
|
||||
-# minLength: 2,
|
||||
-# select: function( event, ui ) {
|
||||
-# $(this).next(".p_product_ref_id").val(ui.item.id)
|
||||
-# form = $(this).closest(".price_line_form")
|
||||
-# $.ajax( {
|
||||
-# url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
|
||||
-# dataType: "json",
|
||||
-# data: {
|
||||
-# type: "price",
|
||||
-# qte: form.find(".input_price_line_qte").val(),
|
||||
-# p_customer_id: $(".p_customer_id").val()
|
||||
-# },
|
||||
-# success: function (data) {
|
||||
-# form.find(".input_price_line_price_u_ht").val(data.price);
|
||||
-# form.find(".input_price_line_tva_account_id").val(data.tva_account_id);
|
||||
-# form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
|
||||
-# form.find(".input_price_line_weight_u").val(data.weight);
|
||||
-# }
|
||||
-# });
|
||||
-# //return false
|
||||
-# }
|
||||
-# });
|
||||
-# });
|
Reference in New Issue
Block a user