1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 08:02:40 +01:00
invoiceninja/app/Factory/CloneCreditFactory.php

34 lines
888 B
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @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)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Factory;
use App\Models\Credit;
class CloneCreditFactory
{
2024-01-14 05:05:00 +01:00
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;
$clone_credit->line_items = $credit->line_items;
return $clone_credit;
}
}