1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

Notify all admins on the creation of a refund invoice

This commit is contained in:
Sylvain 2019-12-09 11:55:31 +01:00
parent 510c802ab1
commit 6aa3c0caeb
13 changed files with 65 additions and 6 deletions

View File

@ -10,6 +10,7 @@
- Configuration of phone number in members registration forms: can be required or optional, depending on `PHONE_REQUIRED` configuration - Configuration of phone number in members registration forms: can be required or optional, depending on `PHONE_REQUIRED` configuration
- Improved user experience in defining slots in the calendar management - Improved user experience in defining slots in the calendar management
- Improved notification email to the member when a rolling subscription is taken - Improved notification email to the member when a rolling subscription is taken
- Notify all admins on the creation of a refund invoice
- Calendar management: improved legend display and visual behavior - Calendar management: improved legend display and visual behavior
- Handle Ctrl^C in upgrade scripts - Handle Ctrl^C in upgrade scripts
- Updated moment-timezone - Updated moment-timezone

View File

@ -5,6 +5,8 @@
class Avoir < Invoice class Avoir < Invoice
belongs_to :invoice belongs_to :invoice
after_create :notify_admins_refund_created
validates :payment_method, inclusion: { in: %w[stripe cheque transfer none cash wallet] } validates :payment_method, inclusion: { in: %w[stripe cheque transfer none cash wallet] }
attr_accessor :invoice_items_ids attr_accessor :invoice_items_ids
@ -16,4 +18,12 @@ class Avoir < Invoice
def expire_subscription def expire_subscription
user.subscription.expire(DateTime.current) user.subscription.expire(DateTime.current)
end end
private
def notify_admins_refund_created
NotificationCenter.call type: 'notify_admin_refund_created',
receiver: User.admins,
attached_object: self
end
end end

View File

@ -47,6 +47,7 @@ class NotificationType
notify_admin_archive_complete notify_admin_archive_complete
notify_privacy_policy_changed notify_privacy_policy_changed
notify_admin_import_complete notify_admin_import_complete
notify_admin_refund_created
] ]
# deprecated: # deprecated:
# - notify_member_subscribed_plan_is_changed # - notify_member_subscribed_plan_is_changed

View File

@ -0,0 +1,5 @@
json.title notification.notification_type
json.description t('.refund_created',
AMOUNT: number_to_currency(notification.attached_object.total / 100.00),
USER: notification.attached_object.invoicing_profile&.full_name)
json.url notification_url(notification, format: :json)

View File

@ -0,0 +1,8 @@
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
<p><%= t('.body.refund_created',
AMOUNT: number_to_currency(@attached_object.total / 100.00),
INVOICE: @attached_object.invoice.reference,
USER: @attached_object.invoicing_profile&.full_name) %>
</p>
<p><a href="<%= "#{root_url}api/invoices/#{@attached_object.id}/download" %>" target="_blank"><%= t('.body.download') %></a></p>

View File

@ -351,6 +351,9 @@ en:
notify_privacy_policy_changed: notify_privacy_policy_changed:
policy_updated: "Privacy policy updated." policy_updated: "Privacy policy updated."
click_to_show: "Click here to consult" click_to_show: "Click here to consult"
notify_admin_refund_created:
refund_created: "A refund of %{AMOUNT} has been created for user %{USER}"
statistics: statistics:
# statistics tools for admins # statistics tools for admins
subscriptions: "Subscriptions" subscriptions: "Subscriptions"

View File

@ -351,6 +351,9 @@ es:
notify_privacy_policy_changed: notify_privacy_policy_changed:
policy_updated: "Privacy policy updated." # missing translation policy_updated: "Privacy policy updated." # missing translation
click_to_show: "Click here to consult" # missing translation click_to_show: "Click here to consult" # missing translation
notify_admin_refund_created:
refund_created: "A refund of %{AMOUNT} has been created for user %{USER}" # missing translation
statistics: statistics:
# statistics tools for admins # statistics tools for admins
subscriptions: "Suscripciones" subscriptions: "Suscripciones"

View File

@ -351,6 +351,8 @@ fr:
notify_privacy_policy_changed: notify_privacy_policy_changed:
policy_updated: "Nouvelle mise à jour de la Politique de confidentialité." policy_updated: "Nouvelle mise à jour de la Politique de confidentialité."
click_to_show: "Cliquez ici pour la consulter" click_to_show: "Cliquez ici pour la consulter"
notify_admin_refund_created:
refund_created: "Un avoir de %{AMOUNT} a été généré pour l'utilisateur %{USER}"
statistics: statistics:
# outil de statistiques pour les administrateurs # outil de statistiques pour les administrateurs

View File

@ -313,5 +313,11 @@ en:
content_html: "<p>We wish to inform you that we have just updated our privacy policy.</p><p>We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.</p><p>By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.</p>" content_html: "<p>We wish to inform you that we have just updated our privacy policy.</p><p>We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.</p><p>By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.</p>"
link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." link_to_policy: "Cliquez ici pour consultez la politique de confidentialité."
notify_admin_refund_created:
subject: "A refund has been generated"
body:
refund_created: "A refund of %{AMOUNT} has been generated on invoice %{INVOICE} of user %{USER}"
download: "Click here to download this refund invoice"
shared: shared:
hello: "Hello %{user_name}" hello: "Hello %{user_name}"

View File

