suite
This commit is contained in:
parent
624a82f017
commit
6c27e12a7e
2
Gemfile
2
Gemfile
@ -108,3 +108,5 @@ gem 'axlsx', '3.0.0.pre'
|
||||
gem 'axlsx_rails'
|
||||
|
||||
gem 'iban-tools'
|
||||
|
||||
gem "mailjet"
|
||||
|
22
Gemfile.lock
22
Gemfile.lock
@ -126,6 +126,8 @@ GEM
|
||||
countries (~> 3.0)
|
||||
sort_alphabetical (~> 1.0)
|
||||
crass (1.0.4)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
elasticsearch (7.3.0)
|
||||
elasticsearch-api (= 7.3.0)
|
||||
elasticsearch-transport (= 7.3.0)
|
||||
@ -165,6 +167,9 @@ GEM
|
||||
nokogiri (>= 1.6.0)
|
||||
ruby_parser (~> 3.5)
|
||||
htmlentities (4.3.4)
|
||||
http-accept (1.7.0)
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
i18n (1.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n_data (0.8.0)
|
||||
@ -209,9 +214,16 @@ GEM
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
mailjet (1.5.4)
|
||||
activesupport (>= 3.1.0)
|
||||
rack (>= 1.4.0)
|
||||
rest-client
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
method_source (0.9.2)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2019.1009)
|
||||
mimemagic (0.3.3)
|
||||
mini_magick (4.10.1)
|
||||
mini_mime (1.0.2)
|
||||
@ -224,6 +236,7 @@ GEM
|
||||
net-scp (2.0.0)
|
||||
net-ssh (>= 2.6.5, < 6.0.0)
|
||||
net-ssh (5.2.0)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.5.1)
|
||||
nokogiri (1.10.4)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
@ -267,6 +280,11 @@ GEM
|
||||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
regexp_parser (1.6.0)
|
||||
rest-client (2.1.0)
|
||||
http-accept (>= 1.7.0, < 2.0)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
rmagick (4.0.0)
|
||||
ruby-vips (2.0.17)
|
||||
ffi (~> 1.9)
|
||||
@ -327,6 +345,9 @@ GEM
|
||||
railties (>= 3.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.6)
|
||||
unicode_utils (1.4.0)
|
||||
unicorn (5.5.1)
|
||||
kgio (~> 2.6)
|
||||
@ -380,6 +401,7 @@ DEPENDENCIES
|
||||
jquery-rails
|
||||
kaminari-bootstrap
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
mailjet
|
||||
mysql2
|
||||
nokogiri
|
||||
posix-spawn
|
||||
|
@ -39,6 +39,18 @@ class Admin::MOdrFilesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def send_mail
|
||||
@m_odr_file = MOdrFile.find(params[:id])
|
||||
@m_odr_rep = @m_odr_file.m_odr_rep
|
||||
|
||||
@m_odr_rep.send_mail_type(params[:slug].to_s, @m_odr_file)
|
||||
|
||||
redirect_to [:admin, @m_odr_rep]
|
||||
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@m_odr_file = MOdrFile.new(params.require(:m_odr_file).permit!)
|
||||
|
||||
|
@ -10,6 +10,39 @@ class Admin::MOdrRemisesController < ApplicationController
|
||||
@admin_space = "payments"
|
||||
end
|
||||
|
||||
def export_sepa
|
||||
@m_odr_remise = MOdrRemise.find(params[:id])
|
||||
|
||||
@m_odr = @m_odr_remise.m_odr
|
||||
|
||||
@m_odr_virements = @m_odr_remise.m_odr_virements.where(:refused => false)
|
||||
|
||||
|
||||
@prelevement_date = Time.now
|
||||
@iban = @m_odr.iban.to_s
|
||||
@bic = @m_odr.bic.to_s
|
||||
@name = @m_odr.bank_name.to_s
|
||||
|
||||
|
||||
|
||||
|
||||
params[:inline] = false
|
||||
file_path = Rails.root.join("pdf", "sepa", "remise_#{@m_odr_remise.id}.xml")
|
||||
if true or !File.exist?(file_path)
|
||||
@data_to_send = render_to_string(:layout => "admin/m_odr_remises/sepa.html.erb", :layout => false)
|
||||
|
||||
#@data_to_send = "d"
|
||||
|
||||
File.open(file_path, "w+") do |f|
|
||||
f.write(@data_to_send)
|
||||
end
|
||||
end
|
||||
|
||||
send_file file_path, :filename =>"export-#{@m_odr_remise.id}-#{Date.today.strftime("%Y-%m-%d")}.xml" , :type => 'text/xml',:disposition => (params[:inline] ? 'inline' : "attachment")
|
||||
|
||||
end
|
||||
|
||||
|
||||
def confirm
|
||||
|
||||
@m_odr_remise = MOdrRemise.find(params[:id])
|
||||
@ -18,6 +51,8 @@ class Admin::MOdrRemisesController < ApplicationController
|
||||
m_odr_virement.m_odr_rep.change_state("Virement envoyé")
|
||||
m_odr_virement.save
|
||||
|
||||
m_odr_virement.m_odr_rep.send_mail_type("succes", m_odr_virement)
|
||||
|
||||
end
|
||||
@m_odr_remise.confirmed = true
|
||||
@m_odr_remise.save
|
||||
|
@ -57,6 +57,18 @@ class Admin::MOdrRepRibsController < ApplicationController
|
||||
end
|
||||
|
||||
|
||||
def send_mail
|
||||
@m_odr_rep_rib = MOdrRepRib.find(params[:id])
|
||||
@m_odr_rep = @m_odr_rep_rib.m_odr_rep
|
||||
|
||||
@m_odr_rep.send_mail_type("erreur-coordonnees-bancaire", @m_odr_rep_rib)
|
||||
|
||||
redirect_to [:admin, @m_odr_rep]
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@m_odr_rep_rib = MOdrRepRib.find(params[:id])
|
||||
@m_odr_rep_rib.destroy
|
||||
|
@ -97,6 +97,23 @@ class Admin::MOdrRepsController < ApplicationController
|
||||
end
|
||||
|
||||
|
||||
def refuse
|
||||
@m_odr_rep = MOdrRep.find(params[:id])
|
||||
|
||||
|
||||
@m_odr_rep.change_state("Refusée")
|
||||
|
||||
|
||||
redirect_to [:admin, @m_odr_rep]
|
||||
end
|
||||
|
||||
def send_mail
|
||||
@m_odr_rep = MOdrRep.find(params[:id])
|
||||
@m_odr_rep.send_mail_type(params[:slug].to_s)
|
||||
|
||||
redirect_to [:admin, @m_odr_rep]
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -91,6 +91,11 @@ class Admin::MOdrVirementsController < ApplicationController
|
||||
@m_odr_virement.refused = true
|
||||
@m_odr_virement.save
|
||||
@m_odr_virement.m_odr_rep.change_state("Erreur sur virement")
|
||||
|
||||
@m_odr_rep = @m_odr_virement.m_odr_rep
|
||||
|
||||
@m_odr_rep.send_mail_type("erreur-coordonnees-bancaire", @m_odr_virement)
|
||||
|
||||
@m_odr_remise = @m_odr_virement.m_odr_remise if @m_odr_virement.m_odr_remise
|
||||
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ module TranslationHelper
|
||||
r = '<span class="badge badge-primary">Facturée</span>'
|
||||
elsif value == "annulée"
|
||||
r = '<span class="badge badge-dark">Annulée</span>'
|
||||
elsif ["Erreur sur virement", "Refusé"].include?(value)
|
||||
elsif ["Erreur sur virement", "Refusé", "Refusée"].include?(value)
|
||||
r = '<span class="badge badge-danger">'+value+'</span>'
|
||||
elsif ["En cours de traitement"].include?(value)
|
||||
r = '<span class="badge badge-danger" style="background:#865F7C;">'+value+'</span>'
|
||||
|
@ -33,7 +33,7 @@ class MOdrRep < ApplicationRecord
|
||||
def send_mail_type(slug, element = nil)
|
||||
|
||||
if self.m_odr and mail_type = self.m_odr.mail_types.where(:slug => slug).first and self.particulars.first and self.particulars.first.email?
|
||||
mail_hist = MailHist.generate_mail(:fr, mail_type, self.particulars.first.email, {:arguments => {:nom_odr => self.m_odr.name}, :m_odr => self.m_odr, :m_odr_rep => self})
|
||||
mail_hist = MailHist.generate_mail(:fr, mail_type, self.particulars.first.email, {:arguments => {:nom_odr => self.m_odr.name}, :m_odr => self.m_odr, :m_odr_rep => self, :element => element})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,4 +10,8 @@ class MOdrRepRib < ApplicationRecord
|
||||
validates :iban, :presence => true
|
||||
|
||||
validates_with IbanValidator
|
||||
|
||||
has_many :mail_hists, :as => :element
|
||||
|
||||
|
||||
end
|
||||
|
@ -7,6 +7,7 @@ class MOdrVirement < ApplicationRecord
|
||||
|
||||
|
||||
|
||||
|
||||
QI_DYNAMICS = %w(remise iban_to bic_to iban_from bic_from bank_name bank_subject libelle )
|
||||
|
||||
eval(QI_DYNAMICS_CORE)
|
||||
|
@ -15,12 +15,15 @@ class MailHist < ApplicationRecord
|
||||
|
||||
def self.qi_table_order
|
||||
{
|
||||
:m_odr => {:name => "ODR"},
|
||||
:m_odr_rep => {:name => "Participation"},
|
||||
|
||||
:created_at => {:name => "Date", :reorder => true},
|
||||
:from_email => {:name => "Email exp.", :reorder => true},
|
||||
:to_email => {:name => "Email dest.", :reorder => true},
|
||||
:subject => {:name => "Sujet.", :reorder => true},
|
||||
:element => {:name => "Elément"},
|
||||
:mail_type => {:name => "Elément"},
|
||||
:m_odr => {:name => "ODR"},
|
||||
:m_odr_rep => {:name => "Participation"},
|
||||
:actions => "Actions",
|
||||
}
|
||||
end
|
||||
|
75
app/views/admin/m_odr_remises/export_sepa.html.erb
Normal file
75
app/views/admin/m_odr_remises/export_sepa.html.erb
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
|
||||
<CstmrCdtTrfInitn>
|
||||
<GrpHdr>
|
||||
<MsgId><%=@prelevement_date.strftime("%d/%m/%Y").to_slug %>-<%= @m_odr_remise.id %></MsgId>
|
||||
<CreDtTm><%= Time.now.to_time.utc.iso8601 %></CreDtTm>
|
||||
<NbOfTxs><%= @m_odr_virements.count %></NbOfTxs>
|
||||
<CtrlSum><%= '%.2f' % @m_odr_virements.sum(:amount) %></CtrlSum>
|
||||
<InitgPty>
|
||||
<Nm><%= @name %></Nm>
|
||||
</InitgPty>
|
||||
</GrpHdr>
|
||||
<PmtInf>
|
||||
<PmtInfId><%= @prelevement_date.strftime("%d/%m/%Y") %></PmtInfId>
|
||||
<PmtMtd>TRF</PmtMtd>
|
||||
<BtchBookg>false</BtchBookg>
|
||||
<NbOfTxs><%= @m_odr_virements.count %></NbOfTxs>
|
||||
<CtrlSum><%= '%.2f' % @m_odr_virements.sum(:amount) %></CtrlSum>
|
||||
<PmtTpInf>
|
||||
<SvcLvl>
|
||||
<Cd>SEPA</Cd>
|
||||
</SvcLvl>
|
||||
</PmtTpInf>
|
||||
<ReqdExctnDt><%= @prelevement_date.strftime("%Y-%m-%d") %></ReqdExctnDt>
|
||||
<Dbtr>
|
||||
<Nm><%= @name %></Nm>
|
||||
</Dbtr>
|
||||
<DbtrAcct>
|
||||
<Id>
|
||||
<IBAN><%= @iban %></IBAN>
|
||||
</Id>
|
||||
</DbtrAcct>
|
||||
<DbtrAgt>
|
||||
<FinInstnId>
|
||||
<BIC><%= @bic %></BIC>
|
||||
</FinInstnId>
|
||||
</DbtrAgt>
|
||||
<ChrgBr>SLEV</ChrgBr>
|
||||
|
||||
|
||||
<% @m_odr_virements.all.each do |m_odr_virement| %>
|
||||
<CdtTrfTxInf>
|
||||
<PmtId>
|
||||
<EndToEndId><%= m_odr_virement.token %></EndToEndId>
|
||||
</PmtId>
|
||||
<Amt>
|
||||
<InstdAmt Ccy="EUR"><%= '%.2f' % m_odr_virement.amount %></InstdAmt>
|
||||
</Amt>
|
||||
|
||||
<Cdtr>
|
||||
<Nm><%= m_odr_virement.m_odr_rep.long_name %></Nm>
|
||||
</Cdtr>
|
||||
|
||||
<CdtrAgt>
|
||||
<FinInstnId>
|
||||
<BIC><%= m_odr_virement.bic_to %></BIC>
|
||||
</FinInstnId>
|
||||
</CdtrAgt>
|
||||
|
||||
|
||||
<CdtrAcct>
|
||||
<Id>
|
||||
<IBAN><%= m_odr_virement.iban_to.gsub(" ", "") %></IBAN>
|
||||
</Id>
|
||||
</CdtrAcct>
|
||||
<RmtInf>
|
||||
<Ustrd><%= m_odr_virement.token %></Ustrd>
|
||||
</RmtInf>
|
||||
</CdtTrfTxInf>
|
||||
|
||||
<% end %>
|
||||
|
||||
</PmtInf>
|
||||
</CstmrDrctDbtInitn>
|
||||
</Document>
|
@ -7,10 +7,16 @@
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=link_to "Export CSV", export_sepa_admin_m_odr_remise_path(@m_odr_remise)
|
||||
|
||||
|
||||
%br
|
||||
%br
|
||||
=link_to "Confirmer maintenant TOUS les virements", confirm_admin_m_odr_remise_path(@m_odr_remise) if !@m_odr_remise.confirmed
|
||||
|
||||
|
||||
|
||||
|
||||
%hr
|
||||
Virements
|
||||
|
||||
|
@ -94,6 +94,10 @@
|
||||
%br
|
||||
=file.reject_reason
|
||||
=simple_format file.reject_reason_description if file.reject_reason_description?
|
||||
-[["achat-hors-delais", "Achat hors délais"],["facture-illisible", "Facture illisible"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"]].each do |key|
|
||||
%br
|
||||
=link_to "Envoyer un mail de notification : #{key[1]}", send_mail_admin_m_odr_file_path(file, :slug => key[0]), :remote => false
|
||||
%br
|
||||
|
||||
=link_to "Modérer ce fichier", edit_admin_m_odr_file_path(file), :remote => true
|
||||
|
||||
@ -128,9 +132,22 @@
|
||||
=m_odr_rep_rib.reject_reason
|
||||
=simple_format m_odr_rep_rib.reject_reason_description if m_odr_rep_rib.reject_reason_description?
|
||||
|
||||
-if m_odr_rep_rib.mail_hists.count == 0
|
||||
=link_to "Envoyer un mail de notification", send_mail_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => false
|
||||
|
||||
|
||||
=link_to "Modérer ce RIB", edit_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => true
|
||||
|
||||
|
||||
-if @m_odr_rep.state == "Refusée"
|
||||
.red Offre refusée :
|
||||
-[["achat-hors-delais", "Achat hors délais"],["facture-illisible", "Facture illisible"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"]].each do |key|
|
||||
%br
|
||||
=link_to " Envoyer un mail de notification : #{key[1]}", send_mail_admin_m_odr_rep_path(@m_odr_rep, :slug => key[0]), :remote => false
|
||||
|
||||
-else
|
||||
=link_to "Marquer cette offre comme refusée", refuse_admin_m_odr_rep_path(@m_odr_rep)
|
||||
|
||||
|
||||
.columns.span_8{:style => "padding-left:20px;"}
|
||||
-file = @m_odr_rep.m_odr_files.order("id DESC").first
|
||||
@ -162,7 +179,9 @@
|
||||
-params[:search][:per_page] = params[:search][:per_page] || 50
|
||||
-per_page = params[:search][:per_page]
|
||||
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||
-@mail_hists = @m_odr_rep.mail_hists.page(page).per(per_page)
|
||||
-@mail_hists = @m_odr_rep.mail_hists
|
||||
-@mail_hists = sort_by_sorting(@mail_hists, "created_at DESC")
|
||||
-@mail_hists = @mail_hists.page(page).per(per_page)
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_hists}
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
%tr#mail_hist_row{:id => mail_hist.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:mail_type] = capture do
|
||||
%td
|
||||
=mail_hist.mail_type.slug if mail_hist.mail_type
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, mail_hist], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_mail_hist_path(mail_hist), :remote => true
|
||||
= link_to i(:eye), admin_mail_hist_path(mail_hist), :remote => true
|
||||
= link_to i(:eye), admin_mail_hist_path(mail_hist), :remote => false
|
||||
|
||||
|
||||
|
||||
|
@ -7,4 +7,7 @@
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @mail_hist
|
||||
=@mail_hist.subject
|
||||
%hr
|
||||
.content
|
||||
=simple_format @mail_hist.body
|
@ -266,5 +266,5 @@
|
||||
.clear
|
||||
|
||||
|
||||
= timer_watcher()
|
||||
= timer_watcher() if Rails.env.production?
|
||||
|
||||
|
@ -3,6 +3,8 @@ Rails.application.configure do
|
||||
|
||||
HOSTNAME="localhost:3000"
|
||||
|
||||
HOSTNAME="offres.market-inn.fr"
|
||||
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
@ -64,6 +66,9 @@ Rails.application.configure do
|
||||
# routes, locales, etc. This feature depends on the listen gem.
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
|
||||
|
||||
#config.action_mailer.delivery_method = :mailjet
|
||||
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
|
||||
|
||||
|
5
config/initializers/mailjet.rb
Normal file
5
config/initializers/mailjet.rb
Normal file
@ -0,0 +1,5 @@
|
||||
Mailjet.configure do |config|
|
||||
config.api_key = 'ed3dc73b653201199717a1a0167eba75'
|
||||
config.secret_key = '8533d4572966755e69f1886f907715a1'
|
||||
#config.default_from = 'nbally@olwen-capital.com'
|
||||
end
|
@ -15,6 +15,7 @@ Rails.application.routes.draw do
|
||||
resources :m_odr_remises do
|
||||
member do
|
||||
get :confirm
|
||||
get :export_sepa
|
||||
end
|
||||
collection do
|
||||
get :generate_all
|
||||
@ -116,6 +117,7 @@ Rails.application.routes.draw do
|
||||
resources :m_odr_files do
|
||||
member do
|
||||
get :download
|
||||
get :send_mail
|
||||
end
|
||||
collection do
|
||||
|
||||
@ -127,6 +129,9 @@ Rails.application.routes.draw do
|
||||
resources :m_odr_reps do
|
||||
member do
|
||||
get :generate_virement
|
||||
get :send_mail
|
||||
get :refuse
|
||||
|
||||
end
|
||||
collection do
|
||||
|
||||
@ -137,7 +142,7 @@ Rails.application.routes.draw do
|
||||
namespace :admin do
|
||||
resources :m_odr_rep_ribs do
|
||||
member do
|
||||
|
||||
get :send_mail
|
||||
end
|
||||
collection do
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user