mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 21:53:08 -06:00
Refactor
This commit is contained in:
parent
59f57c96e9
commit
c4c4fbc34c
@ -185,7 +185,7 @@ class ReportQuery implements ReportQueryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See ReportQueryInterface::incomeInPeriodCorrected
|
* See ReportQueryInterface::incomeInPeriod
|
||||||
*
|
*
|
||||||
* This method returns all "expense" journals in a certain period, which are both transfers to a shared account
|
* This method returns all "expense" journals in a certain period, which are both transfers to a shared account
|
||||||
* and "ordinary" withdrawals. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
|
* and "ordinary" withdrawals. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
|
||||||
|
@ -16,7 +16,7 @@ interface ReportQueryInterface
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See ReportQueryInterface::incomeInPeriodCorrected
|
* See ReportQueryInterface::incomeInPeriod
|
||||||
*
|
*
|
||||||
* This method returns all "expense" journals in a certain period, which are both transfers to a shared account
|
* This method returns all "expense" journals in a certain period, which are both transfers to a shared account
|
||||||
* and "ordinary" withdrawals. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
|
* and "ordinary" withdrawals. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
|
||||||
|
@ -113,7 +113,7 @@ class BudgetController extends Controller
|
|||||||
/*
|
/*
|
||||||
* Sum of expenses on this day:
|
* Sum of expenses on this day:
|
||||||
*/
|
*/
|
||||||
$sum = $repository->expensesOnDayCorrected($budget, $start);
|
$sum = $repository->expensesOnDay($budget, $start);
|
||||||
$amount = bcadd($amount, $sum);
|
$amount = bcadd($amount, $sum);
|
||||||
$entries->push([clone $start, $amount]);
|
$entries->push([clone $start, $amount]);
|
||||||
$start->addDay();
|
$start->addDay();
|
||||||
|
@ -107,7 +107,7 @@ class CategoryController extends Controller
|
|||||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
$array = $repository->getCategoriesAndExpensesCorrected($start, $end);
|
$array = $repository->getCategoriesAndExpenses($start, $end);
|
||||||
// sort by callback:
|
// sort by callback:
|
||||||
uasort(
|
uasort(
|
||||||
$array,
|
$array,
|
||||||
@ -151,8 +151,8 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
while ($start <= $end) {
|
while ($start <= $end) {
|
||||||
$spent = $repository->spentOnDaySumCorrected($category, $start);
|
$spent = $repository->spentOnDaySum($category, $start);
|
||||||
$earned = $repository->earnedOnDaySumCorrected($category, $start);
|
$earned = $repository->earnedOnDaySum($category, $start);
|
||||||
$date = Navigation::periodShow($start, '1D');
|
$date = Navigation::periodShow($start, '1D');
|
||||||
$entries->push([clone $start, $date, $spent, $earned]);
|
$entries->push([clone $start, $date, $spent, $earned]);
|
||||||
$start->addDay();
|
$start->addDay();
|
||||||
@ -194,8 +194,8 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
while ($start <= $end) {
|
while ($start <= $end) {
|
||||||
$spent = $repository->spentOnDaySumCorrected($category, $start);
|
$spent = $repository->spentOnDaySum($category, $start);
|
||||||
$earned = $repository->earnedOnDaySumCorrected($category, $start);
|
$earned = $repository->earnedOnDaySum($category, $start);
|
||||||
$theDate = Navigation::periodShow($start, '1D');
|
$theDate = Navigation::periodShow($start, '1D');
|
||||||
$entries->push([clone $start, $theDate, $spent, $earned]);
|
$entries->push([clone $start, $theDate, $spent, $earned]);
|
||||||
$start->addDay();
|
$start->addDay();
|
||||||
|
@ -52,7 +52,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function expensesOnDayCorrected(Budget $budget, Carbon $date)
|
public function expensesOnDay(Budget $budget, Carbon $date)
|
||||||
{
|
{
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
$sum = $budget->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
$sum = $budget->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
||||||
|
@ -35,7 +35,7 @@ interface BudgetRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function expensesOnDayCorrected(Budget $budget, Carbon $date);
|
public function expensesOnDay(Budget $budget, Carbon $date);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
|
@ -67,7 +67,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getCategoriesAndExpensesCorrected(Carbon $start, Carbon $end)
|
public function getCategoriesAndExpenses(Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$set = Auth::user()->transactionjournals()
|
$set = Auth::user()->transactionjournals()
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
@ -212,7 +212,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function spentOnDaySumCorrected(Category $category, Carbon $date)
|
public function spentOnDaySum(Category $category, Carbon $date)
|
||||||
{
|
{
|
||||||
return $category->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
return $category->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function earnedOnDaySumCorrected(Category $category, Carbon $date)
|
public function earnedOnDaySum(Category $category, Carbon $date)
|
||||||
{
|
{
|
||||||
return $category->transactionjournals()->transactionTypes([TransactionType::DEPOSIT])->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
return $category->transactionjournals()->transactionTypes([TransactionType::DEPOSIT])->onDate($date)->get(['transaction_journals.*'])->sum('amount');
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ interface CategoryRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getCategoriesAndExpensesCorrected(Carbon $start, Carbon $end);
|
public function getCategoriesAndExpenses(Carbon $start, Carbon $end);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
@ -156,7 +156,7 @@ interface CategoryRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function spentOnDaySumCorrected(Category $category, Carbon $date);
|
public function spentOnDaySum(Category $category, Carbon $date);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -167,7 +167,7 @@ interface CategoryRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function earnedOnDaySumCorrected(Category $category, Carbon $date);
|
public function earnedOnDaySum(Category $category, Carbon $date);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@ -23,10 +23,10 @@ class Budget extends Twig_Extension
|
|||||||
{
|
{
|
||||||
$functions = [];
|
$functions = [];
|
||||||
$functions[] = new Twig_SimpleFunction(
|
$functions[] = new Twig_SimpleFunction(
|
||||||
'spentInRepetitionCorrected', function (LimitRepetition $repetition) {
|
'spentInRepetition', function (LimitRepetition $repetition) {
|
||||||
$cache = new CacheProperties;
|
$cache = new CacheProperties;
|
||||||
$cache->addProperty($repetition->id);
|
$cache->addProperty($repetition->id);
|
||||||
$cache->addProperty('spentInRepetitionCorrected');
|
$cache->addProperty('spentInRepetition');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
{% for limit in limits %}
|
{% for limit in limits %}
|
||||||
{% for rep in limit.limitRepetitions %}
|
{% for rep in limit.limitRepetitions %}
|
||||||
{% set spentInRep = spentInRepetitionCorrected(rep) %}
|
{% set spentInRep = spentInRepetition(rep) %}
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title"><a href="{{ route('budgets.show',[budget.id,rep.id]) }}">{{ rep.startdate.formatLocalized(monthFormat) }}</a>
|
<h3 class="box-title"><a href="{{ route('budgets.show',[budget.id,rep.id]) }}">{{ rep.startdate.formatLocalized(monthFormat) }}</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user