1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 11:12:43 +01:00
invoiceninja/app/Factory/CloneInvoiceToQuoteFactory.php

56 lines
1.9 KiB
PHP
Raw Normal View History

2019-04-23 14:22:13 +02:00
<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2019-05-11 05:32:07 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 05:32:07 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
2019-04-23 14:22:13 +02:00
namespace App\Factory;
use App\Models\Invoice;
use App\Models\Quote;
class CloneInvoiceToQuoteFactory
{
public static function create(Invoice $invoice, $user_id) : ?Quote
{
$quote = new Quote();
$quote->discount = $invoice->discount;
$quote->is_amount_discount = $invoice->is_amount_discount;
$quote->po_number = $invoice->po_number;
$quote->is_deleted = false;
$quote->footer = $invoice->footer;
$quote->public_notes = $invoice->public_notes;
$quote->private_notes = $invoice->private_notes;
$quote->terms = $invoice->terms;
$quote->tax_name1 = $invoice->tax_name1;
$quote->tax_rate1 = $invoice->tax_rate1;
$quote->tax_name2 = $invoice->tax_name2;
$quote->tax_rate2 = $invoice->tax_rate2;
$quote->tax_rate3 = $invoice->tax_rate3;
$quote->tax_rate3 = $invoice->tax_rate3;
$quote->custom_value1 = $invoice->custom_value1;
$quote->custom_value2 = $invoice->custom_value2;
$quote->custom_value3 = $invoice->custom_value3;
$quote->custom_value4 = $invoice->custom_value4;
$quote->amount = $invoice->amount;
2021-01-19 22:30:04 +01:00
//$quote->balance = $invoice->amount;
$quote->partial = $invoice->partial;
$quote->partial_due_date = $invoice->partial_due_date;
$quote->last_viewed = $invoice->last_viewed;
2019-04-23 14:22:13 +02:00
$quote->status_id = Quote::STATUS_DRAFT;
$quote->number = '';
$quote->date = null;
$quote->due_date = null;
$quote->partial_due_date = null;
$quote->line_items = $invoice->line_items;
2019-04-23 14:22:13 +02:00
return $quote;
}
}