diff --git a/app/controllers/admin/buy_lists_controller.rb b/app/controllers/admin/buy_lists_controller.rb index 662c25d..e555dcc 100644 --- a/app/controllers/admin/buy_lists_controller.rb +++ b/app/controllers/admin/buy_lists_controller.rb @@ -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{ diff --git a/app/controllers/admin/edit_watchers_controller.rb b/app/controllers/admin/edit_watchers_controller.rb index 11ec4f4..5e464a0 100644 --- a/app/controllers/admin/edit_watchers_controller.rb +++ b/app/controllers/admin/edit_watchers_controller.rb @@ -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 diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index b480168..c839a72 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -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" diff --git a/app/controllers/admin/timer_watchers_controller.rb b/app/controllers/admin/timer_watchers_controller.rb index 35d689c..7d37b85 100644 --- a/app/controllers/admin/timer_watchers_controller.rb +++ b/app/controllers/admin/timer_watchers_controller.rb @@ -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 diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index e1ee85d..a9decf8 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -123,8 +123,10 @@ class PCustomer < ApplicationRecord end after_initialize do - self.p_payment_type_id = 41 if !self.p_payment_type_id? - + begin + self.p_payment_type_id = 41 if !self.p_payment_type_id? + rescue + end end diff --git a/app/models/p_sheet_line.rb b/app/models/p_sheet_line.rb index 926c7dd..140e231 100644 --- a/app/models/p_sheet_line.rb +++ b/app/models/p_sheet_line.rb @@ -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 diff --git a/app/models/v_contact.rb b/app/models/v_contact.rb index 195c00f..3d15cb3 100644 --- a/app/models/v_contact.rb +++ b/app/models/v_contact.rb @@ -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) diff --git a/app/views/admin/admins/show.html.haml b/app/views/admin/admins/show.html.haml index 8d8f6eb..dc200a3 100644 --- a/app/views/admin/admins/show.html.haml +++ b/app/views/admin/admins/show.html.haml @@ -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 @@ -86,4 +86,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 37beefd..b84b535 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -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,8 +113,8 @@ %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 %tr.prdct_tr @@ -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