mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 05:44:37 -04:00
Define the Client Statement Class
This commit is contained in:
parent
c5ac9cacaf
commit
9e5417ab1c
96
app/DataMapper/Schedule/ClientStatement.php
Normal file
96
app/DataMapper/Schedule/ClientStatement.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
|
class ClientStatement
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the template name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $template = 'client_statement';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of clients hashed_ids
|
||||||
|
*
|
||||||
|
* Leave blank if this action should apply to all clients
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public array $clients = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The consts to be used to define the date_range variable of the statement
|
||||||
|
*/
|
||||||
|
public const THIS_MONTH = 'this_month';
|
||||||
|
public const THIS_QUARTER = 'this_quarter';
|
||||||
|
public const THIS_YEAR = 'this_year';
|
||||||
|
public const PREVIOUS_MONTH = 'previous_month';
|
||||||
|
public const PREVIOUS_QUARTER = 'previous_quarter';
|
||||||
|
public const PREVIOUS_YEAR = 'previous_year';
|
||||||
|
public const CUSTOM_RANGE = "custom_range";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date range the statement should include
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $date_range = 'this_month';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a custom range is select for the date range then
|
||||||
|
* the start_date should be supplied in Y-m-d format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $start_date = '';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a custom range is select for the date range then
|
||||||
|
* the end_date should be supplied in Y-m-d format
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $end_date = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag which allows the payment table
|
||||||
|
* to be shown
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
public bool $show_payments_table = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag which allows the aging table
|
||||||
|
* to be shown
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
public bool $show_aging_table = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String const which defines whether
|
||||||
|
* the invoices to be shown are either
|
||||||
|
* paid or unpaid
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public string $status = 'paid'; // paid | unpaid
|
||||||
|
|
||||||
|
}
|
@ -28,9 +28,8 @@ class StoreSchedulerRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
nlog($this->all());
|
||||||
$rules = [
|
$rules = [
|
||||||
'name' => ['bail', 'required', Rule::unique('schedulers')->where('company_id', auth()->user()->company()->id)],
|
|
||||||
'is_paused' => 'bail|sometimes|boolean',
|
'is_paused' => 'bail|sometimes|boolean',
|
||||||
'frequency_id' => 'bail|required|integer|digits_between:1,12',
|
'frequency_id' => 'bail|required|integer|digits_between:1,12',
|
||||||
'next_run' => 'bail|required|date:Y-m-d',
|
'next_run' => 'bail|required|date:Y-m-d',
|
||||||
@ -38,6 +37,10 @@ class StoreSchedulerRequest extends Request
|
|||||||
'parameters' => 'bail|array',
|
'parameters' => 'bail|array',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$rules['name'] = ['bail', 'required', Rule::unique('schedulers')->where('company_id', auth()->user()->company()->id)];
|
||||||
|
|
||||||
|
nlog($rules);
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,12 @@ class Scheduler extends BaseModel
|
|||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'start_from',
|
'name',
|
||||||
'is_paused',
|
'frequency_id',
|
||||||
'repeat_every',
|
'next_run',
|
||||||
'scheduled_run',
|
'scheduled_run',
|
||||||
'action_class',
|
'template',
|
||||||
'action_name',
|
'is_paused',
|
||||||
'parameters',
|
'parameters',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class Scheduler extends BaseModel
|
|||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
'updated_at' => 'timestamp',
|
'updated_at' => 'timestamp',
|
||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
'paused' => 'boolean',
|
'is_paused' => 'boolean',
|
||||||
'is_deleted' => 'boolean',
|
'is_deleted' => 'boolean',
|
||||||
'parameters' => 'array',
|
'parameters' => 'array',
|
||||||
];
|
];
|
||||||
|
@ -69,8 +69,21 @@ class SchedulerTest extends TestCase
|
|||||||
'next_run' => '2023-01-31',
|
'next_run' => '2023-01-31',
|
||||||
'template' => 'client_statement',
|
'template' => 'client_statement',
|
||||||
'clients' => [],
|
'clients' => [],
|
||||||
|
'parameters' => [
|
||||||
|
'date_range' => 'last_month',
|
||||||
|
'show_payments_table' => true,
|
||||||
|
'show_aging_table' => true,
|
||||||
|
'status' => 'paid'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->postJson('/api/v1/task_schedulers', $data);
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteSchedule()
|
public function testDeleteSchedule()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user