mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-11 16:36:56 +00:00
Compare commits
15 Commits
develop-20
...
develop-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5bf80a0cb | ||
|
|
ef1c64096d | ||
|
|
ef35eaffb4 | ||
|
|
869ee7c735 | ||
|
|
6c534f01eb | ||
|
|
3a9d89b53d | ||
|
|
badff64cfd | ||
|
|
abacfa212e | ||
|
|
add2e859c4 | ||
|
|
92f6421fc4 | ||
|
|
f350c19ec1 | ||
|
|
8170804d74 | ||
|
|
4400f6217d | ||
|
|
e223cea74e | ||
|
|
2f62e11338 |
@@ -44,6 +44,8 @@ use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use League\Fractal\Resource\Item;
|
||||
use Symfony\Component\HttpKernel\Exception\GoneHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Class StoreController
|
||||
@@ -82,7 +84,7 @@ class StoreController extends Controller
|
||||
*
|
||||
* Store a new transaction.
|
||||
*
|
||||
* @throws FireflyException|ValidationException
|
||||
* @throws FireflyException|GoneHttpException|ValidationException
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
@@ -133,7 +135,7 @@ class StoreController extends Controller
|
||||
|
||||
$selectedGroup = $collector->getGroups()->first();
|
||||
if (null === $selectedGroup) {
|
||||
throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
||||
throw HttpException::fromStatusCode(410, '200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
||||
}
|
||||
|
||||
// enrich
|
||||
|
||||
@@ -198,15 +198,29 @@ class ApplyRules extends Command
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accountRepository->setUser($this->getUser());
|
||||
foreach ($accountList as $accountId) {
|
||||
$accountId = (int) $accountId;
|
||||
$account = $accountRepository->find($accountId);
|
||||
if (null !== $account && in_array($account->accountType->type, $this->acceptedAccounts, true)) {
|
||||
$finalList->push($account);
|
||||
$accountId = (int)$accountId;
|
||||
if (0 === $accountId) {
|
||||
$this->friendlyWarning('You provided an account with ID 0 (zero). It will be ignored.');
|
||||
|
||||
continue;
|
||||
}
|
||||
$account = $accountRepository->find($accountId);
|
||||
if (null === $account) {
|
||||
$this->friendlyWarning(sprintf('There is no account with ID #%d, it cannot be added.', $accountId));
|
||||
|
||||
continue;
|
||||
}
|
||||
$type = $account->accountType->type;
|
||||
if (!in_array($account->accountType->type, $this->acceptedAccounts, true)) {
|
||||
$this->friendlyWarning(sprintf('Account "%s" with ID #%d is of type "%s" and cannot be added.', $account->name, $accountId, $type));
|
||||
|
||||
continue;
|
||||
}
|
||||
$finalList->push($account);
|
||||
}
|
||||
|
||||
if (0 === $finalList->count()) {
|
||||
$this->friendlyError('Please make sure all accounts in --accounts are asset accounts or liabilities.');
|
||||
$this->friendlyError('There are no accounts in the selection. Please make sure all accounts in --accounts are asset accounts or liabilities.');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -225,13 +239,27 @@ class ApplyRules extends Command
|
||||
$ruleGroupList = explode(',', $ruleGroupString);
|
||||
|
||||
foreach ($ruleGroupList as $ruleGroupId) {
|
||||
$ruleGroup = $this->ruleGroupRepository->find((int) $ruleGroupId);
|
||||
if (true === $ruleGroup->active) {
|
||||
$this->ruleGroupSelection[] = $ruleGroup->id;
|
||||
$ruleGroupId = (int)$ruleGroupId;
|
||||
|
||||
if (0 === $ruleGroupId) {
|
||||
$this->friendlyWarning('You added a rule group with ID 0 (zero). It will be skipped.');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$ruleGroup = $this->ruleGroupRepository->find($ruleGroupId);
|
||||
|
||||
if (null === $ruleGroup) {
|
||||
$this->friendlyWarning(sprintf('There is no rule group with ID #%d, this ID will be ignored.', $ruleGroupId));
|
||||
|
||||
continue;
|
||||
}
|
||||
if (false === $ruleGroup->active) {
|
||||
$this->friendlyWarning(sprintf('Will ignore inactive rule group #%d ("%s")', $ruleGroup->id, $ruleGroup->title));
|
||||
$this->friendlyWarning(sprintf('Rule group with ID #%d is not active, so this ID will be ignored.', $ruleGroupId));
|
||||
|
||||
continue;
|
||||
}
|
||||
$this->ruleGroupSelection[] = $ruleGroupId;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -247,10 +275,24 @@ class ApplyRules extends Command
|
||||
$ruleList = explode(',', $ruleString);
|
||||
|
||||
foreach ($ruleList as $ruleId) {
|
||||
$rule = $this->ruleRepository->find((int) $ruleId);
|
||||
if ($rule instanceof Rule && true === $rule->active) {
|
||||
$this->ruleSelection[] = $rule->id;
|
||||
$ruleId = (int)$ruleId;
|
||||
if (0 === $ruleId) {
|
||||
$this->friendlyWarning('You added a rule with ID 0 (zero). It will be skipped.');
|
||||
|
||||
continue;
|
||||
}
|
||||
$rule = $this->ruleRepository->find($ruleId);
|
||||
if (null === $rule) {
|
||||
$this->friendlyWarning(sprintf('There is no rule with ID #%d, this ID will be ignored.', $ruleId));
|
||||
|
||||
continue;
|
||||
}
|
||||
if (false === $rule->active) {
|
||||
$this->friendlyWarning(sprintf('Rule with ID #%d is not active, so this ID will be ignored.', $ruleId));
|
||||
|
||||
continue;
|
||||
}
|
||||
$this->ruleSelection[] = $ruleId;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -304,10 +346,12 @@ class ApplyRules extends Command
|
||||
|
||||
private function getRulesToApply(): Collection
|
||||
{
|
||||
Log::debug('getRulesToApply()');
|
||||
$rulesToApply = new Collection();
|
||||
|
||||
/** @var RuleGroup $group */
|
||||
foreach ($this->groups as $group) {
|
||||
Log::debug(sprintf('Scanning rule group #%d', $group->id));
|
||||
$rules = $this->ruleGroupRepository->getActiveStoreRules($group);
|
||||
|
||||
/** @var Rule $rule */
|
||||
@@ -318,16 +362,20 @@ class ApplyRules extends Command
|
||||
Log::debug(sprintf('Will include rule #%d "%s"', $rule->id, $rule->title));
|
||||
$rulesToApply->push($rule);
|
||||
}
|
||||
if (!$test) {
|
||||
Log::debug(sprintf('Will not include rule #%d', $rule->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('Found %d rules to apply.', $rulesToApply->count()));
|
||||
|
||||
return $rulesToApply;
|
||||
}
|
||||
|
||||
private function includeRule(Rule $rule, RuleGroup $group): bool
|
||||
{
|
||||
return in_array($group->id, $this->ruleGroupSelection, true)
|
||||
|| in_array($rule->id, $this->ruleSelection, true)
|
||||
return in_array((int)$group->id, $this->ruleGroupSelection, true)
|
||||
|| in_array((int)$rule->id, $this->ruleSelection, true)
|
||||
|| $this->allRules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ use Override;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\GoneHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -71,6 +72,7 @@ class Handler extends ExceptionHandler
|
||||
AuthenticationException::class,
|
||||
LaravelValidationException::class,
|
||||
NotFoundHttpException::class,
|
||||
GoneHttpException::class,
|
||||
OAuthServerException::class,
|
||||
LaravelOAuthException::class,
|
||||
TokenMismatchException::class,
|
||||
|
||||
@@ -70,8 +70,12 @@ class UpdatedGroupEventHandler
|
||||
foreach ($event->transactionGroup->transactionJournals as $journal) {
|
||||
$source = $journal->transactions()->where('amount', '<', '0')->first();
|
||||
$dest = $journal->transactions()->where('amount', '>', '0')->first();
|
||||
$repository->deleteStatisticsForModel($source->account, $journal->date);
|
||||
$repository->deleteStatisticsForModel($dest->account, $journal->date);
|
||||
if (null !== $source) {
|
||||
$repository->deleteStatisticsForModel($source->account, $journal->date);
|
||||
}
|
||||
if (null !== $dest) {
|
||||
$repository->deleteStatisticsForModel($dest->account, $journal->date);
|
||||
}
|
||||
|
||||
$categories = $journal->categories;
|
||||
$tags = $journal->tags;
|
||||
|
||||
@@ -720,6 +720,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
|
||||
->transactionJournals()
|
||||
->whereNotNull('bill_id')
|
||||
->where('transaction_type_id', '!=', $withdrawal->id)
|
||||
->update(['bill_id' => null]);
|
||||
->update(['bill_id' => null])
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ return [
|
||||
// see cer.php for exchange rates feature flag.
|
||||
],
|
||||
'version' => 'develop/2026-01-10',
|
||||
'build_time' => 1768053746,
|
||||
'build_time' => 1768068238,
|
||||
'api_version' => '2.1.0', // field is no longer used.
|
||||
'db_version' => 28, // field is no longer used.
|
||||
|
||||
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -3218,9 +3218,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "25.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.5.tgz",
|
||||
"integrity": "sha512-FuLxeLuSVOqHPxSN1fkcD8DLU21gAP7nCKqGRJ/FglbCUBs0NYN6TpHcdmyLeh8C0KwGIaZQJSv+OYG+KZz+Gw==",
|
||||
"version": "25.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.6.tgz",
|
||||
"integrity": "sha512-NNu0sjyNxpoiW3YuVFfNz7mxSQ+S4X2G28uqg2s+CzoqoQjLPsWSbsFFyztIAqt2vb8kfEAsJNepMGPTxFDx3Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user