Some cleaning up. About to release 3.2.1

This commit is contained in:
James Cole
2014-12-15 19:39:01 +01:00
parent 16678aa5e1
commit b999a8f0fb
10 changed files with 74 additions and 58 deletions

View File

@@ -48,7 +48,7 @@ class HomeController extends BaseController
$transactions = []; $transactions = [];
foreach ($accounts as $account) { foreach ($accounts as $account) {
$set = $jrnls->getInDateRangeAccount($account, 10, $start, $end); $set = $jrnls->getInDateRangeAccount($account, $start, $end, 10);
if (count($set) > 0) { if (count($set) > 0) {
$transactions[] = [$set, $account]; $transactions[] = [$set, $account];
} }

View File

@@ -138,8 +138,7 @@ class TestContentSeeder extends Seeder
*/ */
public function createTransaction( public function createTransaction(
Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null
) ) {
{
$user = User::whereEmail('thegrumpydictator@gmail.com')->first(); $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
$euro = TransactionCurrency::whereCode('EUR')->first(); $euro = TransactionCurrency::whereCode('EUR')->first();
@@ -161,7 +160,6 @@ class TestContentSeeder extends Seeder
'transaction_journal_id' => $journal->id, 'transaction_journal_id' => $journal->id,
'amount' => $amount * -1 'amount' => $amount * -1
] ]
); );
Transaction::create( Transaction::create(
[ [
@@ -169,7 +167,6 @@ class TestContentSeeder extends Seeder
'transaction_journal_id' => $journal->id, 'transaction_journal_id' => $journal->id,
'amount' => $amount 'amount' => $amount
] ]
); );
if (!is_null($budget)) { if (!is_null($budget)) {
$journal->budgets()->save($budget); $journal->budgets()->save($budget);

View File

@@ -14,13 +14,10 @@ class PiggybankPart
{ {
/** @var float */ /** @var float */
public $amountPerBar; public $amountPerBar;
/** @var float */
public $currentamount;
/** @var float */ /** @var float */
public $cumulativeAmount; public $cumulativeAmount;
/** @var float */
public $currentamount;
/** @var \Reminder */ /** @var \Reminder */
public $reminder; public $reminder;
@@ -38,11 +35,12 @@ class PiggybankPart
*/ */
public function getReminder() public function getReminder()
{ {
if(is_null($this->reminder)) { if (is_null($this->reminder)) {
$this->reminder = $this->repetition->piggybank->reminders()->where('startdate', $bar->getStartdate()->format('Y-m-d'))->where( $this->reminder = $this->repetition->piggybank->reminders()->where('startdate', $bar->getStartdate()->format('Y-m-d'))->where(
'enddate', $bar->getTargetdate()->format('Y-m-d') 'enddate', $bar->getTargetdate()->format('Y-m-d')
)->first(); )->first();
} }
return $this->reminder; return $this->reminder;
} }
@@ -145,22 +143,6 @@ class PiggybankPart
$this->currentamount = $currentamount; $this->currentamount = $currentamount;
} }
/**
* @return float
*/
public function getAmountPerBar()
{
return $this->amountPerBar;
}
/**
* @param float $amountPerBar
*/
public function setAmountPerBar($amountPerBar)
{
$this->amountPerBar = $amountPerBar;
}
/** /**
* @return float * @return float
*/ */
@@ -177,7 +159,21 @@ class PiggybankPart
$this->cumulativeAmount = $cumulativeAmount; $this->cumulativeAmount = $cumulativeAmount;
} }
/**
* @return float
*/
public function getAmountPerBar()
{
return $this->amountPerBar;
}
/**
* @param float $amountPerBar
*/
public function setAmountPerBar($amountPerBar)
{
$this->amountPerBar = $amountPerBar;
}
} }

View File

