diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index f222177b8d84..12ce6c4f50c6 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -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) { diff --git a/app/Http/Controllers/BankTransactionRuleController.php b/app/Http/Controllers/BankTransactionRuleController.php index ba9dab0a9081..d507cdf2bd3f 100644 --- a/app/Http/Controllers/BankTransactionRuleController.php +++ b/app/Http/Controllers/BankTransactionRuleController.php @@ -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()); } diff --git a/app/Http/Requests/Activity/ShowActivityRequest.php b/app/Http/Requests/Activity/ShowActivityRequest.php index 688ad62f3476..3203aa599842 100644 --- a/app/Http/Requests/Activity/ShowActivityRequest.php +++ b/app/Http/Requests/Activity/ShowActivityRequest.php @@ -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); } } diff --git a/app/Http/Requests/BankTransactionRule/BulkBankTransactionRuleRequest.php b/app/Http/Requests/BankTransactionRule/BulkBankTransactionRuleRequest.php new file mode 100644 index 000000000000..a491da5e63f2 --- /dev/null +++ b/app/Http/Requests/BankTransactionRule/BulkBankTransactionRuleRequest.php @@ -0,0 +1,37 @@ +user()->isAdmin(); + } + + public function rules() + { + + return [ + 'ids' => 'required|bail|array', + 'action' => 'in:archive,restore,delete' + ]; + + } +} diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index ea3b4038153a..1f97fb73f876 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -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' => ""], diff --git a/tests/Feature/ActivityApiTest.php b/tests/Feature/ActivityApiTest.php index c5e6c6cbaaa1..115bed1732fc 100644 --- a/tests/Feature/ActivityApiTest.php +++ b/tests/Feature/ActivityApiTest.php @@ -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); + } + } diff --git a/tests/Feature/Bank/BankTransactionRuleTest.php b/tests/Feature/Bank/BankTransactionRuleTest.php index 2f3b8c215ee8..87f0be350f68 100644 --- a/tests/Feature/Bank/BankTransactionRuleTest.php +++ b/tests/Feature/Bank/BankTransactionRuleTest.php @@ -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() { diff --git a/tests/Feature/Bank/BankTransactionTest.php b/tests/Feature/Bank/BankTransactionTest.php index 0a47c4d7404b..9be72919ffc8 100644 --- a/tests/Feature/Bank/BankTransactionTest.php +++ b/tests/Feature/Bank/BankTransactionTest.php @@ -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'