mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-12 00:52:01 -06:00
Reset some code.
This commit is contained in:
parent
966186cccd
commit
6f063a134f
@ -23,7 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Api\V1\Requests\AccountRequest;
|
||||
use FireflyIII\Api\V1\Requests\AccountStoreRequest;
|
||||
use FireflyIII\Api\V1\Requests\AccountUpdateRequest;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@ -76,7 +79,7 @@ class AccountController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \FireflyIII\Models\Account $account
|
||||
* @param Account $account
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@ -132,7 +135,7 @@ class AccountController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* List all of them.
|
||||
* List all piggies.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
@ -177,7 +180,7 @@ class AccountController extends Controller
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function show(Request $request, Account $account): JsonResponse
|
||||
{
|
||||
@ -196,11 +199,12 @@ class AccountController extends Controller
|
||||
/**
|
||||
* Store a new instance.
|
||||
*
|
||||
* @param AccountRequest $request
|
||||
* @param AccountStoreRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function store(AccountRequest $request): JsonResponse
|
||||
public function store(AccountStoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$account = $this->repository->store($data);
|
||||
@ -285,12 +289,13 @@ class AccountController extends Controller
|
||||
/**
|
||||
* Update account.
|
||||
*
|
||||
* @param AccountRequest $request
|
||||
* @param Account $account
|
||||
* @param AccountUpdateRequest $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update(AccountRequest $request, Account $account): JsonResponse
|
||||
public function update(AccountUpdateRequest $request, Account $account): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AccountRequest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
* AccountStoreRequest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
@ -24,12 +24,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Rules\IsBoolean;
|
||||
|
||||
/**
|
||||
* Class AccountRequest
|
||||
* Class AccountStoreRequest
|
||||
*/
|
||||
class AccountRequest extends Request
|
||||
class AccountStoreRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
@ -47,6 +48,7 @@ class AccountRequest extends Request
|
||||
* Get all data from the request.
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAll(): array
|
||||
{
|
||||
@ -103,7 +105,7 @@ class AccountRequest extends Request
|
||||
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
|
||||
$rules = [
|
||||
'name' => 'required|min:1|uniqueAccountForUser',
|
||||
'type' => 'required|in:' . $types,
|
||||
'type' => sprintf('in:%s', $types),
|
||||
'iban' => 'iban|nullable',
|
||||
'bic' => 'bic|nullable',
|
||||
'account_number' => 'between:1,255|nullable|uniqueAccountNumberForUser',
|
||||
@ -114,8 +116,8 @@ class AccountRequest extends Request
|
||||
'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||
'active' => [new IsBoolean],
|
||||
'include_net_worth' => [new IsBoolean],
|
||||
'account_role' => 'in:' . $accountRoles . '|required_if:type,asset',
|
||||
'credit_card_type' => 'in:' . $ccPaymentTypes . '|required_if:account_role,ccAsset',
|
||||
'account_role' => sprintf('in:%s|required_if:type,asset', $accountRoles),
|
||||
'credit_card_type' => sprintf('in:%s|required_if:account_role,ccAsset', $ccPaymentTypes),
|
||||
'monthly_payment_date' => 'date' . '|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull',
|
||||
'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage',
|
||||
'liability_amount' => 'required_if:type,liability|min:0|numeric',
|
||||
@ -124,17 +126,6 @@ class AccountRequest extends Request
|
||||
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
|
||||
'notes' => 'min:0|max:65536',
|
||||
];
|
||||
switch ($this->method()) {
|
||||
default:
|
||||
break;
|
||||
case 'PUT':
|
||||
case 'PATCH':
|
||||
$account = $this->route()->parameter('account');
|
||||
$rules['name'] .= ':' . $account->id;
|
||||
$rules['account_number'] .= ':' . $account->id;
|
||||
$rules['type'] = 'in:' . $types;
|
||||
break;
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
133
app/Api/V1/Requests/AccountUpdateRequest.php
Normal file
133
app/Api/V1/Requests/AccountUpdateRequest.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AccountUpdateRequest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Rules\IsBoolean;
|
||||
|
||||
/**
|
||||
* Class AccountUpdateRequest
|
||||
*/
|
||||
class AccountUpdateRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Authorize logged in users.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
// Only allow authenticated users
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all data from the request.
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAll(): array
|
||||
{
|
||||
$active = true;
|
||||
$includeNetWorth = true;
|
||||
if (null !== $this->get('active')) {
|
||||
$active = $this->boolean('active');
|
||||
}
|
||||
if (null !== $this->get('include_net_worth')) {
|
||||
$includeNetWorth = $this->boolean('include_net_worth');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => $this->string('name'),
|
||||
'active' => $active,
|
||||
'include_net_worth' => $includeNetWorth,
|
||||
'accountType' => $this->string('type'),
|
||||
'account_type_id' => null,
|
||||
'currency_id' => $this->integer('currency_id'),
|
||||
'currency_code' => $this->string('currency_code'),
|
||||
'virtualBalance' => $this->string('virtual_balance'),
|
||||
'iban' => $this->string('iban'),
|
||||
'BIC' => $this->string('bic'),
|
||||
'accountNumber' => $this->string('account_number'),
|
||||
'accountRole' => $this->string('account_role'),
|
||||
'openingBalance' => $this->string('opening_balance'),
|
||||
'openingBalanceDate' => $this->date('opening_balance_date'),
|
||||
'ccType' => $this->string('credit_card_type'),
|
||||
'ccMonthlyPaymentDate' => $this->string('monthly_payment_date'),
|
||||
'notes' => $this->string('notes'),
|
||||
'interest' => $this->string('interest'),
|
||||
'interest_period' => $this->string('interest_period'),
|
||||
];
|
||||
|
||||
if ('liability' === $data['accountType']) {
|
||||
$data['openingBalance'] = bcmul($this->string('liability_amount'), '-1');
|
||||
$data['openingBalanceDate'] = $this->date('liability_start_date');
|
||||
$data['accountType'] = $this->string('liability_type');
|
||||
$data['account_type_id'] = null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rules that the incoming request must be matched against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$account = $this->route()->parameter('account');
|
||||
$accountRoles = implode(',', config('firefly.accountRoles'));
|
||||
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
|
||||
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
|
||||
$rules = [
|
||||
'name' => sprintf('required|min:1|uniqueAccountForUser:%d', $account->id),
|
||||
'type' => sprintf('in:%s', $types),
|
||||
'iban' => 'iban|nullable',
|
||||
'bic' => 'bic|nullable',
|
||||
'account_number' => sprintf('between:1,255|nullable|uniqueAccountNumberForUser:%d', $account->id),
|
||||
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
|
||||
'opening_balance_date' => 'date|required_with:opening_balance|nullable',
|
||||
'virtual_balance' => 'numeric|nullable',
|
||||
'currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||
'active' => [new IsBoolean],
|
||||
'include_net_worth' => [new IsBoolean],
|
||||
'account_role' => sprintf('in:%s|required_if:type,asset', $accountRoles),
|
||||
'credit_card_type' => sprintf('in:%s|required_if:account_role,ccAsset', $ccPaymentTypes),
|
||||
'monthly_payment_date' => 'date' . '|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull',
|
||||
'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage',
|
||||
'liability_amount' => 'required_if:type,liability|min:0|numeric',
|
||||
'liability_start_date' => 'required_if:type,liability|date',
|
||||
'interest' => 'required_if:type,liability|between:0,100|numeric',
|
||||
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
|
||||
'notes' => 'min:0|max:65536',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
@ -166,7 +166,7 @@ class JournalFormRequest extends Request
|
||||
'notes' => 'min:1|max:50000|nullable',
|
||||
// and then transaction rules:
|
||||
'description' => 'required|between:1,255',
|
||||
'amount' => 'numeric|required|more:0|less:10000000',//
|
||||
'amount' => 'numeric|required|more:0|less:1000000000',
|
||||
'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable',
|
||||
'category' => 'between:1,255|nullable',
|
||||
'source_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
||||
|
@ -172,7 +172,7 @@ class TransactionGroupTwig extends Twig_Extension
|
||||
private function normalGroupAmount(array $array): string
|
||||
{
|
||||
// take cue from the first entry in the array:
|
||||
$first = $array['transactions'][0];
|
||||
$first = reset($array['transactions']);
|
||||
$type = $first['transaction_type_type'] ?? TransactionType::WITHDRAWAL;
|
||||
$amount = $array['sum'] ?? '0';
|
||||
$colored = true;
|
||||
|
@ -27,7 +27,7 @@
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="true">
|
||||
stopOnFailure="false">
|
||||
<listeners>
|
||||
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
|
||||
</listeners>
|
||||
|
@ -27,7 +27,7 @@
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="true">
|
||||
stopOnFailure="false">
|
||||
<listeners>
|
||||
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
|
||||
</listeners>
|
||||
|
@ -1,46 +1,19 @@
|
||||
<div class="list-group">
|
||||
{% for group in groups %}
|
||||
<a class="list-group-item" href="{{ route('transactions.show', [group.id]) }}">
|
||||
<a class="list-group-item" href="{{ route('transactions.show', [group.id]) }}">
|
||||
{% for transaction in group.transactions %}
|
||||
{{ transaction.description }}
|
||||
<span class="pull-right small">
|
||||
{{ transactionAmount(transaction) }}
|
||||
</span>
|
||||
<br />
|
||||
<br/>
|
||||
{% endfor %}
|
||||
{% if group.count > 1 %}
|
||||
|
||||
<span class="pull-right small">
|
||||
<span class="pull-right small">
|
||||
{{ groupAmount(group) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
{# if group do something with format #}
|
||||
{#{% if group.count > 1 %}
|
||||
(group)
|
||||
{% endif %}
|
||||
#}
|
||||
{# loop each transaction #}
|
||||
{#
|
||||
<a class="list-group-item" title="{{ transaction.date.formatLocalized(trans('config.month_and_day')) }}"
|
||||
{% if transaction.transaction_type_type == 'Opening balance' %}
|
||||
href="#"
|
||||
{% else %}
|
||||
href="{{ route('transactions.show',transaction.journal_id) }}"
|
||||
{% endif %}>
|
||||
{{ transaction|transactionIcon }}
|
||||
{{ transaction|transactionDescription }}
|
||||
<span class="pull-right small">
|
||||
{{ transaction|transactionAmount }}
|
||||
</span>
|
||||
|
||||
</a>
|
||||
{% endfor %}
|
||||
#}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
@ -1 +0,0 @@
|
||||
<h1 style="color:red;">DO NOT USE ME</h1>
|
@ -1,79 +0,0 @@
|
||||
<h1 style="color:red;">DO NOT USE</h1>
|
||||
|
||||
|
||||
{#
|
||||
{{ transactions.render|raw }}
|
||||
|
||||
<table class="table table-hover table-condensed {% if sorting %}sortable-table{% endif %}">
|
||||
<thead>
|
||||
<tr class="ignore">
|
||||
<th class="hidden-xs no_select_boxes" colspan="2"> </th>
|
||||
<th class="hidden-xs select_boxes" colspan="2" style="display: none;"><input name="select_all" class="select_all" type="checkbox"/></th>
|
||||
<th>{{ trans('list.description') }}</th>
|
||||
<th>{{ trans('list.amount') }}</th>
|
||||
<th class="hidden-xs hidden-sm">{{ trans('list.date') }}</th>
|
||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.from') }}</th>
|
||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.to') }}</th>
|
||||
{% if not hideBudgets %}
|
||||
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
|
||||
{% endif %}
|
||||
|
||||
{% if not hideCategories %}
|
||||
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
|
||||
{% endif %}
|
||||
|
||||
{% if not hideBills %}
|
||||
<th class="hidden-xs"><i class="fa fa-fw fa-calendar-o" title="{{ trans('list.bill') }}"></i></th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for transaction in transactions %}
|
||||
{% include 'partials.journal-row' %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row mass_edit_all hidden-xs" style="display: none;padding:8px;">
|
||||
<div class="col-lg-8 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="btn-group dropup mass_button_options" style="display:none;">
|
||||
<button type="button" class="btn btn-default">{{ 'actions'|_ }}</button>
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" class="mass_edit"><i class="fa fa-fw fa-pencil"></i> <span>{{ 'edit'|_ }}</span></a></li>
|
||||
<li><a href="#" class="bulk_edit"><i class="fa fa-fw fa-pencil-square-o"></i> <span>{{ 'bulk_edit'|_ }}</span></a></li>
|
||||
<li><a href="#" class="mass_delete"><i class="fa fa-fw fa-trash"></i> <span>{{ 'delete'|_ }}</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12 hidden-xs">
|
||||
<div class="mass_buttons btn-group btn-group pull-right">
|
||||
<a href="#" class="btn btn-default mass_select"><i class="fa fa-fw fa-check-square-o"></i> {{ 'select_transactions'|_ }}</a>
|
||||
<a href="#" class="btn btn-default mass_stop_select" style="display:none;"><i class="fa faw-fw fa-square-o"
|
||||
></i> {{ 'stop_selection'|_ }}</a>
|
||||
|
||||
{% if showReconcile == true %}
|
||||
{% if Route.getCurrentRoute.getName =='accounts.show.all' %}
|
||||
<a href="{{ route('accounts.reconcile', [account.id, start.format('Ymd')]) }}" class="btn btn-info mass_reconcile"><i
|
||||
class="fa fa-fw fa-check"></i> {{ 'reconcile_this_account'|_ }}</a>
|
||||
{% else %}
|
||||
<a href="{{ route('accounts.reconcile', [account.id, start.format('Ymd'), end.format('Ymd')]) }}" class="btn btn-info mass_reconcile"><i
|
||||
class="fa fa-fw fa-check"></i> {{ 'reconcile_this_account'|_ }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="padding:8px;">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
{{ transactions.render|raw }}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var edit_selected_txt = "{{ trans('firefly.edit')|escape('js') }}";
|
||||
var edit_bulk_selected_txt = "{{ trans('firefly.bulk_edit')|escape('js') }}";
|
||||
var delete_selected_txt = "{{ trans('firefly.delete')|escape('js') }}";
|
||||
</script>
|
||||
#}
|
@ -1,80 +0,0 @@
|
||||
{# render pagination #}
|
||||
{{ transactions.render|raw }}
|
||||
|
||||
<table class="table table-hover table-condensed {% if sorting %}sortable-table{% endif %}">
|
||||
<thead>
|
||||
<tr class="ignore">
|
||||
{# hidden row for checkboxes #}
|
||||
<th class="hidden-xs select_boxes" style="display: none;"><input name="select_all" class="select_all" type="checkbox"/></th>
|
||||
|
||||
{# header for icon #}
|
||||
<th class="hidden-xs"></th>
|
||||
<th>{{ trans('list.description') }}</th>
|
||||
<th style="text-align:right;">{{ trans('list.amount') }}</th>
|
||||
<th class="hidden-xs hidden-sm">{{ trans('list.date') }}</th>
|
||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.from') }}</th>
|
||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.to') }}</th>
|
||||
|
||||
{# Only show budgets when asked in some way #}
|
||||
{% if showBudgets %}
|
||||
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
|
||||
{% endif %}
|
||||
|
||||
{# Only show categories when asked in some way #}
|
||||
{% if showCategories %}
|
||||
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
|
||||
{% endif %}
|
||||
|
||||
{# Only show bill when asked in some way #}
|
||||
{% if showBill %}
|
||||
<th class="hidden-xs"><i class="fa fa-fw fa-calendar-o" title="{{ trans('list.bill') }}"></i></th>
|
||||
{% endif %}
|
||||
|
||||
{# visible row for edit/delete buttons #}
|
||||
<th class="hidden-xs no_select_boxes"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for transaction in transactions %}
|
||||
{% include 'partials.transaction-row' %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row mass_edit_all hidden-xs" style="display: none;padding:8px;">
|
||||
<div class="col-lg-8 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="btn-group dropup mass_button_options" style="display:none;">
|
||||
<button type="button" class="btn btn-default">{{ 'actions'|_ }}</button>
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" class="mass_edit"><i class="fa fa-fw fa-pencil"></i> <span>{{ 'edit'|_ }}</span></a></li>
|
||||
<li><a href="#" class="bulk_edit"><i class="fa fa-fw fa-pencil-square-o"></i> <span>{{ 'bulk_edit'|_ }}</span></a></li>
|
||||
<li><a href="#" class="mass_delete"><i class="fa fa-fw fa-trash"></i> <span>{{ 'delete'|_ }}</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12 hidden-xs">
|
||||
<div class="mass_buttons btn-group btn-group pull-right">
|
||||
<a href="#" class="btn btn-default mass_select"><i class="fa fa-fw fa-check-square-o"></i> {{ 'select_transactions'|_ }}</a>
|
||||
<a href="#" class="btn btn-default mass_stop_select" style="display:none;"><i class="fa faw-fw fa-square-o"
|
||||
></i> {{ 'stop_selection'|_ }}</a>
|
||||
|
||||
{% if showReconcile == true %}
|
||||
{% if Route.getCurrentRoute.getName =='accounts.show.all' %}
|
||||
<a href="{{ route('accounts.reconcile', [account.id, start.format('Ymd')]) }}" class="btn btn-info mass_reconcile"><i
|
||||
class="fa fa-fw fa-check"></i> {{ 'reconcile_this_account'|_ }}</a>
|
||||
{% else %}
|
||||
<a href="{{ route('accounts.reconcile', [account.id, start.format('Ymd'), end.format('Ymd')]) }}" class="btn btn-info mass_reconcile"><i
|
||||
class="fa fa-fw fa-check"></i> {{ 'reconcile_this_account'|_ }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="padding:8px;">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
{{ transactions.render|raw }}
|
||||
</div>
|
||||
</div>
|
@ -23,15 +23,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\V1\Controllers;
|
||||
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use Exception;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Transformers\AccountTransformer;
|
||||
use FireflyIII\Transformers\PiggyBankTransformer;
|
||||
use FireflyIII\Transformers\TransactionTransformer;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Passport\Passport;
|
||||
@ -62,6 +62,8 @@ class AccountControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('destroy')->atLeast()->once()->andReturn(true);
|
||||
@ -189,7 +191,8 @@ class AccountControllerTest extends TestCase
|
||||
* Opening balance without date.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreInvalidBalance(): void
|
||||
{
|
||||
@ -227,7 +230,8 @@ class AccountControllerTest extends TestCase
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreLiability(): void
|
||||
{
|
||||
@ -273,13 +277,12 @@ class AccountControllerTest extends TestCase
|
||||
* CC type present when account is a credit card.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
*/
|
||||
public function testStoreNoCreditCardData(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
|
||||
// mock calls:
|
||||
@ -313,13 +316,13 @@ class AccountControllerTest extends TestCase
|
||||
* No currency information (is allowed).
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreNoCurrencyInfo(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
|
||||
// mock calls to transformer:
|
||||
@ -351,13 +354,12 @@ class AccountControllerTest extends TestCase
|
||||
* Name already in use.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
*/
|
||||
public function testStoreNotUnique(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
|
||||
// mock calls:
|
||||
@ -393,13 +395,13 @@ class AccountControllerTest extends TestCase
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreValid(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
$account = $this->getRandomAsset();
|
||||
|
||||
@ -432,13 +434,13 @@ class AccountControllerTest extends TestCase
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreWithCurrencyCode(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
$account = $this->getRandomAsset();
|
||||
|
||||
@ -470,36 +472,31 @@ class AccountControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Show index.
|
||||
* Show transactions.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
*/
|
||||
public function testTransactionsBasic(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
|
||||
// default mocks
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionGroupTransformer::class);
|
||||
|
||||
// objects
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
|
||||
// calls to account repos.
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('isAsset')->atLeast()->once()->andReturnTrue();
|
||||
|
||||
// mock collector:
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
$collector->shouldReceive('setUser')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('withAPIInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->withArgs([50])->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedTransactions')->andReturn($paginator);
|
||||
$collector->shouldReceive('getPaginatedGroups')->andReturn($paginator);
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
@ -515,45 +512,38 @@ class AccountControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Show index.
|
||||
* Show transactions but submit a limit.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
*/
|
||||
public function testTransactionsOpposing(): void
|
||||
public function testTransactionsLimit(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
|
||||
// default mocks
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionGroupTransformer::class);
|
||||
|
||||
// objects
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
|
||||
// calls to account repos.
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('isAsset')->atLeast()->once()->andReturnFalse();
|
||||
|
||||
// mock collector:
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
$collector->shouldReceive('setUser')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->andReturnSelf();
|
||||
$collector->shouldReceive('setOpposingAccounts')->atLeast()->once()->andReturnSelf();
|
||||
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('withAPIInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->withArgs([10])->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedTransactions')->andReturn($paginator);
|
||||
$collector->shouldReceive('getPaginatedGroups')->andReturn($paginator);
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
$revenue = $this->getRandomAsset();
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
// test API
|
||||
$response = $this->get(route('api.v1.accounts.transactions', [$revenue->id]));
|
||||
$response = $this->get(route('api.v1.accounts.transactions', [$asset->id]) . '?limit=10');
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(['data' => [],]);
|
||||
$response->assertJson(['meta' => ['pagination' => ['total' => 0, 'count' => 0, 'per_page' => 50, 'current_page' => 1, 'total_pages' => 1]],]);
|
||||
@ -568,31 +558,26 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testTransactionsRange(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
|
||||
// default mocks
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionGroupTransformer::class);
|
||||
|
||||
// objects
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
|
||||
// calls to account repos.
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('isAsset')->atLeast()->once()->andReturnTrue();
|
||||
|
||||
// mock collector:
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
$collector->shouldReceive('setUser')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->andReturnSelf();
|
||||
$collector->shouldReceive('withAPIInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedGroups')->andReturn($paginator);
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedTransactions')->andReturn($paginator);
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
@ -611,7 +596,7 @@ class AccountControllerTest extends TestCase
|
||||
* Update first asset account we find. Name can be the same as it was.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountUpdateRequest
|
||||
*/
|
||||
public function testUpdate(): void
|
||||
{
|
||||
@ -636,9 +621,11 @@ class AccountControllerTest extends TestCase
|
||||
$account = $this->getRandomAsset();
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => $account->name,
|
||||
'type' => 'asset',
|
||||
'account_role' => 'defaultAsset',
|
||||
'active' => true,
|
||||
'include_net_worth' => true,
|
||||
'name' => $account->name,
|
||||
'type' => 'asset',
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
@ -652,7 +639,7 @@ class AccountControllerTest extends TestCase
|
||||
* Update first asset account we find. Name can be the same as it was.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountUpdateRequest
|
||||
*/
|
||||
public function testUpdateCurrencyCode(): void
|
||||
{
|
||||
@ -690,5 +677,54 @@ class AccountControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a liability
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountUpdateRequest
|
||||
*/
|
||||
public function testUpdateLiability(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('update')->atLeast()->once();
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
$transformer->shouldReceive('setCurrentScope')->withAnyArgs()->atLeast()->once()->andReturnSelf();
|
||||
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
|
||||
|
||||
$account = $this->getRandomAsset();
|
||||
// data to submit
|
||||
$data = [
|
||||
'active' => true,
|
||||
'include_net_worth' => true,
|
||||
'name' => $account->name,
|
||||
'type' => 'liability',
|
||||
'liability_type' => 'loan',
|
||||
'liability_amount' => '100',
|
||||
'interest' => '1',
|
||||
'interest_period' => 'yearly',
|
||||
'liability_start_date' => '2019-01-01',
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->put(route('api.v1.accounts.update', [$account->id]), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(['data' => ['type' => 'accounts', 'links' => true],]);
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -80,6 +80,9 @@ class AttachmentControllerTest extends TestCase
|
||||
*/
|
||||
public function testDownload(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
@ -109,6 +112,9 @@ class AttachmentControllerTest extends TestCase
|
||||
*/
|
||||
public function testDownloadNotExisting(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
@ -79,6 +79,9 @@ class TagControllerTest extends TestCase
|
||||
*/
|
||||
public function testDeleteByTag(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->inRandomOrder()->first();
|
||||
@ -152,6 +155,9 @@ class TagControllerTest extends TestCase
|
||||
*/
|
||||
public function testShowByTag(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->inRandomOrder()->first();
|
||||
|
Loading…
Reference in New Issue
Block a user