wip debug

This commit is contained in:
Barnabé 2021-09-07 15:32:27 +02:00
parent 3bec5568eb
commit 7567ffbd34
9 changed files with 24 additions and 19 deletions

View File

@ -12,7 +12,7 @@ class Admin::BuyListsController < ApplicationController
@price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids)
@price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids)
@price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids).unscoped
if params[:search][:s_brand].present? && params[:search][:s_brand] != ""
@price_lines = @price_lines.joins(p_product_ref: :p_product).where("s_brand_id = ?", params[:search][:s_brand])
@ -61,7 +61,7 @@ class Admin::BuyListsController < ApplicationController
@price_lines = @price_lines.where("price_lines.cc_creation_date >= ?", @start) if @start
@price_lines = @price_lines.where("price_lines.cc_creation_date <= ?", @stop.end_of_day) if @stop
@price_lines = @price_lines.where(:cc_block_type => "Demande de commande")
respond_to do |format|
format.html{

View File

@ -15,7 +15,7 @@ class Admin::EditWatchersController < ApplicationController
@edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).group(:admin_id).all
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).select(:admin_id).group(:admin_id).all
else
render :action => :new

View File

@ -278,8 +278,8 @@ class Admin::PriceDocumentsController < ApplicationController
@ref_price_lines = @demande.price_line_block.price_lines
@ref_price_lines.group(:p_product_ref_id).each do |plr|
@price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte))
@ref_price_lines.unscoped.select(:p_product_ref_id).group(:p_product_ref_id).each do |plr|
@price_document.price_line_block.price_lines << PriceLine.new(:price_line_ref_id => plr.id, :p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte))
end
@ -294,6 +294,8 @@ class Admin::PriceDocumentsController < ApplicationController
if @price_document.save
redirect_to consult_edit_admin_price_document_path(:id => @price_document.token)
else
@demande = PriceDocument.where(:id => @price_document.doc_ref_id).first
render action: "consult"
end
@ -330,6 +332,7 @@ class Admin::PriceDocumentsController < ApplicationController
def update
raise
@price_document = PriceDocument.find(params[:id])
@avoir = true if @price_document.label == "Avoir"

View File

@ -50,7 +50,7 @@ class Admin::TimerWatchersController < ApplicationController
@edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).group(:admin_id).all
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).select(:admin_id).group(:admin_id).all

View File

@ -123,8 +123,10 @@ class PCustomer < ApplicationRecord
end
after_initialize do
begin
self.p_payment_type_id = 41 if !self.p_payment_type_id?
rescue
end
end

View File

@ -172,7 +172,7 @@ class PSheetLine < ApplicationRecord
def stock_is_ok
if !self.stock_done
if self.brut_product_needs_ok.size == self.p_sheet_line_stocks.group(:p_brut_product_id).length
if self.brut_product_needs_ok.size == self.p_sheet_line_stocks.select(:p_brut_product_id).group(:p_brut_product_id).length
self.stock_done = true
self.save

View File

@ -203,7 +203,7 @@ class VContact < ApplicationRecord
# Mettre nbr_mvt à 0 pour toutes les cartes actives qui n'ont pas eu de mouvement
vc_ids = VolumePeriodique.group(:codemanaginn).map{|a| a.codemanaginn}
vc_ids = VolumePeriodique.select(:codemanaginn).group(:codemanaginn).map{|a| a.codemanaginn}
VContact.where(:enabled => true).where("codemanaginn not in(?)", vc_ids).update_all(:nbr_mvt => 0, :cc_cagnotte => 0, :cc_total => 0, :cc_remise => 0)

View File

@ -47,7 +47,7 @@
%th Client
%th Temps passé
%th
-@timer_watchers.group(:p_customer_id).order("p_customer_id DESC").uniq.each do |twp|
-@timer_watchers.select(:p_customer_id).group(:p_customer_id).order("p_customer_id DESC").uniq.each do |twp|
%tbody
%tr
%td

View File

@ -30,7 +30,7 @@
=ic(:times)
%td
Statut :
=select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select"
=select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.select(:state).group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select"
%td
Marque :
@ -113,7 +113,7 @@
%tbody
-p_product_id = nil
-@price_lines.where.not(:p_product_ref_id => nil).group(:p_product_ref_id).order("p_product_id ASC").each do |plr|
-@price_lines.select("DISTINCT ON (price_lines.p_product_ref_id) price_lines.*").where.not(:p_product_ref_id => nil).order("price_lines.p_product_ref_id, p_product_id ASC").each do |plr|
-if p_product_id != plr.p_product_id
-p_product_id = plr.p_product_id
@ -190,15 +190,15 @@
%td.col-detail
=link_to [:admin, price_line.price_line_block.price_lineable] do
=price_line.price_line_block.price_lineable.id
=price_line.price_line_block.price_lineable.past_id
=#price_line.price_line_block.price_lineable.past_id
%td.col-detail
=link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
=#link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
%td
=state_helper price_line.price_line_block.price_lineable.state
=#state_helper price_line.price_line_block.price_lineable.state
%td
=price_line.comment
@ -209,7 +209,7 @@
= l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date
%td
= l price_line.cc_wish_date, :format => "semaine %V (%Y)"
= #l price_line.cc_wish_date, :format => "semaine %V (%Y)"
%td
=price_line.qte.to_i