Rearrange code [skip ci]

This commit is contained in:
James Cole 2016-12-14 18:59:12 +01:00
parent f19b99194c
commit 848cfabcba
45 changed files with 321 additions and 319 deletions

View File

@ -17,8 +17,6 @@ use Crypt;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
@ -192,7 +190,10 @@ class VerifyDatabase extends Command
->where('transaction_types.type', $transactionType)
->whereIn('account_types.type', $accountTypes)
->whereNull('transaction_journals.deleted_at')
->get(['transaction_journals.id', 'transaction_journals.user_id', 'users.email', 'account_types.type as a_type', 'transaction_types.type']);
->get(
['transaction_journals.id', 'transaction_journals.user_id', 'users.email', 'account_types.type as a_type',
'transaction_types.type']
);
foreach ($set as $entry) {
$this->error(
sprintf(

View File

@ -21,17 +21,6 @@ namespace FireflyIII\Generator\Chart\Basic;
interface GeneratorInterface
{
/**
* Expects data as:
*
* key => value
*
* @param array $data
*
* @return array
*/
public function pieChart(array $data): array;
/**
* Will generate a (ChartJS) compatible array from the given input. Expects this format:
*
@ -57,6 +46,17 @@ interface GeneratorInterface
*/
public function multiSet(array $data): array;
/**
* Expects data as:
*
* key => value
*
* @param array $data
*
* @return array
*/
public function pieChart(array $data): array;
/**
* Will generate a (ChartJS) compatible array from the given input. Expects this format:
*

View File

@ -142,6 +142,35 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
}
/**
* @param array $entries
*
* @return array
*/
public function pieChart(array $entries): array
{
$data = [
'datasets' => [
0 => [],
],
'labels' => [],
];
$index = 0;
foreach ($entries as $entry) {
if (bccomp($entry['amount'], '0') === -1) {
$entry['amount'] = bcmul($entry['amount'], '-1');
}
$data['datasets'][0]['data'][] = round($entry['amount'], 2);
$data['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$data['labels'][] = $entry['name'];
$index++;
}
return $data;
}
/**
* @param array $entries
*
@ -177,33 +206,4 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
}
/**
* @param array $entries
*
* @return array
*/
public function pieChart(array $entries): array
{
$data = [
'datasets' => [
0 => [],
],
'labels' => [],
];
$index = 0;
foreach ($entries as $entry) {
if (bccomp($entry['amount'], '0') === -1) {
$entry['amount'] = bcmul($entry['amount'], '-1');
}
$data['datasets'][0]['data'][] = round($entry['amount'], 2);
$data['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$data['labels'][] = $entry['name'];
$index++;
}
return $data;
}
}

View File

@ -79,6 +79,22 @@ class BillLine
$this->bill = $bill;
}
/**
* @return Carbon
*/
public function getLastHitDate(): Carbon
{
return $this->lastHitDate;
}
/**
* @param Carbon $lastHitDate
*/
public function setLastHitDate(Carbon $lastHitDate)
{
$this->lastHitDate = $lastHitDate;
}
/**
* @return string
*/
@ -151,21 +167,5 @@ class BillLine
$this->hit = $hit;
}
/**
* @param Carbon $lastHitDate
*/
public function setLastHitDate(Carbon $lastHitDate)
{
$this->lastHitDate = $lastHitDate;
}
/**
* @return Carbon
*/
public function getLastHitDate(): Carbon
{
return $this->lastHitDate;
}
}

View File

@ -61,6 +61,7 @@ class ConfigurationController extends Controller
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$mustConfirmAccount = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'))->data;
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$siteOwner = env('SITE_OWNER');
// email settings:
$sendErrorMessage = [
@ -71,7 +72,10 @@ class ConfigurationController extends Controller
'mail_for_blocked_login' => FireflyConfig::get('mail_for_blocked_login', config('firefly.configuration.mail_for_blocked_login'))->data,
];
return view('admin.configuration.index', compact('subTitle', 'subTitleIcon', 'singleUserMode', 'mustConfirmAccount', 'isDemoSite', 'sendErrorMessage'));
return view(
'admin.configuration.index',
compact('subTitle', 'subTitleIcon', 'singleUserMode', 'mustConfirmAccount', 'isDemoSite', 'sendErrorMessage', 'siteOwner')
);
}

View File

@ -14,11 +14,11 @@ namespace FireflyIII\Http\Controllers\Auth;
use Auth;
use Config;
use FireflyConfig;
use FireflyIII\Events\BlockedUseOfDomain;
use FireflyIII\Events\BlockedUseOfEmail;
use FireflyIII\Events\RegisteredUser;
use FireflyIII\Http\Controllers\Controller;
use FireflyConfig;
use FireflyIII\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
@ -114,7 +114,6 @@ class RegisterController extends Controller
}
$user = $this->create($request->all());
// trigger user registration event:

View File

