diff --git a/app/controllers/admin/m_odr_files_controller.rb b/app/controllers/admin/m_odr_files_controller.rb index 7ca2c86..690e2b2 100644 --- a/app/controllers/admin/m_odr_files_controller.rb +++ b/app/controllers/admin/m_odr_files_controller.rb @@ -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" diff --git a/app/controllers/admin/m_odr_remises_controller.rb b/app/controllers/admin/m_odr_remises_controller.rb index 42f293b..be558a4 100644 --- a/app/controllers/admin/m_odr_remises_controller.rb +++ b/app/controllers/admin/m_odr_remises_controller.rb @@ -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 diff --git a/app/controllers/admin/m_odr_reps_controller.rb b/app/controllers/admin/m_odr_reps_controller.rb index fb947a4..338aed6 100644 --- a/app/controllers/admin/m_odr_reps_controller.rb +++ b/app/controllers/admin/m_odr_reps_controller.rb @@ -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) diff --git a/app/models/m_odr_remise.rb b/app/models/m_odr_remise.rb index e2b2242..c1ac54b 100644 --- a/app/models/m_odr_remise.rb +++ b/app/models/m_odr_remise.rb @@ -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 diff --git a/app/models/m_odr_rep.rb b/app/models/m_odr_rep.rb index d148244..c20b453 100644 --- a/app/models/m_odr_rep.rb +++ b/app/models/m_odr_rep.rb @@ -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 diff --git a/app/views/admin/m_odr_files/_form.html.haml b/app/views/admin/m_odr_files/_form.html.haml index 778503c..c638c3a 100644 --- a/app/views/admin/m_odr_files/_form.html.haml +++ b/app/views/admin/m_odr_files/_form.html.haml @@ -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 :" diff --git a/app/views/admin/m_odr_remises/_m_odr_remise.html.haml b/app/views/admin/m_odr_remises/_m_odr_remise.html.haml index 30aee55..1a234c9 100644 --- a/app/views/admin/m_odr_remises/_m_odr_remise.html.haml +++ b/app/views/admin/m_odr_remises/_m_odr_remise.html.haml @@ -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 diff --git a/app/views/admin/m_odr_remises/index.html.haml b/app/views/admin/m_odr_remises/index.html.haml index 696738a..20120a7 100644 --- a/app/views/admin/m_odr_remises/index.html.haml +++ b/app/views/admin/m_odr_remises/index.html.haml @@ -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} diff --git a/app/views/admin/m_odr_reps/_left_column.html.haml b/app/views/admin/m_odr_reps/_left_column.html.haml index 4aec764..468ffa0 100644 --- a/app/views/admin/m_odr_reps/_left_column.html.haml +++ b/app/views/admin/m_odr_reps/_left_column.html.haml @@ -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" diff --git a/app/views/admin/m_odr_reps/index.html.haml b/app/views/admin/m_odr_reps/index.html.haml index c6517ae..24aeea5 100644 --- a/app/views/admin/m_odr_reps/index.html.haml +++ b/app/views/admin/m_odr_reps/index.html.haml @@ -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