mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 17:31:09 -06:00
Various optimisations.
This commit is contained in:
parent
d67db74ca2
commit
2d4b148b2c
@ -24,25 +24,19 @@ class ChartJsBillChartGenerator implements BillChartGenerator
|
||||
*/
|
||||
public function frontpage(Collection $paid, Collection $unpaid)
|
||||
{
|
||||
|
||||
// loop paid and create single entry:
|
||||
$paidDescriptions = [];
|
||||
$paidAmount = 0;
|
||||
$unpaidDescriptions = [];
|
||||
$unpaidAmount = 0;
|
||||
|
||||
bcscale(2);
|
||||
|
||||
/** @var TransactionJournal $entry */
|
||||
foreach ($paid as $entry) {
|
||||
|
||||
foreach ($paid as $entry) { // loop paid and create single entry:
|
||||
$paidDescriptions[] = $entry->description;
|
||||
$paidAmount = bcadd($paidAmount, $entry->amount);
|
||||
}
|
||||
|
||||
// loop unpaid:
|
||||
/** @var Bill $entry */
|
||||
foreach ($unpaid as $entry) {
|
||||
foreach ($unpaid as $entry) { // loop unpaid:
|
||||
$description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
|
||||
$amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
|
||||
$unpaidDescriptions[] = $description;
|
||||
|
@ -3,6 +3,11 @@
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
|
||||
/**
|
||||
* Class RabobankDebetCredit
|
||||
*
|
||||
* @package FireflyIII\Helpers\Csv\Converter
|
||||
*/
|
||||
class RabobankDebetCredit extends BasicConverter implements ConverterInterface
|
||||
{
|
||||
|
||||
|
@ -119,7 +119,7 @@ class Data
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getHasHeaders()
|
||||
public function hasHeaders()
|
||||
{
|
||||
return $this->hasHeaders;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class Importer
|
||||
*/
|
||||
protected function parseRow($index)
|
||||
{
|
||||
return (($this->data->getHasHeaders() && $index > 1) || !$this->data->getHasHeaders());
|
||||
return (($this->data->hasHeaders() && $index > 1) || !$this->data->hasHeaders());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,26 +24,20 @@ class OpposingAccount implements PostProcessorInterface
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
// first priority. try to find the account based on ID, if any.
|
||||
if ($this->data['opposing-account-id'] instanceof Account) {
|
||||
if ($this->data['opposing-account-id'] instanceof Account) { // first priority. try to find the account based on ID, if any
|
||||
$this->data['opposing-account-object'] = $this->data['opposing-account-id'];
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
// second: try to find the account based on IBAN, if any.
|
||||
if ($this->data['opposing-account-iban'] instanceof Account) {
|
||||
if ($this->data['opposing-account-iban'] instanceof Account) { // second: try to find the account based on IBAN, if any.
|
||||
$this->data['opposing-account-object'] = $this->data['opposing-account-iban'];
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
$rules = ['iban' => 'iban'];
|
||||
$check = ['iban' => $this->data['opposing-account-iban']];
|
||||
$validator = Validator::make($check, $rules);
|
||||
$result = !$validator->fails();
|
||||
|
||||
|
||||
if (is_string($this->data['opposing-account-iban']) && strlen($this->data['opposing-account-iban']) > 0) {
|
||||
if ($result) {
|
||||
$this->data['opposing-account-object'] = $this->parseIbanString();
|
||||
@ -51,14 +45,11 @@ class OpposingAccount implements PostProcessorInterface
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
// third: try to find account based on name, if any.
|
||||
if ($this->data['opposing-account-name'] instanceof Account) {
|
||||
if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any.
|
||||
$this->data['opposing-account-object'] = $this->data['opposing-account-name'];
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
if (is_string($this->data['opposing-account-name'])) {
|
||||
$this->data['opposing-account-object'] = $this->parseNameString();
|
||||
|
||||
|
@ -202,11 +202,10 @@ class ReportHelper implements ReportHelperInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return BillCollection
|
||||
*/
|
||||
public function getBillReport(Carbon $start, Carbon $end, $shared)
|
||||
public function getBillReport(Carbon $start, Carbon $end)
|
||||
{
|
||||
/** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */
|
||||
$repository = App::make('FireflyIII\Repositories\Bill\BillRepositoryInterface');
|
||||
|
@ -37,11 +37,10 @@ interface ReportHelperInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return BillCollection
|
||||
*/
|
||||
public function getBillReport(Carbon $start, Carbon $end, $shared);
|
||||
public function getBillReport(Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
|
@ -176,9 +176,7 @@ class CategoryController extends Controller
|
||||
$start = new Carbon($year . '-01-01');
|
||||
$end = new Carbon($year . '-12-31');
|
||||
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache = new CacheProperties; // chart properties for cache:
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('category');
|
||||
@ -192,14 +190,11 @@ class CategoryController extends Controller
|
||||
$entries = new Collection;
|
||||
|
||||
while ($start < $end) {
|
||||
// month is the current end of the period:
|
||||
$month = clone $start;
|
||||
$month = clone $start; // month is the current end of the period
|
||||
$month->endOfMonth();
|
||||
// make a row:
|
||||
$row = [clone $start];
|
||||
$row = [clone $start]; // make a row:
|
||||
|
||||
// each budget, fill the row:
|
||||
foreach ($categories as $category) {
|
||||
foreach ($categories as $category) { // each budget, fill the row
|
||||
$spent = $repository->spentInPeriodCorrected($category, $start, $month, $shared);
|
||||
$row[] = $spent;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class CsvController extends Controller
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$headers[] = trans('firefly.csv_column') . ' #' . $i;
|
||||
}
|
||||
if ($this->data->getHasHeaders()) {
|
||||
if ($this->data->hasHeaders()) {
|
||||
$headers = $firstRow;
|
||||
}
|
||||
|
||||
@ -184,7 +184,6 @@ class CsvController extends Controller
|
||||
return redirect(route('csv.index'));
|
||||
}
|
||||
|
||||
|
||||
// process given roles and mapping:
|
||||
$roles = $this->wizard->processSelectedRoles(Input::get('role'));
|
||||
$maps = $this->wizard->processSelectedMapping($roles, Input::get('map'));
|
||||
@ -192,9 +191,7 @@ class CsvController extends Controller
|
||||
Session::put('csv-map', $maps);
|
||||
Session::put('csv-roles', $roles);
|
||||
|
||||
/*
|
||||
* Go back when no roles defined:
|
||||
*/
|
||||
// Go back when no roles defined:
|
||||
if (count($roles) === 0) {
|
||||
Session::flash('warning', 'Please select some roles.');
|
||||
|
||||
@ -256,7 +253,7 @@ class CsvController extends Controller
|
||||
// After these values are prepped, read the actual CSV file
|
||||
$reader = $this->data->getReader();
|
||||
$map = $this->data->getMap();
|
||||
$hasHeaders = $this->data->getHasHeaders();
|
||||
$hasHeaders = $this->data->hasHeaders();
|
||||
$values = $this->wizard->getMappableValues($reader, $map, $hasHeaders);
|
||||
$map = $this->data->getMap();
|
||||
$mapped = $this->data->getMapped();
|
||||
|
@ -566,7 +566,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
);
|
||||
$journal->save();
|
||||
|
||||
|
||||
if ($data['openingBalance'] < 0) {
|
||||
$firstAccount = $opposing;
|
||||
$secondAccount = $account;
|
||||
@ -578,26 +577,11 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$firstAmount = $data['openingBalance'];
|
||||
$secondAmount = $data['openingBalance'] * -1;
|
||||
}
|
||||
$one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]);
|
||||
$one->save();// first transaction: from
|
||||
|
||||
// first transaction: from
|
||||
$one = new Transaction(
|
||||
[
|
||||
'account_id' => $firstAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => $firstAmount
|
||||
]
|
||||
);
|
||||
$one->save();
|
||||
|
||||
// second transaction: to
|
||||
$two = new Transaction(
|
||||
[
|
||||
'account_id' => $secondAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => $secondAmount
|
||||
]
|
||||
);
|
||||
$two->save();
|
||||
$two = new Transaction(['account_id' => $secondAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $secondAmount]);
|
||||
$two->save(); // second transaction: to
|
||||
|
||||
return $journal;
|
||||
|
||||
@ -606,6 +590,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
protected function updateMetadata(Account $account, array $data)
|
||||
{
|
||||
|
@ -115,14 +115,14 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param int $journalId
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date)
|
||||
public function getWithDate($journalId, Carbon $date)
|
||||
{
|
||||
return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d 00:00:00'))->first();
|
||||
return Auth::user()->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,12 +62,12 @@ interface JournalRepositoryInterface
|
||||
public function getTransactionType($type);
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param int $journalId
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date);
|
||||
public function getWithDate($journalId, Carbon $date);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
|
@ -57,7 +57,8 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateIban($attribute, $value)
|
||||
{
|
||||
@ -200,9 +201,10 @@ class FireflyValidator extends Validator
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @return bool
|
||||
* @internal param $parameters
|
||||
*
|
||||
*/
|
||||
protected function validateByAccountId($value)
|
||||
{
|
||||
|
@ -3,6 +3,11 @@ namespace Helper;
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
/**
|
||||
* Class Acceptance
|
||||
*
|
||||
* @package Helper
|
||||
*/
|
||||
class Acceptance extends \Codeception\Module
|
||||
{
|
||||
|
||||
|
@ -3,6 +3,11 @@ namespace Helper;
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
/**
|
||||
* Class Functional
|
||||
*
|
||||
* @package Helper
|
||||
*/
|
||||
class Functional extends \Codeception\Module
|
||||
{
|
||||
|
||||
|
@ -3,6 +3,11 @@ namespace Helper;
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
/**
|
||||
* Class Unit
|
||||
*
|
||||
* @package Helper
|
||||
*/
|
||||
class Unit extends \Codeception\Module
|
||||
{
|
||||
|
||||
|
@ -8,6 +8,11 @@ namespace _generated;
|
||||
use Codeception\Module\PhpBrowser;
|
||||
use Helper\Acceptance;
|
||||
|
||||
/**
|
||||
* Class AcceptanceTesterActions
|
||||
*
|
||||
* @package _generated
|
||||
*/
|
||||
trait AcceptanceTesterActions
|
||||
{
|
||||
/**
|
||||
|
@ -7,6 +7,11 @@ namespace _generated;
|
||||
|
||||
use Helper\Functional;
|
||||
|
||||
/**
|
||||
* Class FunctionalTesterActions
|
||||
*
|
||||
* @package _generated
|
||||
*/
|
||||
trait FunctionalTesterActions
|
||||
{
|
||||
/**
|
||||
|
@ -9,6 +9,11 @@ use Codeception\Module\Laravel5;
|
||||
use Codeception\Module\Asserts;
|
||||
use Helper\Unit;
|
||||
|
||||
/**
|
||||
* Class UnitTesterActions
|
||||
*
|
||||
* @package _generated
|
||||
*/
|
||||
trait UnitTesterActions
|
||||
{
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user