Add some debug, fix balance report bug.

This commit is contained in:
James Cole
2016-12-22 21:45:04 +01:00
parent 90d58c5c39
commit 8fb9577660
2 changed files with 30 additions and 6 deletions

View File

@@ -203,9 +203,24 @@ class BudgetRepository implements BudgetRepositoryInterface
{
$query = LimitRepetition::leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00'))
->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00'))
->where('budgets.user_id', $this->user->id);
->where(
function (Builder $q1) use ($start, $end) {
$q1->where(
function (Builder $q2) use ($start, $end) {
$q2->where('limit_repetitions.enddate', '>=', $start->format('Y-m-d 00:00:00'));
$q2->where('limit_repetitions.enddate', '<=', $end->format('Y-m-d 00:00:00'));
}
)
->orWhere(
function (Builder $q3) use ($start, $end) {
$q3->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00'));
$q3->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00'));
}
);
}
)
->where('budgets.user_id', $this->user->id)
->whereNull('budgets.deleted_at');
$set = $query->get(['limit_repetitions.*', 'budget_limits.budget_id']);
@@ -383,10 +398,11 @@ class BudgetRepository implements BudgetRepositoryInterface
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string
{
// collect amount of transaction journals, which is easy:
$budgetIds = $budgets->pluck('id')->toArray();
$budgetIds = $budgets->pluck('id')->toArray();
$accountIds = $accounts->pluck('id')->toArray();
Log::debug('spentInPeriod: Now in spentInPeriod for these budgets: ', $budgetIds);
Log::debug(sprintf('spentInPeriod: Now in spentInPeriod for these budgets (%d): ', count($budgetIds)), $budgetIds);
Log::debug('spentInPeriod: and these accounts: ', $accountIds);
Log::debug(sprintf('spentInPeriod: Start date is "%s", end date is "%s"', $start->format('Y-m-d'), $end->format('Y-m-d')));