2020-01-30 02:27:22 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-01-30 02:27:22 +01:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-01-30 02:27:22 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-01-30 02:27:22 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Factory;
|
|
|
|
|
|
|
|
use App\Models\Credit;
|
|
|
|
|
|
|
|
class CloneCreditFactory
|
|
|
|
{
|
|
|
|
public static function create(Credit $credit, $user_id) : ?Credit
|
|
|
|
{
|
|
|
|
$clone_credit = $credit->replicate();
|
|
|
|
$clone_credit->status_id = credit::STATUS_DRAFT;
|
|
|
|
$clone_credit->number = null;
|
|
|
|
$clone_credit->date = null;
|
|
|
|
$clone_credit->due_date = null;
|
|
|
|
$clone_credit->partial_due_date = null;
|
|
|
|
$clone_credit->user_id = $user_id;
|
2021-01-19 22:30:04 +01:00
|
|
|
//$clone_credit->balance = $credit->amount;
|
2020-01-30 02:27:22 +01:00
|
|
|
$clone_credit->line_items = $credit->line_items;
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-01-30 02:27:22 +01:00
|
|
|
return $clone_credit;
|
|
|
|
}
|
|
|
|
}
|