1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

(feature) Improved attached ICS file texts, in reservations emails

This commit is contained in:
Sylvain 2022-07-27 12:04:17 +02:00
parent 28e9d69237
commit 445e63b44c
5 changed files with 36 additions and 11 deletions

View File

@ -8,6 +8,7 @@
- Updated rails locales files
- Usage of the rails logger instead of printing to standard output
- Optionnaly add a username column to the member list (#375)
- Improved attached ICS file texts, in reservations emails
- Fix a bug: canceled trainings are still shown on the public profile page
- Fix a bug: prevent same slot booking feature ignores canceled reservations
- Fix a bug: wrong currency on invoices files

View File

@ -54,7 +54,7 @@ class NotificationsMailer < NotifyWith::NotificationsMailer
end
def notify_member_create_reservation
attachments[@attached_object.ics_filename] = @attached_object.to_ics.encode(Encoding::ISO_8859_15)
attachments[@attached_object.ics_filename] = @attached_object.to_ics.encode(Encoding::UTF_8)
mail(to: @recipient.email,
subject: t('notifications_mailer.notify_member_create_reservation.subject'),
template_name: 'notify_member_create_reservation')

View File

@ -24,8 +24,8 @@ module ICalendarConcern
cal.event do |e|
e.dtstart = start_time
e.dtend = group_slots.last[:end_at]
e.summary = I18n.t('reservation_ics.summary', TYPE: I18n.t("reservation_ics.type.#{reservable.class.name}"))
e.description = I18n.t('reservation_ics.description', COUNT: group_slots.count, ITEM: reservable.name)
e.summary = title
e.description = I18n.t('reservation_ics.description_slot', COUNT: group_slots.count, ITEM: reservable.name)
e.ip_class = 'PRIVATE'
e.alarm do |a|
@ -38,5 +38,33 @@ module ICalendarConcern
end
cal
end
private
def title
case reservable_type
when 'Machine', 'Training', 'Space'
reservable.name
when 'Event'
reservable.title
else
Rails.logger.warn "Unexpected reservable type #{reservable_type}"
reservable_type
end
end
def description(group_slots)
case reservable_type
when 'Machine', 'Space'
I18n.t('reservation_ics.description_slot', COUNT: group_slots.count, ITEM: reservable.name)
when 'Training'
I18n.t('reservation_ics.description_training', TYPE: reservable.name)
when 'Event'
I18n.t('reservation_ics.description_event', NUMBER: nb_reserve_places + tickets.map(&:booked).reduce(:+))
else
Rails.logger.warn "Unexpected reservable type #{reservable_type}"
I18n.t('reservation_ics.description_slot', COUNT: group_slots.count, ITEM: reservable_type)
end
end
end
end

View File

@ -249,7 +249,7 @@ class PDF::Invoice < Prawn::Document
data += [[I18n.t('invoices.including_amount_payed_on_ordering'), number_to_currency(total)]]
# checking the round number
rounded = sprintf('%.2f', total_vat / 100.00).to_f + sprintf('%.2f', total_ht / 100.00)
rounded = (sprintf('%.2f', total_vat / 100.00).to_f + sprintf('%.2f', total_ht / 100.00).to_f).to_s
if rounded != sprintf('%.2f', total_calc)
Rails.logger.error 'rounding the numbers cause an invoice inconsistency. ' \
"Total expected: #{sprintf('%.2f', total_calc)}, total computed: #{rounded}"

View File

@ -245,13 +245,9 @@ en:
reservations: "Reservations"
available_seats: "Available seats"
reservation_ics:
summary: "%{TYPE} reservation"
type:
Machine: "Machine"
Space: "Space"
Event: "Event"
Training: "Training"
description: "You have reserved %{COUNT} slots of %{ITEM}"
description_slot: "You have booked %{COUNT} slots of %{ITEM}"
description_training: "You have booked a %{TYPE} training"
description_event: "You have booked %{NUMBER} tickets for this event"
alarm_summary: "Remind your reservation"
roles:
member: "Member"