1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Save documents to Company Entity

This commit is contained in:
David Bomba 2021-01-13 21:12:14 +11:00
parent a6121295c2
commit 3b02dd56e0
5 changed files with 33 additions and 8 deletions

View File

@ -37,7 +37,7 @@ class CloneQuoteToInvoiceFactory
$invoice->due_date = null;
$invoice->partial_due_date = null;
$invoice->number = null;
$invoice->date = now()->format('Y-m-d');
return $invoice;
}
}

View File

@ -32,6 +32,7 @@ use App\Transformers\CompanyTransformer;
use App\Transformers\CompanyUserTransformer;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\SavesDocuments;
use App\Utils\Traits\Uploadable;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
@ -47,6 +48,7 @@ class CompanyController extends BaseController
use DispatchesJobs;
use MakesHash;
use Uploadable;
use SavesDocuments;
protected $entity_type = Company::class;
@ -402,14 +404,17 @@ class CompanyController extends BaseController
*/
public function update(UpdateCompanyRequest $request, Company $company)
{
if ($request->hasFile('company_logo') || (is_array($request->input('settings')) && !array_key_exists('company_logo', $request->input('settings')))) {
if ($request->hasFile('company_logo') || (is_array($request->input('settings')) && !array_key_exists('company_logo', $request->input('settings'))))
$this->removeLogo($company);
}
$company = $this->company_repo->save($request->all(), $company);
$company->saveSettings($request->input('settings'), $company);
if ($request->has('documents'))
$this->saveDocuments($request->input('documents'), $company, false);
$this->uploadLogo($request->file('company_logo'), $company, $company);
return $this->itemResponse($company);

View File

@ -36,8 +36,26 @@ class CreateInvoicePdf implements ShouldQueue
{
MultiDB::setDb($event->company->db);
$event->invoice->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
});
if(isset($event->invoice))
{
$event->invoice->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
});
}
if(isset($event->quote))
{
$event->quote->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
});
}
if(isset($event->credit))
{
$event->credit->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
});
}
}
}

View File

@ -226,6 +226,7 @@ class EventServiceProvider extends ServiceProvider
],
CreditWasUpdated::class => [
UpdatedCreditActivity::class,
CreateInvoicePdf::class,
],
CreditWasEmailedAndFailed::class => [
],
@ -334,6 +335,7 @@ class EventServiceProvider extends ServiceProvider
],
QuoteWasUpdated::class => [
QuoteUpdatedActivity::class,
CreateInvoicePdf::class,
],
QuoteWasEmailed::class => [
QuoteEmailActivity::class,

View File

@ -58,9 +58,9 @@ class QuoteService
return $this;
}
$convert_quote = new ConvertQuote($this->quote->client);
$convert_quote = (new ConvertQuote($this->quote->client))->run($this->quote);
$this->invoice = $convert_quote->run($this->quote);
$this->invoice = $convert_quote;
$this->quote->fresh();