@ -52,6 +52,7 @@ class ReportController extends Controller
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return \Illuminate\Http\JsonResponse
*/
public function netWorth(Collection $accounts, Carbon $start, Carbon $end)
@ -131,6 +132,7 @@ class ReportController extends Controller
/**
* Shows sum income and expense, debet/credit: operations
*
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts

View File

@ -170,7 +170,7 @@ class CurrencyController extends Controller
if (!auth()->user()->hasRole('owner')) {
Session::flash('warning', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')]));
Session::flash('warning', trans('firefly.ask_site_owner', ['site_owner' => env('SITE_OWNER')]));
}

View File

@ -17,7 +17,6 @@ namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use ExpandedForm;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Export\Processor;
use FireflyIII\Export\ProcessorInterface;
use FireflyIII\Http\Requests\ExportFormRequest;
use FireflyIII\Models\AccountType;

View File

@ -208,7 +208,7 @@ class HomeController extends Controller
'debugbar',
'attachments.preview',
'budgets.income',
'currencies.default'
'currencies.default',
];

View File

@ -16,7 +16,6 @@ namespace FireflyIII\Http\Controllers\Report;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
@ -57,6 +56,33 @@ class OperationsController extends Controller
}
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function income(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('income-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
//return $cache->get();
}
$income = $this->getIncomeReport($start, $end, $accounts);
$result = view('reports.partials.income', compact('income'))->render();
$cache->store($result);
return $result;
}
/**
* @param Collection $accounts
* @param Carbon $start
@ -101,33 +127,6 @@ class OperationsController extends Controller
}
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function income(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('income-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
//return $cache->get();
}
$income = $this->getIncomeReport($start, $end, $accounts);
$result = view('reports.partials.income', compact('income'))->render();
$cache->store($result);
return $result;
}
/**
* @param Carbon $start
* @param Carbon $end

View File

@ -161,6 +161,7 @@ class JournalFormRequest extends Request
private function getFieldOrEmptyString(string $field): string
{
$string = $this->get($field) ?? '';
return trim($string);
}
}

View File

@ -59,27 +59,6 @@ class ReportFormRequest extends Request
return $collection;
}
/**
* @return Collection
*/
public function getCategoryList(): Collection
{
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$set = $this->get('category');
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->find(intval($categoryId));
if (!is_null($category->id)) {
$collection->push($category);
}
}
}
return $collection;
}
/**
* @return Collection
*/
@ -101,6 +80,27 @@ class ReportFormRequest extends Request
return $collection;
}
/**
* @return Collection
*/
public function getCategoryList(): Collection
{
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$set = $this->get('category');
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->find(intval($categoryId));
if (!is_null($category->id)) {
$collection->push($category);
}
}
}
return $collection;
}
/**
* @return Carbon
* @throws FireflyException

View File

@ -14,17 +14,13 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\Account;
use Carbon\Carbon;
use Crypt;
use DB;
use FireflyIII\Helpers\Collection\Account as AccountCollection;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\User;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Log;
use stdClass;
use Steam;
/**

View File

@ -188,6 +188,20 @@ class User extends Authenticatable
return $this->hasMany('FireflyIII\Models\Rule');
}
/**
* Send the password reset notification.
*
* @param string $token
*
* @return void
*/
public function sendPasswordResetNotification($token)
{
$ip = Request::ip();
event(new RequestedNewPassword($this, $token, $ip));
}
/**
* @return HasMany
*/
@ -212,18 +226,5 @@ class User extends Authenticatable
return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal');
}
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$ip = Request::ip();
event(new RequestedNewPassword($this, $token, $ip));
}
}

View File

@ -847,7 +847,7 @@ return [
'setting_is_demo_site' => 'Demo site',
'setting_is_demo_site_explain' => 'If you check this box, this installation will behave as if it is the demo site, which can have weird side effects.',
'setting_send_email_notifications' => 'Send email notifications',
'setting_send_email_explain' => 'Firefly III can send you email notifications about certain events. They will be sent to <code>:email</code>. This email address can be set in the <code>.env</code> file.',
'setting_send_email_explain' => 'Firefly III can send you email notifications about certain events. They will be sent to <code>:site_owner</code>. This email address can be set in the <code>.env</code> file.',
'mail_for_lockout_help' => 'When a user is locked out',
'mail_for_blocked_domain_help' => 'When a user tries to register using a blocked domain',
'mail_for_blocked_email_help' => 'When a user tries to register using a blocked email address',

View File

@ -426,7 +426,7 @@ return [
'deleted_currency' => 'Valuta :name verwijderd',
'created_currency' => 'Nieuwe valuta :name opgeslagen',
'updated_currency' => 'Valuta :name bijgewerkt',
'ask_site_owner' => 'Vraag :owner of deze valuta wilt toevoegen, verwijderen of wijzigen.',
'ask_site_owner' => 'Vraag :site_owner of deze valuta wilt toevoegen, verwijderen of wijzigen.',
'currencies_intro' => 'Firefly III ondersteunt diverse valuta die je hier kan instellen en bewerken.',
'make_default_currency' => 'maak standaard',
'default_currency' => 'standaard',

View File

@ -76,11 +76,11 @@
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">{{ 'setting_send_email_notifications'|_ }}</h3>
<h3 class="box-title">{{ trans('firefly.setting_send_email_notifications') }}</h3>
</div>
<div class="box-body">
<p class="text-info">
{{ 'setting_send_email_explain'|_ }}
{{ trans('firefly.setting_send_email_explain',{site_owner: siteOwner})|raw }}
</p>
{{ ExpandedForm.checkbox('mail_for_lockout','1', sendErrorMessage.mail_for_lockout, {helpText: trans('firefly.mail_for_lockout_help')}) }}
{{ ExpandedForm.checkbox('mail_for_blocked_domain','1', sendErrorMessage.mail_for_blocked_domain, {helpText: trans('firefly.mail_for_blocked_domain_help')}) }}