1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 09:04:35 +01:00
invoiceninja/app/Services/Quote/ConvertQuote.php

55 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2020-07-01 03:06:40 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2020-07-01 03:06:40 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2020-07-01 03:06:40 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\Quote;
use App\Factory\CloneQuoteToInvoiceFactory;
2020-06-02 12:19:29 +02:00
use App\Models\Quote;
use App\Repositories\InvoiceRepository;
class ConvertQuote
{
private $client;
private $invoice_repo;
public function __construct($client)
{
$this->client = $client;
$this->invoice_repo = new InvoiceRepository();
}
/**
* @param $quote
* @return mixed
*/
public function run($quote)
{
2020-10-28 11:10:49 +01:00
$invoice = CloneQuoteToInvoiceFactory::create($quote, $quote->user_id);
2020-11-03 13:35:05 +01:00
$invoice = $this->invoice_repo->save([], $invoice);
$invoice->fresh();
$invoice->service()
2021-01-19 22:30:04 +01:00
// ->markSent()
// ->createInvitations()
->save();
$quote->invoice_id = $invoice->id;
2020-06-02 12:19:29 +02:00
$quote->status_id = Quote::STATUS_CONVERTED;
$quote->save();
// maybe should return invoice here
return $invoice;
}
}