@ -299,7 +299,7 @@ es:
warning_last_closed_period_over_1_year: "Please remind to periodically close your accounting periods. Last closed period ended at %{LAST_END}." warning_last_closed_period_over_1_year: "Please remind to periodically close your accounting periods. Last closed period ended at %{LAST_END}."
warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}." warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}."
notify_admin_archive_complete: #translation_missing notify_admin_archive_complete: #translation_missing
subject: "Archiving completed" subject: "Archiving completed"
body: body:
archive_complete: "You have closed the accounting period from %{START} to %{END}. Archiving of data is now complete." archive_complete: "You have closed the accounting period from %{START} to %{END}. Archiving of data is now complete."
@ -307,11 +307,17 @@ es:
here: "here." here: "here."
save_on_secured: "Remember that you must save this archive on a secured external support, which may be requested by the tax authorities during a check." save_on_secured: "Remember that you must save this archive on a secured external support, which may be requested by the tax authorities during a check."
notify_privacy_policy_changed: #translation_missing notify_privacy_policy_changed: #translation_missing
subject: "Privacy policy updated" subject: "Privacy policy updated"
body: body:
content_html: "<p>We wish to inform you that we have just updated our privacy policy.</p><p>We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.</p><p>By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.</p>" content_html: "<p>We wish to inform you that we have just updated our privacy policy.</p><p>We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.</p><p>By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.</p>"
link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." link_to_policy: "Cliquez ici pour consultez la politique de confidentialité."
notify_admin_refund_created: #translation_missing
subject: "A refund has been generated"
body:
refund_created: "A refund of %{AMOUNT} has been generated on invoice %{INVOICE} of user %{USER}"
download: "Click here to download this refund invoice"
shared: shared:
hello: "¡Hola %{user_name}!" hello: "¡Hola %{user_name}!"

View File

@ -313,5 +313,11 @@ fr:
content_html: "<p>Nous souhaitons vous signaler que nous venons de mettre à jour notre politique de confidentialité.</p><p>Nous pouvons apporter régulièrement des modifications à notre politique de confidentialité. Conformément à la réglementation, une notification vous sera envoyée à chaque mise à jour.</p><p>En accédant ou en utilisant nos services après la mise à jour de la Politique de confidentialité, nous considérerons que vous acceptez les termes de celle-ci, mises à jour comprises.</p>" content_html: "<p>Nous souhaitons vous signaler que nous venons de mettre à jour notre politique de confidentialité.</p><p>Nous pouvons apporter régulièrement des modifications à notre politique de confidentialité. Conformément à la réglementation, une notification vous sera envoyée à chaque mise à jour.</p><p>En accédant ou en utilisant nos services après la mise à jour de la Politique de confidentialité, nous considérerons que vous acceptez les termes de celle-ci, mises à jour comprises.</p>"
link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." link_to_policy: "Cliquez ici pour consultez la politique de confidentialité."
notify_admin_refund_created:
subject: "Un avoir a été généré"
body:
refund_created: "Un avoir de %{AMOUNT} a été généré sur la facture %{INVOICE} de l'utilisateur %{USER}"
download: "Cliquez ici pour télécharger cet avoir"
shared: shared:
hello: "Bonjour %{user_name}" hello: "Bonjour %{user_name}"

View File

@ -299,7 +299,7 @@ pt:
warning_last_closed_period_over_1_year: "Please remind to periodically close your accounting periods. Last closed period ended at %{LAST_END}." warning_last_closed_period_over_1_year: "Please remind to periodically close your accounting periods. Last closed period ended at %{LAST_END}."
warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}." warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}."
notify_admin_archive_complete: #translation_missing notify_admin_archive_complete: #translation_missing
subject: "Archiving completed" subject: "Archiving completed"
body: body:
archive_complete: "You have closed the accounting period from %{START} to %{END}. Archiving of data is now complete." archive_complete: "You have closed the accounting period from %{START} to %{END}. Archiving of data is now complete."
@ -307,11 +307,17 @@ pt:
here: "here." here: "here."
save_on_secured: "Remember that you must save this archive on a secured external support, which may be requested by the tax authorities during a check." save_on_secured: "Remember that you must save this archive on a secured external support, which may be requested by the tax authorities during a check."
notify_privacy_policy_changed: #translation_missing notify_privacy_policy_changed: #translation_missing
subject: "Privacy policy updated" subject: "Privacy policy updated"
body: body:
content_html: "<p>We wish to inform you that we have just updated our privacy policy.</p><p>We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.</p><p>By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.</p>" content_html: "<p>We wish to inform you that we have just updated our privacy policy.</p><p>We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.</p><p>By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.</p>"
link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." link_to_policy: "Cliquez ici pour consultez la politique de confidentialité."
notify_admin_refund_created: #translation_missing
subject: "A refund has been generated"
body:
refund_created: "A refund of %{AMOUNT} has been generated on invoice %{INVOICE} of user %{USER}"
download: "Click here to download this refund invoice"
shared: shared:
hello: "Olá %{user_name}" hello: "Olá %{user_name}"

View File

@ -349,8 +349,10 @@ pt:
notify_admin_archive_complete: # missing translation notify_admin_archive_complete: # missing translation
archive_complete: "Data archiving from %{START} to %{END} is done. <a href='api/accounting_periods/%{ID}/archive' target='_blank'>click here to download</a>. Remember to save it on an external secured media." # missing translation archive_complete: "Data archiving from %{START} to %{END} is done. <a href='api/accounting_periods/%{ID}/archive' target='_blank'>click here to download</a>. Remember to save it on an external secured media." # missing translation
notify_privacy_policy_changed: notify_privacy_policy_changed:
policy_updated: "Privacy policy updated." # missing translation policy_updated: "Privacy policy updated." # missing translation
click_to_show: "Click here to consult" # missing translation click_to_show: "Click here to consult" # missing translation
notify_admin_refund_created:
refund_created: "A refund of %{AMOUNT} has been created for user %{USER}" # missing translation
statistics: statistics:
# statistics tools for admins # statistics tools for admins