Expand API and routes.

This commit is contained in:
James Cole
2018-12-08 21:26:20 +01:00
parent 3b15415a1b
commit 05b0425929
27 changed files with 686 additions and 516 deletions

View File

@@ -33,6 +33,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService;
use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Log;
@@ -341,6 +342,25 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return null;
}
/**
* Return a list of exchange rates with this currency.
*
* @param TransactionCurrency $currency
*
* @return Collection
*/
public function getExchangeRates(TransactionCurrency $currency): Collection
{
/** @var CurrencyExchangeRate $rate */
return $this->user->currencyExchangeRates()
->where(
function (Builder $query) use ($currency) {
$query->where('from_currency_id', $currency->id);
$query->orWhere('to_currency_id', $currency->id);
}
)->get();
}
/**
* @param User $user
*/

View File

@@ -37,16 +37,16 @@ interface CurrencyRepositoryInterface
/**
* @param TransactionCurrency $currency
*
* @return bool
* @return int
*/
public function currencyInUse(TransactionCurrency $currency): bool;
public function countJournals(TransactionCurrency $currency): int;
/**
* @param TransactionCurrency $currency
*
* @return int
* @return bool
*/
public function countJournals(TransactionCurrency $currency): int;
public function currencyInUse(TransactionCurrency $currency): bool;
/**
* @param TransactionCurrency $currency
@@ -176,6 +176,15 @@ interface CurrencyRepositoryInterface
*/
public function getExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date): ?CurrencyExchangeRate;
/**
* Return a list of exchange rates with this currency.
*
* @param TransactionCurrency $currency
*
* @return Collection
*/
public function getExchangeRates(TransactionCurrency $currency): Collection;
/**
* @param User $user
*/