mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-02 19:16:39 +00:00
Catch some amounts
This commit is contained in:
@@ -62,7 +62,7 @@ class Request extends FormRequest
|
||||
return [
|
||||
'currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'currency_code' => 'min:3|max:51|exists:transaction_currencies,code',
|
||||
'amount' => 'numeric|gt:0',
|
||||
'amount' => 'numeric|gt:0|max:1000000000',
|
||||
'start' => 'date',
|
||||
'end' => 'date',
|
||||
];
|
||||
|
@@ -72,8 +72,8 @@ class StoreRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'name' => 'between:1,255|uniqueObjectForUser:bills,name',
|
||||
'amount_min' => 'numeric|gt:0|required',
|
||||
'amount_max' => 'numeric|gt:0|required',
|
||||
'amount_min' => 'numeric|gt:0|required|max:1000000000',
|
||||
'amount_max' => 'numeric|gt:0|required|max:1000000000',
|
||||
'currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'currency_code' => 'min:3|max:51|exists:transaction_currencies,code',
|
||||
'date' => 'date|required',
|
||||
|
@@ -75,8 +75,8 @@ class UpdateRequest extends FormRequest
|
||||
|
||||
return [
|
||||
'name' => sprintf('between:1,255|uniqueObjectForUser:bills,name,%d', $bill->id),
|
||||
'amount_min' => 'numeric|gt:0',
|
||||
'amount_max' => 'numeric|gt:0',
|
||||
'amount_min' => 'numeric|gt:0|max:1000000000',
|
||||
'amount_max' => 'numeric|gt:0|max:1000000000',
|
||||
'currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'currency_code' => 'min:3|max:51|exists:transaction_currencies,code',
|
||||
'date' => 'date',
|
||||
|
@@ -57,7 +57,7 @@ class StoreRequest extends FormRequest
|
||||
return [
|
||||
'start' => 'required|before:end|date',
|
||||
'end' => 'required|after:start|date',
|
||||
'amount' => 'required|gt:0',
|
||||
'amount' => 'required|gt:0|max:1000000000',
|
||||
'currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'currency_code' => 'min:3|max:51|exists:transaction_currencies,code',
|
||||
];
|
||||
|
@@ -61,7 +61,7 @@ class UpdateRequest extends FormRequest
|
||||
return [
|
||||
'start' => 'date',
|
||||
'end' => 'date',
|
||||
'amount' => 'gt:0',
|
||||
'amount' => 'gt:0|max:1000000000',
|
||||
'currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'currency_code' => 'min:3|max:51|exists:transaction_currencies,code',
|
||||
];
|
||||
|
@@ -116,7 +116,7 @@ class UpdateRequest extends FormRequest
|
||||
|
||||
// amount
|
||||
'transactions.*.amount' => 'numeric|gt:0|max:100000000000',
|
||||
'transactions.*.foreign_amount' => 'nullable|numeric|gte:0',
|
||||
'transactions.*.foreign_amount' => 'nullable|numeric|gte:0|max:1000000000',
|
||||
|
||||
// description
|
||||
'transactions.*.description' => 'nullable|between:1,1000',
|
||||
|
@@ -134,10 +134,10 @@ class AccountController extends Controller
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
|
||||
// the default currency of the user (could be the same!)
|
||||
'native_id' => (string)$default->id,
|
||||
'native_code' => $default->code,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
'native_currency_id' => (string)$default->id,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
'start' => $start->toAtomString(),
|
||||
'end' => $end->toAtomString(),
|
||||
'period' => '1D',
|
||||
|
@@ -127,24 +127,24 @@ class BudgetController extends Controller
|
||||
$return = [];
|
||||
foreach ($rows as $row) {
|
||||
$current = [
|
||||
'label' => $budget->name,
|
||||
'currency_id' => (string)$row['currency_id'],
|
||||
'currency_code' => $row['currency_code'],
|
||||
'currency_name' => $row['currency_name'],
|
||||
'currency_decimal_places' => $row['currency_decimal_places'],
|
||||
'native_id' => (string)$row['native_id'],
|
||||
'native_code' => $row['native_code'],
|
||||
'native_name' => $row['native_name'],
|
||||
'native_decimal_places' => $row['native_decimal_places'],
|
||||
'period' => null,
|
||||
'start' => $row['start'],
|
||||
'end' => $row['end'],
|
||||
'entries' => [
|
||||
'label' => $budget->name,
|
||||
'currency_id' => (string) $row['currency_id'],
|
||||
'currency_code' => $row['currency_code'],
|
||||
'currency_name' => $row['currency_name'],
|
||||
'currency_decimal_places' => $row['currency_decimal_places'],
|
||||
'native_currency_id' => (string) $row['native_currency_id'],
|
||||
'native_currency_code' => $row['native_currency_code'],
|
||||
'native_currency_name' => $row['native_currency_name'],
|
||||
'native_currency_decimal_places' => $row['native_currency_decimal_places'],
|
||||
'period' => null,
|
||||
'start' => $row['start'],
|
||||
'end' => $row['end'],
|
||||
'entries' => [
|
||||
'spent' => $row['spent'],
|
||||
'left' => $row['left'],
|
||||
'overspent' => $row['overspent'],
|
||||
],
|
||||
'native_entries' => [
|
||||
'native_entries' => [
|
||||
'spent' => $row['native_spent'],
|
||||
'left' => $row['native_left'],
|
||||
'overspent' => $row['native_overspent'],
|
||||
@@ -170,7 +170,8 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared between the "noBudgetLimits" function and "processLimit". Will take a single set of expenses and return its info.
|
||||
* Shared between the "noBudgetLimits" function and "processLimit". Will take a single set of expenses and return
|
||||
* its info.
|
||||
*
|
||||
* @param array<int, array<int, string>> $array
|
||||
*
|
||||
@@ -192,24 +193,24 @@ class BudgetController extends Controller
|
||||
foreach ($array as $currencyId => $block) {
|
||||
$this->currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
|
||||
$return[$currencyId] ??= [
|
||||
'currency_id' => (string)$currencyId,
|
||||
'currency_code' => $block['currency_code'],
|
||||
'currency_name' => $block['currency_name'],
|
||||
'currency_symbol' => $block['currency_symbol'],
|
||||
'currency_decimal_places' => (int)$block['currency_decimal_places'],
|
||||
'native_id' => (string)$this->currency->id,
|
||||
'native_code' => $this->currency->code,
|
||||
'native_name' => $this->currency->name,
|
||||
'native_symbol' => $this->currency->symbol,
|
||||
'native_decimal_places' => $this->currency->decimal_places,
|
||||
'start' => $start->toAtomString(),
|
||||
'end' => $end->toAtomString(),
|
||||
'spent' => '0',
|
||||
'native_spent' => '0',
|
||||
'left' => '0',
|
||||
'native_left' => '0',
|
||||
'overspent' => '0',
|
||||
'native_overspent' => '0',
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $block['currency_code'],
|
||||
'currency_name' => $block['currency_name'],
|
||||
'currency_symbol' => $block['currency_symbol'],
|
||||
'currency_decimal_places' => (int) $block['currency_decimal_places'],
|
||||
'native_currency_id' => (string) $this->currency->id,
|
||||
'native_currency_code' => $this->currency->code,
|
||||
'native_currency_name' => $this->currency->name,
|
||||
'native_currency_symbol' => $this->currency->symbol,
|
||||
'native_currency_decimal_places' => $this->currency->decimal_places,
|
||||
'start' => $start->toAtomString(),
|
||||
'end' => $end->toAtomString(),
|
||||
'spent' => '0',
|
||||
'native_spent' => '0',
|
||||
'left' => '0',
|
||||
'native_left' => '0',
|
||||
'overspent' => '0',
|
||||
'native_overspent' => '0',
|
||||
];
|
||||
$currentBudgetArray = $block['budgets'][$budgetId];
|
||||
|
||||
|
@@ -118,11 +118,11 @@ class CategoryController extends Controller
|
||||
'currency_name' => $currency->name,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
'native_id' => (string)$default->id,
|
||||
'native_code' => $default->code,
|
||||
'native_name' => $default->name,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
'native_currency_id' => (string)$default->id,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
'period' => null,
|
||||
'start' => $start->toAtomString(),
|
||||
'end' => $end->toAtomString(),
|
||||
|
@@ -206,10 +206,10 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => 'bills-paid-in-native',
|
||||
'value' => $nativeAmount,
|
||||
'currency_id' => (string)$info['native_id'],
|
||||
'currency_code' => $info['native_code'],
|
||||
'currency_symbol' => $info['native_symbol'],
|
||||
'currency_decimal_places' => $info['native_decimal_places'],
|
||||
'currency_id' => (string)$info['native_currency_id'],
|
||||
'currency_code' => $info['native_currency_code'],
|
||||
'currency_symbol' => $info['native_currency_symbol'],
|
||||
'currency_decimal_places' => $info['native_currency_decimal_places'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -230,10 +230,10 @@ class BasicController extends Controller
|
||||
$return[] = [
|
||||
'key' => 'bills-unpaid-in-native',
|
||||
'value' => $nativeAmount,
|
||||
'currency_id' => (string)$info['native_id'],
|
||||
'currency_code' => $info['native_code'],
|
||||
'currency_symbol' => $info['native_symbol'],
|
||||
'currency_decimal_places' => $info['native_decimal_places'],
|
||||
'currency_id' => (string)$info['native_currency_id'],
|
||||
'currency_code' => $info['native_currency_code'],
|
||||
'currency_symbol' => $info['native_currency_symbol'],
|
||||
'currency_decimal_places' => $info['native_currency_decimal_places'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@ use Illuminate\Http\JsonResponse;
|
||||
*/
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
|
||||
public function list(ListRequest $request): JsonResponse
|
||||
{
|
||||
// collect transactions:
|
||||
|
@@ -51,7 +51,7 @@ class NetWorth implements NetWorthInterface
|
||||
|
||||
private CurrencyRepositoryInterface $currencyRepos;
|
||||
private User $user;
|
||||
private null|UserGroup $userGroup;
|
||||
private null | UserGroup $userGroup;
|
||||
|
||||
/**
|
||||
* This method collects the user's net worth in ALL the user's currencies
|
||||
@@ -80,18 +80,18 @@ class NetWorth implements NetWorthInterface
|
||||
// default "native" currency has everything twice, for consistency.
|
||||
$netWorth = [
|
||||
'native' => [
|
||||
'balance' => '0',
|
||||
'native_balance' => '0',
|
||||
'currency_id' => $default->id,
|
||||
'currency_code' => $default->code,
|
||||
'currency_name' => $default->name,
|
||||
'currency_symbol' => $default->symbol,
|
||||
'currency_decimal_places' => $default->decimal_places,
|
||||
'native_id' => $default->id,
|
||||
'native_code' => $default->code,
|
||||
'native_name' => $default->name,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
'balance' => '0',
|
||||
'native_balance' => '0',
|
||||
'currency_id' => $default->id,
|
||||
'currency_code' => $default->code,
|
||||
'currency_name' => $default->name,
|
||||
'currency_symbol' => $default->symbol,
|
||||
'currency_decimal_places' => $default->decimal_places,
|
||||
'native_currency_id' => $default->id,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
],
|
||||
];
|
||||
$balances = app('steam')->balancesByAccountsConverted($accounts, $date);
|
||||
@@ -103,7 +103,7 @@ class NetWorth implements NetWorthInterface
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
$currencyId = $currency->id;
|
||||
$currencyCode = $currency->code;
|
||||
$balance = '0';
|
||||
$nativeBalance = '0';
|
||||
if (array_key_exists($account->id, $balances)) {
|
||||
@@ -118,25 +118,25 @@ class NetWorth implements NetWorthInterface
|
||||
$nativeVirtualBalance = $converter->convert($default, $currency, $account->created_at, $virtualBalance);
|
||||
$nativeBalance = bcsub($nativeBalance, $nativeVirtualBalance);
|
||||
}
|
||||
$netWorth[$currencyId] ??= [
|
||||
'balance' => '0',
|
||||
'native_balance' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_name' => $currency->name,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
'native_id' => $default->id,
|
||||
'native_code' => $default->code,
|
||||
'native_name' => $default->name,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
$netWorth[$currencyCode] ??= [
|
||||
'balance' => '0',
|
||||
'native_balance' => '0',
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_name' => $currency->name,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
'native_currency_id' => (string) $default->id,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
];
|
||||
|
||||
$netWorth[$currencyId]['balance'] = bcadd($balance, $netWorth[$currencyId]['balance']);
|
||||
$netWorth[$currencyId]['native_balance'] = bcadd($nativeBalance, $netWorth[$currencyId]['native_balance']);
|
||||
$netWorth['native']['balance'] = bcadd($nativeBalance, $netWorth['native']['balance']);
|
||||
$netWorth['native']['native_balance'] = bcadd($nativeBalance, $netWorth['native']['native_balance']);
|
||||
$netWorth[$currencyCode]['balance'] = bcadd($balance, $netWorth[$currencyCode]['balance']);
|
||||
$netWorth[$currencyCode]['native_balance'] = bcadd($nativeBalance, $netWorth[$currencyCode]['native_balance']);
|
||||
$netWorth['native']['balance'] = bcadd($nativeBalance, $netWorth['native']['balance']);
|
||||
$netWorth['native']['native_balance'] = bcadd($nativeBalance, $netWorth['native']['native_balance']);
|
||||
}
|
||||
$cache->store($netWorth);
|
||||
$converter->summarize();
|
||||
@@ -144,7 +144,7 @@ class NetWorth implements NetWorthInterface
|
||||
return $netWorth;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
public function setUser(null | Authenticatable | User $user): void
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
return;
|
||||
@@ -189,7 +189,7 @@ class NetWorth implements NetWorthInterface
|
||||
}
|
||||
|
||||
$return[$currency->id] ??= [
|
||||
'id' => (string)$currency->id,
|
||||
'id' => (string) $currency->id,
|
||||
'name' => $currency->name,
|
||||
'symbol' => $currency->symbol,
|
||||
'code' => $currency->code,
|
||||
@@ -202,7 +202,7 @@ class NetWorth implements NetWorthInterface
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function getRepository(): AccountRepositoryInterface|AdminAccountRepositoryInterface
|
||||
private function getRepository(): AccountRepositoryInterface | AdminAccountRepositoryInterface
|
||||
{
|
||||
if (null === $this->userGroup) {
|
||||
return $this->accountRepository;
|
||||
@@ -220,7 +220,7 @@ class NetWorth implements NetWorthInterface
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if (1 === (int)$this->getRepository()->getMetaValue($account, 'include_net_worth')) {
|
||||
if (1 === (int) $this->getRepository()->getMetaValue($account, 'include_net_worth')) {
|
||||
$filtered->push($account);
|
||||
}
|
||||
}
|
||||
|
@@ -86,11 +86,11 @@ class BillRepository implements BillRepositoryInterface
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
'native_id' => (string)$default->id,
|
||||
'native_name' => $default->name,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_code' => $default->code,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
'native_currency_id' => (string)$default->id,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
'sum' => '0',
|
||||
'native_sum' => '0',
|
||||
];
|
||||
@@ -159,11 +159,11 @@ class BillRepository implements BillRepositoryInterface
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
'native_id' => (string)$default->id,
|
||||
'native_name' => $default->name,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_code' => $default->code,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
'native_currency_id' => (string)$default->id,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
'sum' => '0',
|
||||
'native_sum' => '0',
|
||||
];
|
||||
|
@@ -44,26 +44,25 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
$converter = new ExchangeRateConverter();
|
||||
$default = app('amount')->getDefaultCurrency();
|
||||
$availableBudgets = $this->userGroup->availableBudgets()
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->get()
|
||||
;
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->get();
|
||||
|
||||
/** @var AvailableBudget $availableBudget */
|
||||
foreach ($availableBudgets as $availableBudget) {
|
||||
$currencyId = $availableBudget->transaction_currency_id;
|
||||
$return[$currencyId] ??= [
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $availableBudget->transactionCurrency->code,
|
||||
'currency_symbol' => $availableBudget->transactionCurrency->symbol,
|
||||
'currency_name' => $availableBudget->transactionCurrency->name,
|
||||
'currency_decimal_places' => $availableBudget->transactionCurrency->decimal_places,
|
||||
'native_id' => $default->id,
|
||||
'native_code' => $default->code,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_name' => $default->name,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
'amount' => '0',
|
||||
'native_amount' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $availableBudget->transactionCurrency->code,
|
||||
'currency_symbol' => $availableBudget->transactionCurrency->symbol,
|
||||
'currency_name' => $availableBudget->transactionCurrency->name,
|
||||
'currency_decimal_places' => $availableBudget->transactionCurrency->decimal_places,
|
||||
'native_currency_id' => $default->id,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
'amount' => '0',
|
||||
'native_amount' => '0',
|
||||
];
|
||||
$nativeAmount = $converter->convert($availableBudget->transactionCurrency, $default, $availableBudget->start_date, $availableBudget->amount);
|
||||
$return[$currencyId]['amount'] = bcadd($return[$currencyId]['amount'], $availableBudget->amount);
|
||||
|
@@ -62,10 +62,10 @@ class AccountBalanceGrouped
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'native_id' => (string)$currency['native_id'],
|
||||
'native_symbol' => $currency['native_symbol'],
|
||||
'native_code' => $currency['native_code'],
|
||||
'native_decimal_places' => $currency['native_decimal_places'],
|
||||
'native_currency_id' => (string)$currency['native_currency_id'],
|
||||
'native_currency_symbol' => $currency['native_currency_symbol'],
|
||||
'native_currency_code' => $currency['native_currency_code'],
|
||||
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
||||
'start' => $this->start->toAtomString(),
|
||||
'end' => $this->end->toAtomString(),
|
||||
'period' => $this->preferredRange,
|
||||
@@ -78,10 +78,10 @@ class AccountBalanceGrouped
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'native_id' => (string)$currency['native_id'],
|
||||
'native_symbol' => $currency['native_symbol'],
|
||||
'native_code' => $currency['native_code'],
|
||||
'native_decimal_places' => $currency['native_decimal_places'],
|
||||
'native_currency_id' => (string)$currency['native_currency_id'],
|
||||
'native_currency_symbol' => $currency['native_currency_symbol'],
|
||||
'native_currency_code' => $currency['native_currency_code'],
|
||||
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
||||
'start' => $this->start->toAtomString(),
|
||||
'end' => $this->end->toAtomString(),
|
||||
'period' => $this->preferredRange,
|
||||
@@ -138,10 +138,10 @@ class AccountBalanceGrouped
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
// native currency info (could be the same)
|
||||
'native_id' => (string)$this->default->id,
|
||||
'native_code' => $this->default->code,
|
||||
'native_symbol' => $this->default->symbol,
|
||||
'native_decimal_places' => $this->default->decimal_places,
|
||||
'native_currency_id' => (string)$this->default->id,
|
||||
'native_currency_code' => $this->default->code,
|
||||
'native_currency_symbol' => $this->default->symbol,
|
||||
'native_currency_decimal_places' => $this->default->decimal_places,
|
||||
];
|
||||
|
||||
// set the array (in monetary info) with spent/earned in this $period, if it does not exist.
|
||||
@@ -214,11 +214,11 @@ class AccountBalanceGrouped
|
||||
'currency_code' => $default->code,
|
||||
'currency_name' => $default->name,
|
||||
'currency_decimal_places' => $default->decimal_places,
|
||||
'native_id' => (string)$defaultCurrencyId,
|
||||
'native_symbol' => $default->symbol,
|
||||
'native_code' => $default->code,
|
||||
'native_name' => $default->name,
|
||||
'native_decimal_places' => $default->decimal_places,
|
||||
'native_currency_id' => (string)$defaultCurrencyId,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -50,8 +50,8 @@ trait CleansChartData
|
||||
if (array_key_exists('currency_id', $array)) {
|
||||
$array['currency_id'] = (string)$array['currency_id'];
|
||||
}
|
||||
if (array_key_exists('native_id', $array)) {
|
||||
$array['native_id'] = (string)$array['native_id'];
|
||||
if (array_key_exists('native_currency_id', $array)) {
|
||||
$array['native_currency_id'] = (string)$array['native_currency_id'];
|
||||
}
|
||||
if (!array_key_exists('start', $array)) {
|
||||
throw new FireflyException(sprintf('Data-set "%s" is missing the "start"-variable.', $index));
|
||||
|
@@ -58,10 +58,10 @@ trait ConvertsExchangeRates
|
||||
$native = app('amount')->getDefaultCurrency();
|
||||
$currency = $this->getCurrency((int)$set['currency_id']);
|
||||
if ($native->id === $currency->id) {
|
||||
$set['native_id'] = (string)$currency->id;
|
||||
$set['native_code'] = $currency->code;
|
||||
$set['native_symbol'] = $currency->symbol;
|
||||
$set['native_decimal_places'] = $currency->decimal_places;
|
||||
$set['native_currency_id'] = (string)$currency->id;
|
||||
$set['native_currency_code'] = $currency->code;
|
||||
$set['native_currency_symbol'] = $currency->symbol;
|
||||
$set['native_currency_decimal_places'] = $currency->decimal_places;
|
||||
|
||||
return $set;
|
||||
}
|
||||
@@ -112,20 +112,20 @@ trait ConvertsExchangeRates
|
||||
$amount = $this->convertAmount($entry['sum'], $currency, $native);
|
||||
$entry['converted'] = true;
|
||||
$entry['native_sum'] = $amount;
|
||||
$entry['native_id'] = (string)$native->id;
|
||||
$entry['native_name'] = $native->name;
|
||||
$entry['native_symbol'] = $native->symbol;
|
||||
$entry['native_code'] = $native->code;
|
||||
$entry['native_decimal_places'] = $native->decimal_places;
|
||||
$entry['native_currency_id'] = (string)$native->id;
|
||||
$entry['native_currency_name'] = $native->name;
|
||||
$entry['native_currency_symbol'] = $native->symbol;
|
||||
$entry['native_currency_code'] = $native->code;
|
||||
$entry['native_currency_decimal_places'] = $native->decimal_places;
|
||||
}
|
||||
if ($currency->id === $native->id) {
|
||||
$entry['converted'] = false;
|
||||
$entry['native_sum'] = $entry['sum'];
|
||||
$entry['native_id'] = (string)$native->id;
|
||||
$entry['native_name'] = $native->name;
|
||||
$entry['native_symbol'] = $native->symbol;
|
||||
$entry['native_code'] = $native->code;
|
||||
$entry['native_decimal_places'] = $native->decimal_places;
|
||||
$entry['native_currency_id'] = (string)$native->id;
|
||||
$entry['native_currency_name'] = $native->name;
|
||||
$entry['native_currency_symbol'] = $native->symbol;
|
||||
$entry['native_currency_code'] = $native->code;
|
||||
$entry['native_currency_decimal_places'] = $native->decimal_places;
|
||||
}
|
||||
$return[] = $entry;
|
||||
}
|
||||
|
@@ -139,7 +139,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
// balance:
|
||||
'current_balance' => $balance,
|
||||
'native_current_balance' => $nativeBalance,
|
||||
'current_balance_date' => $this->getDate(),
|
||||
'current_balance_date' => $this->getDate()->endOfDay()->toAtomString(),
|
||||
|
||||
// more meta
|
||||
|
||||
|
@@ -223,7 +223,6 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
'recurrence_id' => $meta['recurrence_id'],
|
||||
'recurrence_total' => $meta['recurrence_total'],
|
||||
'recurrence_count' => $meta['recurrence_count'],
|
||||
'bunq_payment_id' => $meta['bunq_payment_id'],
|
||||
'external_url' => $meta['external_url'],
|
||||
'import_hash_v2' => $meta['import_hash_v2'],
|
||||
'sepa_cc' => $meta['sepa_cc'],
|
||||
|
@@ -34,7 +34,9 @@ Route::group(
|
||||
Route::get('basic', ['uses' => 'BasicController@basic', 'as' => 'basic']);
|
||||
}
|
||||
);
|
||||
// V2 API route for TransactionList API endpoints
|
||||
// V2 API route for all kinds of Transaction lists.
|
||||
// A lot of endpoints involve transactions. So any time Firefly III needs to list transactions
|
||||
// it's coming from these endpoints.
|
||||
Route::group(
|
||||
[
|
||||
'namespace' => 'FireflyIII\Api\V2\Controllers\Transaction\List',
|
||||
@@ -42,7 +44,11 @@ Route::group(
|
||||
'as' => 'api.v2.',
|
||||
],
|
||||
static function (): void {
|
||||
// basic list
|
||||
Route::get('transactions', ['uses' => 'TransactionController@list', 'as' => 'transactions.list']);
|
||||
|
||||
// list by parent or related object.
|
||||
// note how the check is done on the user group, not the user itself.
|
||||
Route::get('accounts/{userGroupAccount}/transactions', ['uses' => 'AccountController@list', 'as' => 'accounts.transactions']);
|
||||
}
|
||||
);
|
||||
@@ -152,6 +158,7 @@ Route::group(
|
||||
);
|
||||
|
||||
// V2 API route for budgets and budget limits:
|
||||
// TODO Validate from here down.
|
||||
Route::group(
|
||||
[
|
||||
'namespace' => 'FireflyIII\Api\V2\Controllers\Model',
|
||||
|
Reference in New Issue
Block a user