This commit is contained in:
Nicolas Bally 2019-02-04 09:42:06 +01:00
parent 46d54dfafd
commit f1049b24a0
4 changed files with 152 additions and 67 deletions

View File

@ -131,9 +131,9 @@ class PProduct < ActiveRecord::Base
else else
if !(p_product_stock = self.product_stocks.where(:p_color => nil, :p_size_id => nil).first) if !(p_product_stock = self.p_product_stocks.where(:p_color => nil, :p_size_id => nil).first)
p_product_stock = self.product_stocks.create(:stock_th_ok => 0, :stock_ok => 0) p_product_stock = self.p_product_stocks.create(:stock_th_ok => 0, :stock_ok => 0)
ids_new_saveds << p_product_stock.id ids_new_saveds << p_product_stock.id
end end

View File

@ -63,6 +63,7 @@
-p_product = form.object.p_product if form.object.p_product -p_product = form.object.p_product if form.object.p_product
%table.table.order_table %table.table.order_table
-if p_product and p_product.p_sizes.count > 0
%tr %tr
%th %th
@ -99,6 +100,26 @@
=number_to_currency form.object.price =number_to_currency form.object.price
%td.price_color_tot.price_td %td.price_color_tot.price_td
-elsif form.object.p_product
%tr.color_line
%td
-p_product.p_product_stocks.each do |ps|
%td
-if ps
-p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock_id => ps.id).first
-if p_sheet_line_line
=form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
=builder.hidden_field :p_product_stock_id,:label => false, :as => :string
=builder.input :qte,:label => false, :as => :string, :input_html => {:class => "qte"}
%td.qte_tot.price_td
%td.price.price_td{:data => {:price => form.object.price}}
=number_to_currency form.object.price
%td.price_color_tot.price_td
-if form.object.p_product -if form.object.p_product
%table{:style => "width:100%"} %table{:style => "width:100%"}

View File

@ -54,6 +54,7 @@
%td{:colspan => 4} %td{:colspan => 4}
-if sheet_line.p_product.p_colors.count > 0
-sheet_line.p_product.p_colors.all.each do |pc| -sheet_line.p_product.p_colors.all.each do |pc|
-qte_tot = 0.0 -qte_tot = 0.0
%tr %tr
@ -87,6 +88,67 @@
%td %td
=number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i =number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i
-elsif sheet_line.p_product.p_sizes.count > 0
-qte_tot = 0.0
%tr
%td
%td{:colspan => 1, :style => "text-align:right;"}
%table.size_table
%tr
%td
-sheet_line.p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |psize|
%td.p_size_td
-psl = p_sheet_line_lines.joins(:p_product_stock).where(:p_product_stocks => {:p_size_id => psize.id} ).first
-if psl
=psl.qte
-qte_tot += psl.qte
%td{}
=qte_tot.to_i
%td
=number_to_currency sheet_line.price.to_f
%td
=number_to_currency sheet_line.price.to_f * qte_tot.to_i
%td
=number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i
-else
%tr
-qte_tot = 0.0
%td
%td{:colspan => 1, :style => "text-align:right;"}
%table.size_table
%tr
%td
-p_sheet_line_lines.joins(:p_product_stock).each do |psl|
-qte_tot += psl.qte
%td{}
=qte_tot.to_i
%td
=number_to_currency sheet_line.price.to_f
%td
=number_to_currency sheet_line.price.to_f * qte_tot.to_i
%td
=number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i

View File

@ -42,7 +42,7 @@
Réf client : Réf client :
=sheet_line.cust_ref =sheet_line.cust_ref
-if p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.length > 0
-p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.each do |psize| -p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.each do |psize|
%th.p_size_td=psize.p_size.name %th.p_size_td=psize.p_size.name
@ -50,6 +50,7 @@
%td{:colspan => 4} %td{:colspan => 4}
-p_sheet_line_lines.group(:p_color_id).uniq.each do |pc| -p_sheet_line_lines.group(:p_color_id).uniq.each do |pc|
-qte_tot = 0.0 -qte_tot = 0.0
-if pc.p_color
%tr %tr
%td{:colspan => 3, :style => "text-align:right;"} %td{:colspan => 3, :style => "text-align:right;"}
%table.size_table %table.size_table
@ -61,6 +62,7 @@
%td %td
=pc.p_color.name =pc.p_color.name
-p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.each do |psize| -p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.each do |psize|
%td.p_size_td %td.p_size_td