Some cleaning up

This commit is contained in:
James Cole 2015-05-17 09:18:44 +02:00
parent 6ca119c4db
commit e6263f9ff5
20 changed files with 58 additions and 111 deletions

View File

@ -34,15 +34,6 @@ and the philosophy behind it.
It's III, or 3, because [version 2](https://github.com/JC5/Firefly) and version 1 (not online) preceded it. It has been growing steadily ever since.
## Running and installing
If you're still interested please read [the installation guide](https://github.com/JC5/firefly-iii/wiki/Installation),
[the upgrade guide](https://github.com/JC5/firefly-iii/wiki/Upgrade-instructions) (if applicable)
and the **[first use guide](https://github.com/JC5/firefly-iii/wiki/First-use)**.
If you want to try out Firefly III, you can do so on [this dedicated website](https://geld.nder.be/).
This site always runs the latest version of Firefly III. If you want to use it, please read the [privacy considerations](https://github.com/JC5/firefly-iii/wiki/Privacy-on-demo-site) for this demo-site.
## Current features
- [A double-entry bookkeeping system](https://en.wikipedia.org/wiki/Double-entry_bookkeeping_system);
@ -86,6 +77,16 @@ _Please note that everything in these screenshots is fictional and may not be re
![Piggy banks](https://i.nder.be/hkud0h53)
## Running and installing
If you're still interested please read [the installation guide](https://github.com/JC5/firefly-iii/wiki/Installation),
[the upgrade guide](https://github.com/JC5/firefly-iii/wiki/Upgrade-instructions) (if applicable)
and the **[first use guide](https://github.com/JC5/firefly-iii/wiki/First-use)**.
If you want to try out Firefly III, you can do so on [this dedicated website](https://geld.nder.be/).
This site always runs the latest version of Firefly III. If you want to use it, please read the [privacy considerations](https://github.com/JC5/firefly-iii/wiki/Privacy-on-demo-site) for this demo-site.
## Current state
Firefly III is pretty much all grown up. Full test coverage (nerd alert!) is coming. One of the things on the todo-list

View File

@ -21,7 +21,7 @@ class BalanceLine
/** @var BudgetModel */
protected $budget;
/** @var float */
/** @var float */
protected $budgetAmount = 0.0;
/**
@ -40,22 +40,6 @@ class BalanceLine
$this->balanceEntries->push($balanceEntry);
}
/**
* @return Collection
*/
public function getBalanceEntries()
{
return $this->balanceEntries;
}
/**
* @param Collection $balanceEntries
*/
public function setBalanceEntries($balanceEntries)
{
$this->balanceEntries = $balanceEntries;
}
/**
* @return BudgetModel
*/
@ -72,6 +56,20 @@ class BalanceLine
$this->budget = $budget;
}
/**
* @return float
*/
public function left()
{
$start = $this->getBudgetAmount();
/** @var BalanceEntry $balanceEntry */
foreach ($this->getBalanceEntries() as $balanceEntry) {
$start += $balanceEntry->getSpent();
}
return $start;
}
/**
* @return float
*/
@ -89,17 +87,20 @@ class BalanceLine
}
/**
* @return float
* @return Collection
*/
public function left() {
$start = $this->getBudgetAmount();
/** @var BalanceEntry $balanceEntry */
foreach($this->getBalanceEntries() as $balanceEntry) {
$start += $balanceEntry->getSpent();
}
return $start;
public function getBalanceEntries()
{
return $this->balanceEntries;
}
/**
* @param Collection $balanceEntries
*/
public function setBalanceEntries($balanceEntries)
{
$this->balanceEntries = $balanceEntries;
}
}

View File

@ -30,7 +30,9 @@ class ReportHelper implements ReportHelperInterface
protected $query;
/**
* @param ReportHelperInterface $helper
* @param ReportQueryInterface $query
*
* @internal param ReportHelperInterface $helper
*/
public function __construct(ReportQueryInterface $query)
{

View File

@ -33,50 +33,6 @@ class BillController extends Controller
View::share('mainTitleIcon', 'fa-calendar-o');
}
/**
* @param AccountRepositoryInterface $repository
* @param Bill $bill
*
* @return \Illuminate\Http\RedirectResponse
*/
public function add(AccountRepositoryInterface $repository, Bill $bill)
{
$matches = explode(',', $bill->match);
$description = [];
$expense = null;
// get users expense accounts:
$accounts = $repository->getAccounts(Config::get('firefly.accountTypesByIdentifier.expense'));
foreach ($matches as $match) {
$match = strtolower($match);
// find expense account for each word if not found already:
if (is_null($expense)) {
/** @var Account $account */
foreach ($accounts as $account) {
$name = strtolower($account->name);
if (!(strpos($name, $match) === false)) {
$expense = $account;
break;
}
}
}
if (is_null($expense)) {
$description[] = $match;
}
}
$parameters = [
'description' => ucfirst(join(' ', $description)),
'expense_account' => is_null($expense) ? '' : $expense->name,
'amount' => round(($bill->amount_min + $bill->amount_max), 2),
];
Session::put('preFilled', $parameters);
return Redirect::to(route('transactions.create', 'withdrawal'));
}
/**
* @return $this
*/

View File

@ -63,13 +63,11 @@ class HomeController extends Controller
$savings = $repository->getSavingsAccounts();
$piggyBankAccounts = $repository->getPiggyBankAccounts();
$savingsTotal = 0;
foreach ($savings as $savingAccount) {
$savingsTotal += Steam::balance($savingAccount, $end);
}
// check if all books are correct.
$sum = $repository->sumOfEverything();
if ($sum != 0) {
Session::flash(

View File

@ -38,7 +38,7 @@ class JsonController extends Controller
$end = Session::get('end', Carbon::now()->endOfMonth());
$amount = 0;
// these two functions are the same as the chart TODO
// these two functions are the same as the chart
$bills = $repository->getActiveBills();
/** @var Bill $bill */
@ -141,7 +141,7 @@ class JsonController extends Controller
{
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$amount = $reportQuery->journalsByExpenseAccount($start, $end, true)->sum('queryAmount');
$amount = $reportQuery->expenseInPeriod($start, $end, true)->sum('queryAmount') * -1;
return Response::json(['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]);
}

View File

@ -2,7 +2,6 @@
use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Helpers\Report\ReportQueryInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\LimitRepetition;
@ -37,9 +36,10 @@ class ReportController extends Controller
}
/**
* @param AccountRepositoryInterface $repository
*
* @return View
* @internal param ReportHelperInterface $helper
*
*/
public function index(AccountRepositoryInterface $repository)
{
@ -65,6 +65,8 @@ class ReportController extends Controller
* @param string $year
* @param string $month
*
* @param bool $shared
*
* @return \Illuminate\View\View
*/
public function month($year = '2014', $month = '1', $shared = false)
@ -98,7 +100,7 @@ class ReportController extends Controller
'accounts',
'incomes', 'incomeTopLength',
'expenses', 'expenseTopLength',
'budgets','balance',
'budgets', 'balance',
'categories'
)
);
@ -106,7 +108,9 @@ class ReportController extends Controller
}
/**
* @param $year
* @param $year
*
* @param bool $shared
*
* @return $this
*/

View File

@ -223,7 +223,6 @@ Route::group(
Route::get('/bills/rescan/{bill}', ['uses' => 'BillController@rescan', 'as' => 'bills.rescan']); # rescan for matching.
Route::get('/bills/create', ['uses' => 'BillController@create', 'as' => 'bills.create']);
Route::get('/bills/edit/{bill}', ['uses' => 'BillController@edit', 'as' => 'bills.edit']);
Route::get('/bills/add/{bill}', ['uses' => 'BillController@add', 'as' => 'bills.add']);
Route::get('/bills/delete/{bill}', ['uses' => 'BillController@delete', 'as' => 'bills.delete']);
Route::get('/bills/show/{bill}', ['uses' => 'BillController@show', 'as' => 'bills.show']);
Route::post('/bills/store', ['uses' => 'BillController@store', 'as' => 'bills.store']);

View File

@ -256,10 +256,12 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @param Budget $budget
* @param Carbon $date
* @param Carbon $start
* @param Carbon $end
* @param bool $shared
*
* @return float
* @internal param Carbon $date
*/
public function spentInPeriod(Budget $budget, Carbon $start, Carbon $end, $shared = true)
{

View File

@ -168,6 +168,8 @@ class CategoryRepository implements CategoryRepositoryInterface
* @param Carbon $start
* @param Carbon $end
*
* @param bool $shared
*
* @return float
*/
public function spentInPeriod(Category $category, Carbon $start, Carbon $end, $shared = false)

View File

@ -75,6 +75,8 @@ interface CategoryRepositoryInterface
* @param \Carbon\Carbon $start
* @param \Carbon\Carbon $end
*
* @param bool $shared
*
* @return float
*/
public function spentInPeriod(Category $category, Carbon $start, Carbon $end, $shared = false);

View File

@ -198,7 +198,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* @param array $data
*
* @return PiggyBank
* @internal param PiggyBank $account
*/
public function update(PiggyBank $piggyBank, array $data)
{

2
database/.gitignore vendored
View File

@ -1 +1 @@
*.sqlite

View File

@ -10,7 +10,6 @@
<th>{{ trans('list.active') }}</th>
<th>{{ trans('list.automatch') }}</th>
<th>{{ trans('list.repeat_freq') }}</th>
<th data-defaultsort="disabled">&nbsp;</th>
</tr></thead>
<tbody>
{% for entry in bills %}
@ -75,11 +74,6 @@
skips over {{entry.skip}}
{% endif %}
</td>
<td>
{% if entry.active %}
<a href="{{route('bills.add',entry.id)}}" class="btn btn-success btn-xs"><i class="fa fa-fw fa-plus-circle"></i></a>
{% endif %}
</td>
</tr>
{% endfor %}

View File

@ -41,7 +41,6 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::countAccounts
* @todo Implement testCountAccounts().
*/
public function testCountAccounts()
{
@ -83,7 +82,6 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::getCreditCards
* @todo Implement testGetCreditCards().
*/
public function testGetCreditCards()
{
@ -459,7 +457,6 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::getTransfersInRange
* @todo Implement testGetTransfersInRange().
*/
public function testGetTransfersInRange()
{

View File

@ -126,7 +126,6 @@ class BillRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::getJournalsInRange
* @todo Implement testGetJournalsInRange().
*/
public function testGetJournalsInRange()
{
@ -144,7 +143,6 @@ class BillRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::getPossiblyRelatedJournals
* @todo Implement testGetPossiblyRelatedJournals().
*/
public function testGetPossiblyRelatedJournals()
{
@ -439,7 +437,6 @@ class BillRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::update
* @todo Implement testUpdate().
*/
public function testUpdate()
{

View File

@ -58,7 +58,6 @@ class BudgetRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::destroy
* @todo Implement testDestroy().
*/
public function testDestroy()
{
@ -71,7 +70,6 @@ class BudgetRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Budget\BudgetRepository::expensesOnDay
* @todo Implement testExpensesOnDay().
*/
public function testExpensesOnDay()
{

View File

@ -46,7 +46,6 @@ class CategoryRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Category\CategoryRepository::destroy
* @todo Implement testDestroy().
*/
public function testDestroy()
{

View File

@ -132,7 +132,6 @@ class PiggyBankRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getEvents
* @todo Implement testGetEvents().
*/
public function testGetEvents()
{
@ -185,7 +184,6 @@ class PiggyBankRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::store
* @todo Implement testStore().
*/
public function testStore()
{
@ -208,7 +206,6 @@ class PiggyBankRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::update
* @todo Implement testUpdate().
*/
public function testUpdate()
{

View File

@ -330,7 +330,6 @@ class TagRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Tag\TagRepository::get
* @todo Implement testGet().
*/
public function testGet()
{