Skip to content

Firefly III: a personal finances manager

Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop

James Cole0c9a41a9297d
diff --cc app/JsonApi/V2/Accounts/AccountRequest.php
index c0b6e05c49,f595004be3..251d91c33e
--- a/app/JsonApi/V2/Accounts/AccountRequest.php
+++ b/app/JsonApi/V2/Accounts/AccountRequest.php
@@@ -1,13 -1,10 +1,15 @@@
<?php
+ declare(strict_types=1);
+
namespace FireflyIII\JsonApi\V2\Accounts;
-use FireflyIII\Rules\BelongsUser;
+use FireflyIII\Rules\Account\IsUniqueAccount;
+use FireflyIII\Rules\IsBoolean;
+use FireflyIII\Rules\IsValidPositiveAmount;
+use FireflyIII\Rules\UniqueAccountNumber;
+use FireflyIII\Rules\UniqueIban;
+use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Support\Facades\Log;
use LaravelJsonApi\Laravel\Http\Requests\ResourceRequest;
@@@ -22,37 -16,18 +21,37 @@@ class AccountRequest extends ResourceRe
public function rules(): array
{
Log::debug(__METHOD__);
-
- exit('am i used');
+ $accountRoles = implode(',', config('firefly.accountRoles'));
+ $ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
+ $types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
+ $type = $this->convertString('type');
+ //var_dump($types);exit;
return [
- 'type' => [
- new BelongsUser(),
- ],
- 'name' => [
- 'nullable',
- 'string',
- 'max:255',
- ],
+ 'name' => ['required', 'max:1024', 'min:1'], // , new IsUniqueAccount()
+ 'account_type' => ['required','max:1024','min:1', sprintf('in:%s', $types)],
+// 'iban' => ['iban', 'nullable', new UniqueIban(null, $type)],
+// 'bic' => 'bic|nullable',
+// 'account_number' => ['min:1', 'max:255', 'nullable', new UniqueAccountNumber(null, $type)],
+// 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
+// 'opening_balance_date' => 'date|required_with:opening_balance|nullable',
+// 'virtual_balance' => 'numeric|nullable',
+// 'order' => 'numeric|nullable',
+// 'currency_id' => 'numeric|exists:transaction_currencies,id',
+// 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
+// 'active' => [new IsBoolean()],
+// 'include_net_worth' => [new IsBoolean()],
+// 'account_role' => sprintf('nullable|in:%s|required_if:type,asset', $accountRoles),
+// 'credit_card_type' => sprintf('nullable|in:%s|required_if:account_role,ccAsset', $ccPaymentTypes),
+// 'monthly_payment_date' => 'nullable|date|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull',
+// 'liability_type' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:loan,debt,mortgage',
+// 'liability_amount' => ['required_with:liability_start_date', new IsValidPositiveAmount()],
+// 'liability_start_date' => 'required_with:liability_amount|date',
+// 'liability_direction' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:credit,debit',
+// 'interest' => 'min:0|max:100|numeric',
+// 'interest_period' => sprintf('nullable|in:%s', implode(',', config('firefly.interest_periods'))),
+// 'notes' => 'min:0|max:32768',
++
];
}
-
}
diff --cc app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php
index ce750fd0fa,a61ff74de5..9d524a94ef
--- a/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php
+++ b/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php
@@@ -51,9 -51,8 +51,7 @@@ class CrudAccount extends CrudResourc
return $enrichment->enrichSingle($account);
}
- public function create(array $validatedData): Account
- {
- exit('here we are');
+ public function create(array $validatedData): Account {
+ var_dump($validatedData);exit;
- die('in create method.');
}
}
diff --cc app/Support/Steam.php
index 10150da8b9,9fb5793d01..a03b2185fc
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@@ -44,26 -44,29 +44,28 @@@ class Stea
*/
public function balanceIgnoreVirtual(Account $account, Carbon $date): string
{
- Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
-
+ //Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
/** @var AccountRepositoryInterface $repository */
- $repository = app(AccountRepositoryInterface::class);
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser($account->user);
- $currencyId = (int) $repository->getMetaValue($account, 'currency_id');
- $transactions = $account->transactions()
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
- ->where('transactions.transaction_currency_id', $currencyId)
- ->get(['transactions.amount'])->toArray();
- $nativeBalance = $this->sumTransactions($transactions, 'amount');
+ $currencyId = (int) $repository->getMetaValue($account, 'currency_id');
+ $transactions = $account->transactions()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
+ ->where('transactions.transaction_currency_id', $currencyId)
+ ->get(['transactions.amount'])->toArray()
+ ;
+ $nativeBalance = $this->sumTransactions($transactions, 'amount');
// get all balances in foreign currency:
- $transactions = $account->transactions()
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
- ->where('transactions.foreign_currency_id', $currencyId)
- ->where('transactions.transaction_currency_id', '!=', $currencyId)
- ->get(['transactions.foreign_amount'])->toArray();
+ $transactions = $account->transactions()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
+ ->where('transactions.foreign_currency_id', $currencyId)
+ ->where('transactions.transaction_currency_id', '!=', $currencyId)
+ ->get(['transactions.foreign_amount'])->toArray()
+ ;
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
@@@ -214,9 -221,9 +220,9 @@@
*/
public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string
{
- Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
+// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
// abuse chart properties:
- $cache = new CacheProperties();
+ $cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty('balance');
$cache->addProperty($date);
@@@ -386,9 -396,9 +395,9 @@@
*/
public function balanceConverted(Account $account, Carbon $date, TransactionCurrency $native): string
{
- Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
+// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
Log::debug(sprintf('Now in balanceConverted (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));
- $cache = new CacheProperties();
+ $cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty('balance');
$cache->addProperty($date);
@@@ -617,9 -633,9 +632,9 @@@
public function balancePerCurrency(Account $account, Carbon $date): array
{
- Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
+// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
// abuse chart properties:
- $cache = new CacheProperties();
+ $cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty('balance-per-currency');
$cache->addProperty($date);