Commit 6791d0db authored by gwendal's avatar gwendal
Browse files

add the user who edit the service sale template in the mail to treasurer + refactoring

parent 50ae6b0d
......@@ -36,6 +36,7 @@ class ServiceSaleTemplatesController < WebController
# PATCH/PUT /service_sale_templates/1
def update
if @service_sale_template.update(service_sale_template_params)
TreasurerMailer.notify_service_sale_template_change(@service_sale_template, @service_sale_template.previous_changes, current_member).deliver_now
redirect_to @service_sale_template.service, notice: 'Service sale template was successfully updated.'
else
render :edit
......
......@@ -16,10 +16,17 @@ class TreasurerMailer < ActionMailer::Base
end
end
def notify_service_sale_template_change(sst, changes)
def notify_service_sale_template_change(sst, changes, user)
@sst = sst
@changes = changes
mail(to: "#{Settings.mail.treasurer}", subject: "[#{Settings.organization_name}] #{t('.subject', login: @sst.service.login)}")
@user = user
mail(
to: "#{Settings.mail.treasurer}",
subject: "[#{Settings.organization_name}] #{t('.subject', login: @sst.service.login)}"
) do |format|
format.text
format.html
end
end
def notify_invoice_is_cancelled(invoice)
......
......@@ -6,7 +6,6 @@ class ServiceSaleTemplate < ActiveRecord::Base
acts_as_currency_value :amount, :currency_code => "EUR"
after_initialize :setup
after_save :notify_service_sale_template_change
validates_presence_of :description
......@@ -100,8 +99,4 @@ class ServiceSaleTemplate < ActiveRecord::Base
end
end
def notify_service_sale_template_change
TreasurerMailer.notify_service_sale_template_change(self, self.changes).deliver_now
# MemberMailer.notify_service_sale_template_change(self, self.changes).deliver_now
end
end
<%= t('.body',
login: @sst.service.login,
sst_address: polymorphic_url(@sst),
user: @user.name,
sst_change: @changes.to_h.to_yaml
) %>
<%= t('.service_change', login: @sst.service.login) %>
<%= polymorphic_url(@sst) %>
<%= @changes.to_h.to_yaml %>
......@@ -556,7 +556,13 @@ fr:
notify_service_sale_template_change:
hi: "Bonjour"
subject: "Changement d'item de facturation %{login}"
service_change: "Le service %{login} a eu un changement d'élément de facturation :"
body: |
Le service %{login} a eu un changement d'élément de facturation, enregistré par %{user}.
Il est disponible à l'adresse : %{sst_address}.
Les changements sont :
%{sst_change}
notify_invoice_is_cancelled:
subject: "Facture annulée"
invoice_cancelled: "La facture %{id} a été annulée."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment