mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
7f6d4ca9c4
@ -1 +1 @@
|
|||||||
5.7.8
|
5.7.9
|
@ -862,7 +862,7 @@ class CheckData extends Command
|
|||||||
}
|
}
|
||||||
$records = DB::table($table)
|
$records = DB::table($table)
|
||||||
->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id")
|
->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id")
|
||||||
->where("{$table}.{$company_id}", '!=', "{$tableName}.company_id")
|
->whereRaw("{$table}.{$company_id} != {$tableName}.company_id")
|
||||||
->get(["{$table}.id"]);
|
->get(["{$table}.id"]);
|
||||||
|
|
||||||
if ($records->count()) {
|
if ($records->count()) {
|
||||||
|
@ -38,7 +38,10 @@ class ExpenseFilters extends QueryFilters
|
|||||||
->orWhere('custom_value1', 'like', '%'.$filter.'%')
|
->orWhere('custom_value1', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
->orWhere('custom_value2', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
->orWhere('custom_value3', 'like', '%'.$filter.'%')
|
||||||
->orWhere('custom_value4', 'like', '%'.$filter.'%');
|
->orWhere('custom_value4', 'like', '%'.$filter.'%')
|
||||||
|
->orWhereHas('category', function ($q) use ($filter) {
|
||||||
|
$q->where('name', 'like', '%'.$filter.'%');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,16 +169,27 @@ class ExpenseFilters extends QueryFilters
|
|||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sort_col[0] == 'client_id') {
|
if ($sort_col[0] == 'client_id' && in_array($sort_col[1], ['asc', 'desc'])) {
|
||||||
return $this->builder->orderBy(\App\Models\Client::select('name')
|
return $this->builder
|
||||||
|
->orderByRaw('ISNULL(client_id), client_id '. $sort_col[1])
|
||||||
|
->orderBy(\App\Models\Client::select('name')
|
||||||
->whereColumn('clients.id', 'expenses.client_id'), $sort_col[1]);
|
->whereColumn('clients.id', 'expenses.client_id'), $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sort_col[0] == 'vendor_id') {
|
if ($sort_col[0] == 'vendor_id' && in_array($sort_col[1], ['asc', 'desc'])) {
|
||||||
return $this->builder->orderBy(\App\Models\Vendor::select('name')
|
return $this->builder
|
||||||
|
->orderByRaw('ISNULL(vendor_id), vendor_id '. $sort_col[1])
|
||||||
|
->orderBy(\App\Models\Vendor::select('name')
|
||||||
->whereColumn('vendors.id', 'expenses.vendor_id'), $sort_col[1]);
|
->whereColumn('vendors.id', 'expenses.vendor_id'), $sort_col[1]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($sort_col[0] == 'category_id' && in_array($sort_col[1], ['asc', 'desc'])) {
|
||||||
|
return $this->builder
|
||||||
|
->orderByRaw('ISNULL(category_id), category_id '. $sort_col[1])
|
||||||
|
->orderBy(\App\Models\ExpenseCategory::select('name')
|
||||||
|
->whereColumn('expense_categories.id', 'expenses.category_id'), $sort_col[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($sort_col) && in_array($sort_col[1], ['asc', 'desc']) && in_array($sort_col[0], ['public_notes', 'date', 'id_number', 'custom_value1', 'custom_value2', 'custom_value3', 'custom_value4'])) {
|
if (is_array($sort_col) && in_array($sort_col[1], ['asc', 'desc']) && in_array($sort_col[0], ['public_notes', 'date', 'id_number', 'custom_value1', 'custom_value2', 'custom_value3', 'custom_value4'])) {
|
||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
|
@ -229,6 +229,32 @@ class InvoiceFilters extends QueryFilters
|
|||||||
return $this->builder->where('due_date', '>=', $date);
|
return $this->builder->where('due_date', '>=', $date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function date_range(string $date_range = ''): Builder
|
||||||
|
{
|
||||||
|
$parts = explode(",", $date_range);
|
||||||
|
|
||||||
|
if (count($parts) != 3) {
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!in_array($parts[0], ['date','due_date'])) {
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
$start_date = Carbon::parse($parts[1]);
|
||||||
|
$end_date = Carbon::parse($parts[2]);
|
||||||
|
|
||||||
|
return $this->builder->whereBetween($parts[0], [$start_date, $end_date]);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(\Exception $e){
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the list based on $sort.
|
* Sorts the list based on $sort.
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
namespace App\Filters;
|
namespace App\Filters;
|
||||||
|
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PaymentFilters.
|
* PaymentFilters.
|
||||||
@ -177,6 +178,33 @@ class PaymentFilters extends QueryFilters
|
|||||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function date_range(string $date_range = ''): Builder
|
||||||
|
{
|
||||||
|
$parts = explode(",", $date_range);
|
||||||
|
|
||||||
|
if (count($parts) != 3) {
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!in_array($parts[0], ['date'])) {
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
$start_date = Carbon::parse($parts[1]);
|
||||||
|
$end_date = Carbon::parse($parts[2]);
|
||||||
|
|
||||||
|
return $this->builder->whereBetween($parts[0], [$start_date, $end_date]);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(\Exception $e){
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
*
|
*
|
||||||
|
@ -89,7 +89,7 @@ class InvoiceController extends Controller
|
|||||||
$data = Cache::get($hash);
|
$data = Cache::get($hash);
|
||||||
$invitation = false;
|
$invitation = false;
|
||||||
|
|
||||||
match($data['entity_type']){
|
match($data['entity_type'] ?? false){
|
||||||
'invoice' => $invitation = InvoiceInvitation::withTrashed()->find($data['invitation_id']),
|
'invoice' => $invitation = InvoiceInvitation::withTrashed()->find($data['invitation_id']),
|
||||||
'quote' => $invitation = QuoteInvitation::withTrashed()->find($data['invitation_id']),
|
'quote' => $invitation = QuoteInvitation::withTrashed()->find($data['invitation_id']),
|
||||||
'credit' => $invitation = CreditInvitation::withTrashed()->find($data['invitation_id']),
|
'credit' => $invitation = CreditInvitation::withTrashed()->find($data['invitation_id']),
|
||||||
|
@ -92,15 +92,73 @@ class ImportController extends Controller
|
|||||||
|
|
||||||
$class_map = $this->getEntityMap($entityType);
|
$class_map = $this->getEntityMap($entityType);
|
||||||
|
|
||||||
|
$hints = $this->setImportHints($entityType, $class_map::importable(), $csv_array[0]);
|
||||||
|
|
||||||
$data['mappings'][$entityType] = [
|
$data['mappings'][$entityType] = [
|
||||||
'available' => $class_map::importable(),
|
'available' => $class_map::importable(),
|
||||||
'headers' => array_slice($csv_array, 0, 2),
|
'headers' => array_slice($csv_array, 0, 2),
|
||||||
|
'hints' => $hints,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setImportHints($entity_type, $available_keys, $headers): array
|
||||||
|
{
|
||||||
|
$hints = [];
|
||||||
|
|
||||||
|
$translated_keys = collect($available_keys)->map(function ($value,$key){
|
||||||
|
|
||||||
|
$parts = explode(".", $value);
|
||||||
|
$index = $parts[0];
|
||||||
|
$label = $parts[1] ?? $parts[0];
|
||||||
|
|
||||||
|
return ['key' => $key, 'index' => ctrans("texts.{$index}"), 'label' => ctrans("texts.{$label}")];
|
||||||
|
|
||||||
|
})->toArray();
|
||||||
|
|
||||||
|
|
||||||
|
foreach($headers as $key => $value) {
|
||||||
|
|
||||||
|
$hit = false;
|
||||||
|
$unsetKey = false;
|
||||||
|
// array_multisort(array_column($translated_keys, 'label'), SORT_ASC, $translated_keys);
|
||||||
|
|
||||||
|
foreach($translated_keys as $tkey => $tvalue)
|
||||||
|
{
|
||||||
|
|
||||||
|
if($this->testMatch($value, $tvalue['label'])) {
|
||||||
|
$hit = $available_keys[$tvalue['key']];
|
||||||
|
$unsetKey = $tkey;
|
||||||
|
}
|
||||||
|
// elseif($this->testMatch($value, $tvalue['index'])) {
|
||||||
|
// $hit = $available_keys[$tvalue['key']];
|
||||||
|
// $unsetKey = $tkey;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($hit) {
|
||||||
|
$hints[$key] = $hit;
|
||||||
|
unset($translated_keys[$unsetKey]);
|
||||||
|
} else {
|
||||||
|
$hints[$key] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
nlog($translated_keys);
|
||||||
|
|
||||||
|
return $hints;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function testMatch($haystack, $needle): bool
|
||||||
|
{
|
||||||
|
return stripos($haystack, $needle) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
private function convertEncoding($data)
|
private function convertEncoding($data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,16 +24,19 @@ class UpdateGroupSettingRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize() : bool
|
public function authorize() : bool
|
||||||
{
|
{
|
||||||
return auth()->user()->can('edit', $this->group_setting);
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return $user->can('edit', $this->group_setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
$rules['settings'] = new ValidClientGroupSettingsRule();
|
|
||||||
|
|
||||||
// $rules['name'] = 'unique:group_settings,name,'.$this->id.',id,company_id,'.$this->group_setting->company_id;
|
return [
|
||||||
|
'settings' => [new ValidClientGroupSettingsRule()],
|
||||||
|
];
|
||||||
|
|
||||||
return $rules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepareForValidation()
|
public function prepareForValidation()
|
||||||
|
@ -106,40 +106,40 @@ class CreditInvitation extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
public function credit()
|
public function credit(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Credit::class)->withTrashed();
|
return $this->belongsTo(Credit::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
public function entity()
|
public function entity(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Credit::class)->withTrashed();
|
return $this->belongsTo(Credit::class)->withTrashed();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
public function contact()
|
public function contact(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ClientContact::class, 'client_contact_id', 'id')->withTrashed();
|
return $this->belongsTo(ClientContact::class, 'client_contact_id', 'id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
public function user()
|
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class)->withTrashed();
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
public function company()
|
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,15 @@ class GroupSettingRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
public function save($data, GroupSetting $group_setting) :?GroupSetting
|
public function save($data, GroupSetting $group_setting) :?GroupSetting
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(isset($data['settings']['translations'])) {
|
||||||
|
unset($data['settings']['translations']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($data['settings']['pdf_variables'])) {
|
||||||
|
unset($data['settings']['pdf_variables']);
|
||||||
|
}
|
||||||
|
|
||||||
$group_setting->fill($data);
|
$group_setting->fill($data);
|
||||||
$group_setting->save();
|
$group_setting->save();
|
||||||
|
|
||||||
@ -25,16 +34,16 @@ class GroupSettingRepository extends BaseRepository
|
|||||||
$settings = $group_setting->settings;
|
$settings = $group_setting->settings;
|
||||||
unset($settings->company_logo);
|
unset($settings->company_logo);
|
||||||
$group_setting->settings = $settings;
|
$group_setting->settings = $settings;
|
||||||
$group_setting->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! array_key_exists('settings', $data) || count((array) $data['settings']) == 0) {
|
if (! array_key_exists('settings', $data) || count((array) $data['settings']) == 0) {
|
||||||
$settings = new \stdClass;
|
$settings = new \stdClass;
|
||||||
$settings->entity = Client::class;
|
$settings->entity = Client::class;
|
||||||
$group_setting->settings = $settings;
|
$group_setting->settings = $settings;
|
||||||
$group_setting->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$group_setting->save();
|
||||||
|
|
||||||
return $group_setting;
|
return $group_setting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,12 @@ trait ClientGroupSettingsSaver
|
|||||||
unset($settings->translations);
|
unset($settings->translations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach(['translations','pdf_variables'] as $key){
|
||||||
|
if (property_exists($settings, $key)) {
|
||||||
|
unset($settings->{$key});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//18-07-2022 removed || empty($settings->{$key}) from this check to allow "0" values to persist
|
//18-07-2022 removed || empty($settings->{$key}) from this check to allow "0" values to persist
|
||||||
foreach ($settings as $key => $value) {
|
foreach ($settings as $key => $value) {
|
||||||
if (! isset($settings->{$key}) || (! is_object($settings->{$key}) && strlen($settings->{$key}) == 0)) {
|
if (! isset($settings->{$key}) || (! is_object($settings->{$key}) && strlen($settings->{$key}) == 0)) {
|
||||||
|
@ -15,8 +15,8 @@ return [
|
|||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => env('APP_VERSION','5.7.8'),
|
'app_version' => env('APP_VERSION','5.7.9'),
|
||||||
'app_tag' => env('APP_TAG','5.7.8'),
|
'app_tag' => env('APP_TAG','5.7.9'),
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'api_secret' => env('API_SECRET', ''),
|
||||||
|
4
public/storage/.htaccess
Normal file
4
public/storage/.htaccess
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<Files *.php>
|
||||||
|
Order deny,Allow
|
||||||
|
Deny from all
|
||||||
|
</Files>
|
0
storage/app/public/.gitignore
vendored
Executable file → Normal file
0
storage/app/public/.gitignore
vendored
Executable file → Normal file
@ -48,6 +48,70 @@ class InvoiceTest extends TestCase
|
|||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInvoiceGetDatesBetween()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/invoices?date_range=date,2023-01-01,2023-01-01', )
|
||||||
|
->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvoiceGetDatesBetween2()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/invoices?date_range=date', )
|
||||||
|
->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvoiceGetDatesBetween3()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/invoices?date_range=x', )
|
||||||
|
->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvoiceGetDatesBetween4()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/invoices?date_range=date,2023223123,312312321', )
|
||||||
|
->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvoiceGetDatesBetween5()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/invoices?date_range=date,x,23423', )
|
||||||
|
->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvoiceGetDatesBetween6()
|
||||||
|
{
|
||||||
|
Invoice::factory()->count(10)->create([
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'client_id' => $this->client->id,
|
||||||
|
'date' => '1971-01-02',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/invoices?date_range=date,1971-01-01,1971-01-03', )
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$this->assertCount(10, $arr['data']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testInvoiceGetPaidReversedInvoice()
|
public function testInvoiceGetPaidReversedInvoice()
|
||||||
{
|
{
|
||||||
@ -66,7 +130,6 @@ class InvoiceTest extends TestCase
|
|||||||
$this->assertCount(1, $arr['data']);
|
$this->assertCount(1, $arr['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testInvoiceGetPaidInvoices()
|
public function testInvoiceGetPaidInvoices()
|
||||||
{
|
{
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
|
@ -60,7 +60,80 @@ class PaymentTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPatymentGetClientStatus()
|
public function testPaymentGetBetweenQuery1()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/payments?date_range=date,2023-01-01,2023-02-01');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPaymentGetBetweenQuery2()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/payments?date_range=');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPaymentGetBetweenQuery3()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/payments?date_range=1,1,1,1,1');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPaymentGetBetweenQuery4()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/payments?date_range=date,34343,34343434343');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPaymentGetBetweenQuery5()
|
||||||
|
{
|
||||||
|
Payment::factory()->count(10)->create([
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'client_id' => $this->client->id,
|
||||||
|
'date' => '2023-01-02',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/payments?date_range=date,2023-01-01,2023-01-03');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$this->assertCount(10, $arr['data']);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/payments?date_range=date,2053-10-01,2053-10-03');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$this->assertCount(0, $arr['data']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPaymentGetClientStatus()
|
||||||
{
|
{
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user