Repository navigation
fix(refunds): give back the tax an order was charged, to the cent #680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
207702c
1139bfb
b5355c2
3238d69
0cf12e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,33 @@ public function getByPaymentGatewayCartIdExclusiveLock(string $payment_gateway_c | |
| ->getOneOrNullResult(); | ||
| } | ||
|
|
||
| /** | ||
| * @param int $order_id | ||
| * @return SummitOrder|null | ||
| */ | ||
| public function getByIdExclusiveLockRefreshingRefunds(int $order_id): ?SummitOrder | ||
| { | ||
| $order = $this->getByIdExclusiveLock($order_id); | ||
| if (!$order instanceof SummitOrder) return null; | ||
|
|
||
| // A queue worker keeps its entity manager from one job to the next, so | ||
| // it can hold the order's tickets and their refund requests as they | ||
| // were before the lock was granted. Read them again, in one query. | ||
| $this->getEntityManager() | ||
| ->createQueryBuilder() | ||
| ->select("t, r, tr") | ||
| ->from(SummitAttendeeTicket::class, "t") | ||
| ->leftJoin("t.refund_requests", "r") | ||
| ->leftJoin("r.refunded_taxes", "tr") | ||
| ->where("t.order = :order") | ||
| ->setParameter("order", $order) | ||
|
Comment on lines
+106
to
+111
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed, this is a real gap.
How it happens:
The order lock doesn't prevent this. It serializes the transactions but does not refresh the collection the worker already holds. Rooting the query at the order and fetch-joining its tickets fixes it ( |
||
| ->getQuery() | ||
| ->setHint(\Doctrine\ORM\Query::HINT_REFRESH, true) | ||
| ->getResult(); | ||
|
|
||
| return $order; | ||
| } | ||
|
|
||
| /** | ||
| * @param string $email | ||
| * @return mixed | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.