mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
parent
33d89d52c2
commit
d2ab03061f
@ -277,8 +277,8 @@ This will be the last release to support PHP 7.0.
|
||||
- Can now make rules for attachments, see [issue 608](https://github.com/firefly-iii/firefly-iii/issues/608), as suggested by [dzaikos](https://github.com/dzaikos).
|
||||
|
||||
### Fixed
|
||||
- Fixed [issue 629](https://github.com/firefly-iii/firefly-iii/issues/629), reported by forcaeluz
|
||||
- Fixed [issue 630](https://github.com/firefly-iii/firefly-iii/issues/630), reported by welbert
|
||||
- Fixed [issue 629](https://github.com/firefly-iii/firefly-iii/issues/629), reported by @forcaeluz
|
||||
- Fixed [issue 630](https://github.com/firefly-iii/firefly-iii/issues/630), reported by @welbert
|
||||
- And more various bug fixes.
|
||||
|
||||
## [4.3.8] - 2017-04-08
|
||||
|
@ -50,7 +50,7 @@ interface JournalCollectorInterface
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function amountMore(string $amount): JournalCollectorInterface;
|
||||
public function amountIs(string $amount): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
@ -64,7 +64,7 @@ interface JournalCollectorInterface
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function amountIs(string $amount): JournalCollectorInterface;
|
||||
public function amountMore(string $amount): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
|
@ -282,7 +282,7 @@ class AccountController extends Controller
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currency = $currencyRepos->find($currencyId);
|
||||
if ($currencyId === 0) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty('chart.budget.budget');
|
||||
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$final = clone $last;
|
||||
|
@ -217,13 +217,13 @@ class CurrencyController extends Controller
|
||||
{
|
||||
$currencies = $this->repository->get();
|
||||
$defaultCurrency = $this->repository->getCurrencyByPreference(Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR')));
|
||||
$isOwner = true;
|
||||
$isOwner = true;
|
||||
if (!$this->userRepository->hasRole(auth()->user(), 'owner')) {
|
||||
$request->session()->flash('info', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')]));
|
||||
$isOwner = false;
|
||||
}
|
||||
|
||||
return view('currencies.index', compact('currencies', 'defaultCurrency','isOwner'));
|
||||
return view('currencies.index', compact('currencies', 'defaultCurrency', 'isOwner'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +116,7 @@ class HomeController extends Controller
|
||||
}
|
||||
}
|
||||
// last few lines
|
||||
$logContent = 'Truncated from this point <----|'.substr($logContent, -4096);
|
||||
$logContent = 'Truncated from this point <----|' . substr($logContent, -4096);
|
||||
|
||||
return view('debug', compact('phpVersion', 'extensions', 'carbon', 'now', 'drivers', 'currentDriver', 'userAgent', 'phpOs', 'interface', 'logContent'));
|
||||
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
|
@ -93,7 +93,7 @@ class NewUserController extends Controller
|
||||
// also store currency preference from input:
|
||||
$currency = $currencyRepository->find(intval($request->input('amount_currency_id_bank_balance')));
|
||||
|
||||
if(!is_null($currency->id)) {
|
||||
if (!is_null($currency->id)) {
|
||||
// store currency preference:
|
||||
Preferences::set('currencyPreference', $currency->code);
|
||||
Preferences::mark();
|
||||
|
@ -232,13 +232,13 @@ class SplitController extends Controller
|
||||
{
|
||||
$sourceAccounts = $journal->sourceAccountList();
|
||||
$destinationAccounts = $journal->destinationAccountList();
|
||||
$notes = '';
|
||||
$notes = '';
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
if (!is_null($note)) {
|
||||
$notes = $note->text;
|
||||
}
|
||||
$array = [
|
||||
$array = [
|
||||
'journal_description' => $request->old('journal_description', $journal->description),
|
||||
'journal_amount' => $journal->amountPositive(),
|
||||
'sourceAccounts' => $sourceAccounts,
|
||||
|
@ -43,10 +43,10 @@ class StartFireflySession extends StartSession
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
// public function handle($request, Closure $next)
|
||||
// {
|
||||
// return parent::handle($request, $next); // defer to the right stuff
|
||||
// }
|
||||
// public function handle($request, Closure $next)
|
||||
// {
|
||||
// return parent::handle($request, $next); // defer to the right stuff
|
||||
// }
|
||||
|
||||
/**
|
||||
* Store the current URL for the request if necessary.
|
||||
|
@ -126,6 +126,7 @@ class AbnAmroDescription implements SpecificInterface
|
||||
/**
|
||||
* Parses the current description in SEPA format
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
* @return bool true if the description is SEPA format, false otherwise
|
||||
*/
|
||||
protected function parseSepaDescription()
|
||||
|
@ -33,8 +33,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\Specifics;
|
||||
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class SnsDescription
|
||||
*
|
||||
@ -65,8 +63,9 @@ class SnsDescription implements SpecificInterface
|
||||
*/
|
||||
public function run(array $row): array
|
||||
{
|
||||
$row[17] = ltrim($row[17],"'");
|
||||
$row[17] = rtrim($row[17],"'");
|
||||
$row[17] = ltrim($row[17], "'");
|
||||
$row[17] = rtrim($row[17], "'");
|
||||
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Bill extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
|
@ -53,12 +53,12 @@ class Budget extends Model
|
||||
'active' => 'boolean',
|
||||
'encrypted' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $fillable = ['user_id', 'name', 'active'];
|
||||
/** @var array */
|
||||
protected $hidden = ['encrypted'];
|
||||
/** @var array */
|
||||
protected $rules = ['name' => 'required|between:1,200',];
|
||||
/** @var array */
|
||||
protected $hidden = ['encrypted'];
|
||||
/** @var array */
|
||||
protected $rules = ['name' => 'required|between:1,200',];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
|
@ -41,7 +41,7 @@ class Configuration extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
@ -36,7 +36,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
class CurrencyExchangeRate extends Model
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $dates = ['date'];
|
||||
|
||||
/**
|
||||
|
@ -42,15 +42,15 @@ class LimitRepetition extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'startdate' => 'date',
|
||||
'enddate' => 'date',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['startdate', 'enddate'];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $dates = ['startdate', 'enddate'];
|
||||
/** @var array */
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
|
||||
/**
|
||||
|
@ -39,12 +39,12 @@ class Note extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $fillable = ['title', 'text'];
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ class PiggyBank extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
@ -56,12 +56,12 @@ class PiggyBank extends Model
|
||||
'active' => 'boolean',
|
||||
'encrypted' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['startdate', 'targetdate'];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $dates = ['startdate', 'targetdate'];
|
||||
/** @var array */
|
||||
protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate'];
|
||||
/** @var array */
|
||||
protected $hidden = ['targetamount_encrypted', 'encrypted'];
|
||||
/** @var array */
|
||||
protected $hidden = ['targetamount_encrypted', 'encrypted'];
|
||||
|
||||
/**
|
||||
* @param PiggyBank $value
|
||||
|
@ -39,12 +39,12 @@ class PiggyBankEvent extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'date' => 'datetime',
|
||||
];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $dates = ['date'];
|
||||
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
|
||||
protected $hidden = ['amount_encrypted'];
|
||||
|
@ -41,16 +41,16 @@ class PiggyBankRepetition extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
'startdate' => 'date',
|
||||
'targetdate' => 'date',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['startdate', 'targetdate'];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $dates = ['startdate', 'targetdate'];
|
||||
/** @var array */
|
||||
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
|
||||
|
||||
/**
|
||||
|
@ -44,12 +44,12 @@ class Preference extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $fillable = ['user_id', 'data', 'name', 'data'];
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ class Role extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class TransactionCurrency
|
||||
@ -43,15 +42,15 @@ class TransactionCurrency extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
'decimal_places' => 'int',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['date'];
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
protected $dates = ['date'];
|
||||
/** @var array */
|
||||
protected $fillable = ['name', 'code', 'symbol', 'decimal_places'];
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ class TransactionJournal extends Model
|
||||
'completed' => 'boolean',
|
||||
];
|
||||
/** @var array */
|
||||
protected $dates = ['date','interest_date', 'book_date', 'process_date'];
|
||||
protected $dates = ['date', 'interest_date', 'book_date', 'process_date'];
|
||||
/** @var array */
|
||||
protected $fillable
|
||||
= ['user_id', 'transaction_type_id', 'bill_id', 'interest_date', 'book_date', 'process_date',
|
||||
|
@ -297,7 +297,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
protected function storeInitialBalance(Account $account, array $data): TransactionJournal
|
||||
{
|
||||
$amount = strval($data['openingBalance']);
|
||||
Log::debug(sprintf('Submitted amount is %s',$amount));
|
||||
Log::debug(sprintf('Submitted amount is %s', $amount));
|
||||
|
||||
if (bccomp($amount, '0') === 0) {
|
||||
return new TransactionJournal;
|
||||
@ -326,7 +326,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$secondAmount = bcmul($amount, '-1');
|
||||
Log::debug(sprintf('First amount is %s, second amount is %s', $firstAmount, $secondAmount));
|
||||
|
||||
if (bccomp($amount,'0') === -1) {
|
||||
if (bccomp($amount, '0') === -1) {
|
||||
Log::debug(sprintf('%s is a negative number.', $amount));
|
||||
$firstAccount = $opposing;
|
||||
$secondAccount = $account;
|
||||
@ -508,8 +508,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
protected function validOpeningBalanceData(array $data): bool
|
||||
{
|
||||
$data['openingBalance'] = strval($data['openingBalance'] ?? '');
|
||||
if (isset($data['openingBalance']) && !is_null($data['openingBalance']) && strlen($data['openingBalance']) > 0 &&
|
||||
isset($data['openingBalanceDate'])) {
|
||||
if (isset($data['openingBalance']) && !is_null($data['openingBalance']) && strlen($data['openingBalance']) > 0
|
||||
&& isset($data['openingBalanceDate'])) {
|
||||
Log::debug('Array has valid opening balance data.');
|
||||
|
||||
return true;
|
||||
|
@ -24,10 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Transaction as TransactionModel;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences as Prefs;
|
||||
|
@ -176,7 +176,7 @@ class Preferences
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $value
|
||||
*
|
||||
* @return Preference
|
||||
*/
|
||||
|
@ -28,7 +28,6 @@ use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Steam;
|
||||
|
||||
@ -75,16 +74,16 @@ class Modifier
|
||||
Log::debug(sprintf('Destination is %s? %s', $modifier['value'], var_export($res, true)));
|
||||
break;
|
||||
case 'category':
|
||||
$res = self::category($transaction, $modifier['value']);
|
||||
$res = self::category($transaction, $modifier['value']);
|
||||
Log::debug(sprintf('Category is %s? %s', $modifier['value'], var_export($res, true)));
|
||||
break;
|
||||
case 'budget':
|
||||
$res = self::budget($transaction, $modifier['value']);
|
||||
$res = self::budget($transaction, $modifier['value']);
|
||||
Log::debug(sprintf('Budget is %s? %s', $modifier['value'], var_export($res, true)));
|
||||
break;
|
||||
case 'bill':
|
||||
$name = Steam::tryDecrypt($transaction->bill_name);
|
||||
$res = self::stringCompare($name, $modifier['value']);
|
||||
$res = self::stringCompare($name, $modifier['value']);
|
||||
Log::debug(sprintf('Bill is %s? %s', $modifier['value'], var_export($res, true)));
|
||||
break;
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ namespace FireflyIII\Support\Twig;
|
||||
|
||||
|
||||
use FireflyIII\Models\Account as AccountModel;
|
||||
use FireflyIII\Models\Transaction as TransactionModel;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
|
@ -29,10 +29,11 @@ use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;
|
||||
|
||||
/**
|
||||
* Class Journal
|
||||
*
|
||||
@ -82,7 +83,6 @@ class Journal extends Twig_Extension
|
||||
public function getFilters(): array
|
||||
{
|
||||
$filters = [
|
||||
$this->typeIcon(),
|
||||
new Twig_SimpleFilter('journalTotalAmount', [TransactionJournalExtension::class, 'totalAmount'], ['is_safe' => ['html']]),
|
||||
];
|
||||
|
||||
@ -227,38 +227,4 @@ class Journal extends Twig_Extension
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 5.
|
||||
*
|
||||
* @return Twig_SimpleFilter
|
||||
*/
|
||||
protected function typeIcon(): Twig_SimpleFilter
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'typeIcon', function (TransactionJournal $journal): string {
|
||||
|
||||
switch (true) {
|
||||
case $journal->isWithdrawal():
|
||||
$txt = sprintf('<i class="fa fa-long-arrow-left fa-fw" title="%s"></i>', trans('firefly.withdrawal'));
|
||||
break;
|
||||
case $journal->isDeposit():
|
||||
$txt = sprintf('<i class="fa fa-long-arrow-right fa-fw" title="%s"></i>', trans('firefly.deposit'));
|
||||
break;
|
||||
case $journal->isTransfer():
|
||||
$txt = sprintf('<i class="fa fa-fw fa-exchange" title="%s"></i>', trans('firefly.transfer'));
|
||||
break;
|
||||
case $journal->isOpeningBalance():
|
||||
$txt = sprintf('<i class="fa-fw fa fa-star-o" title="%s"></i>', trans('firefly.openingBalance'));
|
||||
break;
|
||||
default:
|
||||
$txt = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $txt;
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,12 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
|
||||
use FireflyIII\Models\Transaction as TransactionModel;
|
||||
use FireflyIII\Support\Twig\Extension\Transaction as TransactionExtension;
|
||||
use Steam;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
@ -46,6 +43,7 @@ class Transaction extends Twig_Extension
|
||||
new Twig_SimpleFilter('transactionIcon', [TransactionExtension::class, 'icon'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('transactionDescription', [TransactionExtension::class, 'description']),
|
||||
new Twig_SimpleFilter('transactionIsSplit', [TransactionExtension::class, 'isSplit'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('transactionReconciled', [TransactionExtension::class, 'isReconciled'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('transactionHasAtt', [TransactionExtension::class, 'hasAttachments'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('transactionAmount', [TransactionExtension::class, 'amount'], ['is_safe' => ['html']]),
|
||||
new Twig_SimpleFilter('transactionArrayAmount', [TransactionExtension::class, 'amountArray'], ['is_safe' => ['html']]),
|
||||
@ -58,19 +56,6 @@ class Transaction extends Twig_Extension
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
$functions = [
|
||||
$this->transactionIdBudgets(),
|
||||
$this->transactionIdCategories(),
|
||||
];
|
||||
|
||||
return $functions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension.
|
||||
*
|
||||
@ -80,110 +65,4 @@ class Transaction extends Twig_Extension
|
||||
{
|
||||
return 'transaction';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
public function transactionIdBudgets(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'transactionIdBudgets', function (int $transactionId): string {
|
||||
$transaction = TransactionModel::find($transactionId);
|
||||
|
||||
return $this->getTransactionBudgets($transaction);
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
public function transactionIdCategories(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'transactionIdCategories', function (int $transactionId): string {
|
||||
$transaction = TransactionModel::find($transactionId);
|
||||
|
||||
return $this->getTransactionCategories($transaction);
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionModel $transaction
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getTransactionBudgets(TransactionModel $transaction): string
|
||||
{
|
||||
// journal has a budget:
|
||||
if (isset($transaction->transaction_journal_budget_id)) {
|
||||
$name = Steam::decrypt(intval($transaction->transaction_journal_budget_encrypted), $transaction->transaction_journal_budget_name);
|
||||
|
||||
return sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_journal_budget_id]), $name, $name);
|
||||
}
|
||||
|
||||
// transaction has a budget
|
||||
if (isset($transaction->transaction_budget_id)) {
|
||||
$name = Steam::decrypt(intval($transaction->transaction_budget_encrypted), $transaction->transaction_budget_name);
|
||||
|
||||
return sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name);
|
||||
}
|
||||
|
||||
// see if the transaction has a budget:
|
||||
$budgets = $transaction->budgets()->get();
|
||||
if ($budgets->count() === 0) {
|
||||
$budgets = $transaction->transactionJournal()->first()->budgets()->get();
|
||||
}
|
||||
if ($budgets->count() > 0) {
|
||||
$str = [];
|
||||
foreach ($budgets as $budget) {
|
||||
$str[] = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$budget->id]), $budget->name, $budget->name);
|
||||
}
|
||||
|
||||
return join(', ', $str);
|
||||
}
|
||||
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionModel $transaction
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getTransactionCategories(TransactionModel $transaction): string
|
||||
{
|
||||
// journal has a category:
|
||||
if (isset($transaction->transaction_journal_category_id)) {
|
||||
$name = Steam::decrypt(intval($transaction->transaction_journal_category_encrypted), $transaction->transaction_journal_category_name);
|
||||
|
||||
return sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_journal_category_id]), $name, $name);
|
||||
}
|
||||
|
||||
// transaction has a category:
|
||||
if (isset($transaction->transaction_category_id)) {
|
||||
$name = Steam::decrypt(intval($transaction->transaction_category_encrypted), $transaction->transaction_category_name);
|
||||
|
||||
return sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_category_id]), $name, $name);
|
||||
}
|
||||
|
||||
// see if the transaction has a category:
|
||||
$categories = $transaction->categories()->get();
|
||||
if ($categories->count() === 0) {
|
||||
$categories = $transaction->transactionJournal()->first()->categories()->get();
|
||||
}
|
||||
if ($categories->count() > 0) {
|
||||
$str = [];
|
||||
foreach ($categories as $category) {
|
||||
$str[] = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$category->id]), $category->name, $category->name);
|
||||
}
|
||||
|
||||
return join(', ', $str);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -62,9 +62,9 @@ class SetBudget implements ActionInterface
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app(BudgetRepositoryInterface::class);
|
||||
$repository->setUser($journal->user);
|
||||
$search = $this->action->action_value;
|
||||
$search = $this->action->action_value;
|
||||
$budgets = $repository->getActiveBudgets();
|
||||
$budget = $budgets->filter(
|
||||
$budget = $budgets->filter(
|
||||
function (Budget $current) use ($search) {
|
||||
return $current->name === $search;
|
||||
}
|
||||
@ -76,7 +76,12 @@ class SetBudget implements ActionInterface
|
||||
}
|
||||
|
||||
if ($journal->transactionType->type !== TransactionType::WITHDRAWAL) {
|
||||
Log::debug(sprintf('RuleAction SetBudget could not set budget of journal #%d to "%s" because journal is a %s.', $journal->id, $search, $journal->transactionType->type));
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'RuleAction SetBudget could not set budget of journal #%d to "%s" because journal is a %s.', $journal->id, $search,
|
||||
$journal->transactionType->type
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ class AbstractTrigger
|
||||
|
||||
/**
|
||||
* AbstractTrigger constructor.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function __construct()
|
||||
@ -57,6 +58,7 @@ class AbstractTrigger
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param string $triggerValue
|
||||
* @param bool $stopProcessing
|
||||
*
|
||||
@ -73,6 +75,7 @@ class AbstractTrigger
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param RuleTrigger $trigger
|
||||
*
|
||||
* @return AbstractTrigger
|
||||
@ -89,6 +92,7 @@ class AbstractTrigger
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param string $triggerValue
|
||||
*
|
||||
* @return AbstractTrigger
|
||||
|
@ -63,7 +63,7 @@ class HasAttachment extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$minimum = intval($this->triggerValue);
|
||||
$minimum = intval($this->triggerValue);
|
||||
$attachments = $journal->attachments()->count();
|
||||
if ($attachments >= $minimum) {
|
||||
Log::debug(
|
||||
|
@ -47,6 +47,7 @@ final class UserAction extends AbstractTrigger implements TriggerInterface
|
||||
* false.
|
||||
*
|
||||
* @param null $value
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return bool
|
||||
@ -60,6 +61,7 @@ final class UserAction extends AbstractTrigger implements TriggerInterface
|
||||
* This trigger is always triggered, because the rule that it is a part of has been pre-selected on this condition.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return bool
|
||||
|
30
composer.lock
generated
30
composer.lock
generated
@ -3952,16 +3952,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "5.2.2",
|
||||
"version": "5.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "8ed1902a57849e117b5651fc1a5c48110946c06b"
|
||||
"reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b",
|
||||
"reference": "8ed1902a57849e117b5651fc1a5c48110946c06b",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
|
||||
"reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3970,7 +3970,7 @@
|
||||
"php": "^7.0",
|
||||
"phpunit/php-file-iterator": "^1.4.2",
|
||||
"phpunit/php-text-template": "^1.2.1",
|
||||
"phpunit/php-token-stream": "^1.4.11 || ^2.0",
|
||||
"phpunit/php-token-stream": "^2.0",
|
||||
"sebastian/code-unit-reverse-lookup": "^1.0.1",
|
||||
"sebastian/environment": "^3.0",
|
||||
"sebastian/version": "^2.0.1",
|
||||
@ -4012,7 +4012,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-08-03T12:40:43+00:00"
|
||||
"time": "2017-11-03T13:47:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
@ -4390,30 +4390,30 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "2.0.2",
|
||||
"version": "2.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a"
|
||||
"reference": "1174d9018191e93cb9d719edec01257fc05f8158"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/ae068fede81d06e7bb9bb46a367210a3d3e1fe6a",
|
||||
"reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1174d9018191e93cb9d719edec01257fc05f8158",
|
||||
"reference": "1174d9018191e93cb9d719edec01257fc05f8158",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.0",
|
||||
"sebastian/diff": "^2.0",
|
||||
"sebastian/exporter": "^3.0"
|
||||
"sebastian/exporter": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0"
|
||||
"phpunit/phpunit": "^6.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
"dev-master": "2.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -4444,13 +4444,13 @@
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to compare PHP values for equality",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/comparator",
|
||||
"homepage": "https://github.com/sebastianbergmann/comparator",
|
||||
"keywords": [
|
||||
"comparator",
|
||||
"compare",
|
||||
"equality"
|
||||
],
|
||||
"time": "2017-08-03T07:14:59+00:00"
|
||||
"time": "2017-11-03T07:16:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
|
Loading…
Reference in New Issue
Block a user