This commit is contained in:
James Cole 2019-10-05 05:18:40 +02:00
parent 67f9d23714
commit 9b001f7c15
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 7 additions and 8 deletions

View File

@ -46,11 +46,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon created_at * @property Carbon created_at
* @property Carbon updated_at * @property Carbon updated_at
* @property User $user * @property User $user
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at * @property \Illuminate\Support\Carbon|null $deleted_at
* @property bool $encrypted
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\BudgetLimit[] $budgetlimits
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
* @method static bool|null forceDelete() * @method static bool|null forceDelete()

View File

@ -69,12 +69,15 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
public function budgeted(Carbon $start, Carbon $end, TransactionCurrency $currency, ?Collection $budgets = null): string public function budgeted(Carbon $start, Carbon $end, TransactionCurrency $currency, ?Collection $budgets = null): string
{ {
$query = BudgetLimit $query = BudgetLimit
::where('start_date', $start->format('Y-m-d 00:00:00')) ::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('end_date', $end->format('Y-m-d 00:00:00')) ->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
->where('transaction_currency_id', $currency->id); ->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
->where('budget_limits.transaction_currency_id', $currency->id)
->where('budgets.user_id', $this->user->id);
if (null !== $budgets && $budgets->count() > 0) { if (null !== $budgets && $budgets->count() > 0) {
$query->whereIn('budget_id', $budgets->pluck('id')->toArray()); $query->whereIn('budget_limits.budget_id', $budgets->pluck('id')->toArray());
} }
$set = $query->get(['budget_limits.*']); $set = $query->get(['budget_limits.*']);
$result = '0'; $result = '0';
/** @var BudgetLimit $budgetLimit */ /** @var BudgetLimit $budgetLimit */