mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Some small code optimisations.
This commit is contained in:
@@ -43,6 +43,8 @@ class AuthController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->middleware('guest', ['except' => 'getLogout']);
|
$this->middleware('guest', ['except' => 'getLogout']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ class PasswordController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->middleware('guest');
|
$this->middleware('guest');
|
||||||
}
|
}
|
||||||
|
@@ -150,14 +150,9 @@ class TransactionJournal extends Model
|
|||||||
return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
$amount = '0';
|
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
/** @var Transaction $t */
|
$set = $this->transactions->sortByDesc('amount');
|
||||||
foreach ($this->transactions as $t) {
|
$amount = $set->first()->amount;
|
||||||
if ($t->amount > 0) {
|
|
||||||
$amount = $t->amount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intval($this->tag_count) === 1) {
|
if (intval($this->tag_count) === 1) {
|
||||||
// get amount for single tag:
|
// get amount for single tag:
|
||||||
@@ -176,16 +171,13 @@ class TransactionJournal extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assuming the journal has only one tag. Parameter amount is used as fallback.
|
|
||||||
*
|
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
* @param string $amount
|
* @param $amount
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function amountByTag(Tag $tag, $amount)
|
protected function amountByTagAdvancePayment(Tag $tag, $amount)
|
||||||
{
|
{
|
||||||
if ($tag->tagMode == 'advancePayment') {
|
|
||||||
if ($this->transactionType->type == 'Withdrawal') {
|
if ($this->transactionType->type == 'Withdrawal') {
|
||||||
$others = $tag->transactionJournals()->transactionTypes(['Deposit'])->get();
|
$others = $tag->transactionJournals()->transactionTypes(['Deposit'])->get();
|
||||||
foreach ($others as $other) {
|
foreach ($others as $other) {
|
||||||
@@ -197,9 +189,18 @@ class TransactionJournal extends Model
|
|||||||
if ($this->transactionType->type == 'Deposit') {
|
if ($this->transactionType->type == 'Deposit') {
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tag->tagMode == 'balancingAct') {
|
/**
|
||||||
|
* @param $tag
|
||||||
|
* @param $amount
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function amountByTagBalancingAct($tag, $amount)
|
||||||
|
{
|
||||||
if ($this->transactionType->type == 'Withdrawal') {
|
if ($this->transactionType->type == 'Withdrawal') {
|
||||||
$transfer = $tag->transactionJournals()->transactionTypes(['Transfer'])->first();
|
$transfer = $tag->transactionJournals()->transactionTypes(['Transfer'])->first();
|
||||||
if ($transfer) {
|
if ($transfer) {
|
||||||
@@ -208,6 +209,27 @@ class TransactionJournal extends Model
|
|||||||
return $amount;
|
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;
|
return $amount;
|
||||||
|
@@ -94,15 +94,15 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
*
|
*
|
||||||
* set id of piggy bank.
|
* set id of piggy bank.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $piggyBankId
|
||||||
* @param int $order
|
* @param int $order
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setOrder($id, $order)
|
public function setOrder($piggyBankId, $order)
|
||||||
{
|
{
|
||||||
$piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id)
|
$piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id)
|
||||||
->where('piggy_banks.id', $id)->first(['piggy_banks.*']);
|
->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
|
||||||
if ($piggyBank) {
|
if ($piggyBank) {
|
||||||
$piggyBank->order = $order;
|
$piggyBank->order = $order;
|
||||||
$piggyBank->save();
|
$piggyBank->save();
|
||||||
|
@@ -58,12 +58,12 @@ interface PiggyBankRepositoryInterface
|
|||||||
*
|
*
|
||||||
* set id of piggy bank.
|
* set id of piggy bank.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $piggyBankId
|
||||||
* @param int $order
|
* @param int $order
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setOrder($id, $order);
|
public function setOrder($piggyBankId, $order);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,7 +36,8 @@ return [
|
|||||||
' je jouw tekstbestand bij "CSV-bestand". '
|
' je jouw tekstbestand bij "CSV-bestand". '
|
||||||
. 'Als je hulp nodig hebt, klik dan op het <i class="fa fa-question-circle"></i>-icoontje rechtsboven.',
|
. 'Als je hulp nodig hebt, klik dan op het <i class="fa fa-question-circle"></i>-icoontje rechtsboven.',
|
||||||
'csv_index_beta_warning' => 'Deze tool is nog erg experimenteel. Wees dus voorzichtig.',
|
'csv_index_beta_warning' => 'Deze tool is nog erg experimenteel. Wees dus voorzichtig.',
|
||||||
'csv_header_help' => 'Zet hier een vinkje als de eerste rij van je tekstbestand bestaat uit kolomnamen, en niet uit daadwerkelijke gegevens.',
|
'csv_header_help' => 'Zet hier een vinkje als de eerste rij van je tekstbestand bestaat uit kolomnamen,'.
|
||||||
|
'en niet uit daadwerkelijke gegevens.',
|
||||||
'csv_date_help' => 'Het gebruikte datumformaat in jouw bestand. Gebruik het formaat zoals <a href="https://secure.' .
|
'csv_date_help' => 'Het gebruikte datumformaat in jouw bestand. Gebruik het formaat zoals <a href="https://secure.' .
|
||||||
'php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters">deze' .
|
'php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters">deze' .
|
||||||
' pagina</a> het uitlegt (Engels). Het standaardformaat kan omgaan met data zoals deze: ' . date('Ymd'),
|
' pagina</a> het uitlegt (Engels). Het standaardformaat kan omgaan met data zoals deze: ' . date('Ymd'),
|
||||||
@@ -47,7 +48,8 @@ return [
|
|||||||
'csv_column_roles_title' => 'Bepaal de inhoud van elke kolom',
|
'csv_column_roles_title' => 'Bepaal de inhoud van elke kolom',
|
||||||
'csv_column_roles_text' => 'Firefly kan niet automatisch ontdekken wat elke kolom betekent. Je moet het zelf aangeven. Gebruik de' .
|
'csv_column_roles_text' => 'Firefly kan niet automatisch ontdekken wat elke kolom betekent. Je moet het zelf aangeven. Gebruik de' .
|
||||||
' voorbeeldgegevens als je het ook niet zeker weet. Klik op het <i class="fa fa-question-circle"></i>-icoontje ' .
|
' voorbeeldgegevens als je het ook niet zeker weet. Klik op het <i class="fa fa-question-circle"></i>-icoontje ' .
|
||||||
'rechtsboven om te ontdekken wat elke kolomsoort precies is. Als de kolominhoud een directe relatie heeft met gegevens'
|
'rechtsboven om te ontdekken wat elke kolomsoort precies is. Als de kolominhoud een directe'.
|
||||||
|
' relatie heeft met gegevens'
|
||||||
.
|
.
|
||||||
' die al in Firefly staan, gebruik dan het vinkje. Tijdens de volgende stap komt Firefly hier dan op terug.',
|
' die al in Firefly staan, gebruik dan het vinkje. Tijdens de volgende stap komt Firefly hier dan op terug.',
|
||||||
'csv_column' => 'CSV-kolom',
|
'csv_column' => 'CSV-kolom',
|
||||||
|
@@ -165,7 +165,6 @@
|
|||||||
padding: 6px;
|
padding: 6px;
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
float: left;
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user