modifications diverses

This commit is contained in:
Nicolas Bally 2021-03-03 17:59:55 +01:00
parent 03225eb69b
commit 44912efc1e
10 changed files with 43 additions and 16 deletions

View File

@ -73,8 +73,12 @@ class Admin::MOdrFilesController < ApplicationController
if @m_odr_file.update_attributes(params.require(:m_odr_file).permit!)
@m_odr_file.m_odr_rep.change_state("En cours de traitement")
redirect_to [:admin, @m_odr_rep]
@m_odr_rep = @m_odr_file.m_odr_rep
if request.xhr?
else
redirect_to [:admin, @m_odr_rep]
end
else
render action: "edit"

View File

@ -88,6 +88,10 @@ class Admin::MOdrRemisesController < ApplicationController
def index
@m_odr_remises = MOdrRemise.includes(:m_odr)
if params[:search][:m_odr_id].to_s !=""
@m_odr_remises = @m_odr_remises.where(:m_odr_id => params[:search][:m_odr_id])
end
@m_odr_remises = sort_by_sorting(@m_odr_remises, "created_at DESC")
params[:search][:per_page] = params[:search][:per_page] || 50

View File

@ -10,6 +10,15 @@ class Admin::MOdrRepsController < ApplicationController
@admin_space = "payments"
end
def purge_test
@name = "Simion"
@m_odr_reps = @m_odr_reps.where("cc_particular_name LIKE ? or cc_particular_firstname LIKE ?","%#{@name}%", "%#{@name}%")
@m_odr_reps.all.each do |mor|
mor.destroy
end
end
def index
@m_odr_reps = MOdrRep.includes(:m_odr)

View File

@ -15,6 +15,7 @@ class MOdrRemise < ApplicationRecord
:m_odr_name => "ODR",
:created_at => {:name => "Date", :reorder => true},
:state => {:name => "Etat", :reorder => true},
:ca_amount => {:name => "Montant", :reorder => false, :as => :currency},
:confirmed => {:name => "Confirmé ?", :reorder => true},
:nbr_virements => "Nbr virements",
:actions => "Actions",
@ -37,6 +38,10 @@ class MOdrRemise < ApplicationRecord
end
def ca_amount
self.m_odr_virements.sum(:amount)
end
def m_odr_name
self.m_odr.name if self.m_odr
end

View File

@ -12,9 +12,9 @@ class MOdrRep < ApplicationRecord
has_many :particulars, :dependent => :destroy
accepts_nested_attributes_for :particulars, :allow_destroy => true
has_many :mail_hists
has_many :mail_hists, :dependent => :destroy
has_many :m_odr_virements
has_many :m_odr_virements, :dependent => :destroy
has_many :m_odr_rep_ribs, :dependent => :destroy
accepts_nested_attributes_for :m_odr_rep_ribs, :allow_destroy => true

View File

@ -8,7 +8,7 @@
= f.input :admin_ok, :label => "Décision :", :collection => [["Validé",true], ["Refusé", false]], :as => :select
= f.input :reject_reason, :label => "Motif du rejet :", :collection => ["Mauvais document","Mauvaise qualité rendant le fichier illisible"]
= f.input :reject_reason_description, :label => "Précisions sur le rejet"
= f.input :reject_reason_description, :label => "Précisions :"

View File

@ -5,6 +5,10 @@
-tr[:confirmed] = capture do
%td
="Oui" if m_odr_remise.confirmed
-tr[:ca_amount] = capture do
%td.numeraire
=number_to_currency m_odr_remise.ca_amount

View File

@ -12,18 +12,12 @@
-params[:search] =params[:search] || {}
%table
%tr
%td
Statut :
=select_tag "search[state]", options_for_select([["",""]]+MOdrRep.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state])
%td
Opération :
=select_tag "search[m_odr_id]", options_for_select([["",""]]+MOdr.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:m_odr_id])
%td=text_field_tag :name, params[:name],:class => "form-control", :placeholder => "Nom"
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_remises}

View File

@ -56,6 +56,11 @@ Fichier
=state_helper "Validé"
-elsif file.admin_ok == false
=state_helper "Refusé"
-else
=link_to admin_m_odr_file_path(:id => file.id, :m_odr_file => {:admin_ok => true}), :remote => true, :method => :put do
=ic :check
Valider
=link_to i(:pencil), edit_admin_m_odr_file_path(file), :remote => true
@ -108,7 +113,10 @@ RIB :
=state_helper "Validé"
-elsif m_odr_rep_rib.admin_ok == false
=state_helper "Refusé"
-else
=link_to admin_m_odr_rep_rib_path(:id => m_odr_rep_rib.id, :m_odr_rep_rib => {:admin_ok => true}), :remote => true, :method => :put do
=ic :check
Valider
=link_to i(:pencil), edit_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => true
@ -176,7 +184,7 @@ RIB :
-if @m_odr_rep.admin_ok_to_send and @m_odr_rep.m_odr_virements.where(:refused => false).count == 0
%br
%br
=link_to "Générer le virement", generate_virement_admin_m_odr_rep_path(@m_odr_rep), :class => "btn btn-primary"
=link_to "Générer le virement", generate_virement_admin_m_odr_rep_path(@m_odr_rep), :class => "btn btn-primary", :onclick => "$(this).replaceWith('Virement en cours de génération');"
-if @m_odr_rep.state == "Demande validée"

View File

@ -1,6 +1,5 @@
.qi_header
-if current_admin.has_permission?("odr_rep.create")
.right= link_to 'Ajouter ', new_admin_m_odr_rep_path(), :class => "btn btn-primary", :remote => true
%h1
ODR
%span