Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3028f170e3
@ -54,7 +54,9 @@ class Admin::LineStocksController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@line_stocks = sort_by_sorting(@line_stocks, "date DESC")
|
#@line_stocks = sort_by_sorting(@line_stocks, "date DESC")
|
||||||
|
@line_stocks = @line_stocks.order(date: :desc, id: :desc)
|
||||||
|
|
||||||
|
|
||||||
@all_line_stocks = @line_stocks
|
@all_line_stocks = @line_stocks
|
||||||
|
|
||||||
|
@ -59,6 +59,32 @@ class PArticle < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def serialized_name
|
def serialized_name
|
||||||
"#{self.p_product_ref.cc_name} #{self.p_article_serial_nums.map{|x| x.value}.join(' / ')}"
|
"#{self.p_product_ref.cc_name} #{self.p_article_serial_nums.map{|x| "#{x.p_serial_num_type.name}: #{x.value}"}.join(' / ')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# def self.available_articles
|
||||||
|
# p_articles = PArticle.joins(:line_stocks).where("qte_available > ?", 0)
|
||||||
|
# p_articles.each do |p_article|
|
||||||
|
# if LineStockUsage.where(p_article_id: p_article.id).empty?
|
||||||
|
# p_articles.drop(p_article.id)
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# return p_articles
|
||||||
|
# end
|
||||||
|
|
||||||
|
def self.available_articles
|
||||||
|
p_articles = PArticle.joins(:line_stocks).where("qte_available > ?", 0)
|
||||||
|
used_p_articles_ids = LineStockUsage.where.not(p_article_id: nil).pluck(:p_article_id)#.map{|ls| ls.p_article_id}
|
||||||
|
available_p_articles_ids =[]
|
||||||
|
p_articles.each do |p_article|
|
||||||
|
#puts used_p_articles_ids.include?(p_article.id)
|
||||||
|
if !used_p_articles_ids.include?(p_article.id)
|
||||||
|
available_p_articles_ids << p_article.id
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return PArticle.where(id: available_p_articles_ids)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -18,6 +18,8 @@ class Particular < ApplicationRecord
|
|||||||
validates :country, :presence => true, :if => :force_validation
|
validates :country, :presence => true, :if => :force_validation
|
||||||
#validates :tel, :presence => true, :if => :force_validation
|
#validates :tel, :presence => true, :if => :force_validation
|
||||||
validates :organisation, :presence => true, :if => :force_validation
|
validates :organisation, :presence => true, :if => :force_validation
|
||||||
|
validates :name, :presence => true, :if => :force_validation
|
||||||
|
validates :firstname, :presence => true, :if => :force_validation
|
||||||
attr_accessor :validate_email, :skip_email
|
attr_accessor :validate_email, :skip_email
|
||||||
|
|
||||||
belongs_to :particular_ref, :class_name => "Particular"
|
belongs_to :particular_ref, :class_name => "Particular"
|
||||||
|
@ -12,7 +12,7 @@ class PriceLine < ApplicationRecord
|
|||||||
#has_many :price_line_demands, through: :price_line_resp_selects
|
#has_many :price_line_demands, through: :price_line_resp_selects
|
||||||
has_many :price_line_p_articles
|
has_many :price_line_p_articles
|
||||||
has_many :p_articles, through: :price_line_p_articles
|
has_many :p_articles, through: :price_line_p_articles
|
||||||
accepts_nested_attributes_for :p_articles
|
accepts_nested_attributes_for :p_articles, allow_destroy: true
|
||||||
accepts_nested_attributes_for :price_line_p_articles
|
accepts_nested_attributes_for :price_line_p_articles
|
||||||
|
|
||||||
default_scope { order('position ASC') }
|
default_scope { order('position ASC') }
|
||||||
|
@ -171,7 +171,7 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
line_stock: decr_line_stock
|
line_stock: decr_line_stock
|
||||||
)
|
)
|
||||||
ls_p_art.save
|
ls_p_art.save
|
||||||
|
#p_article.line_stocks << decr_line_stock fonctionne aussi selon la doc : https://guides.rubyonrails.org/association_basics.html#:~:text=The%20collection%20of%20join%20models%20can%20be%20managed
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -16,21 +16,23 @@
|
|||||||
=render :partial => "qi/actions", :locals => {:f => f}
|
=render :partial => "qi/actions", :locals => {:f => f}
|
||||||
/.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
/.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||||
- elsif params[:controller] == "admin/price_lines"
|
- elsif params[:controller] == "admin/price_lines"
|
||||||
= form.inputs do
|
.field
|
||||||
|
= form.inputs do
|
||||||
|
|
||||||
=@price_line.price_line_block.price_lineable.tva_type_id
|
=@price_line.price_line_block.price_lineable.tva_type_id
|
||||||
-if params[:p_product_ref_id]
|
-if params[:p_product_ref_id]
|
||||||
= form.input :p_product_ref_id, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => form.object.label_for(:p_product_ref), input_html: {disabled: true}
|
= form.input :p_product_ref_id, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => form.object.label_for(:p_product_ref), input_html: {disabled: true}
|
||||||
= form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
|
= form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
|
||||||
= form.hidden_field :tva_type_id, value: @price_line.price_line_block.price_lineable.tva_type_id
|
= form.hidden_field :tva_type_id, value: @price_line.price_line_block.price_lineable.tva_type_id
|
||||||
|
|
||||||
-else
|
-else
|
||||||
= form.input :p_product_ref_id, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => form.object.label_for(:p_product_ref), input_html: {disabled: true}
|
= form.input :p_product_ref_id, as: :select, collection: PProductRef.all.distinct.pluck(:cc_name, :id), :label => form.object.label_for(:p_product_ref), input_html: {disabled: true}
|
||||||
= form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
|
= form.hidden_field :p_product_ref_id, value: form.object.p_product_ref_id
|
||||||
-if PGrade::ACTIVATED
|
-if PGrade::ACTIVATED
|
||||||
= form.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade"
|
= form.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade"
|
||||||
%h4 Numero de série :
|
%h4 Numero de série :
|
||||||
.p_article_serial_nums_form
|
.p_article_serial_nums_form
|
||||||
= form.semantic_fields_for :p_article_serial_nums do |form|
|
= form.semantic_fields_for :p_article_serial_nums do |form|
|
||||||
=render :partial => "admin/p_article_serial_nums/form", :locals => {:form => form}
|
=render :partial => "admin/p_article_serial_nums/form", :locals => {:form => form}
|
||||||
%p= link_to_add_fields "Ajouter un numéro de série", form, :p_article_serial_nums, {:class => "btn btn-primary"}
|
%p= link_to_add_fields "Ajouter un numéro de série", form, :p_article_serial_nums, {:class => "btn btn-primary"}
|
||||||
|
%p.destroy{class: "btn btn-danger"}=link_to_remove_fields "Supprimer l'article", form
|
||||||
|
@ -1,26 +1,16 @@
|
|||||||
.particular_apercu
|
%tr#particular_row{:id => particular.id}
|
||||||
-if particular.organisation?
|
-tr = {}
|
||||||
=particular.organisation
|
|
||||||
|
|
||||||
-if particular.firstname? or particular.name?
|
-tr[:actions] = capture do
|
||||||
%strong
|
%td.actions
|
||||||
=particular.firstname
|
= link_to i(:"trash-o"), [:admin, particular], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||||
|
= link_to i(:pencil), edit_admin_particular_path(particular), :remote => true
|
||||||
|
= link_to i(:eye), admin_particular_path(particular), :remote => true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => particular}
|
||||||
|
|
||||||
=particular.name
|
|
||||||
%br
|
|
||||||
|
|
||||||
=particular.address_2
|
|
||||||
|
|
||||||
-if particular.address_3?
|
|
||||||
%br
|
|
||||||
=particular.address_3
|
|
||||||
%br
|
|
||||||
=particular.cp
|
|
||||||
|
|
||||||
=particular.city
|
|
||||||
%br
|
|
||||||
=particular.country
|
|
||||||
%br
|
|
||||||
=particular.tel
|
|
||||||
%br
|
|
||||||
=particular.email
|
|
@ -1,6 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right
|
.right
|
||||||
-if params[:price_document_type_id].to_i == 6 # Facture Achat
|
-if params[:price_document_type_id].to_i == 6 or params[:price_document_type_id].nil? # Facture Achat
|
||||||
= link_to 'Ajouter une facture achat', new_admin_price_document_path(:document_type => "Facture achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
= link_to 'Ajouter une facture achat', new_admin_price_document_path(:document_type => "Facture achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
||||||
-elsif params[:price_document_type_id].to_i == 4 # Commande Achat
|
-elsif params[:price_document_type_id].to_i == 4 # Commande Achat
|
||||||
= link_to 'Ajouter une commande achat', new_admin_price_document_path(:document_type => "Commande achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
= link_to 'Ajouter une commande achat', new_admin_price_document_path(:document_type => "Commande achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
||||||
|
@ -232,7 +232,7 @@
|
|||||||
= link_to i(:"trash-o"), admin_price_line_path(price_line), method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
= link_to i(:"trash-o"), admin_price_line_path(price_line), method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||||
= link_to i(:pencil), edit_admin_price_line_path(price_line), :remote => true
|
= link_to i(:pencil), edit_admin_price_line_path(price_line), :remote => true
|
||||||
= link_to i(:eye), admin_price_line_path(price_line), :remote => true
|
= link_to i(:eye), admin_price_line_path(price_line), :remote => true
|
||||||
= link_to i(:"mobile-alt"), add_p_article_admin_price_lines_path(p_product_ref_id: price_line.p_product_ref.id, price_line_id: price_line.id), :remote => true if price_line.p_product_ref.p_product.stockable and price_line.p_product_ref.p_product.with_serial_number
|
= link_to i(:"mobile-alt"), add_p_article_admin_price_lines_path(p_product_ref_id: price_line.p_product_ref.id, price_line_id: price_line.id), :remote => true if @price_document.price_document_type_id != 6 and price_line.p_product_ref.p_product.stockable and price_line.p_product_ref.p_product.with_serial_number
|
||||||
-price_line.p_articles.each do |p_article|
|
-price_line.p_articles.each do |p_article|
|
||||||
%tr{class: "p_articles_lines p_articles_#{price_line.id}"}
|
%tr{class: "p_articles_lines p_articles_#{price_line.id}"}
|
||||||
%td
|
%td
|
||||||
@ -248,8 +248,7 @@
|
|||||||
-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 and @price_document.stock_generable
|
-# =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable
|
||||||
-# =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable
|
-# =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable
|
||||||
=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.stock_ok and @price_document.stock_generable
|
=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.stock_ok
|
||||||
=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable
|
|
||||||
|
|
||||||
-elsif @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5
|
-elsif @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5
|
||||||
-# %p
|
-# %p
|
||||||
|
@ -1 +1 @@
|
|||||||
= 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.available_articles.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"}
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
.p_articles_form
|
.p_articles_form
|
||||||
= f.semantic_fields_for :p_articles do |form|
|
= f.semantic_fields_for :p_articles do |form|
|
||||||
=render :partial => "admin/p_articles/form", :locals => {:form => form, @price_line => f.object}
|
=render :partial => "admin/p_articles/form", :locals => {:form => form, @price_line => f.object}
|
||||||
|
|
||||||
%p= link_to_add_fields "Ajouter un article", f, :p_articles, {:class => "btn btn-primary"} if f.object.p_articles.count < f.object.qte
|
%p= link_to_add_fields "Ajouter un article", f, :p_articles, {:class => "btn btn-primary"} if f.object.p_articles.count < f.object.qte
|
||||||
=render :partial => "qi/actions", :locals => {:f => f}
|
=render :partial => "qi/actions", :locals => {:f => f}
|
||||||
|
Reference in New Issue
Block a user