1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Factory/CloneCreditFactory.php
Benjamin Beganović 67c6ac1bc2
Test fixes & code improvements (#3267)
- Updated rules for storing credits
- Fixed route controller
- Added test for crud operations
- Added new $invoice object in MockAccountData
- Added & registered CreditPolicy
2020-01-30 14:02:25 +11:00

35 lines
919 B
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
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;
$clone_credit->balance = $credit->amount;
$clone_credit->line_items = $credit->line_items;
$clone_credit->backup = null;
return $clone_credit;
}
}