2020-01-03 10:34:10 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-01-03 10:34:10 +01:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Factory;
|
|
|
|
|
2020-02-26 11:06:08 +01:00
|
|
|
use App\Models\Client;
|
2020-01-03 10:34:10 +01:00
|
|
|
use App\Models\Credit;
|
|
|
|
|
|
|
|
class CreditFactory
|
|
|
|
{
|
2020-02-26 11:46:35 +01:00
|
|
|
public static function create(int $company_id, int $user_id, object $settings= null, Client $client = null) :Credit
|
2020-01-03 10:34:10 +01:00
|
|
|
{
|
|
|
|
$credit = new Credit();
|
|
|
|
$credit->status_id = Credit::STATUS_DRAFT;
|
|
|
|
$credit->number = null;
|
|
|
|
$credit->discount = 0;
|
|
|
|
$credit->is_amount_discount = true;
|
|
|
|
$credit->po_number = '';
|
2020-03-03 10:44:26 +01:00
|
|
|
$credit->footer = '';
|
|
|
|
$credit->terms = '';
|
|
|
|
$credit->public_notes = '';
|
2020-01-03 10:34:10 +01:00
|
|
|
$credit->private_notes = '';
|
|
|
|
$credit->date = null;
|
|
|
|
$credit->due_date = null;
|
|
|
|
$credit->partial_due_date = null;
|
|
|
|
$credit->is_deleted = false;
|
|
|
|
$credit->line_items = json_encode([]);
|
|
|
|
$credit->tax_name1 = '';
|
|
|
|
$credit->tax_rate1 = 0;
|
|
|
|
$credit->tax_name2 = '';
|
|
|
|
$credit->tax_rate2 = 0;
|
|
|
|
$credit->custom_value1 = 0;
|
|
|
|
$credit->custom_value2 = 0;
|
|
|
|
$credit->custom_value3 = 0;
|
|
|
|
$credit->custom_value4 = 0;
|
|
|
|
$credit->amount = 0;
|
|
|
|
$credit->balance = 0;
|
|
|
|
$credit->partial = 0;
|
|
|
|
$credit->user_id = $user_id;
|
|
|
|
$credit->company_id = $company_id;
|
|
|
|
$credit->recurring_id = null;
|
|
|
|
|
|
|
|
return $credit;
|
|
|
|
}
|
|
|
|
}
|