@@ -223,28 +223,28 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
// delete journals: // delete journals:
\TransactionJournal::whereIn( \TransactionJournal::whereIn(
'id', function ($query) use ($model) { 'id', function ($query) use ($model) {
$query->select('transaction_journal_id') $query->select('transaction_journal_id')
->from('transactions')->whereIn( ->from('transactions')->whereIn(
'account_id', function ($query) use ($model) { 'account_id', function ($query) use ($model) {
$query $query
->select('id') ->select('id')
->from('accounts') ->from('accounts')
->where( ->where(
function ($q) use ($model) {
$q->where('id', $model->id);
$q->orWhere(
function ($q) use ($model) { function ($q) use ($model) {
$q->where('id', $model->id); $q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
$q->orWhere( // TODO magic number!
function ($q) use ($model) { $q->where('accounts.account_type_id', 3);
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%'); $q->where('accounts.active', 0);
// TODO magic number!
$q->where('accounts.account_type_id', 3);
$q->where('accounts.active', 0);
}
);
} }
)->where('accounts.user_id', $this->getUser()->id); );
} }
)->get(); )->where('accounts.user_id', $this->getUser()->id);
} }
)->get();
}
)->delete(); )->delete();
/* /*

View File

@@ -87,6 +87,12 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
* Validates an array. Returns an array containing MessageBags * Validates an array. Returns an array containing MessageBags
* errors/warnings/successes. * errors/warnings/successes.
* *
* Ignore PHPMD rules because Laravel 5.0 will make this method superfluous anyway.
*
* @SuppressWarnings("Cyclomatic")
* @SuppressWarnings("NPath")
* @SuppressWarnings("MethodLength")
*
* @param array $model * @param array $model
* *
* @return array * @return array

View File

@@ -158,6 +158,12 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
* Validates an array. Returns an array containing MessageBags * Validates an array. Returns an array containing MessageBags
* errors/warnings/successes. * errors/warnings/successes.
* *
*
* ignored because this method will be gone soon.
* @SuppressWarnings("Cyclomatic")
* @SuppressWarnings("NPath")
* @SuppressWarnings("MethodLength")
*
* @param array $model * @param array $model
* *
* @return array * @return array

View File

@@ -102,6 +102,11 @@ class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransac
* Validates an array. Returns an array containing MessageBags * Validates an array. Returns an array containing MessageBags
* errors/warnings/successes. * errors/warnings/successes.
* *
* ignored because this method will be gone soon.
* @SuppressWarnings("Cyclomatic")
* @SuppressWarnings("NPath")
* @SuppressWarnings("MethodLength")
*
* @param array $model * @param array $model
* *
* @return array * @return array

View File

@@ -194,6 +194,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
* Validates an array. Returns an array containing MessageBags * Validates an array. Returns an array containing MessageBags
* errors/warnings/successes. * errors/warnings/successes.
* *
* ignored because this method will be gone soon.
* @SuppressWarnings("Cyclomatic")
* @SuppressWarnings("NPath")
* @SuppressWarnings("MethodLength")
*
* @param array $model * @param array $model
* *
* @return array * @return array
@@ -614,13 +619,13 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
/** /**
* @param \Account $account * @param \Account $account
* @param int $count
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* @param int $count
* *
* @return Collection * @return Collection
*/ */
public function getInDateRangeAccount(\Account $account, $count = 20, Carbon $start, Carbon $end) public function getInDateRangeAccount(\Account $account, Carbon $start, Carbon $end, $count = 20)
{ {
$accountID = $account->id; $accountID = $account->id;

View File

@@ -15,7 +15,6 @@ class Form
* Takes any collection and tries to make a sensible select list compatible array of it. * Takes any collection and tries to make a sensible select list compatible array of it.
* *
* @param Collection $set * @param Collection $set
* @param null $titleField
* @param bool $addEmpty * @param bool $addEmpty
* @SuppressWarnings("CyclomaticComplexity") * @SuppressWarnings("CyclomaticComplexity")
* *

View File

@@ -14,14 +14,16 @@ if (!function_exists('mf')) {
$amount = round($amount, 2); $amount = round($amount, 2);
$string = number_format($amount, 2, ',', '.'); $string = number_format($amount, 2, ',', '.');
if ($coloured === true && $amount === 0.0) { if ($coloured === true) {
return '<span style="color:#999">&#8364; ' . $string . '</span>'; if ($amount === 0.0) {
} return '<span style="color:#999">&#8364; ' . $string . '</span>';
if ($coloured === true && $amount > 0) { }
return '<span class="text-success">&#8364; ' . $string . '</span>'; if ($amount > 0) {
} return '<span class="text-success">&#8364; ' . $string . '</span>';
if ($coloured === true && $amount < 0) { }
return '<span class="text-danger">&#8364; ' . $string . '</span>'; if ($amount < 0) {
return '<span class="text-danger">&#8364; ' . $string . '</span>';
}
} }
return '&#8364; ' . $string; return '&#8364; ' . $string;