2019-05-24 07:13:17 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-24 07:13:17 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-24 07:13:17 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-24 07:13:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Factory;
|
|
|
|
|
|
|
|
use App\Models\Invoice;
|
|
|
|
use App\Models\RecurringInvoice;
|
|
|
|
|
|
|
|
class InvoiceToRecurringInvoiceFactory
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
public static function create(Invoice $invoice): RecurringInvoice
|
2019-12-30 22:59:12 +01:00
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
$recurring_invoice = new RecurringInvoice();
|
2019-05-24 07:13:17 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_DRAFT;
|
|
|
|
$recurring_invoice->discount = $invoice->discount;
|
|
|
|
$recurring_invoice->number = '';
|
|
|
|
$recurring_invoice->is_amount_discount = $invoice->is_amount_discount;
|
|
|
|
$recurring_invoice->po_number = $invoice->po_number;
|
|
|
|
$recurring_invoice->footer = $invoice->footer;
|
|
|
|
$recurring_invoice->terms = $invoice->terms;
|
|
|
|
$recurring_invoice->public_notes = $invoice->public_notes;
|
|
|
|
$recurring_invoice->private_notes = $invoice->private_notes;
|
|
|
|
$recurring_invoice->date = date_create()->format($invoice->client->date_format());
|
|
|
|
$recurring_invoice->due_date = $invoice->due_date; //todo calculate based on terms
|
|
|
|
$recurring_invoice->is_deleted = $invoice->is_deleted;
|
|
|
|
$recurring_invoice->line_items = $invoice->line_items;
|
|
|
|
$recurring_invoice->tax_name1 = $invoice->tax_name1;
|
|
|
|
$recurring_invoice->tax_rate1 = $invoice->tax_rate1;
|
|
|
|
$recurring_invoice->tax_name2 = $invoice->tax_name2;
|
|
|
|
$recurring_invoice->tax_rate2 = $invoice->tax_rate2;
|
|
|
|
$recurring_invoice->custom_value1 = $invoice->custom_value1;
|
|
|
|
$recurring_invoice->custom_value2 = $invoice->custom_value2;
|
|
|
|
$recurring_invoice->custom_value3 = $invoice->custom_value3;
|
|
|
|
$recurring_invoice->custom_value4 = $invoice->custom_value4;
|
|
|
|
$recurring_invoice->amount = $invoice->amount;
|
2021-01-19 22:30:04 +01:00
|
|
|
// $recurring_invoice->balance = $invoice->balance;
|
2019-12-30 22:59:12 +01:00
|
|
|
$recurring_invoice->user_id = $invoice->user_id;
|
|
|
|
$recurring_invoice->client_id = $invoice->client_id;
|
|
|
|
$recurring_invoice->company_id = $invoice->company_id;
|
|
|
|
$recurring_invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
|
|
|
|
$recurring_invoice->last_sent_date = null;
|
|
|
|
$recurring_invoice->next_send_date = null;
|
|
|
|
$recurring_invoice->remaining_cycles = 0;
|
2021-01-24 07:44:14 +01:00
|
|
|
$recurring_invoice->paid_to_date = 0;
|
2019-05-24 07:13:17 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
return $recurring_invoice;
|
|
|
|
}
|
2019-05-24 07:13:17 +02:00
|
|
|
}
|