mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-28 03:34:32 -06:00
Merge remote-tracking branch 'origin/develop' into feature/abn-amro-import-specifix
This commit is contained in:
commit
a5ac84e1b9
9
.gitignore
vendored
9
.gitignore
vendored
@ -7,3 +7,12 @@ Homestead.json
|
||||
_ide_helper.php
|
||||
_ide_helper_models.php
|
||||
.phpstorm.meta.php
|
||||
|
||||
storage/
|
||||
|
||||
# Eclipse project files
|
||||
.buildpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
.env.local
|
||||
|
@ -10,9 +10,9 @@ install:
|
||||
- composer install
|
||||
- php artisan env
|
||||
- mv -v .env.testing .env
|
||||
- touch storage/database.sqlite
|
||||
- php artisan migrate --env=testing
|
||||
- php artisan migrate --seed --env=testing
|
||||
- php artisan env
|
||||
- touch storage/database/testing.db
|
||||
- php artisan migrate --seed
|
||||
|
||||
script:
|
||||
- phpunit
|
||||
|
69
app/Console/Commands/UpgradeFireflyInstructions.php
Normal file
69
app/Console/Commands/UpgradeFireflyInstructions.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class UpgradeFireflyInstructions
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
*/
|
||||
class UpgradeFireflyInstructions extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly:upgrade-instructions';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
$version = Config::get('firefly.version');
|
||||
$config = Config::get('upgrade.text');
|
||||
$text = isset($config[$version]) ? $config[$version] : null;
|
||||
|
||||
$this->line('+------------------------------------------------------------------------------+');
|
||||
$this->line('');
|
||||
|
||||
if (is_null($text)) {
|
||||
$this->line('Thank you for installing Firefly III, v' . $version);
|
||||
$this->line('If you are upgrading from a previous version,');
|
||||
$this->info('there are no extra upgrade instructions.');
|
||||
$this->line('Firefly III should be ready for use.');
|
||||
} else {
|
||||
$this->line('Thank you for installing Firefly III, v' . $version);
|
||||
$this->line('If you are upgrading from a previous version,');
|
||||
$this->line('please follow these upgrade instructions carefully:');
|
||||
$this->info(wordwrap($text));
|
||||
}
|
||||
|
||||
$this->line('');
|
||||
$this->line('+------------------------------------------------------------------------------+');
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@
|
||||
|
||||
namespace FireflyIII\Console;
|
||||
|
||||
use FireflyIII\Console\Commands\UpgradeFireflyInstructions;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@ -24,14 +25,19 @@ class Kernel extends ConsoleKernel
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
];
|
||||
protected $commands
|
||||
= [
|
||||
UpgradeFireflyInstructions::class
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameters)
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
|
@ -34,25 +34,25 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @param Exception $exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
return parent::report($e);
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @param \Exception $exception
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $e);
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
|
@ -89,18 +89,13 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator
|
||||
{
|
||||
// language:
|
||||
$format = trans('config.month_and_day');
|
||||
$data = [
|
||||
'count' => 0,
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
$data = ['count' => 0, 'labels' => [], 'datasets' => [],];
|
||||
$current = clone $start;
|
||||
while ($current <= $end) {
|
||||
$data['labels'][] = $current->formatLocalized($format);
|
||||
$current->addDay();
|
||||
}
|
||||
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$set = [
|
||||
'label' => $account->name,
|
||||
@ -148,8 +143,8 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => $account->name,
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
$range = Steam::balanceInRange($account, $start, $end);
|
||||
|
@ -35,7 +35,7 @@ class ChartJsBillChartGenerator implements BillChartGenerator
|
||||
'color' => 'rgba(0, 141, 76, 0.7)',
|
||||
'highlight' => 'rgba(0, 141, 76, 0.9)',
|
||||
'label' => trans('firefly.paid'),
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
|
@ -156,7 +156,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
||||
];
|
||||
// get labels from one of the budgets (assuming there's at least one):
|
||||
$first = $entries->first();
|
||||
foreach ($first['budgeted'] as $year => $noInterest) {
|
||||
$keys = array_keys($first['budgeted']);
|
||||
foreach ($keys as $year) {
|
||||
$data['labels'][] = strval($year);
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,12 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => trans('firefly.spent'),
|
||||
'data' => []
|
||||
'data' => [],
|
||||
],
|
||||
[
|
||||
'label' => trans('firefly.earned'),
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@ -95,8 +95,8 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => trans('firefly.spent'),
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
foreach ($entries as $entry) {
|
||||
@ -124,7 +124,8 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
|
||||
];
|
||||
// get labels from one of the categories (assuming there's at least one):
|
||||
$first = $entries->first();
|
||||
foreach ($first['spent'] as $year => $noInterest) {
|
||||
$keys = array_keys($first['spent']);
|
||||
foreach ($keys as $year) {
|
||||
$data['labels'][] = strval($year);
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ class ChartJsPiggyBankChartGenerator implements PiggyBankChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Diff',
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
$sum = '0';
|
||||
|
@ -27,12 +27,12 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => trans('firefly.income'),
|
||||
'data' => []
|
||||
'data' => [],
|
||||
],
|
||||
[
|
||||
'label' => trans('firefly.expenses'),
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@ -60,12 +60,12 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => trans('firefly.income'),
|
||||
'data' => []
|
||||
'data' => [],
|
||||
],
|
||||
[
|
||||
'label' => trans('firefly.expenses'),
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
$data['datasets'][0]['data'][] = round($income, 2);
|
||||
@ -92,12 +92,12 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => trans('firefly.income'),
|
||||
'data' => []
|
||||
'data' => [],
|
||||
],
|
||||
[
|
||||
'label' => trans('firefly.expenses'),
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@ -126,12 +126,12 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => trans('firefly.income'),
|
||||
'data' => []
|
||||
'data' => [],
|
||||
],
|
||||
[
|
||||
'label' => trans('firefly.expenses'),
|
||||
'data' => []
|
||||
]
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
$data['datasets'][0]['data'][] = round($income, 2);
|
||||
|
@ -45,7 +45,6 @@ class FireRulesForStore
|
||||
*/
|
||||
public function handle(TransactionJournalStored $event)
|
||||
{
|
||||
Log::debug('Before event (in handle). From account name is: ' . $event->journal->source_account->name);
|
||||
// get all the user's rule groups, with the rules, order by 'order'.
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
@ -74,7 +73,7 @@ class FireRulesForStore
|
||||
|
||||
}
|
||||
}
|
||||
// echo 'Done processing rules. See log.';
|
||||
// exit;
|
||||
// echo 'Done processing rules. See log.';
|
||||
// exit;
|
||||
}
|
||||
}
|
@ -8,7 +8,13 @@
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Events\TransactionJournalUpdated;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Rules\Processor;
|
||||
use FireflyIII\User;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -36,7 +42,33 @@ class FireRulesForUpdate
|
||||
*/
|
||||
public function handle(TransactionJournalUpdated $event)
|
||||
{
|
||||
Log::debug('Fire rules for update!');
|
||||
// get all the user's rule groups, with the rules, order by 'order'.
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();
|
||||
//
|
||||
/** @var RuleGroup $group */
|
||||
foreach ($groups as $group) {
|
||||
Log::debug('Now processing group "' . $group->title . '".');
|
||||
$rules = $group->rules()
|
||||
->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')
|
||||
->where('rule_triggers.trigger_type', 'user_action')
|
||||
->where('rule_triggers.trigger_value', 'update-journal')
|
||||
->where('rules.active', 1)
|
||||
->get(['rules.*']);
|
||||
/** @var Rule $rule */
|
||||
foreach ($rules as $rule) {
|
||||
Log::debug('Now handling rule #' . $rule->id . ' (' . $rule->title . ')');
|
||||
$processor = new Processor($rule, $event->journal);
|
||||
|
||||
// get some return out of this?
|
||||
$processor->handle();
|
||||
|
||||
if ($rule->stop_processing) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ class CategoryName extends BasicConverter implements ConverterInterface
|
||||
$category = Category::firstOrCreateEncrypted(
|
||||
[
|
||||
'name' => $this->value,
|
||||
'user_id' => Auth::user()->id
|
||||
'user_id' => Auth::user()->id,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Helpers\Csv;
|
||||
|
||||
use Crypt;
|
||||
@ -17,19 +16,27 @@ class Data
|
||||
/** @var string */
|
||||
protected $csvFileContent;
|
||||
|
||||
/** @var string */
|
||||
protected $delimiter;
|
||||
|
||||
/** @var string */
|
||||
protected $csvFileLocation;
|
||||
|
||||
/** @var string */
|
||||
protected $dateFormat;
|
||||
|
||||
/** @var bool */
|
||||
protected $hasHeaders;
|
||||
|
||||
/** @var array */
|
||||
protected $map = [];
|
||||
|
||||
/** @var array */
|
||||
protected $mapped = [];
|
||||
|
||||
/** @var Reader */
|
||||
protected $reader;
|
||||
|
||||
/** @var array */
|
||||
protected $roles = [];
|
||||
|
||||
@ -40,7 +47,6 @@ class Data
|
||||
protected $importAccount = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -52,6 +58,7 @@ class Data
|
||||
$this->sessionMapped();
|
||||
$this->sessionSpecifix();
|
||||
$this->sessionImportAccount();
|
||||
$this->sessionDelimiter();
|
||||
}
|
||||
|
||||
protected function sessionHasHeaders()
|
||||
@ -110,7 +117,15 @@ class Data
|
||||
}
|
||||
}
|
||||
|
||||
protected function sessionDelimiter()
|
||||
{
|
||||
if (Session::has('csv-delimiter')) {
|
||||
$this->delimiter = Session::get('csv-delimiter');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateFormat()
|
||||
@ -119,6 +134,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $dateFormat
|
||||
*/
|
||||
public function setDateFormat($dateFormat)
|
||||
@ -128,6 +144,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $importAccount
|
||||
*/
|
||||
public function setImportAccount($importAccount)
|
||||
@ -137,6 +154,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHeaders()
|
||||
@ -145,6 +163,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bool $hasHeaders
|
||||
*/
|
||||
public function setHasHeaders($hasHeaders)
|
||||
@ -154,6 +173,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMap()
|
||||
@ -162,6 +182,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $map
|
||||
*/
|
||||
public function setMap(array $map)
|
||||
@ -171,6 +192,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMapped()
|
||||
@ -179,6 +201,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $mapped
|
||||
*/
|
||||
public function setMapped(array $mapped)
|
||||
@ -188,17 +211,18 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Reader
|
||||
*/
|
||||
public function getReader()
|
||||
{
|
||||
|
||||
if (strlen($this->csvFileContent) === 0) {
|
||||
$this->loadCsvFile();
|
||||
}
|
||||
|
||||
if (is_null($this->reader)) {
|
||||
$this->reader = Reader::createFromString($this->getCsvFileContent());
|
||||
$this->reader->setDelimiter($this->delimiter);
|
||||
}
|
||||
|
||||
return $this->reader;
|
||||
@ -213,6 +237,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCsvFileLocation()
|
||||
@ -221,6 +246,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $csvFileLocation
|
||||
*/
|
||||
public function setCsvFileLocation($csvFileLocation)
|
||||
@ -230,6 +256,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCsvFileContent()
|
||||
@ -238,6 +265,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $csvFileContent
|
||||
*/
|
||||
public function setCsvFileContent($csvFileContent)
|
||||
@ -246,6 +274,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRoles()
|
||||
@ -254,6 +283,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $roles
|
||||
*/
|
||||
public function setRoles(array $roles)
|
||||
@ -263,6 +293,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSpecifix()
|
||||
@ -271,6 +302,7 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $specifix
|
||||
*/
|
||||
public function setSpecifix($specifix)
|
||||
@ -279,5 +311,22 @@ class Data
|
||||
$this->specifix = $specifix;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter()
|
||||
{
|
||||
return $this->delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $delimiter
|
||||
*/
|
||||
public function setDelimiter($delimiter)
|
||||
{
|
||||
Session::put('csv-delimiter', $delimiter);
|
||||
$this->delimiter = $delimiter;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ class Wizard implements WizardInterface
|
||||
|
||||
|
||||
if (is_array($map)) {
|
||||
foreach ($map as $index => $field) {
|
||||
$keys = array_keys($map);
|
||||
foreach ($keys as $index) {
|
||||
if (isset($roles[$index])) {
|
||||
$name = $roles[$index];
|
||||
if ($configRoles[$name]['mappable']) {
|
||||
|
@ -19,9 +19,12 @@ use FireflyIII\Helpers\Collection\Income;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Budget as BudgetModel;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@ -35,16 +38,26 @@ class ReportHelper implements ReportHelperInterface
|
||||
/** @var ReportQueryInterface */
|
||||
protected $query;
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
protected $budgetRepository;
|
||||
|
||||
/** @var TagRepositoryInterface */
|
||||
protected $tagRepository;
|
||||
|
||||
/**
|
||||
* ReportHelper constructor.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param ReportQueryInterface $query
|
||||
*
|
||||
* @param ReportQueryInterface $query
|
||||
* @param BudgetRepositoryInterface $budgetRepository
|
||||
* @param TagRepositoryInterface $tagRepository
|
||||
*/
|
||||
public function __construct(ReportQueryInterface $query)
|
||||
public function __construct(ReportQueryInterface $query, BudgetRepositoryInterface $budgetRepository, TagRepositoryInterface $tagRepository)
|
||||
{
|
||||
$this->query = $query;
|
||||
|
||||
$this->query = $query;
|
||||
$this->budgetRepository = $budgetRepository;
|
||||
$this->tagRepository = $tagRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -329,105 +342,24 @@ class ReportHelper implements ReportHelperInterface
|
||||
*/
|
||||
public function getBalanceReport(Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
/** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
|
||||
/** @var \FireflyIII\Repositories\Tag\TagRepositoryInterface $tagRepository */
|
||||
$tagRepository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');
|
||||
|
||||
$balance = new Balance;
|
||||
|
||||
// build a balance header:
|
||||
$header = new BalanceHeader;
|
||||
$budgets = $repository->getBudgetsAndLimitsInRange($start, $end);
|
||||
$spentData = $repository->spentPerBudgetPerAccount($budgets, $accounts, $start, $end);
|
||||
$budgets = $this->budgetRepository->getBudgetsAndLimitsInRange($start, $end);
|
||||
$spentData = $this->budgetRepository->spentPerBudgetPerAccount($budgets, $accounts, $start, $end);
|
||||
foreach ($accounts as $account) {
|
||||
$header->addAccount($account);
|
||||
}
|
||||
|
||||
/** @var BudgetModel $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$line = new BalanceLine;
|
||||
$line->setBudget($budget);
|
||||
|
||||
// loop accounts:
|
||||
foreach ($accounts as $account) {
|
||||
$balanceEntry = new BalanceEntry;
|
||||
$balanceEntry->setAccount($account);
|
||||
|
||||
// get spent:
|
||||
$entry = $spentData->filter(
|
||||
function (TransactionJournal $model) use ($budget, $account) {
|
||||
return $model->account_id == $account->id && $model->budget_id == $budget->id;
|
||||
}
|
||||
);
|
||||
$spent = 0;
|
||||
if (!is_null($entry->first())) {
|
||||
$spent = $entry->first()->spent;
|
||||
}
|
||||
$balanceEntry->setSpent($spent);
|
||||
$line->addBalanceEntry($balanceEntry);
|
||||
}
|
||||
// add line to balance:
|
||||
$balance->addBalanceLine($line);
|
||||
$balance->addBalanceLine($this->createBalanceLine($budget, $accounts, $spentData));
|
||||
}
|
||||
|
||||
// then a new line for without budget.
|
||||
// and one for the tags:
|
||||
// and one for "left unbalanced".
|
||||
$empty = new BalanceLine;
|
||||
$tags = new BalanceLine;
|
||||
$diffLine = new BalanceLine;
|
||||
$tagsLeft = $tagRepository->allCoveredByBalancingActs($accounts, $start, $end);
|
||||
|
||||
$tags->setRole(BalanceLine::ROLE_TAGROLE);
|
||||
$diffLine->setRole(BalanceLine::ROLE_DIFFROLE);
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$entry = $spentData->filter(
|
||||
function (TransactionJournal $model) use ($account) {
|
||||
return $model->account_id == $account->id && is_null($model->budget_id);
|
||||
}
|
||||
);
|
||||
$spent = 0;
|
||||
if (!is_null($entry->first())) {
|
||||
$spent = $entry->first()->spent;
|
||||
}
|
||||
$leftEntry = $tagsLeft->filter(
|
||||
function (Tag $tag) use ($account) {
|
||||
return $tag->account_id == $account->id;
|
||||
}
|
||||
);
|
||||
$left = 0;
|
||||
if (!is_null($leftEntry->first())) {
|
||||
$left = $leftEntry->first()->sum;
|
||||
}
|
||||
bcscale(2);
|
||||
$diff = bcadd($spent, $left);
|
||||
|
||||
// budget
|
||||
$budgetEntry = new BalanceEntry;
|
||||
$budgetEntry->setAccount($account);
|
||||
$budgetEntry->setSpent($spent);
|
||||
$empty->addBalanceEntry($budgetEntry);
|
||||
|
||||
// balanced by tags
|
||||
$tagEntry = new BalanceEntry;
|
||||
$tagEntry->setAccount($account);
|
||||
$tagEntry->setLeft($left);
|
||||
$tags->addBalanceEntry($tagEntry);
|
||||
|
||||
// difference:
|
||||
$diffEntry = new BalanceEntry;
|
||||
$diffEntry->setAccount($account);
|
||||
$diffEntry->setSpent($diff);
|
||||
$diffLine->addBalanceEntry($diffEntry);
|
||||
|
||||
}
|
||||
|
||||
$balance->addBalanceLine($empty);
|
||||
$balance->addBalanceLine($tags);
|
||||
$balance->addBalanceLine($diffLine);
|
||||
$balance->addBalanceLine($this->createEmptyBalanceLine($accounts, $spentData));
|
||||
$balance->addBalanceLine($this->createTagsBalanceLine($accounts, $start, $end));
|
||||
$balance->addBalanceLine($this->createDifferenceBalanceLine($accounts, $spentData, $start, $end));
|
||||
|
||||
$balance->setBalanceHeader($header);
|
||||
|
||||
@ -511,4 +443,157 @@ class ReportHelper implements ReportHelperInterface
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Collection $accounts
|
||||
* @param Collection $spentData
|
||||
*
|
||||
* @return BalanceLine
|
||||
*/
|
||||
private function createBalanceLine(BudgetModel $budget, Collection $accounts, Collection $spentData)
|
||||
{
|
||||
$line = new BalanceLine;
|
||||
$line->setBudget($budget);
|
||||
|
||||
// loop accounts:
|
||||
foreach ($accounts as $account) {
|
||||
$balanceEntry = new BalanceEntry;
|
||||
$balanceEntry->setAccount($account);
|
||||
|
||||
// get spent:
|
||||
$entry = $spentData->filter(
|
||||
function (TransactionJournal $model) use ($budget, $account) {
|
||||
return $model->account_id == $account->id && $model->budget_id == $budget->id;
|
||||
}
|
||||
);
|
||||
$spent = 0;
|
||||
if (!is_null($entry->first())) {
|
||||
$spent = $entry->first()->spent;
|
||||
}
|
||||
$balanceEntry->setSpent($spent);
|
||||
$line->addBalanceEntry($balanceEntry);
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $spentData
|
||||
*
|
||||
* @return BalanceLine
|
||||
*/
|
||||
private function createEmptyBalanceLine(Collection $accounts, Collection $spentData)
|
||||
{
|
||||
$empty = new BalanceLine;
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$entry = $spentData->filter(
|
||||
function (TransactionJournal $model) use ($account) {
|
||||
return $model->account_id == $account->id && is_null($model->budget_id);
|
||||
}
|
||||
);
|
||||
$spent = 0;
|
||||
if (!is_null($entry->first())) {
|
||||
$spent = $entry->first()->spent;
|
||||
}
|
||||
|
||||
// budget
|
||||
$budgetEntry = new BalanceEntry;
|
||||
$budgetEntry->setAccount($account);
|
||||
$budgetEntry->setSpent($spent);
|
||||
$empty->addBalanceEntry($budgetEntry);
|
||||
|
||||
}
|
||||
|
||||
return $empty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return BalanceLine
|
||||
*/
|
||||
private function createTagsBalanceLine(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
$tags = new BalanceLine;
|
||||
$tagsLeft = $this->tagRepository->allCoveredByBalancingActs($accounts, $start, $end);
|
||||
|
||||
$tags->setRole(BalanceLine::ROLE_TAGROLE);
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$leftEntry = $tagsLeft->filter(
|
||||
function (Tag $tag) use ($account) {
|
||||
return $tag->account_id == $account->id;
|
||||
}
|
||||
);
|
||||
$left = 0;
|
||||
if (!is_null($leftEntry->first())) {
|
||||
$left = $leftEntry->first()->sum;
|
||||
}
|
||||
bcscale(2);
|
||||
|
||||
// balanced by tags
|
||||
$tagEntry = new BalanceEntry;
|
||||
$tagEntry->setAccount($account);
|
||||
$tagEntry->setLeft($left);
|
||||
$tags->addBalanceEntry($tagEntry);
|
||||
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $spentData
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
* @return BalanceLine
|
||||
*/
|
||||
private function createDifferenceBalanceLine(Collection $accounts, Collection $spentData, Carbon $start, Carbon $end)
|
||||
{
|
||||
$diff = new BalanceLine;
|
||||
$tagsLeft = $this->tagRepository->allCoveredByBalancingActs($accounts, $start, $end);
|
||||
|
||||
$diff->setRole(BalanceLine::ROLE_DIFFROLE);
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$entry = $spentData->filter(
|
||||
function (TransactionJournal $model) use ($account) {
|
||||
return $model->account_id == $account->id && is_null($model->budget_id);
|
||||
}
|
||||
);
|
||||
$spent = 0;
|
||||
if (!is_null($entry->first())) {
|
||||
$spent = $entry->first()->spent;
|
||||
}
|
||||
$leftEntry = $tagsLeft->filter(
|
||||
function (Tag $tag) use ($account) {
|
||||
return $tag->account_id == $account->id;
|
||||
}
|
||||
);
|
||||
$left = 0;
|
||||
if (!is_null($leftEntry->first())) {
|
||||
$left = $leftEntry->first()->sum;
|
||||
}
|
||||
bcscale(2);
|
||||
$diffValue = bcadd($spent, $left);
|
||||
|
||||
// difference:
|
||||
$diffEntry = new BalanceEntry;
|
||||
$diffEntry->setAccount($account);
|
||||
$diffEntry->setSpent($diffValue);
|
||||
$diff->addBalanceEntry($diffEntry);
|
||||
|
||||
}
|
||||
|
||||
return $diff;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
->get(
|
||||
[
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`,"%Y-%m") AS `dateFormatted`'),
|
||||
DB::Raw('SUM(`t_from`.`amount`) AS `sum`')
|
||||
DB::Raw('SUM(`t_from`.`amount`) AS `sum`'),
|
||||
]
|
||||
);
|
||||
$array = [];
|
||||
@ -95,7 +95,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
->get(
|
||||
[
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`,"%Y-%m") AS `dateFormatted`'),
|
||||
DB::Raw('SUM(`t_to`.`amount`) AS `sum`')
|
||||
DB::Raw('SUM(`t_to`.`amount`) AS `sum`'),
|
||||
]
|
||||
);
|
||||
$array = [];
|
||||
|
@ -133,7 +133,7 @@ class AccountController extends Controller
|
||||
'ccMonthlyPaymentDate' => $account->getMeta('ccMonthlyPaymentDate'),
|
||||
'openingBalanceDate' => $openingBalance ? $openingBalance->date->format('Y-m-d') : null,
|
||||
'openingBalance' => $openingBalanceAmount,
|
||||
'virtualBalance' => round($account->virtual_balance, 2)
|
||||
'virtualBalance' => round($account->virtual_balance, 2),
|
||||
];
|
||||
Session::flash('preFilled', $preFilled);
|
||||
Session::flash('gaEventCategory', 'accounts');
|
||||
@ -251,12 +251,10 @@ class AccountController extends Controller
|
||||
'virtualBalance' => round($request->input('virtualBalance'), 2),
|
||||
'openingBalance' => round($request->input('openingBalance'), 2),
|
||||
'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
|
||||
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
|
||||
'openingBalanceCurrency' => intval($request->input('amount_currency_id_openingBalance')),
|
||||
'ccType' => $request->input('ccType'),
|
||||
'ccMonthlyPaymentDate' => $request->input('ccMonthlyPaymentDate'),
|
||||
];
|
||||
|
||||
|
||||
$repository->update($account, $accountData);
|
||||
|
||||
Session::flash('success', 'Account "' . $account->name . '" updated.');
|
||||
|
@ -66,15 +66,7 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$this->validate(
|
||||
$request, [
|
||||
$this->loginUsername() => 'required', 'password' => 'required',
|
||||
]
|
||||
);
|
||||
|
||||
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||
// the login attempts for this application. We'll key this by the username and
|
||||
// the IP address of the client making these requests into this application.
|
||||
$this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required',]);
|
||||
$throttles = $this->isUsingThrottlesLoginsTrait();
|
||||
|
||||
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
|
||||
@ -102,10 +94,6 @@ class AuthController extends Controller
|
||||
$message = trans('firefly.' . $code . '_error', ['email' => $credentials['email']]);
|
||||
}
|
||||
|
||||
|
||||
// If the login attempt was unsuccessful we will increment the number of attempts
|
||||
// to login and redirect the user back to the login form. Of course, when this
|
||||
// user surpasses their maximum number of attempts they will get locked out.
|
||||
if ($throttles) {
|
||||
$this->incrementLoginAttempts($request);
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ class BudgetController extends Controller
|
||||
* @param Collection $accounts
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function multiYear(BudgetRepositoryInterface $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets)
|
||||
|
@ -43,6 +43,8 @@ class CategoryController extends Controller
|
||||
* @param SCRI $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function all(SCRI $repository, Category $category)
|
||||
@ -53,8 +55,6 @@ class CategoryController extends Controller
|
||||
$start = Navigation::startOfPeriod($start, $range);
|
||||
$end = new Carbon;
|
||||
$entries = new Collection;
|
||||
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
@ -67,29 +67,21 @@ class CategoryController extends Controller
|
||||
$spentArray = $repository->spentPerDay($category, $start, $end);
|
||||
$earnedArray = $repository->earnedPerDay($category, $start, $end);
|
||||
|
||||
|
||||
while ($start <= $end) {
|
||||
$currentEnd = Navigation::endOfPeriod($start, $range);
|
||||
|
||||
// get the sum from $spentArray and $earnedArray:
|
||||
$spent = $this->getSumOfRange($start, $currentEnd, $spentArray);
|
||||
$earned = $this->getSumOfRange($start, $currentEnd, $earnedArray);
|
||||
|
||||
$date = Navigation::periodShow($start, $range);
|
||||
$spent = $this->getSumOfRange($start, $currentEnd, $spentArray);
|
||||
$earned = $this->getSumOfRange($start, $currentEnd, $earnedArray);
|
||||
$date = Navigation::periodShow($start, $range);
|
||||
$entries->push([clone $start, $date, $spent, $earned]);
|
||||
$start = Navigation::addPeriod($start, $range, 0);
|
||||
}
|
||||
// limit the set to the last 40:
|
||||
$entries = $entries->reverse();
|
||||
$entries = $entries->slice(0, 48);
|
||||
$entries = $entries->reverse();
|
||||
|
||||
$data = $this->generator->all($entries);
|
||||
$data = $this->generator->all($entries);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -161,23 +153,8 @@ class CategoryController extends Controller
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/**
|
||||
* category
|
||||
* year:
|
||||
* spent: x
|
||||
* earned: x
|
||||
* year
|
||||
* spent: x
|
||||
* earned: x
|
||||
*/
|
||||
$entries = new Collection;
|
||||
// go by category, not by year.
|
||||
|
||||
// given a set of categories and accounts, it should not be difficult to get
|
||||
// the exact array of data we need.
|
||||
|
||||
// then get the data for "no category".
|
||||
$set = $repository->listMultiYear($categories, $accounts, $start, $end);
|
||||
$set = $repository->listMultiYear($categories, $accounts, $start, $end);
|
||||
|
||||
/** @var Category $category */
|
||||
foreach ($categories as $category) {
|
||||
@ -336,6 +313,10 @@ class CategoryController extends Controller
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // cant avoid it.
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // it's long but ok.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function earnedInPeriod(CRI $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
@ -360,18 +341,15 @@ class CategoryController extends Controller
|
||||
$entries = new Collection;
|
||||
|
||||
while ($start < $end) { // filter the set:
|
||||
$row = [clone $start];
|
||||
// get possibly relevant entries from the big $set
|
||||
$currentSet = $set->filter(
|
||||
$row = [clone $start];
|
||||
$currentSet = $set->filter( // get possibly relevant entries from the big $set
|
||||
function (Category $category) use ($start) {
|
||||
return $category->dateFormatted == $start->format("Y-m");
|
||||
}
|
||||
);
|
||||
// check for each category if its in the current set.
|
||||
/** @var Category $category */
|
||||
foreach ($categories as $category) {
|
||||
// if its in there, use the value.
|
||||
$entry = $currentSet->filter(
|
||||
foreach ($categories as $category) { // check for each category if its in the current set.
|
||||
$entry = $currentSet->filter( // if its in there, use the value.
|
||||
function (Category $cat) use ($category) {
|
||||
return ($cat->id == $category->id);
|
||||
}
|
||||
@ -382,7 +360,6 @@ class CategoryController extends Controller
|
||||
$row[] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$entries->push($row);
|
||||
$start->addMonth();
|
||||
}
|
||||
@ -403,6 +380,9 @@ class CategoryController extends Controller
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
|
||||
* @SuppressWarnings(PHPMD.ExcessuveMethodLength) // need the length
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function spentInPeriod(CRI $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
@ -427,18 +407,15 @@ class CategoryController extends Controller
|
||||
$entries = new Collection;
|
||||
|
||||
while ($start < $end) { // filter the set:
|
||||
$row = [clone $start];
|
||||
// get possibly relevant entries from the big $set
|
||||
$currentSet = $set->filter(
|
||||
$row = [clone $start];
|
||||
$currentSet = $set->filter(// get possibly relevant entries from the big $set
|
||||
function (Category $category) use ($start) {
|
||||
return $category->dateFormatted == $start->format("Y-m");
|
||||
}
|
||||
);
|
||||
// check for each category if its in the current set.
|
||||
/** @var Category $category */
|
||||
foreach ($categories as $category) {
|
||||
// if its in there, use the value.
|
||||
$entry = $currentSet->filter(
|
||||
foreach ($categories as $category) {// check for each category if its in the current set.
|
||||
$entry = $currentSet->filter(// if its in there, use the value.
|
||||
function (Category $cat) use ($category) {
|
||||
return ($cat->id == $category->id);
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ class ReportController extends Controller
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // cant avoid it.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function yearInOut(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
|
@ -57,7 +57,7 @@ class Controller extends BaseController
|
||||
$localeconv = [
|
||||
'mon_decimal_point' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)),
|
||||
'mon_thousands_sep' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL)),
|
||||
'frac_digits' => $numberFormatter->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)
|
||||
'frac_digits' => $numberFormatter->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS),
|
||||
];
|
||||
View::share('monthFormat', $this->monthFormat);
|
||||
View::share('monthAndDayFormat', $this->monthAndDayFormat);
|
||||
|
@ -79,8 +79,8 @@ class CsvController extends Controller
|
||||
if ($this->data->hasHeaders()) {
|
||||
$headers = $firstRow;
|
||||
}
|
||||
|
||||
foreach (Config::get('csv.roles') as $name => $role) {
|
||||
$keys = array_keys(Config::get('csv.roles'));
|
||||
foreach ($keys as $name) {
|
||||
$availableRoles[$name] = trans('firefly.csv_column_' . $name);//$role['name'];
|
||||
}
|
||||
ksort($availableRoles);
|
||||
@ -105,7 +105,7 @@ class CsvController extends Controller
|
||||
}
|
||||
$data = [
|
||||
'date-format' => Session::get('csv-date-format'),
|
||||
'has-headers' => Session::get('csv-has-headers')
|
||||
'has-headers' => Session::get('csv-has-headers'),
|
||||
];
|
||||
if (Session::has('csv-map')) {
|
||||
$data['map'] = Session::get('csv-map');
|
||||
@ -162,6 +162,7 @@ class CsvController extends Controller
|
||||
Session::forget('csv-roles');
|
||||
Session::forget('csv-mapped');
|
||||
Session::forget('csv-specifix');
|
||||
SessioN::forget('csv-delimiter');
|
||||
|
||||
// get list of supported specifix
|
||||
$specifix = [];
|
||||
@ -169,6 +170,13 @@ class CsvController extends Controller
|
||||
$specifix[$entry] = trans('firefly.csv_specifix_' . $entry);
|
||||
}
|
||||
|
||||
// get a list of delimiters:
|
||||
$delimiters = [
|
||||
',' => trans('form.csv_comma'),
|
||||
';' => trans('form.csv_semicolon'),
|
||||
'tab' => trans('form.csv_tab'),
|
||||
];
|
||||
|
||||
// get a list of asset accounts:
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Asset account', 'Default account']));
|
||||
|
||||
@ -176,7 +184,7 @@ class CsvController extends Controller
|
||||
$uploadPossible = is_writable(storage_path('upload'));
|
||||
$path = storage_path('upload');
|
||||
|
||||
return view('csv.index', compact('subTitle', 'uploadPossible', 'path', 'specifix', 'accounts'));
|
||||
return view('csv.index', compact('subTitle', 'uploadPossible', 'path', 'specifix', 'accounts', 'delimiters'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -323,6 +331,8 @@ class CsvController extends Controller
|
||||
*
|
||||
* STEP SIX
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) it's 6, but it's allright.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function saveMapping()
|
||||
@ -367,6 +377,9 @@ class CsvController extends Controller
|
||||
*
|
||||
* STEP TWO
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // need the length.
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly 5, its ok
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
@ -385,9 +398,17 @@ class CsvController extends Controller
|
||||
$settings['has-headers'] = intval(Input::get('has_headers')) === 1;
|
||||
$settings['specifix'] = Input::get('specifix');
|
||||
$settings['import-account'] = intval(Input::get('csv_import_account'));
|
||||
$settings['map'] = [];
|
||||
$settings['mapped'] = [];
|
||||
$settings['roles'] = [];
|
||||
$settings['delimiter'] = Input::get('csv_delimiter', ',');
|
||||
|
||||
// A tab character cannot be used itself as option value in HTML
|
||||
// See http://stackoverflow.com/questions/6064135/valid-characters-in-option-value
|
||||
if ($settings['delimiter'] == 'tab') {
|
||||
$settings['delimiter'] = "\t";
|
||||
}
|
||||
|
||||
$settings['map'] = [];
|
||||
$settings['mapped'] = [];
|
||||
$settings['roles'] = [];
|
||||
|
||||
if ($request->hasFile('csv_config')) { // Process config file if present.
|
||||
$data = file_get_contents($request->file('csv_config')->getRealPath());
|
||||
@ -405,6 +426,7 @@ class CsvController extends Controller
|
||||
$this->data->setRoles($settings['roles']);
|
||||
$this->data->setSpecifix($settings['specifix']);
|
||||
$this->data->setImportAccount($settings['import-account']);
|
||||
$this->data->setDelimiter($settings['delimiter']);
|
||||
|
||||
return redirect(route('csv.column-roles'));
|
||||
|
||||
|
@ -186,7 +186,7 @@ class PiggyBankController extends Controller
|
||||
'leftForPiggyBanks' => $repository->leftOnAccount($account, $end),
|
||||
'sumOfSaved' => $piggyBank->savedSoFar,
|
||||
'sumOfTargets' => round($piggyBank->targetamount, 2),
|
||||
'leftToSave' => $piggyBank->leftToSave
|
||||
'leftToSave' => $piggyBank->leftToSave,
|
||||
];
|
||||
} else {
|
||||
$accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], $piggyBank->savedSoFar);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\DeleteAccountFormRequest;
|
||||
use FireflyIII\Http\Requests\ProfileFormRequest;
|
||||
use FireflyIII\User;
|
||||
@ -126,7 +125,7 @@ class ProfileController extends Controller
|
||||
'email' => $email,
|
||||
'password' => 'deleted',
|
||||
'blocked' => 1,
|
||||
'blocked_code' => 'deleted'
|
||||
'blocked_code' => 'deleted',
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\RuleFormRequest;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
@ -54,7 +53,7 @@ class RuleController extends Controller
|
||||
|
||||
// process the rule itself:
|
||||
$data = [
|
||||
'rule_group_id' => intval($request->get('rule_group_id')),
|
||||
'rule_group_id' => $ruleGroup->id,
|
||||
'title' => $request->get('title'),
|
||||
'trigger' => $request->get('trigger'),
|
||||
'description' => $request->get('description'),
|
||||
@ -101,44 +100,12 @@ class RuleController extends Controller
|
||||
// has old input?
|
||||
if (Input::old()) {
|
||||
// process old triggers.
|
||||
$newIndex = 0;
|
||||
foreach (Input::old('rule-trigger') as $index => $entry) {
|
||||
$count = ($newIndex + 1);
|
||||
$triggerCount++;
|
||||
$oldTrigger = $entry;
|
||||
$oldValue = Input::old('rule-trigger-value')[$index];
|
||||
$oldChecked = isset(Input::old('rule-trigger-stop')[$index]) ? true : false;
|
||||
$oldTriggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => $oldTrigger,
|
||||
'oldValue' => $oldValue,
|
||||
'oldChecked' => $oldChecked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
$oldTriggers = $this->getPreviousTriggers();
|
||||
$triggerCount = count($oldTriggers);
|
||||
|
||||
// process old actions
|
||||
$newIndex = 0;
|
||||
foreach (Input::old('rule-action') as $index => $entry) {
|
||||
$count = ($newIndex + 1);
|
||||
$actionCount++;
|
||||
$oldAction = $entry;
|
||||
$oldValue = Input::old('rule-action-value')[$index];
|
||||
$oldChecked = isset(Input::old('rule-action-stop')[$index]) ? true : false;
|
||||
$oldActions[] = view(
|
||||
'rules.partials.action',
|
||||
[
|
||||
'oldTrigger' => $oldAction,
|
||||
'oldValue' => $oldValue,
|
||||
'oldChecked' => $oldChecked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
$oldActions = $this->getPreviousActions();
|
||||
$actionCount = count($oldActions);
|
||||
}
|
||||
|
||||
$subTitleIcon = 'fa-clone';
|
||||
@ -164,114 +131,22 @@ class RuleController extends Controller
|
||||
*/
|
||||
public function edit(Rule $rule)
|
||||
{
|
||||
|
||||
// count for current rule's triggers/actions.
|
||||
$triggerCount = 0;
|
||||
$actionCount = 0;
|
||||
|
||||
// collection of those triggers/actions.
|
||||
$oldTriggers = [];
|
||||
$oldActions = [];
|
||||
|
||||
// has old input?
|
||||
if (Input::old()) {
|
||||
// process old triggers.
|
||||
$newIndex = 0;
|
||||
foreach (Input::old('rule-trigger') as $index => $entry) {
|
||||
$count = ($newIndex + 1);
|
||||
$triggerCount++;
|
||||
$oldTrigger = $entry;
|
||||
$oldValue = Input::old('rule-trigger-value')[$index];
|
||||
$oldChecked = isset(Input::old('rule-trigger-stop')[$index]) ? true : false;
|
||||
$oldTriggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => $oldTrigger,
|
||||
'oldValue' => $oldValue,
|
||||
'oldChecked' => $oldChecked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
|
||||
// process old actions
|
||||
$newIndex = 0;
|
||||
foreach (Input::old('rule-action') as $index => $entry) {
|
||||
$count = ($newIndex + 1);
|
||||
$actionCount++;
|
||||
$oldAction = $entry;
|
||||
$oldValue = Input::old('rule-action-value')[$index];
|
||||
$oldChecked = isset(Input::old('rule-action-stop')[$index]) ? true : false;
|
||||
$oldActions[] = view(
|
||||
'rules.partials.action',
|
||||
[
|
||||
'oldTrigger' => $oldAction,
|
||||
'oldValue' => $oldValue,
|
||||
'oldChecked' => $oldChecked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
$oldTriggers = $this->getPreviousTriggers();
|
||||
$triggerCount = count($oldTriggers);
|
||||
$oldActions = $this->getPreviousActions();
|
||||
$actionCount = count($oldActions);
|
||||
} else {
|
||||
// get current triggers
|
||||
$newIndex = 0;
|
||||
/**
|
||||
* @var int $index
|
||||
* @var RuleTrigger $entry
|
||||
*/
|
||||
foreach ($rule->ruleTriggers as $index => $entry) {
|
||||
if ($entry->trigger_type != 'user_action') {
|
||||
$count = ($newIndex + 1);
|
||||
$triggerCount++;
|
||||
$oldTrigger = $entry->trigger_type;
|
||||
$oldValue = $entry->trigger_value;
|
||||
$oldChecked = $entry->stop_processing;
|
||||
$oldTriggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => $oldTrigger,
|
||||
'oldValue' => $oldValue,
|
||||
'oldChecked' => $oldChecked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// get current actions
|
||||
$newIndex = 0;
|
||||
/**
|
||||
* @var int $index
|
||||
* @var RuleAction $entry
|
||||
*/
|
||||
foreach ($rule->ruleActions as $index => $entry) {
|
||||
$count = ($newIndex + 1);
|
||||
$actionCount++;
|
||||
$oldAction = $entry->action_type;
|
||||
$oldValue = $entry->action_value;
|
||||
$oldChecked = $entry->stop_processing;
|
||||
$oldActions[] = view(
|
||||
'rules.partials.action',
|
||||
[
|
||||
'oldTrigger' => $oldAction,
|
||||
'oldValue' => $oldValue,
|
||||
'oldChecked' => $oldChecked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
$oldTriggers = $this->getCurrentTriggers($rule);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$oldActions = $this->getCurrentActions($rule);
|
||||
$actionCount = count($oldActions);
|
||||
}
|
||||
|
||||
// get rule trigger for update / store-journal:
|
||||
$primaryTrigger = $rule->ruleTriggers()->where('trigger_type', 'user_action')->first()->trigger_value;
|
||||
|
||||
|
||||
$subTitle = trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
$subTitle = trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (Session::get('rules.rule.edit.fromUpdate') !== true) {
|
||||
@ -283,9 +158,9 @@ class RuleController extends Controller
|
||||
|
||||
return view(
|
||||
'rules.rule.edit', compact(
|
||||
'rule', 'subTitle', 'primaryTrigger',
|
||||
'oldTriggers', 'oldActions', 'triggerCount', 'actionCount'
|
||||
)
|
||||
'rule', 'subTitle', 'primaryTrigger',
|
||||
'oldTriggers', 'oldActions', 'triggerCount', 'actionCount'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -459,5 +334,113 @@ class RuleController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getCurrentActions(Rule $rule)
|
||||
{
|
||||
$index = 0;
|
||||
$actions = [];
|
||||
|
||||
/** @var RuleAction $entry */
|
||||
foreach ($rule->ruleActions as $entry) {
|
||||
$count = ($index + 1);
|
||||
$actions[] = view(
|
||||
'rules.partials.action',
|
||||
[
|
||||
'oldTrigger' => $entry->action_type,
|
||||
'oldValue' => $entry->action_value,
|
||||
'oldChecked' => $entry->stop_processing,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$index++;
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getCurrentTriggers(Rule $rule)
|
||||
{
|
||||
$index = 0;
|
||||
$triggers = [];
|
||||
|
||||
/** @var RuleTrigger $entry */
|
||||
foreach ($rule->ruleTriggers as $entry) {
|
||||
if ($entry->trigger_type != 'user_action') {
|
||||
$count = ($index + 1);
|
||||
$triggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => $entry->trigger_type,
|
||||
'oldValue' => $entry->trigger_value,
|
||||
'oldChecked' => $entry->stop_processing,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
return $triggers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getPreviousActions()
|
||||
{
|
||||
$newIndex = 0;
|
||||
$actions = [];
|
||||
foreach (Input::old('rule-action') as $index => $entry) {
|
||||
$count = ($newIndex + 1);
|
||||
$checked = isset(Input::old('rule-action-stop')[$index]) ? true : false;
|
||||
$actions[] = view(
|
||||
'rules.partials.action',
|
||||
[
|
||||
'oldTrigger' => $entry,
|
||||
'oldValue' => Input::old('rule-action-value')[$index],
|
||||
'oldChecked' => $checked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getPreviousTriggers()
|
||||
{
|
||||
$newIndex = 0;
|
||||
$triggers = [];
|
||||
foreach (Input::old('rule-trigger') as $index => $entry) {
|
||||
$count = ($newIndex + 1);
|
||||
$oldChecked = isset(Input::old('rule-trigger-stop')[$index]) ? true : false;
|
||||
$triggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => $entry,
|
||||
'oldValue' => Input::old('rule-trigger-value')[$index],
|
||||
'oldChecked' => $oldChecked,
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
}
|
||||
|
||||
return $triggers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class RuleGroupController extends Controller
|
||||
Session::flash('gaEventCategory', 'rules');
|
||||
Session::flash('gaEventAction', 'create-rule-group');
|
||||
|
||||
return view('rules.rule-group.create', compact('subTitleIcon', 'what', 'subTitle'));
|
||||
return view('rules.rule-group.create', compact('subTitleIcon', 'subTitle'));
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ class TagController extends Controller
|
||||
$subTitleIcon = 'fa-tag';
|
||||
|
||||
$preFilled = [
|
||||
'tagMode' => 'nothing'
|
||||
'tagMode' => 'nothing',
|
||||
];
|
||||
if (!Input::old('tagMode')) {
|
||||
Session::flash('preFilled', $preFilled);
|
||||
|
@ -58,9 +58,7 @@ class TransactionController extends Controller
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get());
|
||||
$budgets[0] = trans('form.noBudget');
|
||||
|
||||
// piggy bank list:
|
||||
$piggyBanks = Auth::user()->piggyBanks()->orderBy('order', 'ASC')->get();
|
||||
$piggyBanks = Auth::user()->piggyBanks()->orderBy('order', 'ASC')->get();
|
||||
/** @var PiggyBank $piggy */
|
||||
foreach ($piggyBanks as $piggy) {
|
||||
$piggy->name = $piggy->name . ' (' . Amount::format($piggy->currentRelevantRep()->currentamount, false) . ')';
|
||||
@ -161,7 +159,7 @@ class TransactionController extends Controller
|
||||
'date' => $journal->date->format('Y-m-d'),
|
||||
'category' => '',
|
||||
'budget_id' => 0,
|
||||
'piggy_bank_id' => 0
|
||||
'piggy_bank_id' => 0,
|
||||
];
|
||||
// get tags:
|
||||
$preFilled['tags'] = join(',', $journal->tags->pluck('tag')->toArray());
|
||||
@ -295,7 +293,6 @@ class TransactionController extends Controller
|
||||
*/
|
||||
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att)
|
||||
{
|
||||
|
||||
$journalData = $request->getJournalData();
|
||||
|
||||
// if not withdrawal, unset budgetid.
|
||||
@ -305,7 +302,6 @@ class TransactionController extends Controller
|
||||
|
||||
$journal = $repository->store($journalData);
|
||||
|
||||
// save attachments:
|
||||
$att->saveAttachmentsForModel($journal);
|
||||
|
||||
// flash errors
|
||||
@ -347,10 +343,6 @@ class TransactionController extends Controller
|
||||
public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att, TransactionJournal $journal)
|
||||
{
|
||||
|
||||
if ($journal->isOpeningBalance()) {
|
||||
return view('error')->with('message', 'Cannot edit this transaction. Edit the account instead!');
|
||||
}
|
||||
|
||||
$journalData = $request->getJournalData();
|
||||
$repository->update($journal, $journalData);
|
||||
|
||||
|
@ -54,6 +54,7 @@ class Binder
|
||||
private function performBinding($key, $value, $route)
|
||||
{
|
||||
$class = $this->binders[$key];
|
||||
|
||||
return $class::routeBinder($value, $route);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ class EncryptCookies extends BaseEncrypter
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
protected $except
|
||||
= [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ class Range
|
||||
Session::put('first', Carbon::now()->startOfYear());
|
||||
}
|
||||
}
|
||||
|
||||
// check "sum of everything".
|
||||
|
||||
|
||||
$current = Carbon::now()->formatLocalized('%B %Y');
|
||||
$next = Carbon::now()->endOfMonth()->addDay()->formatLocalized('%B %Y');
|
||||
$prev = Carbon::now()->startOfMonth()->subDay()->formatLocalized('%B %Y');
|
||||
|
@ -53,7 +53,7 @@ class AccountFormRequest extends Request
|
||||
'ccMonthlyPaymentDate' => 'date',
|
||||
'amount_currency_id_openingBalance' => 'exists:transaction_currencies,id',
|
||||
'amount_currency_id_virtualBalance' => 'exists:transaction_currencies,id',
|
||||
'what' => 'in:' . $types
|
||||
'what' => 'in:' . $types,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class BudgetFormRequest extends Request
|
||||
|
||||
return [
|
||||
'name' => $nameRule,
|
||||
'active' => 'numeric|between:0,1'
|
||||
'active' => 'numeric|between:0,1',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ class RuleFormRequest extends Request
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$rules['rule-action-value.' . $i] = 'required_if:rule-action.' . $i . ',' . $contextActions . '|ruleActionValue';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class RuleGroupFormRequest extends Request
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => $titleRule,
|
||||
'title' => $titleRule,
|
||||
'description' => 'between:1,5000',
|
||||
];
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class TagFormRequest extends Request
|
||||
'latitude' => 'numeric|min:-90|max:90',
|
||||
'longitude' => 'numeric|min:-90|max:90',
|
||||
'zoomLevel' => 'numeric|min:0|max:80',
|
||||
'tagMode' => 'required|in:nothing,balancingAct,advancePayment'
|
||||
'tagMode' => 'required|in:nothing,balancingAct,advancePayment',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ use Crypt;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\Account
|
||||
*
|
||||
@ -30,8 +30,8 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBank[] $piggyBanks
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
|
||||
* @property-read \FireflyIII\User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account accountTypeIn($types)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account hasMetaValue($name, $value)
|
||||
* @method static Builder|\FireflyIII\Models\Account accountTypeIn($types)
|
||||
* @method static Builder|\FireflyIII\Models\Account hasMetaValue($name, $value)
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
*/
|
||||
@ -41,12 +41,13 @@ class Account extends Model
|
||||
|
||||
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
|
||||
protected $hidden = ['virtual_balance_encrypted', 'encrypted'];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $rules
|
||||
= [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'account_type_id' => 'required|exists:account_types,id',
|
||||
'name' => 'required',
|
||||
'active' => 'required|boolean'
|
||||
'active' => 'required|boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -126,15 +127,6 @@ class Account extends Model
|
||||
return $this->belongsTo('FireflyIII\Models\AccountType');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -293,6 +285,11 @@ class Account extends Model
|
||||
return $this->belongsTo('FireflyIII\User');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $value
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public static function routeBinder(Account $value)
|
||||
{
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\AccountMeta
|
||||
@ -18,14 +17,8 @@ use Watson\Validating\ValidatingTrait;
|
||||
class AccountMeta extends Model
|
||||
{
|
||||
|
||||
use ValidatingTrait;
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
protected $fillable = ['account_id', 'name', 'data'];
|
||||
protected $rules
|
||||
= [
|
||||
'account_id' => 'required|exists:accounts,id',
|
||||
'name' => 'required|between:1,100',
|
||||
'data' => 'required'
|
||||
];
|
||||
protected $table = 'account_meta';
|
||||
|
||||
/**
|
||||
@ -48,14 +41,6 @@ class AccountMeta extends Model
|
||||
return json_decode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
|
@ -17,6 +17,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class AccountType extends Model
|
||||
{
|
||||
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
//
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
@ -25,13 +27,4 @@ class AccountType extends Model
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
/** @noinspection PhpMissingParentCallCommonInspection */
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at'];
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +175,11 @@ class Attachment extends Model
|
||||
$this->attributes['notes'] = Crypt::encrypt($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $value
|
||||
*
|
||||
* @return Attachment
|
||||
*/
|
||||
public static function routeBinder(Attachment $value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
|
@ -28,6 +28,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property boolean $match_encrypted
|
||||
* @property-read Collection|TransactionJournal[] $transactionjournals
|
||||
* @property-read User $user
|
||||
* @property Carbon $nextExpectedMatch
|
||||
* @property Carbon $lastFoundMatch
|
||||
*/
|
||||
class Bill extends Model
|
||||
{
|
||||
@ -36,15 +38,7 @@ class Bill extends Model
|
||||
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
|
||||
|
||||
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'date'];
|
||||
}
|
||||
protected $dates = ['created_at', 'updated_at', 'date'];
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
@ -127,6 +121,11 @@ class Bill extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Bill $value
|
||||
*
|
||||
* @return Bill
|
||||
*/
|
||||
public static function routeBinder(Bill $value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
|
@ -23,6 +23,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property-read Collection|BudgetLimit[] $budgetlimits
|
||||
* @property-read Collection|TransactionJournal[] $transactionjournals
|
||||
* @property-read User $user
|
||||
* @property string $dateFormatted
|
||||
* @property string $budgeted
|
||||
*/
|
||||
class Budget extends Model
|
||||
{
|
||||
@ -31,6 +33,7 @@ class Budget extends Model
|
||||
|
||||
protected $fillable = ['user_id', 'name', 'active'];
|
||||
protected $hidden = ['encrypted'];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'startdate', 'enddate'];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
@ -69,14 +72,6 @@ class Budget extends Model
|
||||
return $this->hasMany('FireflyIII\Models\BudgetLimit');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at', 'startdate', 'enddate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
@ -125,6 +120,11 @@ class Budget extends Model
|
||||
return $this->belongsTo('FireflyIII\User');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $value
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public static function routeBinder(Budget $value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
|
@ -22,6 +22,7 @@ class BudgetLimit extends Model
|
||||
{
|
||||
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
protected $dates = ['created_at', 'updated_at', 'startdate'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@ -31,14 +32,6 @@ class BudgetLimit extends Model
|
||||
return $this->belongsTo('FireflyIII\Models\Budget');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'startdate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
@ -21,6 +21,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property boolean $encrypted
|
||||
* @property-read Collection|TransactionJournal[] $transactionjournals
|
||||
* @property-read User $user
|
||||
* @property string $dateFormatted
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
@ -28,6 +29,7 @@ class Category extends Model
|
||||
|
||||
protected $fillable = ['user_id', 'name'];
|
||||
protected $hidden = ['encrypted'];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
@ -57,15 +59,6 @@ class Category extends Model
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -112,6 +105,11 @@ class Category extends Model
|
||||
return $this->belongsTo('FireflyIII\User');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $value
|
||||
*
|
||||
* @return Category
|
||||
*/
|
||||
public static function routeBinder(Category $value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
|
@ -1,24 +1,14 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\Component
|
||||
* Class Component
|
||||
*
|
||||
* @property integer $id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Carbon $deleted_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @package FireflyIII\Models
|
||||
*/
|
||||
class Component extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = ['user_id', 'name', 'class'];
|
||||
|
||||
/**
|
||||
@ -28,4 +18,5 @@ class Component extends Model
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class LimitRepetition extends Model
|
||||
{
|
||||
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
protected $dates = ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@ -30,14 +31,6 @@ class LimitRepetition extends Model
|
||||
return $this->belongsTo('FireflyIII\Models\BudgetLimit');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
@ -47,6 +40,11 @@ class LimitRepetition extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function routeBinder($value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
|
@ -27,7 +27,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property-read Account $account
|
||||
* @property-read Collection|PiggyBankRepetition[] $piggyBankRepetitions
|
||||
* @property-read Collection|PiggyBankEvent[] $piggyBankEvents
|
||||
* @property string $reminder
|
||||
* @property string $reminder
|
||||
*/
|
||||
class PiggyBank extends Model
|
||||
{
|
||||
@ -36,6 +36,7 @@ class PiggyBank extends Model
|
||||
protected $fillable
|
||||
= ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate', 'remind_me', 'reminder_skip'];
|
||||
protected $hidden = ['targetamount_encrypted', 'encrypted'];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'startdate', 'targetdate'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@ -72,14 +73,6 @@ class PiggyBank extends Model
|
||||
return $this->hasMany('FireflyIII\Models\PiggyBankRepetition');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at', 'startdate', 'targetdate'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $value
|
||||
@ -122,6 +115,11 @@ class PiggyBank extends Model
|
||||
$this->attributes['targetamount'] = strval(round($value, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $value
|
||||
*
|
||||
* @return PiggyBank
|
||||
*/
|
||||
public static function routeBinder(PiggyBank $value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
|
@ -19,18 +19,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class PiggyBankEvent extends Model
|
||||
{
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'date'];
|
||||
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
/** @noinspection PhpMissingParentCallCommonInspection */
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'date'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -24,14 +24,7 @@ class PiggyBankRepetition extends Model
|
||||
|
||||
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
|
||||
protected $hidden = ['currentamount_encrypted'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'startdate', 'targetdate'];
|
||||
}
|
||||
protected $dates = ['created_at', 'updated_at', 'startdate', 'targetdate'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@ -23,6 +23,7 @@ class Preference extends Model
|
||||
|
||||
protected $fillable = ['user_id', 'data', 'name'];
|
||||
protected $hidden = ['data_encrypted', 'name_encrypted'];
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
@ -39,14 +40,6 @@ class Preference extends Model
|
||||
return json_decode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
class Rule extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -15,15 +15,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
/**
|
||||
* FireflyIII\Models\RuleAction
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $rule_id
|
||||
* @property integer $order
|
||||
* @property boolean $active
|
||||
* @property boolean $stop_processing
|
||||
* @property string $action_type
|
||||
* @property string $action_value
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $rule_id
|
||||
* @property integer $order
|
||||
* @property boolean $active
|
||||
* @property boolean $stop_processing
|
||||
* @property string $action_type
|
||||
* @property string $action_value
|
||||
* @property-read \FireflyIII\Models\Rule $rule
|
||||
*/
|
||||
class RuleAction extends Model
|
||||
|
@ -14,16 +14,16 @@ use Illuminate\Database\Eloquent\Model;
|
||||
/**
|
||||
* FireflyIII\Models\RuleTrigger
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $rule_id
|
||||
* @property integer $order
|
||||
* @property string $title
|
||||
* @property string $trigger_type
|
||||
* @property string $trigger_value
|
||||
* @property boolean $active
|
||||
* @property boolean $stop_processing
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $rule_id
|
||||
* @property integer $order
|
||||
* @property string $title
|
||||
* @property string $trigger_type
|
||||
* @property string $trigger_value
|
||||
* @property boolean $active
|
||||
* @property boolean $stop_processing
|
||||
* @property-read \FireflyIII\Models\Rule $rule
|
||||
*/
|
||||
class RuleTrigger extends Model
|
||||
|
@ -9,7 +9,6 @@ use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\Tag
|
||||
@ -31,18 +30,8 @@ use Watson\Validating\ValidatingTrait;
|
||||
*/
|
||||
class Tag extends Model
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
|
||||
protected $rules
|
||||
= [
|
||||
'tag' => 'required|min:1',
|
||||
'description' => 'min:1',
|
||||
'date' => 'date',
|
||||
'latitude' => 'numeric|min:-90|max:90',
|
||||
'longitude' => 'numeric|min:-90|max:90',
|
||||
'tagMode' => 'required|in:nothing,balancingAct,advancePayment'
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'date'];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
@ -76,15 +65,6 @@ class Tag extends Model
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'date'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the model to the database.
|
||||
*
|
||||
@ -170,6 +150,11 @@ class Tag extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Tag $value
|
||||
*
|
||||
* @return Tag
|
||||
*/
|
||||
public static function routeBinder(Tag $value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
|
@ -33,8 +33,10 @@ class Transaction extends Model
|
||||
'account_id' => 'required|exists:accounts,id',
|
||||
'transaction_journal_id' => 'required|exists:transaction_journals,id',
|
||||
'description' => 'between:1,255',
|
||||
'amount' => 'required|numeric'
|
||||
'amount' => 'required|numeric',
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
@ -55,14 +57,6 @@ class Transaction extends Model
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
|
@ -25,14 +25,7 @@ class TransactionCurrency extends Model
|
||||
|
||||
|
||||
protected $fillable = ['name', 'code', 'symbol'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
@ -44,6 +37,8 @@ class TransactionCurrency extends Model
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public static function routeBinder(TransactionCurrency $currency)
|
||||
{
|
||||
|
@ -22,13 +22,7 @@ class TransactionGroup extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
|
@ -12,7 +12,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournal
|
||||
@ -55,23 +54,13 @@ use Watson\Validating\ValidatingTrait;
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $fillable
|
||||
= ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted', 'tag_count'];
|
||||
protected $hidden = ['encrypted'];
|
||||
protected $rules
|
||||
= [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'transaction_type_id' => 'required|exists:transaction_types,id',
|
||||
'bill_id' => 'exists:bills,id',
|
||||
'transaction_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'description' => 'required|between:1,1024',
|
||||
'completed' => 'required|boolean',
|
||||
'date' => 'required|date',
|
||||
'encrypted' => 'required|boolean'
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
@ -140,72 +129,6 @@ class TransactionJournal extends Model
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
* @param $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function amountByTagAdvancePayment(Tag $tag, $amount)
|
||||
{
|
||||
if ($this->isWithdrawal()) {
|
||||
$others = $tag->transactionJournals()->transactionTypes([TransactionType::DEPOSIT])->get();
|
||||
foreach ($others as $other) {
|
||||
$amount = bcsub($amount, $other->amount_positive);
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
if ($this->isDeposit()) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tag
|
||||
* @param $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function amountByTagBalancingAct($tag, $amount)
|
||||
{
|
||||
if ($this->isWithdrawal()) {
|
||||
$transfer = $tag->transactionJournals()->transactionTypes([TransactionType::TRANSFER])->first();
|
||||
if ($transfer) {
|
||||
$amount = bcsub($amount, $transfer->amount_positive);
|
||||
|
||||
return $amount;
|
||||
}
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming the journal has only one tag. Parameter amount is used as fallback.
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @param string $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function amountByTag(Tag $tag, $amount)
|
||||
{
|
||||
if ($tag->tagMode == 'advancePayment') {
|
||||
return $this->amountByTagAdvancePayment($tag, $amount);
|
||||
}
|
||||
|
||||
if ($tag->tagMode == 'balancingAct') {
|
||||
return $this->amountByTagBalancingAct($tag, $amount);
|
||||
|
||||
}
|
||||
|
||||
return $amount;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
@ -215,27 +138,6 @@ class TransactionJournal extends Model
|
||||
return $this->belongsToMany('FireflyIII\Models\Tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function amountByTags($amount)
|
||||
{
|
||||
$firstBalancingAct = $this->tags()->where('tagMode', 'balancingAct')->first();
|
||||
if ($firstBalancingAct) {
|
||||
return $this->amountByTag($firstBalancingAct, $amount);
|
||||
}
|
||||
|
||||
$firstAdvancePayment = $this->tags()->where('tagMode', 'advancePayment')->first();
|
||||
if ($firstAdvancePayment) {
|
||||
return $this->amountByTag($firstAdvancePayment, $amount);
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
@ -245,15 +147,6 @@ class TransactionJournal extends Model
|
||||
return $this->hasMany('FireflyIII\Models\Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'date', 'deleted_at'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the model to the database.
|
||||
*
|
||||
@ -314,21 +207,6 @@ class TransactionJournal extends Model
|
||||
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param Account $account
|
||||
*/
|
||||
public function scopeAccountIs(EloquentBuilder $query, Account $account)
|
||||
{
|
||||
if (!isset($this->joinedTransactions)) {
|
||||
$query->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
$this->joinedTransactions = true;
|
||||
}
|
||||
$query->where('transactions.account_id', $account->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -355,19 +233,6 @@ class TransactionJournal extends Model
|
||||
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeOnDate(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
return $query->where('date', '=', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -514,15 +379,18 @@ class TransactionJournal extends Model
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
*
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder($value, $route)
|
||||
public static function routeBinder($value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
$validTypes = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER];
|
||||
$object = TransactionJournal::where('transaction_journals.id', $value)
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereIn('transaction_types.type', $validTypes)
|
||||
->where('user_id', Auth::user()->id)->first(['transaction_journals.*']);
|
||||
if ($object) {
|
||||
return $object;
|
||||
}
|
||||
|
@ -24,13 +24,7 @@ class TransactionType extends Model
|
||||
const TRANSFER = 'Transfer';
|
||||
const OPENING_BALANCE = 'Opening balance';
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
@ -65,6 +59,8 @@ class TransactionType extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactionJournals()
|
||||
|
@ -17,14 +17,16 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'FireflyIII\Model' => 'FireflyIII\Policies\ModelPolicy',
|
||||
];
|
||||
protected $policies
|
||||
= [
|
||||
'FireflyIII\Model' => 'FireflyIII\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any application authentication / authorization services.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
|
||||
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(GateContract $gate)
|
||||
|
@ -29,19 +29,19 @@ class EventServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected $listen
|
||||
= [
|
||||
'FireflyIII\Events\TransactionJournalUpdated' => [
|
||||
'FireflyIII\Events\TransactionJournalUpdated' => [
|
||||
'FireflyIII\Handlers\Events\ScanForBillsAfterUpdate',
|
||||
|
||||
'FireflyIII\Handlers\Events\UpdateJournalConnection',
|
||||
'FireflyIII\Handlers\Events\FireRulesForUpdate',
|
||||
|
||||
],
|
||||
'FireflyIII\Events\TransactionJournalStored' => [
|
||||
'FireflyIII\Events\TransactionJournalStored' => [
|
||||
'FireflyIII\Handlers\Events\ScanForBillsAfterStore',
|
||||
|
||||
'FireflyIII\Handlers\Events\ConnectJournalToPiggyBank',
|
||||
'FireflyIII\Handlers\Events\FireRulesForStore',
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
@ -11,8 +11,8 @@ use FireflyIII\Support\Twig\Budget;
|
||||
use FireflyIII\Support\Twig\General;
|
||||
use FireflyIII\Support\Twig\Journal;
|
||||
use FireflyIII\Support\Twig\PiggyBank;
|
||||
use FireflyIII\Support\Twig\Translation;
|
||||
use FireflyIII\Support\Twig\Rule;
|
||||
use FireflyIII\Support\Twig\Translation;
|
||||
use FireflyIII\Validation\FireflyValidator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Twig;
|
||||
@ -54,7 +54,6 @@ class FireflyServiceProvider extends ServiceProvider
|
||||
public function register()
|
||||
{
|
||||
|
||||
|
||||
$this->app->bind(
|
||||
'preferences', function () {
|
||||
return new Preferences;
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace FireflyIII\Providers;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
/**
|
||||
* Class RouteServiceProvider
|
||||
@ -24,7 +24,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
@ -37,13 +38,16 @@ class RouteServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->group(['namespace' => $this->namespace], function ($router) {
|
||||
$router->group(
|
||||
['namespace' => $this->namespace], function ($router) {
|
||||
require app_path('Http/routes.php');
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
'accounts.*',
|
||||
'ccType.data as ccType',
|
||||
'accountRole.data as accountRole',
|
||||
DB::Raw('SUM(`transactions`.`amount`) AS `balance`')
|
||||
DB::Raw('SUM(`transactions`.`amount`) AS `balance`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -323,7 +323,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
$journal = TransactionJournal
|
||||
::orderBy('transaction_journals.date', 'ASC')
|
||||
->accountIs($account)
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transactions.account_id', $account->id)
|
||||
->transactionTypes([TransactionType::OPENING_BALANCE])
|
||||
->orderBy('created_at', 'ASC')
|
||||
->first(['transaction_journals.*']);
|
||||
@ -377,6 +378,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // need the complexity.
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function update(Account $account, array $data)
|
||||
@ -390,15 +393,10 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
$this->updateMetadata($account, $data);
|
||||
$openingBalance = $this->openingBalanceTransaction($account);
|
||||
|
||||
// if has openingbalance?
|
||||
if ($data['openingBalance'] != 0) {
|
||||
// if opening balance, do an update:
|
||||
if ($openingBalance) {
|
||||
// update existing opening balance.
|
||||
$this->updateInitialBalance($account, $openingBalance, $data);
|
||||
} else {
|
||||
// create new opening balance.
|
||||
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
|
||||
$opposingData = [
|
||||
'user' => $data['user'],
|
||||
@ -480,7 +478,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
[
|
||||
'account_id' => $account->id,
|
||||
'name' => $field,
|
||||
'data' => $data[$field]
|
||||
'data' => $data[$field],
|
||||
]
|
||||
);
|
||||
$metaData->save();
|
||||
@ -509,7 +507,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
'description' => 'Initial balance for "' . $account->name . '"',
|
||||
'completed' => true,
|
||||
'date' => $data['openingBalanceDate'],
|
||||
'encrypted' => true
|
||||
'encrypted' => true,
|
||||
]
|
||||
);
|
||||
|
||||
@ -547,21 +545,21 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
foreach ($validFields as $field) {
|
||||
$entry = $account->accountMeta()->where('name', $field)->first();
|
||||
|
||||
// update if new data is present:
|
||||
if ($entry && isset($data[$field])) {
|
||||
$entry->data = $data[$field];
|
||||
$entry->save();
|
||||
}
|
||||
// no entry but data present?
|
||||
if (!$entry && isset($data[$field])) {
|
||||
$metaData = new AccountMeta(
|
||||
[
|
||||
'account_id' => $account->id,
|
||||
'name' => $field,
|
||||
'data' => $data[$field]
|
||||
]
|
||||
);
|
||||
$metaData->save();
|
||||
if (isset($data[$field])) {
|
||||
// update if new data is present:
|
||||
if (!is_null($entry)) {
|
||||
$entry->data = $data[$field];
|
||||
$entry->save();
|
||||
} else {
|
||||
$metaData = new AccountMeta(
|
||||
[
|
||||
'account_id' => $account->id,
|
||||
'name' => $field,
|
||||
'data' => $data[$field],
|
||||
]
|
||||
);
|
||||
$metaData->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
->get(
|
||||
[
|
||||
'transaction_journals.bill_id',
|
||||
DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`')
|
||||
DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -476,7 +476,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
->get(
|
||||
[
|
||||
'bills.*',
|
||||
DB::Raw('(`bills`.`amount_min` + `bills`.`amount_max` / 2) as `expectedAmount`')
|
||||
DB::Raw('(`bills`.`amount_min` + `bills`.`amount_max` / 2) as `expectedAmount`'),
|
||||
]
|
||||
)->sortBy('name');
|
||||
|
||||
@ -540,8 +540,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
/** @var Account $creditCard */
|
||||
foreach ($creditCards as $creditCard) {
|
||||
if ($creditCard->balance == 0) {
|
||||
// find a transfer TO the credit card which should account for
|
||||
// anything paid. If not, the CC is not yet used.
|
||||
// find a transfer TO the credit card which should account for anything paid. If not, the CC is not yet used.
|
||||
$set = TransactionJournal::whereIn(
|
||||
'transaction_journals.id', function (Builder $q) use ($creditCard, $start, $end) {
|
||||
$q->select('transaction_journals.id')
|
||||
|
@ -89,7 +89,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
->get(
|
||||
[
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`, "%Y-%m") AS `dateFormatted`'),
|
||||
DB::Raw('SUM(`transactions`.`amount`) as `monthlyAmount`')
|
||||
DB::Raw('SUM(`transactions`.`amount`) as `monthlyAmount`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -316,7 +316,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
[
|
||||
'budgets.*',
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`, "%Y-%m") AS `dateFormatted`'),
|
||||
DB::Raw('SUM(`transactions`.`amount`) AS `sumAmount`')
|
||||
DB::Raw('SUM(`transactions`.`amount`) AS `sumAmount`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -559,7 +559,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
[
|
||||
'budgets.*',
|
||||
DB::Raw('DATE_FORMAT(`limit_repetitions`.`startdate`,"%Y") as `dateFormatted`'),
|
||||
DB::Raw('SUM(`limit_repetitions`.`amount`) as `budgeted`')
|
||||
DB::Raw('SUM(`limit_repetitions`.`amount`) as `budgeted`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -575,6 +575,8 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // it's a query.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end)
|
||||
@ -601,7 +603,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
[
|
||||
'budgets.*',
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`, "%Y") AS `dateFormatted`'),
|
||||
DB::Raw('SUM(`transactions`.`amount`) AS `sumAmount`')
|
||||
DB::Raw('SUM(`transactions`.`amount`) AS `sumAmount`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -718,7 +720,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
->get(
|
||||
[
|
||||
't_from.account_id', 'budget_transaction_journal.budget_id',
|
||||
DB::Raw('SUM(`t_from`.`amount`) AS `spent`')
|
||||
DB::Raw('SUM(`t_from`.`amount`) AS `spent`'),
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -76,22 +76,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
/*
|
||||
* select categories.id, DATE_FORMAT(transaction_journals.date,"%Y") as dateFormatted, transaction_types.type, SUM(amount) as sum from categories
|
||||
|
||||
left join category_transaction_journal ON category_transaction_journal.category_id = categories.id
|
||||
left join transaction_journals ON transaction_journals.id = category_transaction_journal.transaction_journal_id
|
||||
left join transaction_types ON transaction_types.id = transaction_journals.transaction_type_id
|
||||
left join transactions ON transactions.transaction_journal_id = transaction_journals.id
|
||||
|
||||
|
||||
where
|
||||
categories.user_id =1
|
||||
and transaction_types.type in ("Withdrawal","Deposit")
|
||||
and transactions.account_id IN (2,4,6,10,11,610,725,879,1248)
|
||||
|
||||
group by categories.id, transaction_types.type, dateFormatted
|
||||
*/
|
||||
$set = Auth::user()->categories()
|
||||
->leftJoin('category_transaction_journal', 'category_transaction_journal.category_id', '=', 'categories.id')
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'category_transaction_journal.transaction_journal_id')
|
||||
@ -100,6 +85,8 @@ group by categories.id, transaction_types.type, dateFormatted
|
||||
->whereIn('transaction_types.type', [TransactionType::DEPOSIT, TransactionType::WITHDRAWAL])
|
||||
->whereIn('transactions.account_id', $accounts->pluck('id')->toArray())
|
||||
->whereIn('categories.id', $categories->pluck('id')->toArray())
|
||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
||||
->groupBy('categories.id')
|
||||
->groupBy('transaction_types.type')
|
||||
->groupBy('dateFormatted')
|
||||
@ -108,7 +95,7 @@ group by categories.id, transaction_types.type, dateFormatted
|
||||
'categories.*',
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`,"%Y") as `dateFormatted`'),
|
||||
'transaction_types.type',
|
||||
DB::Raw('SUM(`amount`) as `sum`')
|
||||
DB::Raw('SUM(`amount`) as `sum`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -158,7 +145,7 @@ group by categories.id, transaction_types.type, dateFormatted
|
||||
[
|
||||
'categories.*',
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`,"%Y-%m") as `dateFormatted`'),
|
||||
DB::Raw('SUM(`t_dest`.`amount`) AS `earned`')
|
||||
DB::Raw('SUM(`t_dest`.`amount`) AS `earned`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -212,7 +199,7 @@ group by categories.id, transaction_types.type, dateFormatted
|
||||
[
|
||||
'categories.*',
|
||||
DB::Raw('DATE_FORMAT(`transaction_journals`.`date`,"%Y-%m") as `dateFormatted`'),
|
||||
DB::Raw('SUM(`t_src`.`amount`) AS `spent`')
|
||||
DB::Raw('SUM(`t_src`.`amount`) AS `spent`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -286,7 +273,7 @@ group by categories.id, transaction_types.type, dateFormatted
|
||||
|
||||
$single = $query->first(
|
||||
[
|
||||
DB::Raw('SUM(`transactions`.`amount`) as `sum`')
|
||||
DB::Raw('SUM(`transactions`.`amount`) as `sum`'),
|
||||
]
|
||||
);
|
||||
if (!is_null($single)) {
|
||||
|
@ -25,7 +25,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*/
|
||||
public function countJournals(Category $category)
|
||||
{
|
||||
return $category->transactionJournals()->count();
|
||||
return $category->transactionjournals()->count();
|
||||
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*/
|
||||
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end)
|
||||
{
|
||||
return $category->transactionJournals()->before($end)->after($start)->count();
|
||||
return $category->transactionjournals()->before($end)->after($start)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,14 +196,14 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
[
|
||||
'account_id' => $fromAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => $data['amount'] * -1
|
||||
'amount' => $data['amount'] * -1,
|
||||
]
|
||||
);
|
||||
Transaction::create( // second transaction.
|
||||
[
|
||||
'account_id' => $toAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => $data['amount']
|
||||
'amount' => $data['amount'],
|
||||
]
|
||||
);
|
||||
$journal->completed = 1;
|
||||
@ -323,6 +323,8 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
protected function storeAccounts(TransactionType $type, array $data)
|
||||
{
|
||||
|
@ -8,6 +8,11 @@ use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class RuleGroupRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\RuleGroup
|
||||
*/
|
||||
class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
{
|
||||
/**
|
||||
|
@ -52,6 +52,8 @@ interface RuleGroupRepositoryInterface
|
||||
public function resetRuleGroupOrder();
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resetRulesInGroupOrder(RuleGroup $ruleGroup);
|
||||
|
@ -35,7 +35,7 @@ class ComponentRepository
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->whereIn('accounts.id', $ids)
|
||||
->after($start)
|
||||
->first([DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`')]);
|
||||
->first([DB::raw('SUM(`transactions`.`amount`) as `journalAmount`')]);
|
||||
$amount = $entry->journalAmount;
|
||||
|
||||
return $amount;
|
||||
|
@ -27,6 +27,8 @@ class TagRepository implements TagRepositoryInterface
|
||||
* @param TransactionJournal $journal
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function connect(TransactionJournal $journal, Tag $tag)
|
||||
@ -129,7 +131,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
->get(
|
||||
[
|
||||
't_to.account_id',
|
||||
DB::Raw('SUM(`t_to`.`amount`) as `sum`')
|
||||
DB::Raw('SUM(`t_to`.`amount`) as `sum`'),
|
||||
]
|
||||
);
|
||||
|
||||
@ -316,6 +318,8 @@ class TagRepository implements TagRepositoryInterface
|
||||
* @param TransactionJournal $journal
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function connectAdvancePayment(TransactionJournal $journal, Tag $tag)
|
||||
@ -330,13 +334,11 @@ class TagRepository implements TagRepositoryInterface
|
||||
$withdrawals = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->count();
|
||||
$deposits = $tag->transactionjournals()->where('transaction_type_id', $deposit->id)->count();
|
||||
|
||||
// advance payments cannot accept transfers:
|
||||
if ($journal->transaction_type_id == $transfer->id) {
|
||||
if ($journal->transaction_type_id == $transfer->id) { // advance payments cannot accept transfers:
|
||||
return false;
|
||||
}
|
||||
|
||||
// the first transaction to be attached to this
|
||||
// tag is attached just like that:
|
||||
// the first transaction to be attached to this tag is attached just like that:
|
||||
if ($withdrawals < 1 && $deposits < 1) {
|
||||
$journal->tags()->save($tag);
|
||||
$journal->save();
|
||||
@ -363,6 +365,8 @@ class TagRepository implements TagRepositoryInterface
|
||||
* @param TransactionJournal $journal
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's complex but nothing can be done.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function matchAll(TransactionJournal $journal, Tag $tag)
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Rules\Actions;
|
||||
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
@ -21,7 +22,7 @@ interface ActionInterface
|
||||
/**
|
||||
* TriggerInterface constructor.
|
||||
*
|
||||
* @param RuleAction $action
|
||||
* @param RuleAction $action
|
||||
* @param TransactionJournal $journal
|
||||
*/
|
||||
public function __construct(RuleAction $action, TransactionJournal $journal);
|
||||
|
@ -10,11 +10,8 @@
|
||||
namespace FireflyIII\Rules\Actions;
|
||||
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ClearBudget
|
||||
|
@ -10,11 +10,8 @@
|
||||
namespace FireflyIII\Rules\Actions;
|
||||
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ClearCategory
|
||||
|
@ -15,6 +15,7 @@ use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class SetBudget
|
||||
*
|
||||
@ -56,7 +57,7 @@ class SetBudget implements ActionInterface
|
||||
Log::debug('Will set budget "' . $search . '" (#' . $budget->id . ') on journal #' . $this->journal->id . '.');
|
||||
$this->journal->budgets()->save($budget);
|
||||
} else {
|
||||
Log::debug('Could not find budget "'.$search.'". Failed.');
|
||||
Log::debug('Could not find budget "' . $search . '". Failed.');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -39,6 +39,9 @@ class Processor
|
||||
|
||||
/**
|
||||
* Processor constructor.
|
||||
*
|
||||
* @param Rule $rule
|
||||
* @param TransactionJournal $journal
|
||||
*/
|
||||
public function __construct(Rule $rule, TransactionJournal $journal)
|
||||
{
|
||||
@ -69,7 +72,7 @@ class Processor
|
||||
$foundTriggers = 0;
|
||||
$hitTriggers = 0;
|
||||
/** @var RuleTrigger $trigger */
|
||||
foreach ($this->rule->ruleTriggers()->orderBy('order', 'ASC')->get() as $index => $trigger) {
|
||||
foreach ($this->rule->ruleTriggers()->orderBy('order', 'ASC')->get() as $trigger) {
|
||||
$foundTriggers++;
|
||||
$type = $trigger->trigger_type;
|
||||
|
||||
@ -107,7 +110,7 @@ class Processor
|
||||
* @var int $index
|
||||
* @var RuleAction $action
|
||||
*/
|
||||
foreach ($this->rule->ruleActions()->orderBy('order', 'ASC')->get() as $index => $action) {
|
||||
foreach ($this->rule->ruleActions()->orderBy('order', 'ASC')->get() as $action) {
|
||||
$type = $action->action_type;
|
||||
$class = $this->actionTypes[$type];
|
||||
Log::debug('Action #' . $action->id . ' for rule #' . $action->rule_id . ' (' . $type . ')');
|
||||
|
@ -44,29 +44,29 @@ class FromAccountEnds implements TriggerInterface
|
||||
*/
|
||||
public function triggered()
|
||||
{
|
||||
$fromAccountName = strtolower($this->journal->source_account->name);
|
||||
$fromAccountNameLength = strlen($fromAccountName);
|
||||
$search = strtolower($this->trigger->trigger_value);
|
||||
$searchLength = strlen($search);
|
||||
$name = strtolower($this->journal->source_account->name);
|
||||
$nameLength = strlen($name);
|
||||
$search = strtolower($this->trigger->trigger_value);
|
||||
$searchLength = strlen($search);
|
||||
|
||||
// if the string to search for is longer than the account name,
|
||||
// shorten the search string.
|
||||
if ($searchLength > $fromAccountNameLength) {
|
||||
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $fromAccountName . '" (' . $fromAccountNameLength . '). ');
|
||||
$search = substr($search, ($fromAccountNameLength * -1));
|
||||
if ($searchLength > $nameLength) {
|
||||
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $name . '" (' . $nameLength . '). ');
|
||||
$search = substr($search, ($nameLength * -1));
|
||||
$searchLength = strlen($search);
|
||||
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
|
||||
}
|
||||
|
||||
|
||||
$part = substr($fromAccountName, $searchLength * -1);
|
||||
$part = substr($name, $searchLength * -1);
|
||||
|
||||
if ($part == $search) {
|
||||
Log::debug('"' . $fromAccountName . '" ends with "' . $search . '". Return true.');
|
||||
Log::debug('"' . $name . '" ends with "' . $search . '". Return true.');
|
||||
|
||||
return true;
|
||||
}
|
||||
Log::debug('"' . $fromAccountName . '" does not end with "' . $search . '". Return false.');
|
||||
Log::debug('"' . $name . '" does not end with "' . $search . '". Return false.');
|
||||
|
||||
return false;
|
||||
|
||||
|
@ -29,9 +29,9 @@ class Amount
|
||||
*/
|
||||
public function formatAnything(TransactionCurrency $format, $amount, $coloured = true)
|
||||
{
|
||||
$locale = setlocale(LC_MONETARY, 0);
|
||||
$a = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
||||
$result = $a->formatCurrency($amount, $format->code);
|
||||
$locale = setlocale(LC_MONETARY, 0);
|
||||
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
||||
$result = $formatter->formatCurrency($amount, $format->code);
|
||||
|
||||
if ($coloured === true) {
|
||||
if ($amount == 0) {
|
||||
@ -136,7 +136,7 @@ class Amount
|
||||
{
|
||||
$currency = $transaction->transactionJournal->transactionCurrency;
|
||||
|
||||
return $this->formatAnything($currency, $transaction->amount);
|
||||
return $this->formatAnything($currency, $transaction->amount, $coloured);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @package FireflyIII\Support\Binder
|
||||
*/
|
||||
class CategoryList implements BinderInterface
|
||||
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Log;
|
||||
|
@ -30,16 +30,16 @@ class Domain
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getRuleTriggers()
|
||||
public static function getRuleActions()
|
||||
{
|
||||
return Config::get('firefly.rule-triggers');
|
||||
return Config::get('firefly.rule-actions');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getRuleActions()
|
||||
public static function getRuleTriggers()
|
||||
{
|
||||
return Config::get('firefly.rule-actions');
|
||||
return Config::get('firefly.rule-triggers');
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ class Steam
|
||||
$set = Auth::user()->transactions()
|
||||
->whereIn('account_id', $accounts)
|
||||
->groupBy('account_id')
|
||||
->get(['transactions.account_id', DB::Raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
|
||||
->get(['transactions.account_id', DB::raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
|
||||
|
||||
foreach ($set as $entry) {
|
||||
$list[intval($entry->account_id)] = new Carbon($entry->max_date);
|
||||
|
@ -37,7 +37,7 @@ class Journal extends Twig_Extension
|
||||
{
|
||||
$functions = [
|
||||
$this->invalidJournal(),
|
||||
$this->relevantTags()
|
||||
$this->relevantTags(),
|
||||
];
|
||||
|
||||
return $functions;
|
||||
|
@ -8,18 +8,18 @@ use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Class Rule
|
||||
*
|
||||
* @package FireflyIII\Support\Twig
|
||||
*/
|
||||
class Rule extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
$functions = [];
|
||||
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
public function allJournalTriggers()
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'allJournalTriggers', function () {
|
||||
return [
|
||||
'store-journal' => trans('firefly.rule_trigger_store_journal'),
|
||||
@ -27,8 +27,14 @@ class Rule extends Twig_Extension
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
public function allRuleTriggers()
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'allRuleTriggers', function () {
|
||||
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));
|
||||
$possibleTriggers = [];
|
||||
@ -44,7 +50,15 @@ class Rule extends Twig_Extension
|
||||
|
||||
);
|
||||
|
||||
$functions[] = new Twig_SimpleFunction('allRuleActions', function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
public function allActionTriggers()
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'allRuleActions', function () {
|
||||
// array of valid values for actions
|
||||
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
|
||||
$possibleActions = [];
|
||||
@ -54,9 +68,21 @@ class Rule extends Twig_Extension
|
||||
unset($key, $ruleActions);
|
||||
|
||||
return $possibleActions;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
$this->allJournalTriggers(),
|
||||
$this->allRuleTriggers(),
|
||||
$this->allActionTriggers(),
|
||||
];
|
||||
|
||||
return $functions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
98
app/User.php
98
app/User.php
@ -9,24 +9,24 @@ use Zizaco\Entrust\Traits\EntrustUserTrait;
|
||||
* Class User
|
||||
*
|
||||
* @package FireflyIII
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $remember_token
|
||||
* @property string $reset
|
||||
* @property boolean $blocked
|
||||
* @property string $blocked_code
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Bill[] $bills
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Preference[] $preferences
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $remember_token
|
||||
* @property string $reset
|
||||
* @property boolean $blocked
|
||||
* @property string $blocked_code
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Bill[] $bills
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Role[] $roles
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Role[] $roles
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@ -71,30 +71,6 @@ class User extends Authenticatable
|
||||
return $this->hasMany('FireflyIII\Models\Attachment');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\Tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\Rule');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function ruleGroups()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\RuleGroup');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -127,14 +103,6 @@ class User extends Authenticatable
|
||||
return $this->hasManyThrough('FireflyIII\Models\PiggyBank', 'FireflyIII\Models\Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -143,6 +111,30 @@ class User extends Authenticatable
|
||||
return $this->hasMany('FireflyIII\Models\Preference');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function ruleGroups()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\RuleGroup');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\Rule');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\Tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -151,4 +143,12 @@ class User extends Authenticatable
|
||||
return $this->hasMany('FireflyIII\Models\TransactionJournal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ class FireflyValidator extends Validator
|
||||
* @param array $rules
|
||||
* @param array $messages
|
||||
* @param array $customAttributes
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // inherited from Laravel.
|
||||
*/
|
||||
public function __construct(TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = [])
|
||||
{
|
||||
@ -40,12 +42,10 @@ class FireflyValidator extends Validator
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateRuleTriggerValue($attribute, $value, $parameters)
|
||||
public function validateRuleTriggerValue($attribute)
|
||||
{
|
||||
// get the index from a string like "rule-trigger-value.2".
|
||||
$parts = explode('.', $attribute);
|
||||
@ -54,8 +54,8 @@ class FireflyValidator extends Validator
|
||||
// loop all rule-triggers.
|
||||
// check if rule-value matches the thing.
|
||||
if (is_array($this->data['rule-trigger'])) {
|
||||
$name = isset($this->data['rule-trigger'][$index]) ? $this->data['rule-trigger'][$index] : 'invalid';
|
||||
$value = isset($this->data['rule-trigger-value'][$index]) ? $this->data['rule-trigger-value'][$index] : false;
|
||||
$name = $this->getRuleTriggerName($index);
|
||||
$value = $this->getRuleTriggerValue($index);
|
||||
switch ($name) {
|
||||
default:
|
||||
return true;
|
||||
@ -76,12 +76,10 @@ class FireflyValidator extends Validator
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateRuleActionValue($attribute, $value, $parameters)
|
||||
public function validateRuleActionValue($attribute)
|
||||
{
|
||||
// get the index from a string like "rule-action-value.2".
|
||||
$parts = explode('.', $attribute);
|
||||
@ -383,17 +381,16 @@ class FireflyValidator extends Validator
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // cant remove it
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its as simple as I can get it.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUniquePiggyBankForUser($attribute, $value, $parameters)
|
||||
{
|
||||
$exclude = isset($parameters[0]) ? $parameters[0] : null;
|
||||
$query = DB::table('piggy_banks');
|
||||
$query->whereNull('piggy_banks.deleted_at');
|
||||
$query->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id');
|
||||
$query->where('accounts.user_id', Auth::user()->id);
|
||||
$query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id);
|
||||
if (!is_null($exclude)) {
|
||||
$query->where('piggy_banks.id', '!=', $exclude);
|
||||
}
|
||||
@ -408,7 +405,27 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getRuleTriggerName($index)
|
||||
{
|
||||
return isset($this->data['rule-trigger'][$index]) ? $this->data['rule-trigger'][$index] : 'invalid';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getRuleTriggerValue($index)
|
||||
{
|
||||
return isset($this->data['rule-trigger-value'][$index]) ? $this->data['rule-trigger-value'][$index] : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,13 +55,15 @@
|
||||
],
|
||||
"post-install-cmd": [
|
||||
"php artisan clear-compiled",
|
||||
"php artisan optimize"
|
||||
"php artisan optimize",
|
||||
"php artisan firefly:upgrade-instructions"
|
||||
],
|
||||
"pre-update-cmd": [
|
||||
"php artisan clear-compiled"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"php artisan optimize"
|
||||
"php artisan optimize",
|
||||
"php artisan firefly:upgrade-instructions"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
|
50
composer.lock
generated
50
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "847987de4271f2467a4a5fc50bc04cc9",
|
||||
"hash": "df00127da416acad2a36b6128b82fdd9",
|
||||
"content-hash": "28b178f07a713b4db441e7e1f380916e",
|
||||
"packages": [
|
||||
{
|
||||
@ -759,16 +759,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v5.2.8",
|
||||
"version": "v5.2.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "867914788c2ec942967c3608ed54626228a5f916"
|
||||
"reference": "93dc5b0089eef468157fd7200e575c3861ec59a5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/867914788c2ec942967c3608ed54626228a5f916",
|
||||
"reference": "867914788c2ec942967c3608ed54626228a5f916",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/93dc5b0089eef468157fd7200e575c3861ec59a5",
|
||||
"reference": "93dc5b0089eef468157fd7200e575c3861ec59a5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -883,20 +883,20 @@
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2016-01-12 22:45:00"
|
||||
"time": "2016-01-13 20:29:10"
|
||||
},
|
||||
{
|
||||
"name": "laravelcollective/html",
|
||||
"version": "v5.2",
|
||||
"version": "v5.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LaravelCollective/html.git",
|
||||
"reference": "5a8f1380a0d5ef21cdef37e775d86566307f8358"
|
||||
"reference": "c88b2d59a56ed2290fc5082a1a6099e357c9fdbc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/5a8f1380a0d5ef21cdef37e775d86566307f8358",
|
||||
"reference": "5a8f1380a0d5ef21cdef37e775d86566307f8358",
|
||||
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/c88b2d59a56ed2290fc5082a1a6099e357c9fdbc",
|
||||
"reference": "c88b2d59a56ed2290fc5082a1a6099e357c9fdbc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -937,20 +937,20 @@
|
||||
],
|
||||
"description": "HTML and Form Builders for the Laravel Framework",
|
||||
"homepage": "http://laravelcollective.com",
|
||||
"time": "2015-12-23 07:46:46"
|
||||
"time": "2016-01-16 16:54:49"
|
||||
},
|
||||
{
|
||||
"name": "league/commonmark",
|
||||
"version": "0.12.0",
|
||||
"version": "0.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/commonmark.git",
|
||||
"reference": "3eb64850ee688623db494398a5284a7a4cdf7b47"
|
||||
"reference": "a4e93bc4fd1a8ff8f534040c4a07371ea5f4b484"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/3eb64850ee688623db494398a5284a7a4cdf7b47",
|
||||
"reference": "3eb64850ee688623db494398a5284a7a4cdf7b47",
|
||||
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/a4e93bc4fd1a8ff8f534040c4a07371ea5f4b484",
|
||||
"reference": "a4e93bc4fd1a8ff8f534040c4a07371ea5f4b484",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -962,21 +962,23 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"erusev/parsedown": "~1.0",
|
||||
"jgm/commonmark": "0.22",
|
||||
"jgm/smartpunct": "0.22",
|
||||
"jgm/commonmark": "0.24",
|
||||
"michelf/php-markdown": "~1.4",
|
||||
"mikehaertl/php-shellcommand": "~1.1.0",
|
||||
"phpunit/phpunit": "~4.3|~5.0",
|
||||
"scrutinizer/ocular": "^1.1",
|
||||
"symfony/finder": "~2.3"
|
||||
},
|
||||
"suggest": {
|
||||
"league/commonmark-extras": "Library of useful extensions including smart punctuation"
|
||||
},
|
||||
"bin": [
|
||||
"bin/commonmark"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.13-dev"
|
||||
"dev-master": "0.14-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -1003,7 +1005,7 @@
|
||||
"markdown",
|
||||
"parser"
|
||||
],
|
||||
"time": "2015-11-04 14:24:41"
|
||||
"time": "2016-01-14 04:29:54"
|
||||
},
|
||||
{
|
||||
"name": "league/csv",
|
||||
@ -3897,16 +3899,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/class-loader",
|
||||
"version": "v2.8.1",
|
||||
"version": "v2.8.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/class-loader.git",
|
||||
"reference": "ec74b0a279cf3a9bd36172b3e3061591d380ce6c"
|
||||
"reference": "98e9089a428ed0e39423b67352c57ef5910a3269"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/class-loader/zipball/ec74b0a279cf3a9bd36172b3e3061591d380ce6c",
|
||||
"reference": "ec74b0a279cf3a9bd36172b3e3061591d380ce6c",
|
||||
"url": "https://api.github.com/repos/symfony/class-loader/zipball/98e9089a428ed0e39423b67352c57ef5910a3269",
|
||||
"reference": "98e9089a428ed0e39423b67352c57ef5910a3269",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3945,7 +3947,7 @@
|
||||
],
|
||||
"description": "Symfony ClassLoader Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-12-05 17:37:59"
|
||||
"time": "2016-01-03 15:33:41"
|
||||
},
|
||||
{
|
||||
"name": "symfony/css-selector",
|
||||
|
@ -48,7 +48,7 @@ return [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => storage_path('database.sqlite'),
|
||||
'database' => storage_path('database') . '/testing.db',
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
return [
|
||||
'chart' => 'chartjs',
|
||||
'version' => '3.6.1',
|
||||
'version' => '3.7.0',
|
||||
'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'],
|
||||
'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
|
||||
'csv_import_enabled' => true,
|
||||
|
15
config/upgrade.php
Normal file
15
config/upgrade.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* upgrade.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
'text' => [
|
||||
'3.7.0' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' .
|
||||
'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0'],
|
||||
];
|
46
cover.sh
Executable file
46
cover.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set testing environment
|
||||
cp .env.testing .env
|
||||
|
||||
# set cover:
|
||||
cp phpunit.cover.xml phpunit.xml
|
||||
|
||||
# test!
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
phpdbg -qrr /usr/local/bin/phpunit
|
||||
fi
|
||||
|
||||
# directories to look in:
|
||||
#dirs=("controllers" "database" "factories" "generators" "helpers" "models" "middleware" "repositories" "support")
|
||||
#
|
||||
#if [ ! -z "$1" ]
|
||||
#then
|
||||
# for i in "${dirs[@]}"
|
||||
# do
|
||||
# firstFile="./tests/$i/$1.php"
|
||||
# secondFile="./tests/$i/$1Test.php"
|
||||
# if [ -f "$firstFile" ]
|
||||
# then
|
||||
# # run it!
|
||||
# phpunit --verbose $firstFile
|
||||
# exit $?
|
||||
# fi
|
||||
# if [ -f "$secondFile" ]
|
||||
# then
|
||||
# # run it!
|
||||
# phpunit --verbose $secondFile
|
||||
# exit $?
|
||||
# fi
|
||||
#
|
||||
#
|
||||
# done
|
||||
#
|
||||
#fi
|
||||
|
||||
# restore .env file
|
||||
cp .env.local .env
|
||||
|
||||
# restore cover
|
||||
cp phpunit.default.xml phpunit.xml
|
@ -10,7 +10,8 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName) // method names are mandated by laravel.
|
||||
* @SuppressWarnings("TooManyMethods") // I'm fine with this
|
||||
* @SuppressWarnings(PHPMD.TooManyMethods)
|
||||
*
|
||||
*
|
||||
* Down:
|
||||
* 1. Create new Components based on Budgets.
|
||||
|
@ -5,7 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* Class ChangesForV3310
|
||||
*/
|
||||
|
@ -4,6 +4,9 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class EntrustSetupTables
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
class EntrustSetupTables extends Migration
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user