payment fix & commercial

This commit is contained in:
Barnabé 2021-09-13 15:15:08 +02:00
parent 7567ffbd34
commit 2cf5b53cba
2 changed files with 15 additions and 11 deletions

View File

@ -108,12 +108,13 @@ class Admin::PPaymentsController < ApplicationController
@p_payments = @p_payments.where("affected = ?", params[:affected].to_i) @p_payments = @p_payments.where("affected = ?", params[:affected].to_i)
end end
if params[:remise].to_s != "" # PROBLEME AVEC POSTGRES. Attend un booléen mais le where envoi 1/0
@p_payments = @p_payments.where("remise = ?", params[:remise].to_i) # if params[:remise].to_s != ""
if params[:remise].to_s == "0" # @p_payments = @p_payments.where("remise = ?", params[:remise].to_i)
@p_payments = @p_payments.where(:imported => false) # if params[:remise].to_s == "0"
end # @p_payments = @p_payments.where(:imported => false)
end # end
# end
if params[:p_customer_id].to_s != "" if params[:p_customer_id].to_s != ""
@p_payments = @p_payments.where(:p_customer_id => params[:p_customer_id]) @p_payments = @p_payments.where(:p_customer_id => params[:p_customer_id])

View File

@ -293,7 +293,7 @@
.check_box_search_index .check_box_search_index
<input type="text" class="check_box_search_input" placeholder="Recherche"></input> <input type="text" class="check_box_search_input" placeholder="Recherche"></input>
.check_box_search_index_inner.clientsCheck .check_box_search_index_inner.clientsCheck
-st = StatLine.group(:p_customer_id).order(:p_customer_name) -st = StatLine.select(:p_customer_id, :p_customer_name).group(:p_customer_id, :p_customer_name).order('stat_lines.p_customer_name')
-if current_admin.p_commercial -if current_admin.p_commercial
-st = st.where(:p_customer_id => current_admin.p_commercial.p_customers.ids) -st = st.where(:p_customer_id => current_admin.p_commercial.p_customers.ids)
-st.all.each do |pdt| -st.all.each do |pdt|
@ -675,6 +675,8 @@
%span.text-success %span.text-success
%i.mdi.mdi-arrow-bottom-right %i.mdi.mdi-arrow-bottom-right
=number_to_currency(((@periode_tot_weight.to_f != 0.0 ? @periode_avg_price_per_kg = @ca_produits_degrade / @periode_tot_weight : 0.0)), :precision => 2) =number_to_currency(((@periode_tot_weight.to_f != 0.0 ? @periode_avg_price_per_kg = @ca_produits_degrade / @periode_tot_weight : 0.0)), :precision => 2)
/ DEBUG POUR AFFICHER LA PAGE SANS DATA
- @periode_avg_price_per_kg = 1
="/ Kg" ="/ Kg"
ca moyen / kilo ca moyen / kilo
@ -748,10 +750,10 @@
-@tot_clients_inactifs = (@tot_customs - @periode_lines.group(:p_customer_id).map{|p| p.p_customer_id}.uniq) -@tot_clients_inactifs = (@tot_customs - @periode_lines.group(:p_customer_id).map{|p| p.p_customer_id}.uniq)
-@all_customers_rows = @all_customers_rows.where(id: params[:p_customer_ids]) -@all_customers_rows = @all_customers_rows.where(id: params[:p_customer_ids])
-else -else
-@tot_clients_inactifs = (@all_customers_rows.ids - (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq ) -@tot_clients_inactifs = (@all_customers_rows.ids - (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq )
-@periode_nbr_clients_actifs = (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq.length -@periode_nbr_clients_actifs = (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq.length
/ -@clients_inactifs = [] / -@clients_inactifs = []
/ -@periode_nbr_clients_inactifs = params[:p_customer_ids].each do |a| / -@periode_nbr_clients_inactifs = params[:p_customer_ids].each do |a|
/ -@clients_inactifs << PCustomer.where(id: a, enabled: false) / -@clients_inactifs << PCustomer.where(id: a, enabled: false)
@ -759,7 +761,7 @@
/ -@tot_clients_inactifs = (@clients_inactifs.length - @periode_nbr_clients_actifs) / -@tot_clients_inactifs = (@clients_inactifs.length - @periode_nbr_clients_actifs)
%div{:style => "font-size:0.7em;float:right"} %div{:style => "font-size:0.7em;float:right"}
=link_to admin_p_customers_path(:p_customer_ids => (@all_customers_rows.ids - (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).uniq )), :method => :patch do =link_to admin_p_customers_path(:p_customer_ids => (@all_customers_rows.ids - (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).uniq )), :method => :patch do
=@tot_clients_inactifs.length =@tot_clients_inactifs.length
inactifs inactifs
@ -810,7 +812,8 @@
%span.text-success %span.text-success
%i.mdi.mdi-arrow-bottom-right %i.mdi.mdi-arrow-bottom-right
=number_to_currency((@periode_avg_ca_per_customer = @ca_produits_degrade / @periode_nbr_clients_actifs.to_f), :precision => 0) =number_to_currency((@periode_avg_ca_per_customer = @ca_produits_degrade / @periode_nbr_clients_actifs.to_f), :precision => 0)
/ DEBUG POUR AFFICHER LA PAGE SANS DATA
-@periode_avg_ca_per_customer = 1
ca moyen / clients ca moyen / clients
.mb-0 .mb-0