mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-03 20:56:21 +00:00
Code cleanup. Moving closer to new release.
This commit is contained in:
@@ -299,16 +299,23 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if ($diff < 0 && $account->startBalance > 0) {
|
||||
// percentage lost compared to start.
|
||||
$pct = (($diff * -1) / $account->startBalance) * 100;
|
||||
} else {
|
||||
if ($diff >= 0 && $account->startBalance > 0) {
|
||||
$pct = ($diff / $account->startBalance) * 100;
|
||||
} else {
|
||||
$pct = 100;
|
||||
}
|
||||
|
||||
$pct = $pct > 100 ? 100 : $pct;
|
||||
$account->difference = $diff;
|
||||
$account->percentage = round($pct);
|
||||
|
||||
return;
|
||||
}
|
||||
if ($diff >= 0 && $account->startBalance > 0) {
|
||||
$pct = ($diff / $account->startBalance) * 100;
|
||||
$pct = $pct > 100 ? 100 : $pct;
|
||||
$account->difference = $diff;
|
||||
$account->percentage = round($pct);
|
||||
|
||||
return;
|
||||
}
|
||||
$pct = $pct > 100 ? 100 : $pct;
|
||||
$account->difference = $diff;
|
||||
$account->percentage = round($pct);
|
||||
$account->percentage = 100;
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@@ -531,12 +531,11 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
);
|
||||
|
||||
return [$fromAccount, $destinationAccount];
|
||||
} else {
|
||||
$fromType = AccountType::where('type', 'Cash account')->first();
|
||||
$fromAccount = Account::firstOrCreateEncrypted(
|
||||
['user_id' => $data['user'], 'account_type_id' => $fromType->id, 'name' => 'Cash account', 'active' => 1]
|
||||
);
|
||||
}
|
||||
$fromType = AccountType::where('type', 'Cash account')->first();
|
||||
$fromAccount = Account::firstOrCreateEncrypted(
|
||||
['user_id' => $data['user'], 'account_type_id' => $fromType->id, 'name' => 'Cash account', 'active' => 1]
|
||||
);
|
||||
|
||||
return [$fromAccount, $destinationAccount];
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
if (is_null($moveTo)) {
|
||||
|
||||
$rule->delete();
|
||||
} else {
|
||||
// move
|
||||
$rule->ruleGroup()->associate($moveTo);
|
||||
$rule->save();
|
||||
continue;
|
||||
}
|
||||
// move
|
||||
$rule->ruleGroup()->associate($moveTo);
|
||||
$rule->save();
|
||||
}
|
||||
|
||||
$ruleGroup->delete();
|
||||
|
||||
Reference in New Issue
Block a user