1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00

Fix for approving quotes

This commit is contained in:
Hillel Coren 2016-07-20 10:05:19 +03:00
parent 5be6abfa93
commit 97a56fac13
2 changed files with 7 additions and 21 deletions

View File

@ -11,11 +11,6 @@ class QuoteInvitationWasApproved extends Event
public $quote; public $quote;
/**
* @var Invoice
*/
public $invoice;
/** /**
* @var Invitation * @var Invitation
*/ */
@ -28,10 +23,9 @@ class QuoteInvitationWasApproved extends Event
* @param Invoice $invoice * @param Invoice $invoice
* @param Invitation $invitation * @param Invitation $invitation
*/ */
public function __construct($quote, Invoice $invoice, Invitation $invitation) public function __construct(Invoice $quote, Invitation $invitation)
{ {
$this->quote = $quote; $this->quote = $quote;
$this->invoice = $invoice;
$this->invitation = $invitation; $this->invitation = $invitation;
} }
} }

View File

@ -127,11 +127,11 @@ class InvoiceService extends BaseService
{ {
$account = $quote->account; $account = $quote->account;
if (!$quote->isType(INVOICE_TYPE_QUOTE) || $quote->quote_invoice_id) { if ( ! $account->hasFeature(FEATURE_QUOTES) || ! $quote->isType(INVOICE_TYPE_QUOTE) || $quote->quote_invoice_id) {
return null; return null;
} }
if ($account->auto_convert_quote || ! $account->hasFeature(FEATURE_QUOTES)) { if ($account->auto_convert_quote) {
$invoice = $this->convertQuote($quote); $invoice = $this->convertQuote($quote);
foreach ($invoice->invitations as $invoiceInvitation) { foreach ($invoice->invitations as $invoiceInvitation) {
@ -139,21 +139,13 @@ class InvoiceService extends BaseService
$invitation = $invoiceInvitation; $invitation = $invoiceInvitation;
} }
} }
event(new QuoteInvitationWasApproved($quote, $invoice, $invitation));
return $invoice;
} else { } else {
$quote->markApproved(); $quote->markApproved();
event(new QuoteInvitationWasApproved($quote, null, $invitation));
foreach ($quote->invitations as $invoiceInvitation) {
if ($invitation->contact_id == $invoiceInvitation->contact_id) {
return $invoiceInvitation->invitation_key;
}
}
} }
event(new QuoteInvitationWasApproved($quote, $invitation));
return $invitation->invitation_key;
} }
public function getDatatable($accountId, $clientPublicId = null, $entityType, $search) public function getDatatable($accountId, $clientPublicId = null, $entityType, $search)