Invoice confirmation email is still sent twice

Created on 2 May 2025, 11 days ago

Problem/Motivation

I thought I had fixed this with 🐛 Invoice email is sent twice RTBC but it turns out the confirmation is still sent twice.
I tracked down the issue and figured out this is caused by the InvoiceConfirmationEmail calling InvoiceFileManager::getInvoiceFile() which saves the invoice.

Saving the invoice from a post save is problematic and causes the same transition to be fired twice.
The best fix would probably be to ensure the same transition isn't fired twice from the State machine module itself.

I think this is not an easy fix though as we don't have an ID to rely on that we could use in a static cache to not retrigger the same event twice...

We could do several things here:

  1. Call InvoiceFileManager::getInvoiceFile() from the invoice confirmation subscriber (with an extra parameter indicating the invoice should not be saved).
  2. Add a static cache of invoice IDS that we we check from InvoiceConfirmationSubscriber::sendInvoiceConfirmation()

I think we should do both.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇱Israel jsacksick

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024