mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some cleaning up and suppressing.
This commit is contained in:
parent
31533b5ef8
commit
51062bc80b
@ -313,6 +313,10 @@ class CategoryController extends Controller
|
|||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
*
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // cant avoid it.
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // it's long but ok.
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function earnedInPeriod(CRI $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
public function earnedInPeriod(CRI $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||||
@ -337,18 +341,15 @@ class CategoryController extends Controller
|
|||||||
$entries = new Collection;
|
$entries = new Collection;
|
||||||
|
|
||||||
while ($start < $end) { // filter the set:
|
while ($start < $end) { // filter the set:
|
||||||
$row = [clone $start];
|
$row = [clone $start];
|
||||||
// get possibly relevant entries from the big $set
|
$currentSet = $set->filter( // get possibly relevant entries from the big $set
|
||||||
$currentSet = $set->filter(
|
|
||||||
function (Category $category) use ($start) {
|
function (Category $category) use ($start) {
|
||||||
return $category->dateFormatted == $start->format("Y-m");
|
return $category->dateFormatted == $start->format("Y-m");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// check for each category if its in the current set.
|
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) { // check for each category if its in the current set.
|
||||||
// if its in there, use the value.
|
$entry = $currentSet->filter( // if its in there, use the value.
|
||||||
$entry = $currentSet->filter(
|
|
||||||
function (Category $cat) use ($category) {
|
function (Category $cat) use ($category) {
|
||||||
return ($cat->id == $category->id);
|
return ($cat->id == $category->id);
|
||||||
}
|
}
|
||||||
@ -359,7 +360,6 @@ class CategoryController extends Controller
|
|||||||
$row[] = 0;
|
$row[] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$entries->push($row);
|
$entries->push($row);
|
||||||
$start->addMonth();
|
$start->addMonth();
|
||||||
}
|
}
|
||||||
|
@ -331,6 +331,8 @@ class CsvController extends Controller
|
|||||||
*
|
*
|
||||||
* STEP SIX
|
* STEP SIX
|
||||||
*
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity) it's 6, but it's allright.
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function saveMapping()
|
public function saveMapping()
|
||||||
|
@ -323,6 +323,8 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
*/
|
*/
|
||||||
protected function storeAccounts(TransactionType $type, array $data)
|
protected function storeAccounts(TransactionType $type, array $data)
|
||||||
{
|
{
|
||||||
|
@ -318,6 +318,8 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
*
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function connectAdvancePayment(TransactionJournal $journal, Tag $tag)
|
protected function connectAdvancePayment(TransactionJournal $journal, Tag $tag)
|
||||||
@ -332,13 +334,11 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
$withdrawals = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->count();
|
$withdrawals = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->count();
|
||||||
$deposits = $tag->transactionjournals()->where('transaction_type_id', $deposit->id)->count();
|
$deposits = $tag->transactionjournals()->where('transaction_type_id', $deposit->id)->count();
|
||||||
|
|
||||||
// advance payments cannot accept transfers:
|
if ($journal->transaction_type_id == $transfer->id) { // advance payments cannot accept transfers:
|
||||||
if ($journal->transaction_type_id == $transfer->id) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the first transaction to be attached to this
|
// the first transaction to be attached to this tag is attached just like that:
|
||||||
// tag is attached just like that:
|
|
||||||
if ($withdrawals < 1 && $deposits < 1) {
|
if ($withdrawals < 1 && $deposits < 1) {
|
||||||
$journal->tags()->save($tag);
|
$journal->tags()->save($tag);
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
Loading…
Reference in New Issue
Block a user