1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00

Add statement date range to the statement

This commit is contained in:
David Bomba 2023-01-22 15:03:23 +11:00
parent b7a49b97cd
commit 9628580be0
8 changed files with 106 additions and 17 deletions

View File

@ -91,6 +91,10 @@ class ActivityController extends BaseController
->take($default_activities);
if ($request->has('react')) {
if(!auth()->user()->isAdmin())
return response()->json(['data' => []], 200);
$system = ctrans('texts.system');
$data = $activities->cursor()->map(function ($activity) use ($system) {

View File

@ -16,6 +16,7 @@ use App\Factory\BankTransactionRuleFactory;
use App\Filters\BankTransactionFilters;
use App\Filters\BankTransactionRuleFilters;
use App\Helpers\Bank\Yodlee\Yodlee;
use App\Http\Requests\BankTransactionRule\BulkBankTransactionRuleRequest;
use App\Http\Requests\BankTransactionRule\CreateBankTransactionRuleRequest;
use App\Http\Requests\BankTransactionRule\DestroyBankTransactionRuleRequest;
use App\Http\Requests\BankTransactionRule\EditBankTransactionRuleRequest;
@ -472,25 +473,21 @@ class BankTransactionRuleController extends BaseController
* ),
* )
*/
public function bulk()
public function bulk(BulkBankTransactionRuleRequest $request)
{
$action = request()->input('action');
$action = $request->input('action');
if(!in_array($action, ['archive', 'restore', 'delete']))
return response()->json(['message' => 'Unsupported action.'], 400);
$ids = request()->input('ids');
$ids = $request->input('ids');
$bank_transaction_rules = BankTransactionRule::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
$bank_transaction_rules->each(function ($bank_transaction_rule, $key) use ($action) {
if (auth()->user()->can('edit', $bank_transaction_rule)) {
$this->bank_transaction_repo->{$action}($bank_transaction_rule);
}
});
$bank_transaction_rules = BankTransactionRule::withTrashed()
->whereIn('id', $this->transformKeys($ids))
->company()
->cursor()
->each(function ($bank_transaction_rule, $key) use ($action) {
$this->bank_transaction_repo->{$action}($bank_transaction_rule);
});
/* Need to understand which permission are required for the given bulk action ie. view / edit */
return $this->listResponse(BankTransactionRule::withTrashed()->whereIn('id', $this->transformKeys($ids))->company());
}

View File

@ -23,6 +23,7 @@ class ShowActivityRequest extends Request
*/
public function authorize() : bool
{
return auth()->user()->can('view', Activity::class);
return auth()->user()->isAdmin();
// return auth()->user()->can('view', Activity::class);
}
}

View File

@ -0,0 +1,37 @@
<?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\Http\Requests\BankTransactionRule;
use App\Http\Requests\Request;
class BulkBankTransactionRuleRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return auth()->user()->isAdmin();
}
public function rules()
{
return [
'ids' => 'required|bail|array',
'action' => 'in:archive,restore,delete'
];
}
}

View File

@ -280,8 +280,10 @@ class Design extends BaseDesign
if ($this->type === 'statement') {
$s_date = $this->translateDate(now(), $this->client->date_format(), $this->client->locale());
// $s_date = $this->translateDate(now(), $this->client->date_format(), $this->client->locale());
$s_date = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale()) . " - " . $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale());
return [
['element' => 'tr', 'properties' => ['data-ref' => 'statement-label'], 'elements' => [
['element' => 'th', 'properties' => [], 'content' => ""],

View File

@ -45,4 +45,15 @@ class ActivityApiTest extends TestCase
$response->assertStatus(200);
}
public function testActivityGetWithReact()
{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/activities?react=true');
$response->assertStatus(200);
}
}

View File

@ -41,6 +41,44 @@ class BankTransactionRuleTest extends TestCase
$this->withoutExceptionHandling();
}
public function testBankRuleBulkActions()
{
$data = [
'action' => 'archive',
'ids' => [$this->bank_transaction_rule]
];
$response = $this->withHeaders([
'X-API-TOKEN' => $this->token,
])->post('/api/v1/bank_transaction_rules/bulk', $data)
->assertStatus(200);
$data = [
'ids' => [$this->bank_transaction_rule->hashed_id],
'action' => 'restore'
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/bank_transaction_rules/bulk', $data)
->assertStatus(200);
$data = [
'ids' => [$this->bank_transaction_rule->hashed_id],
'action' => 'delete'
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/bank_transaction_rules/bulk', $data)
->assertStatus(200);
}
public function testValidationContainsRule()
{

View File

@ -64,7 +64,6 @@ class BankTransactionTest extends TestCase
])->post('/api/v1/bank_transactions/bulk', $data)
->assertStatus(200);
$data = [
'ids' => [$this->bank_integration->hashed_id],
'action' => 'delete'