Fixes for converting a quote to invoice (#3727)

This commit is contained in:
David Bomba 2020-05-20 17:45:03 +10:00 committed by GitHub
parent 8ab0238f3f
commit afbb605af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -528,6 +528,21 @@ class QuoteController extends BaseController
return response()->json(['message' => 'Email Sent!'], 200);
}
if($action == 'convert') {
$this->entity_type = Invoice::class;
$this->entity_transformer = InvoiceTransformer::class;
$invoices = $quotes->map(function ($quote, $key) use ($action) {
if (auth()->user()->can('edit', $quote)) {
$invoice = $quote->service()->convertToInvoice();
return $invoice->id;
}
});
return $this->listResponse(Invoice::withTrashed()->whereIn('id', $invoices)->company());
}
/*
* Send the other actions to the switch
*/
@ -642,14 +657,6 @@ class QuoteController extends BaseController
}
return $this->itemResponse($quote->service()->approve()->save());
break;
case 'convert':
$this->entity_type = Invoice::class;
$this->entity_transformer = InvoiceTransformer::class;
return $this->itemResponse($quote->service()->convertToInvoice());
break;
case 'history':
# code...

View File

@ -134,12 +134,11 @@ class QuoteService
$invoice->number = null;
$invoice->save();
$invoice->service()
return $invoice->service()
->markSent()
->createInvitations()
->save();
return $invoice;
}
/**