From 90d132ad20fe89ce4ceb415205203ecd0bc3186e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristia=CC=81n=20Feldsam?= Date: Mon, 29 Apr 2019 12:06:38 +0200 Subject: [PATCH] BasePaymentDriver - Convert Quote - Fix Invitation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristián Feldsam --- app/Models/Invoice.php | 14 ++++++++++++++ app/Ninja/PaymentDrivers/BasePaymentDriver.php | 1 + 2 files changed, 15 insertions(+) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index ad4ba8d42566..9e5e1c55c8b0 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -542,6 +542,20 @@ class Invoice extends EntityModel implements BalanceAffecting }); } + /** + * @return Invitation|null + */ + public function invitationByContactId(int $contactId) + { + foreach ($this->invitations as $invitation) { + if ($invitation->contact_id === $contactId) { + return $invitation; + } + } + + return null; + } + /** * @param $typeId * diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php index 8103b4f7010a..9bbc232decd5 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -703,6 +703,7 @@ class BasePaymentDriver if($invoice->isQuote()) { $invoiceService = app('App\Services\InvoiceService'); $invoice = $invoiceService->convertQuote($invoice); + $invitation = $invoice->invitationByContactId($invitation->contact_id); } $invoice->markSentIfUnsent();