Code cleanup. Moving closer to new release.

This commit is contained in:
James Cole
2016-05-20 17:53:03 +02:00
parent 87f9ca3bb2
commit a74a646777
19 changed files with 248 additions and 191 deletions

View File

@@ -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;
}
);

View File

@@ -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];
}

View File

@@ -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();