Fix bar, also multi currency #2977

This commit is contained in:
James Cole
2020-03-21 15:12:23 +01:00
parent 790e29f15e
commit cf4f76f211
5 changed files with 61 additions and 2 deletions

View File

@@ -290,4 +290,16 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
{
$this->user->availableBudgets()->delete();
}
/**
* @inheritDoc
*/
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget
{
return $this->user
->availableBudgets()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d 00:00:00'))
->where('end_date', $end->format('Y-m-d 00:00:00'))->first();
}
}

View File

@@ -66,6 +66,17 @@ interface AvailableBudgetRepositoryInterface
*/
public function get(?Carbon $start = null, ?Carbon $end = null): Collection;
/**
* Get by transaction currency and date. Should always result in one entry or NULL.
*
* @param Carbon $start
* @param Carbon $end
* @param TransactionCurrency $currency
*
* @return null|AvailableBudget
*/
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget;
/**
* @param TransactionCurrency $currency
* @param Carbon $start