Skip to content

Attach a calendar file of the reservations to the order placed e-mail - #1180

Open
grandnode-dev wants to merge 1 commit into
developfrom
feature/reservation-ics-attachment
Open

grandnode-dev wants to merge 1 commit into
developfrom
feature/reservation-ics-attachment

Conversation

@grandnode-dev

Copy link
Copy Markdown
Member

Type: feature

Issue

A customer who booked a reservation product got the dates only as text in the order e-mail. There was no way to add the booking to a calendar.

Solution

  • The customer's order placed e-mail now carries calendar.ics (text/calendar; method=PUBLISH) whenever the order has a reservation item. There is no setting (D6 in the reservations roadmap).
  • One event per reservation item:
    • Summary: the product name, translated to the order's language.
    • Location: the store name.
    • Description: "Order #N", from the existing Order.Order# resource, so no new resources.
    • UID: the order item id plus the store's host.
  • Products by days get all-day events (DTSTART;VALUE=DATE). The dates are in the store's time zone (R16), and the event includes the end date shown in the order, the day the customer gives the item back.
  • Products by hours or minutes get a UTC start, and the end is the start plus the product's interval.
  • The writer: CalendarFileWriter in Grand.Business.Messages/Calendar is small and needs no new package. It writes RFC 5545 text: CRLF line endings, escaping of \ ; , and new lines, and lines folded at 75 octets without splitting a UTF-8 character.
  • Building the events: GetReservationCalendarCommand (handler in Grand.Business.Messages) builds them from the order's items. OrderMessageProviderService.SendOrderPlacedCustomerMessage asks for it. When building the calendar fails, the e-mail goes without it and the error is logged.
  • Storing the file: the text is kept on the queued e-mail (QueuedEmail.CalendarFile), so it is deleted with the e-mail and needs no cleanup, unlike the invoice download.
    • QueuedMessagesSendScheduleTask passes it to IEmailSender.SendEmail, which attaches it.
    • Requeue in Admin → Message queue copies it.
    • The message queue screen does not show it.
  • Other e-mails: order paid, shipped and the rest carry no calendar.

Breaking changes

  • IEmailSender.SendEmail has a new optional calendarFile parameter before the CancellationToken.
  • IMessageProviderService.SendNotification has a new optional calendarFile parameter at the end.
  • Implementations in plugins need a rebuild.
  • QueuedEmail has a new nullable field CalendarFile.

Testing

  1. As a customer, order a reservation product by hours (e.g. Climbing Wall Session, one slot) and one by days (e.g. the tent, a range of days).
  2. When the message queue sends the order placed e-mail, the customer's message has calendar.ics. Opening it offers to add both events:
    • the slot at its time, as long as the product's interval;
    • the tent as all-day events over the booked days, end date included.
  3. Place an order without a reservation product: its order placed e-mail has no attachment.
  4. The store owner's "new order" e-mail has no calendar.

Unit tests:

  • CalendarFileWriterTests: all-day and timed events, a local time converted to UTC, escaping, folding, two events in one calendar.
  • GetReservationCalendarCommandHandlerTests:
    • day range in the store's time zone;
    • day without an end date;
    • hour and minute intervals;
    • items without a reservation and deleted products skipped;
    • no reservation means no calendar.
  • OrderMessageProviderServiceCalendarTests:
    • order placed attaches the calendar;
    • no calendar when there is no reservation;
    • when building the calendar fails, the e-mail is still sent;
    • order paid has none.
  • QueuedMessagesSendScheduleTaskTests: the calendar is passed to the sender.

Full dotnet test GrandNode.slnx is green. Checkout and Catalog failed only in the parallel run and pass on their own.

E2E on a clone of the shared reservations DB, with the e-mail account pointed at a local SMTP sink:

  • The customer ordered the climbing wall 14 Dec 09:00Z slot and the tent for 11–14 Jan.
  • The "Order Label at local plugins #1 confirmed" e-mail to the customer had calendar.ics:
    • DTSTART:20261214T090000Z / DTEND:20261214T100000Z;
    • DTSTART;VALUE=DATE:20270111 / DTEND;VALUE=DATE:20270115;
    • LOCATION is the store name and DESCRIPTION "Order Label at local plugins #1";
    • CRLF only.
  • The store owner's e-mail had none.

Copilot AI balanced review requested due to automatic review settings December 3, 2026 17:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Comment on lines +369 to +374
catch (Exception ex)
{
//the e-mail goes without the calendar rather than not at all
_logger.LogError(ex, "Error creating the calendar file of the order {OrderNumber}", order.OrderNumber);
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants