mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-11 05:41:24 +00:00
Compare commits
127 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7dad8166d | ||
|
|
2da1b43c37 | ||
|
|
a606315884 | ||
|
|
295feedd77 | ||
|
|
d3b2748c8f | ||
|
|
1b4655fd70 | ||
|
|
05f67ef584 | ||
|
|
04ab7ba07d | ||
|
|
5806323970 | ||
|
|
ee260a3df7 | ||
|
|
7cb41fb333 | ||
|
|
d38adbfdc2 | ||
|
|
e6a6766ef1 | ||
|
|
a1e596491c | ||
|
|
9c920908a6 | ||
|
|
0014bffeb8 | ||
|
|
63c17f99b2 | ||
|
|
ec1e0e2807 | ||
|
|
2f16419a7b | ||
|
|
02c13859e7 | ||
|
|
57ec9b8e36 | ||
|
|
41ad35880d | ||
|
|
3aa946e028 | ||
|
|
53e46895aa | ||
|
|
c61389037d | ||
|
|
6172d60e00 | ||
|
|
f909f1d9ff | ||
|
|
55018ca046 | ||
|
|
19c746a865 | ||
|
|
503d2aa786 | ||
|
|
70d83ab501 | ||
|
|
edab602bb7 | ||
|
|
f9bcc4b1fa | ||
|
|
f3fe86167c | ||
|
|
2189fb46a2 | ||
|
|
7ff4178c8b | ||
|
|
fffd695ef8 | ||
|
|
ee592de035 | ||
|
|
7394e50ae2 | ||
|
|
f42fcff04a | ||
|
|
4eb3ce7c14 | ||
|
|
a977c567ce | ||
|
|
785bd7e905 | ||
|
|
df19f699d4 | ||
|
|
5e6e932e7e | ||
|
|
5bc397f01a | ||
|
|
42209e367f | ||
|
|
d53b1670d3 | ||
|
|
a6d450ba18 | ||
|
|
e8c1a95128 | ||
|
|
edb201f210 | ||
|
|
fe57367a8c | ||
|
|
134194a95b | ||
|
|
41c0e6fe2d | ||
|
|
c07914e733 | ||
|
|
52e2302f4f | ||
|
|
0a6b34b4f2 | ||
|
|
1e06b4dd0b | ||
|
|
5701f95e0b | ||
|
|
60d3572d37 | ||
|
|
ffa6e6a571 | ||
|
|
d6453cd735 | ||
|
|
fd79f9df44 | ||
|
|
4587340293 | ||
|
|
90bfdc7573 | ||
|
|
eca12f661f | ||
|
|
f85878b843 | ||
|
|
6499b5eaab | ||
|
|
7e4fece63d | ||
|
|
512eddf8be | ||
|
|
f0fa93a811 | ||
|
|
3c8de21709 | ||
|
|
81173e8340 | ||
|
|
35a8fa5f02 | ||
|
|
443036936d | ||
|
|
ac88007593 | ||
|
|
2297589dca | ||
|
|
6ada5fa560 | ||
|
|
8f6eefb5e7 | ||
|
|
b36a50381b | ||
|
|
51f84b3060 | ||
|
|
72132a19b0 | ||
|
|
065d165211 | ||
|
|
cabedf39b2 | ||
|
|
5d3806fcd4 | ||
|
|
01695b3342 | ||
|
|
71fb5fe077 | ||
|
|
3bec106840 | ||
|
|
fb01c36be1 | ||
|
|
26d851e69e | ||
|
|
28c18c046b | ||
|
|
318cef7e3b | ||
|
|
e8dc8f25be | ||
|
|
10ccc30240 | ||
|
|
5adc877d5e | ||
|
|
30923afb2b | ||
|
|
4eb6813b43 | ||
|
|
7521a31619 | ||
|
|
fc05beb452 | ||
|
|
1103428a83 | ||
|
|
d06d521bf0 | ||
|
|
8f64f1c0eb | ||
|
|
d11c232171 | ||
|
|
93c73248de | ||
|
|
5bed081ab9 | ||
|
|
c5188c503e | ||
|
|
98ffcac7b6 | ||
|
|
df1e81d611 | ||
|
|
9711170b08 | ||
|
|
e43264bdce | ||
|
|
e0643bed7a | ||
|
|
7f0eb3b064 | ||
|
|
f38e510526 | ||
|
|
25f99b23b2 | ||
|
|
44281fc8a0 | ||
|
|
eed3902cb7 | ||
|
|
94a3bb0443 | ||
|
|
8dcc36880e | ||
|
|
695bb31894 | ||
|
|
f8ded66869 | ||
|
|
8e4bdbc584 | ||
|
|
f7b14b01bc | ||
|
|
705b9bf0f2 | ||
|
|
f0226dbc54 | ||
|
|
1b1dfb0d7b | ||
|
|
8ed5092a76 | ||
|
|
d609821be6 |
@@ -189,7 +189,7 @@ SEND_REPORT_JOURNALS=true
|
||||
ENABLE_EXTERNAL_MAP=false
|
||||
|
||||
#
|
||||
# Enable or disable exchange rate conversion. This function isn't used yet by Firefly III
|
||||
# Enable or disable exchange rate conversion.
|
||||
#
|
||||
ENABLE_EXCHANGE_RATES=false
|
||||
|
||||
|
||||
33
.github/label-actions.yml
vendored
33
.github/label-actions.yml
vendored
@@ -1,16 +1,29 @@
|
||||
# Configuration for Label Actions - https://github.com/dessant/label-actions
|
||||
|
||||
# The `feature` label is added to issues
|
||||
fixed:
|
||||
issues:
|
||||
# Post a comment, `{issue-author}` is an optional placeholder
|
||||
comment: |
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
This issue has been marked as fixed. Thanks for reporting! A new version will be released in due time. Unfortunately, [I cannot give an estimate](https://docs.firefly-iii.org/references/faq/firefly-iii/general/#when-will-you-release-version-the-next-version), but [the roadmap](https://roadmap.firefly-iii.org/) is available for your reading pleasure.
|
||||
|
||||
There is no need to close the issue. It will be closed automatically.
|
||||
|
||||
Thank you for your contributions.
|
||||
feature:
|
||||
issues:
|
||||
# Post a comment, `{issue-author}` is an optional placeholder
|
||||
unlabel: feature
|
||||
comment: |
|
||||
Hi there!
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
This issue has been marked as a feature request. The requested (new) feature will become a part of Firefly III or the data importer in due course.
|
||||
This issue has been marked as a feature request.
|
||||
|
||||
If you come across this issue, please be aware there is NO need to reply with "+1" or "me too" or "I need this too" or whatever. Such comments are not helpful, and do not influence [the roadmap](https://roadmap.firefly-iii.org/). Your comment may be :skull: deleted. You can subscribe to this issue to get updates.
|
||||
|
||||
@@ -20,13 +33,13 @@ epic:
|
||||
issues:
|
||||
# Post a comment, `{issue-author}` is an optional placeholder
|
||||
comment: |
|
||||
Hi there!
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
This issue has been marked as an epic. In epics, large amounts of works are collected that will be part of a major new feature. If you have more ideas that could be a part of this epic, feel free to reply.
|
||||
|
||||
*However*, please be aware there is NO need to reply with "+1" or "me too" or "I need this too" or whatever. Such comments are not helpful, and do not influence [the roadmap](https://roadmap.firefly-iii.org/). Your comment may be :skull: deleted.
|
||||
*However*, please be aware there is NO need to reply with "+1" or "me too" or "I need this too" or whatever. Such comments are not helpful, and do not influence [the roadmap](https://roadmap.firefly-iii.org/). Your comment may be :skull: deleted.
|
||||
|
||||
If you are merely interested in this epic's progress, you can subscribe to this issue to get updates.
|
||||
|
||||
@@ -37,11 +50,11 @@ enhancement:
|
||||
issues:
|
||||
# Post a comment, `{issue-author}` is an optional placeholder
|
||||
comment: |
|
||||
Hi there!
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
This issue has been marked as an enhancement. The requested enhancement to an existing feature will become a part of Firefly III or the data importer in due course.
|
||||
This issue has been marked as an enhancement.
|
||||
|
||||
If you come across this issue, please be aware there is NO need to reply with "+1" or "me too" or "I need this too" or whatever. Such comments are not helpful, and do not influence [the roadmap](https://roadmap.firefly-iii.org/). Your comment may be :skull: deleted. You can subscribe to this issue to get updates.
|
||||
|
||||
@@ -51,7 +64,7 @@ triage:
|
||||
issues:
|
||||
# Post a comment, `{issue-author}` is an optional placeholder
|
||||
comment: |
|
||||
Hi there!
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
@@ -62,7 +75,7 @@ triage:
|
||||
needs-moar-debug:
|
||||
issues:
|
||||
comment: |
|
||||
Hi there!
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
@@ -80,7 +93,7 @@ needs-moar-debug:
|
||||
needs-moar-logs:
|
||||
issues:
|
||||
comment: |
|
||||
Hi there!
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
@@ -96,7 +109,7 @@ needs-moar-logs:
|
||||
v2-layout-issue:
|
||||
issues:
|
||||
comment: |
|
||||
Hi there!
|
||||
Hi there!
|
||||
|
||||
This is an automatic reply. `Share and enjoy`
|
||||
|
||||
|
||||
2
.github/workflows/closed-issues.yml
vendored
2
.github/workflows/closed-issues.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
command_and_close:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: aws-actions/closed-issue-message@v1
|
||||
- uses: aws-actions/closed-issue-message@v2
|
||||
with:
|
||||
message: |
|
||||
Hi there! This is an automatic reply. `Share and enjoy`
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
Over time, many people have contributed to Firefly III. Their efforts are not always visible, but always remembered and appreciated.
|
||||
Please find below all the people who contributed to the Firefly III code. Their names are mentioned in the year of their first contribution.
|
||||
|
||||
## 2025
|
||||
- SoftBrix
|
||||
|
||||
## 2024
|
||||
- Sobuno
|
||||
- TasneemTantawy
|
||||
|
||||
@@ -34,6 +34,7 @@ use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
@@ -41,7 +42,8 @@ use Illuminate\Http\JsonResponse;
|
||||
class AccountController extends Controller
|
||||
{
|
||||
use AccountFilter;
|
||||
protected array $accepts = ['application/json'];
|
||||
// this array only exists to test if the constructor will use it properly.
|
||||
protected array $accepts = ['application/json', 'application/vnd.api+json'];
|
||||
|
||||
/** @var array<int, string> */
|
||||
private array $balanceTypes;
|
||||
@@ -82,12 +84,17 @@ class AccountController extends Controller
|
||||
$return = [];
|
||||
$result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));
|
||||
|
||||
// set date to subday + end-of-day for account balance. so it is at $date 23:59:59
|
||||
$date->subDay()->endOfDay();
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($result as $account) {
|
||||
$nameWithBalance = $account->name;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $this->nativeCurrency;
|
||||
$useCurrency = $currency;
|
||||
if (in_array($account->accountType->type, $this->balanceTypes, true)) {
|
||||
// this one is correct.
|
||||
Log::debug(sprintf('accounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date);
|
||||
$key = $this->convertToNative && $currency->id !== $this->nativeCurrency->id ? 'native_balance' : 'balance';
|
||||
$useCurrency = $this->convertToNative && $currency->id !== $this->nativeCurrency->id ? $this->nativeCurrency : $currency;
|
||||
@@ -100,15 +107,20 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
$return[] = [
|
||||
'id' => (string) $account->id,
|
||||
'name' => $account->name,
|
||||
'name_with_balance' => $nameWithBalance,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => (string) $useCurrency->id,
|
||||
'currency_name' => $useCurrency->name,
|
||||
'currency_code' => $useCurrency->code,
|
||||
'currency_symbol' => $useCurrency->symbol,
|
||||
'currency_decimal_places' => $useCurrency->decimal_places,
|
||||
'id' => (string) $account->id,
|
||||
'name' => $account->name,
|
||||
'name_with_balance' => $nameWithBalance,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => (string) $useCurrency->id,
|
||||
'currency_name' => $useCurrency->name,
|
||||
'currency_code' => $useCurrency->code,
|
||||
'currency_symbol' => $useCurrency->symbol,
|
||||
'currency_decimal_places' => $useCurrency->decimal_places,
|
||||
'account_currency_id' => (string) $currency->id,
|
||||
'account_currency_name' => $currency->name,
|
||||
'account_currency_code' => $currency->code,
|
||||
'account_currency_symbol' => $currency->symbol,
|
||||
'account_currency_decimal_places' => $currency->decimal_places,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||
@@ -41,6 +42,8 @@ class TransactionController extends Controller
|
||||
private TransactionGroupRepositoryInterface $groupRepository;
|
||||
private JournalRepositoryInterface $repository;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
*/
|
||||
@@ -51,10 +54,12 @@ class TransactionController extends Controller
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$userGroup = $this->validateUserGroup($request);
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
$this->groupRepository->setUser($user);
|
||||
$this->groupRepository->setUserGroup($userGroup);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -80,6 +81,10 @@ class AccountController extends Controller
|
||||
/** @var Carbon $end */
|
||||
$end = $dates['end'];
|
||||
|
||||
// set dates to end of day + start of day:
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
// user's preferences
|
||||
$defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value])->pluck('id')->toArray();
|
||||
|
||||
@@ -113,7 +118,7 @@ class AccountController extends Controller
|
||||
];
|
||||
// TODO this code is also present in the V2 chart account controller so this method is due to be deprecated.
|
||||
$currentStart = clone $start;
|
||||
$range = app('steam')->finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);
|
||||
$range = Steam::finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);
|
||||
$previous = array_values($range)[0][$field];
|
||||
while ($currentStart <= $end) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
|
||||
use FireflyIII\Transformers\V2\AbstractTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -59,6 +60,7 @@ abstract class Controller extends BaseController
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
use ValidatesUserGroupTrait;
|
||||
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected const string JSON_CONTENT_TYPE = 'application/json';
|
||||
@@ -67,7 +69,7 @@ abstract class Controller extends BaseController
|
||||
protected array $allowedSort;
|
||||
protected ParameterBag $parameters;
|
||||
protected bool $convertToNative = false;
|
||||
protected array $accepts = ['application/json'];
|
||||
protected array $accepts = ['application/json', 'application/vnd.api+json'];
|
||||
protected TransactionCurrency $nativeCurrency;
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,11 +57,11 @@ class IndexController extends Controller
|
||||
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$piggies = $this->repository->getAll();
|
||||
$entries = $this->repository->getAll();
|
||||
$pageSize = $this->parameters->get('limit');
|
||||
$count = $piggies->count();
|
||||
$piggies = $piggies->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$paginator = new LengthAwarePaginator($piggies, $count, $pageSize, $this->parameters->get('page'));
|
||||
$count = $entries->count();
|
||||
$entries = $entries->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$paginator = new LengthAwarePaginator($entries, $count, $pageSize, $this->parameters->get('page'));
|
||||
$transformer = new ExchangeRateTransformer();
|
||||
$transformer->setParameters($this->parameters); // give params to transformer
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\Transaction;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\Transaction\StoreRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Events\StoredTransactionGroup;
|
||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -37,6 +38,7 @@ use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use League\Fractal\Resource\Item;
|
||||
|
||||
@@ -49,6 +51,8 @@ class StoreController extends Controller
|
||||
|
||||
private TransactionGroupRepositoryInterface $groupRepository;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
*/
|
||||
@@ -59,9 +63,11 @@ class StoreController extends Controller
|
||||
function ($request, $next) {
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
$userGroup = $this->validateUserGroup($request);
|
||||
|
||||
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
|
||||
$this->groupRepository->setUser($admin);
|
||||
$this->groupRepository->setUserGroup($userGroup);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -79,61 +85,58 @@ class StoreController extends Controller
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
app('log')->debug('Now in API StoreController::store()');
|
||||
$data = $request->getAll();
|
||||
$data['user'] = auth()->user()->id;
|
||||
$data = $request->getAll();
|
||||
$data['user'] = auth()->user();
|
||||
$data['user_group'] = $this->userGroup;
|
||||
|
||||
Log::channel('audit')
|
||||
->info('Store new transaction over API.', $data)
|
||||
;
|
||||
Log::channel('audit')->info('Store new transaction over API.', $data);
|
||||
|
||||
try {
|
||||
$transactionGroup = $this->groupRepository->store($data);
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
app('log')->warning('Caught a duplicate transaction. Return error message.');
|
||||
$validator = \Validator::make(
|
||||
['transactions' => [['description' => $e->getMessage()]]],
|
||||
['transactions.0.description' => new IsDuplicateTransaction()]
|
||||
);
|
||||
$validator = Validator::make(['transactions' => [['description' => $e->getMessage()]]], ['transactions.0.description' => new IsDuplicateTransaction()]);
|
||||
|
||||
throw new ValidationException($validator);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->warning('Caught an exception. Return error message.');
|
||||
app('log')->error($e->getMessage());
|
||||
$message = sprintf('Internal exception: %s', $e->getMessage());
|
||||
$validator = \Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);
|
||||
$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);
|
||||
|
||||
throw new ValidationException($validator);
|
||||
}
|
||||
app('preferences')->mark();
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
|
||||
|
||||
$manager = $this->getManager();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
$admin = auth()->user();
|
||||
|
||||
// use new group collector:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector
|
||||
->setUser($admin)
|
||||
->setUserGroup($this->userGroup)
|
||||
// filter on transaction group.
|
||||
->setTransactionGroup($transactionGroup)
|
||||
// all info needed for the API:
|
||||
->withAPIInformation()
|
||||
;
|
||||
|
||||
$selectedGroup = $collector->getGroups()->first();
|
||||
$selectedGroup = $collector->getGroups()->first();
|
||||
if (null === $selectedGroup) {
|
||||
throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
||||
}
|
||||
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
$resource = new Item($selectedGroup, $transformer, 'transactions');
|
||||
$resource = new Item($selectedGroup, $transformer, 'transactions');
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ class ListController extends Controller
|
||||
// get list of budgets. Count it and split it.
|
||||
/** @var RecurringRepositoryInterface $recurringRepos */
|
||||
$recurringRepos = app(RecurringRepositoryInterface::class);
|
||||
$unfiltered = $recurringRepos->getAll();
|
||||
$unfiltered = $recurringRepos->get();
|
||||
|
||||
// filter selection
|
||||
$collection = $unfiltered->filter(
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Chart\ChartData;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Api\CleansChartData;
|
||||
use FireflyIII\Support\Http\Api\CollectsAccountsFromFilter;
|
||||
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
|
||||
@@ -118,7 +119,7 @@ class AccountController extends Controller
|
||||
'native_entries' => [],
|
||||
];
|
||||
$currentStart = clone $params['start'];
|
||||
$range = app('steam')->finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);
|
||||
$range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);
|
||||
|
||||
$previous = array_values($range)[0]['balance'];
|
||||
$previousNative = array_values($range)[0]['native_balance'];
|
||||
|
||||
@@ -21,25 +21,6 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* ConvertDatesToUTC.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Models\AutoBudget;
|
||||
use FireflyIII\Models\AvailableBudget;
|
||||
use FireflyIII\Models\Bill;
|
||||
@@ -33,8 +34,14 @@ use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\RecurrenceTransaction;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CorrectsAmounts extends Command
|
||||
{
|
||||
@@ -45,6 +52,8 @@ class CorrectsAmounts extends Command
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
// transfers must not have foreign currency info if both accounts have the same currency.
|
||||
$this->correctTransfers();
|
||||
// auto budgets must be positive
|
||||
$this->fixAutoBudgets();
|
||||
// available budgets must be positive
|
||||
@@ -62,6 +71,7 @@ class CorrectsAmounts extends Command
|
||||
// rule_triggers must be positive or zero (amount_less, amount_more, amount_is)
|
||||
$this->fixRuleTriggers();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -182,4 +192,63 @@ class CorrectsAmounts extends Command
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function correctTransfers(): void
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$type = TransactionType::where('type', TransactionTypeEnum::TRANSFER->value)->first();
|
||||
$journals = TransactionJournal::where('transaction_type_id', $type->id)->get();
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$repository->setUser($journal->user);
|
||||
$native = Amount::getNativeCurrencyByUserGroup($journal->userGroup);
|
||||
|
||||
/** @var null|Transaction $source */
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var null|Transaction $destination */
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $source || null === $destination) {
|
||||
continue;
|
||||
}
|
||||
if (null === $source->foreign_currency_id || null === $destination->foreign_currency_id) {
|
||||
continue;
|
||||
}
|
||||
$sourceAccount = $source->account;
|
||||
$destAccount = $destination->account;
|
||||
if (null === $sourceAccount || null === $destAccount) {
|
||||
continue;
|
||||
}
|
||||
$sourceCurrency = $repository->getAccountCurrency($sourceAccount) ?? $native;
|
||||
$destCurrency = $repository->getAccountCurrency($destAccount) ?? $native;
|
||||
|
||||
if ($sourceCurrency->id === $destCurrency->id) {
|
||||
Log::debug('Both accounts have the same currency. Removing foreign currency info.');
|
||||
$source->foreign_currency_id = null;
|
||||
$source->foreign_amount = null;
|
||||
$source->save();
|
||||
$destination->foreign_currency_id = null;
|
||||
$destination->foreign_amount = null;
|
||||
$destination->save();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// validate source
|
||||
if ($destCurrency->id !== $source->foreign_currency_id) {
|
||||
Log::debug(sprintf('Journal #%d: Transaction #%d refers to "%s" but should refer to "%s".', $journal->id, $source->id, $source->foreignCurrency->code, $destCurrency->code));
|
||||
$source->foreign_currency_id = $destCurrency->id;
|
||||
$source->save();
|
||||
}
|
||||
|
||||
// validate destination:
|
||||
if ($sourceCurrency->id !== $destination->foreign_currency_id) {
|
||||
Log::debug(sprintf('Journal #%d: Transaction #%d refers to "%s" but should refer to "%s".', $journal->id, $destination->id, $destination->foreignCurrency->code, $sourceCurrency->code));
|
||||
$destination->foreign_currency_id = $sourceCurrency->id;
|
||||
$destination->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,14 @@ class CorrectsNativeAmounts extends Command
|
||||
{
|
||||
$set = $userGroup->accounts()->where(function (EloquentBuilder $q): void {
|
||||
$q->whereNotNull('virtual_balance');
|
||||
$q->orWhere('virtual_balance', '!=', '');
|
||||
|
||||
// this needs a different piece of code for postgres.
|
||||
if ('pgsql' === config('database.default')) {
|
||||
$q->orWhere(DB::raw('CAST(virtual_balance AS TEXT)'), '!=', '');
|
||||
}
|
||||
if ('pgsql' !== config('database.default')) {
|
||||
$q->orWhere('virtual_balance', '!=', '');
|
||||
}
|
||||
})->get();
|
||||
|
||||
/** @var Account $account */
|
||||
@@ -218,7 +225,6 @@ class CorrectsNativeAmounts extends Command
|
||||
$set = DB::table('transactions')
|
||||
->join('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.user_group_id', $userGroup->id)
|
||||
|
||||
->where(function (DatabaseBuilder $q1) use ($currency): void {
|
||||
$q1->where(function (DatabaseBuilder $q2) use ($currency): void {
|
||||
$q2->whereNot('transactions.transaction_currency_id', $currency->id)->whereNull('transactions.foreign_currency_id');
|
||||
|
||||
@@ -21,25 +21,6 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* AddTimezonesToDates.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class ExportsData extends Command
|
||||
{--export-tags : Create a file with all your tags and some meta data.}
|
||||
{--export-recurring : Create a file with all your recurring transactions and some meta data.}
|
||||
{--export-rules : Create a file with all your rules and some meta data.}
|
||||
{--export-bills : Create a file with all your bills and some meta data.}
|
||||
{--export-subscriptions : Create a file with all your subscriptions and some meta data.}
|
||||
{--export-piggies : Create a file with all your piggy banks and some meta data.}
|
||||
{--force : Force overwriting of previous exports if found.}';
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
@@ -106,7 +106,7 @@ class ExportsData extends Command
|
||||
$exporter->setExportTags($options['export']['tags']);
|
||||
$exporter->setExportRecurring($options['export']['recurring']);
|
||||
$exporter->setExportRules($options['export']['rules']);
|
||||
$exporter->setExportBills($options['export']['bills']);
|
||||
$exporter->setExportBills($options['export']['subscriptions']);
|
||||
$exporter->setExportPiggies($options['export']['piggies']);
|
||||
$data = $exporter->export();
|
||||
if (0 === count($data)) {
|
||||
@@ -157,7 +157,7 @@ class ExportsData extends Command
|
||||
'tags' => $this->option('export-tags'),
|
||||
'recurring' => $this->option('export-recurring'),
|
||||
'rules' => $this->option('export-rules'),
|
||||
'bills' => $this->option('export-bills'),
|
||||
'bills' => $this->option('export-subscriptions'),
|
||||
'piggies' => $this->option('export-piggies'),
|
||||
],
|
||||
'start' => $start,
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Factory;
|
||||
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
@@ -34,6 +35,7 @@ use FireflyIII\User;
|
||||
class TagFactory
|
||||
{
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
|
||||
public function findOrCreate(string $tag): ?Tag
|
||||
{
|
||||
@@ -101,6 +103,12 @@ class TagFactory
|
||||
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->user = $user;
|
||||
$this->userGroup = $user->userGroup;
|
||||
}
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Rules\UniqueIban;
|
||||
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
/**
|
||||
@@ -216,12 +215,4 @@ class TransactionFactory
|
||||
{
|
||||
$this->reconciled = $reconciled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
// empty function.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Factory;
|
||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
@@ -36,6 +37,7 @@ class TransactionGroupFactory
|
||||
{
|
||||
private TransactionJournalFactory $journalFactory;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
|
||||
/**
|
||||
* TransactionGroupFactory constructor.
|
||||
@@ -54,7 +56,8 @@ class TransactionGroupFactory
|
||||
public function create(array $data): TransactionGroup
|
||||
{
|
||||
app('log')->debug('Now in TransactionGroupFactory::create()');
|
||||
$this->journalFactory->setUser($this->user);
|
||||
$this->journalFactory->setUser($data['user']);
|
||||
$this->journalFactory->setUserGroup($data['user_group']);
|
||||
$this->journalFactory->setErrorOnHash($data['error_if_duplicate_hash'] ?? false);
|
||||
|
||||
try {
|
||||
@@ -76,7 +79,7 @@ class TransactionGroupFactory
|
||||
|
||||
$group = new TransactionGroup();
|
||||
$group->user()->associate($this->user);
|
||||
$group->userGroup()->associate($data['user_group'] ?? $this->user->userGroup);
|
||||
$group->userGroup()->associate($data['user_group']);
|
||||
$group->title = $title;
|
||||
$group->save();
|
||||
|
||||
@@ -92,4 +95,9 @@ class TransactionGroupFactory
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
@@ -69,6 +70,7 @@ class TransactionJournalFactory
|
||||
private PiggyBankRepositoryInterface $piggyRepository;
|
||||
private TransactionTypeRepositoryInterface $typeRepository;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -176,7 +178,6 @@ class TransactionJournalFactory
|
||||
if (true === FireflyConfig::get('utc', false)->data) {
|
||||
$carbon->setTimezone('UTC');
|
||||
}
|
||||
// $carbon->setTimezone('UTC');
|
||||
|
||||
try {
|
||||
// validate source and destination using a new Validator.
|
||||
@@ -228,7 +229,7 @@ class TransactionJournalFactory
|
||||
$journal = TransactionJournal::create(
|
||||
[
|
||||
'user_id' => $this->user->id,
|
||||
'user_group_id' => $this->user->user_group_id,
|
||||
'user_group_id' => $this->userGroup->id,
|
||||
'transaction_type_id' => $type->id,
|
||||
'bill_id' => $billId,
|
||||
'transaction_currency_id' => $currency->id,
|
||||
@@ -244,7 +245,6 @@ class TransactionJournalFactory
|
||||
|
||||
/** Create two transactions. */
|
||||
$transactionFactory = app(TransactionFactory::class);
|
||||
$transactionFactory->setUser($this->user);
|
||||
$transactionFactory->setJournal($journal);
|
||||
$transactionFactory->setAccount($sourceAccount);
|
||||
$transactionFactory->setCurrency($currency);
|
||||
@@ -263,7 +263,6 @@ class TransactionJournalFactory
|
||||
|
||||
/** @var TransactionFactory $transactionFactory */
|
||||
$transactionFactory = app(TransactionFactory::class);
|
||||
$transactionFactory->setUser($this->user);
|
||||
$transactionFactory->setJournal($journal);
|
||||
$transactionFactory->setAccount($destinationAccount);
|
||||
$transactionFactory->setAccountInformation($destInfo);
|
||||
@@ -404,7 +403,8 @@ class TransactionJournalFactory
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->user = $user;
|
||||
$this->userGroup = $user->userGroup;
|
||||
$this->currencyRepository->setUser($this->user);
|
||||
$this->tagFactory->setUser($user);
|
||||
$this->billRepository->setUser($this->user);
|
||||
@@ -414,6 +414,18 @@ class TransactionJournalFactory
|
||||
$this->accountRepository->setUser($this->user);
|
||||
}
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
$this->currencyRepository->setUserGroup($userGroup);
|
||||
$this->tagFactory->setUserGroup($userGroup);
|
||||
$this->billRepository->setUserGroup($userGroup);
|
||||
$this->budgetRepository->setUserGroup($userGroup);
|
||||
$this->categoryRepository->setUserGroup($userGroup);
|
||||
$this->piggyRepository->setUserGroup($userGroup);
|
||||
$this->accountRepository->setUserGroup($userGroup);
|
||||
}
|
||||
|
||||
private function reconciliationSanityCheck(?Account $sourceAccount, ?Account $destinationAccount): array
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
@@ -33,6 +33,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
@@ -52,7 +53,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
$auditData = [];
|
||||
$dayBefore = clone $this->start;
|
||||
$dayBefore->subDay();
|
||||
|
||||
// set date to subday + end-of-day for account balance. so it is at $date 23:59:59
|
||||
$dayBefore->subDay()->endOfDay();
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($this->accounts as $account) {
|
||||
@@ -133,6 +136,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
;
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$journals = array_reverse($journals, true);
|
||||
// this call is correct.
|
||||
Log::debug(sprintf('getAuditReport: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$dayBeforeBalance = Steam::finalAccountBalance($account, $date);
|
||||
$startBalance = $dayBeforeBalance['balance'];
|
||||
$defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
|
||||
@@ -167,6 +172,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
$journals[$index]['invoice_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'invoice_date');
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
// call is correct.
|
||||
Log::debug(sprintf('getAuditReport end: Call finalAccountBalance with date/time "%s"', $this->end->toIso8601String()));
|
||||
|
||||
return [
|
||||
'journals' => $journals,
|
||||
|
||||
@@ -61,8 +61,12 @@ class PreferencesEventHandler
|
||||
$this->resetTransactions($event->userGroup);
|
||||
// fire laravel command to recalculate them all.
|
||||
if (Amount::convertToNative()) {
|
||||
Log::debug('Will now convert to native.');
|
||||
Artisan::call('correction:recalculate-native-amounts');
|
||||
|
||||
return;
|
||||
}
|
||||
Log::debug('Will NOT convert to native.');
|
||||
}
|
||||
|
||||
private function resetPiggyBanks(UserGroup $userGroup): void
|
||||
|
||||
@@ -38,10 +38,17 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class StoredGroupEventHandler
|
||||
{
|
||||
public function runAllHandlers(StoredTransactionGroup $event): void
|
||||
{
|
||||
$this->processRules($event);
|
||||
$this->recalculateCredit($event);
|
||||
$this->triggerWebhooks($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method grabs all the users rules and processes them.
|
||||
*/
|
||||
public function processRules(StoredTransactionGroup $storedGroupEvent): void
|
||||
private function processRules(StoredTransactionGroup $storedGroupEvent): void
|
||||
{
|
||||
if (false === $storedGroupEvent->applyRules) {
|
||||
app('log')->info(sprintf('Will not run rules on group #%d', $storedGroupEvent->transactionGroup->id));
|
||||
@@ -76,7 +83,7 @@ class StoredGroupEventHandler
|
||||
$newRuleEngine->fire();
|
||||
}
|
||||
|
||||
public function recalculateCredit(StoredTransactionGroup $event): void
|
||||
private function recalculateCredit(StoredTransactionGroup $event): void
|
||||
{
|
||||
$group = $event->transactionGroup;
|
||||
|
||||
@@ -89,7 +96,7 @@ class StoredGroupEventHandler
|
||||
/**
|
||||
* This method processes all webhooks that respond to the "stored transaction group" trigger (100)
|
||||
*/
|
||||
public function triggerWebhooks(StoredTransactionGroup $storedGroupEvent): void
|
||||
private function triggerWebhooks(StoredTransactionGroup $storedGroupEvent): void
|
||||
{
|
||||
app('log')->debug(__METHOD__);
|
||||
$group = $storedGroupEvent->transactionGroup;
|
||||
|
||||
@@ -41,10 +41,19 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class UpdatedGroupEventHandler
|
||||
{
|
||||
public function runAllHandlers(UpdatedTransactionGroup $event): void
|
||||
{
|
||||
$this->unifyAccounts($event);
|
||||
$this->processRules($event);
|
||||
$this->recalculateCredit($event);
|
||||
$this->triggerWebhooks($event);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will check all the rules when a journal is updated.
|
||||
*/
|
||||
public function processRules(UpdatedTransactionGroup $updatedGroupEvent): void
|
||||
private function processRules(UpdatedTransactionGroup $updatedGroupEvent): void
|
||||
{
|
||||
if (false === $updatedGroupEvent->applyRules) {
|
||||
app('log')->info(sprintf('Will not run rules on group #%d', $updatedGroupEvent->transactionGroup->id));
|
||||
@@ -76,7 +85,7 @@ class UpdatedGroupEventHandler
|
||||
$newRuleEngine->fire();
|
||||
}
|
||||
|
||||
public function recalculateCredit(UpdatedTransactionGroup $event): void
|
||||
private function recalculateCredit(UpdatedTransactionGroup $event): void
|
||||
{
|
||||
$group = $event->transactionGroup;
|
||||
|
||||
@@ -86,7 +95,7 @@ class UpdatedGroupEventHandler
|
||||
$object->recalculate();
|
||||
}
|
||||
|
||||
public function triggerWebhooks(UpdatedTransactionGroup $updatedGroupEvent): void
|
||||
private function triggerWebhooks(UpdatedTransactionGroup $updatedGroupEvent): void
|
||||
{
|
||||
app('log')->debug(__METHOD__);
|
||||
$group = $updatedGroupEvent->transactionGroup;
|
||||
|
||||
@@ -25,7 +25,9 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
@@ -52,6 +54,7 @@ class AccountObserver
|
||||
$currency = $repository->getAccountCurrency($account);
|
||||
if (null !== $currency && $currency->id !== $userCurrency->id && '' !== (string) $account->virtual_balance && 0 !== bccomp($account->virtual_balance, '0')) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setUserGroup($account->user->userGroup);
|
||||
$converter->setIgnoreSettings(true);
|
||||
$account->native_virtual_balance = $converter->convert($currency, $userCurrency, today(), $account->virtual_balance);
|
||||
|
||||
@@ -72,12 +75,17 @@ class AccountObserver
|
||||
// app('log')->debug('Observe "deleting" of an account.');
|
||||
$account->accountMeta()->delete();
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($account->user);
|
||||
|
||||
/** @var PiggyBank $piggy */
|
||||
foreach ($account->piggyBanks()->get() as $piggy) {
|
||||
$piggy->accounts()->detach($account);
|
||||
}
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($account->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
foreach ($account->transactions()->get() as $transaction) {
|
||||
$transaction->delete();
|
||||
|
||||
@@ -52,6 +52,7 @@ class AutoBudgetObserver
|
||||
$autoBudget->native_amount = null;
|
||||
if ($autoBudget->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setUserGroup($autoBudget->budget->user->userGroup);
|
||||
$converter->setIgnoreSettings(true);
|
||||
$autoBudget->native_amount = $converter->convert($autoBudget->transactionCurrency, $userCurrency, today(), $autoBudget->amount);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -41,9 +43,13 @@ class BillObserver
|
||||
|
||||
public function deleting(Bill $bill): void
|
||||
{
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($bill->user);
|
||||
|
||||
// app('log')->debug('Observe "deleting" of a bill.');
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($bill->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
$bill->notes()->delete();
|
||||
}
|
||||
@@ -64,6 +70,7 @@ class BillObserver
|
||||
$bill->native_amount_max = null;
|
||||
if ($bill->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setUserGroup($bill->user->userGroup);
|
||||
$converter->setIgnoreSettings(true);
|
||||
$bill->native_amount_min = $converter->convert($bill->transactionCurrency, $userCurrency, today(), $bill->amount_min);
|
||||
$bill->native_amount_max = $converter->convert($bill->transactionCurrency, $userCurrency, today(), $bill->amount_max);
|
||||
|
||||
@@ -54,6 +54,7 @@ class BudgetLimitObserver
|
||||
$budgetLimit->native_amount = null;
|
||||
if ($budgetLimit->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setUserGroup($budgetLimit->budget->user->userGroup);
|
||||
$converter->setIgnoreSettings(true);
|
||||
$budgetLimit->native_amount = $converter->convert($budgetLimit->transactionCurrency, $userCurrency, today(), $budgetLimit->amount);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class BudgetObserver
|
||||
@@ -34,8 +36,13 @@ class BudgetObserver
|
||||
public function deleting(Budget $budget): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a budget.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($budget->user);
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($budget->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
$budgetLimits = $budget->budgetlimits()->get();
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class CategoryObserver
|
||||
@@ -33,8 +35,13 @@ class CategoryObserver
|
||||
public function deleting(Category $category): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a category.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($category->user);
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($category->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
$category->notes()->delete();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class PiggyBankEventObserver
|
||||
$event->native_amount = null;
|
||||
if ($event->piggyBank->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
|
||||
$converter->setIgnoreSettings(true);
|
||||
$event->native_amount = $converter->convert($event->piggyBank->transactionCurrency, $userCurrency, today(), $event->amount);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -46,8 +48,12 @@ class PiggyBankObserver
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a piggy bank.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($piggyBank->accounts()->first()->user);
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($piggyBank->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
|
||||
$piggyBank->piggyBankEvents()->delete();
|
||||
|
||||
@@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class RecurrenceObserver
|
||||
@@ -33,8 +35,13 @@ class RecurrenceObserver
|
||||
public function deleting(Recurrence $recurrence): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a recurrence.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($recurrence->user);
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($recurrence->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
|
||||
$recurrence->recurrenceRepetitions()->delete();
|
||||
|
||||
@@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class TagObserver
|
||||
@@ -34,8 +36,12 @@ class TagObserver
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a tag.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($tag->user);
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($tag->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
|
||||
$tag->locations()->delete();
|
||||
|
||||
@@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalObserver
|
||||
@@ -34,14 +36,20 @@ class TransactionJournalObserver
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a transaction journal.');
|
||||
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($transactionJournal->user);
|
||||
|
||||
|
||||
// to make sure the listener doesn't get back to use and loop
|
||||
TransactionJournal::withoutEvents(static function () use ($transactionJournal): void {
|
||||
foreach ($transactionJournal->transactions()->get() as $transaction) {
|
||||
$transaction->delete();
|
||||
}
|
||||
});
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($transactionJournal->attachments()->get() as $attachment) {
|
||||
$attachment->delete();
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
$transactionJournal->locations()->delete();
|
||||
$transactionJournal->sourceJournalLinks()->delete();
|
||||
|
||||
@@ -258,7 +258,12 @@ trait AccountCollection
|
||||
if (null === $account) {
|
||||
continue;
|
||||
}
|
||||
$balance = Steam::finalAccountBalance($account, $transaction['date']);
|
||||
// the balance must be found BEFORE the transaction date.
|
||||
// so sub one second. This is not perfect, but works well enough.
|
||||
$date = clone $transaction['date'];
|
||||
$date->subSecond();
|
||||
Log::debug(sprintf('accountBalanceIs: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date);
|
||||
$result = bccomp($balance['balance'], $value);
|
||||
Log::debug(sprintf('"%s" vs "%s" is %d', $balance['balance'], $value, $result));
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -405,6 +406,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $internalReference));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -417,6 +419,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $internalReference));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -429,6 +432,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s"', $internalReference));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -441,6 +445,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('"%s%%', $internalReference));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -453,6 +458,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('%%%s"', $internalReference));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -465,6 +471,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('"%s%%', $internalReference));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -697,6 +704,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($externalId)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -706,6 +714,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', '=', json_encode($url));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -718,6 +727,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($internalReference)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -727,6 +737,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'recurrence_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($recurringId)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -862,6 +873,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->whereNotNull('journal_meta.data');
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -871,6 +883,7 @@ trait MetaCollection
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereNotNull('journal_meta.data');
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -915,10 +928,13 @@ trait MetaCollection
|
||||
$q1->where(static function (Builder $q2): void {
|
||||
$q2->where('journal_meta.name', '=', 'external_id');
|
||||
$q2->whereNull('journal_meta.data');
|
||||
$q2->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q3): void {
|
||||
$q3->where('journal_meta.name', '!=', 'external_id');
|
||||
$q3->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q4): void {
|
||||
$q4->whereNull('journal_meta.name');
|
||||
$q4->whereNull('journal_meta.deleted_at');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -933,10 +949,13 @@ trait MetaCollection
|
||||
$q1->where(static function (Builder $q2): void {
|
||||
$q2->where('journal_meta.name', '=', 'external_url');
|
||||
$q2->whereNull('journal_meta.data');
|
||||
$q2->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q3): void {
|
||||
$q3->where('journal_meta.name', '!=', 'external_url');
|
||||
$q3->whereNull('journal_meta.deleted_at');
|
||||
})->orWhere(static function (Builder $q4): void {
|
||||
$q4->whereNull('journal_meta.name');
|
||||
$q4->whereNull('journal_meta.deleted_at');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
'category_id',
|
||||
'budget_id',
|
||||
];
|
||||
$this->stringFields = ['amount', 'foreign_amount'];
|
||||
$this->stringFields = ['amount', 'foreign_amount', 'native_amount', 'native_foreign_amount'];
|
||||
$this->total = 0;
|
||||
$this->fields = [
|
||||
// group
|
||||
@@ -710,10 +710,13 @@ class GroupCollector implements GroupCollectorInterface
|
||||
foreach ($groups as $groudId => $group) {
|
||||
/** @var array $transaction */
|
||||
foreach ($group['transactions'] as $transaction) {
|
||||
$currencyId = (int) $transaction['currency_id'];
|
||||
$currencyId = (int) $transaction['currency_id'];
|
||||
if (null === $transaction['amount']) {
|
||||
throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));
|
||||
}
|
||||
$nativeAmount = (string) ('' === $transaction['native_amount'] ? '0' : $transaction['native_amount']);
|
||||
$nativeForeignAmount = (string) ('' === $transaction['native_foreign_amount'] ? '0' : $transaction['native_foreign_amount']);
|
||||
$foreignAmount = (string) ('' === $transaction['foreign_amount'] ? '0' : $transaction['foreign_amount']);
|
||||
|
||||
// set default:
|
||||
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
|
||||
@@ -722,11 +725,13 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$groups[$groudId]['sums'][$currencyId]['currency_symbol'] = $transaction['currency_symbol'];
|
||||
$groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['currency_decimal_places'];
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = '0';
|
||||
}
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['native_amount'], $nativeAmount);
|
||||
|
||||
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
|
||||
$currencyId = (int) $transaction['foreign_currency_id'];
|
||||
$currencyId = (int) $transaction['foreign_currency_id'];
|
||||
|
||||
// set default:
|
||||
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
|
||||
@@ -735,8 +740,10 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$groups[$groudId]['sums'][$currencyId]['currency_symbol'] = $transaction['foreign_currency_symbol'];
|
||||
$groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['foreign_currency_decimal_places'];
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = '0';
|
||||
}
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['foreign_amount']);
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $foreignAmount);
|
||||
$groups[$groudId]['sums'][$currencyId]['native_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $nativeForeignAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ class NetWorth implements NetWorthInterface
|
||||
Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s')));
|
||||
$default = Amount::getNativeCurrency();
|
||||
$netWorth = [];
|
||||
Log::debug(sprintf('NetWorth: finalAccountsBalance("%s")', $date->format('Y-m-d H:i:s')));
|
||||
$balances = Steam::finalAccountsBalance($accounts, $date);
|
||||
|
||||
/** @var Account $account */
|
||||
@@ -159,6 +160,7 @@ class NetWorth implements NetWorthInterface
|
||||
*/
|
||||
$accounts = $this->getAccounts();
|
||||
$return = [];
|
||||
Log::debug(sprintf('SumNetWorth: finalAccountsBalance("%s")', $date->format('Y-m-d H:i:s')));
|
||||
$balances = Steam::finalAccountsBalance($accounts, $date);
|
||||
foreach ($accounts as $account) {
|
||||
$currency = $this->getRepository()->getAccountCurrency($account);
|
||||
|
||||
@@ -33,6 +33,7 @@ use FireflyIII\Support\Http\Controllers\BasicDataSupport;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
@@ -90,9 +91,11 @@ class IndexController extends Controller
|
||||
$start->subDay();
|
||||
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$startBalances = app('steam')->finalAccountsBalance($accounts, $start);
|
||||
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
||||
$activities = app('steam')->getLastActivities($ids);
|
||||
Log::debug(sprintf('inactive start: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('inactive end: finalAccountsBalance("%s")', $end->format('Y-m-d H:i:s')));
|
||||
$startBalances = Steam::finalAccountsBalance($accounts, $start);
|
||||
$endBalances = Steam::finalAccountsBalance($accounts, $end);
|
||||
$activities = Steam::getLastActivities($ids);
|
||||
|
||||
|
||||
$accounts->each(
|
||||
@@ -102,7 +105,7 @@ class IndexController extends Controller
|
||||
$account->startBalances = Steam::filterAccountBalance($startBalances[$account->id] ?? [], $account, $this->convertToNative, $currency);
|
||||
$account->endBalances = Steam::filterAccountBalance($endBalances[$account->id] ?? [], $account, $this->convertToNative, $currency);
|
||||
$account->differences = $this->subtract($account->startBalances, $account->endBalances);
|
||||
$account->interest = app('steam')->bcround($this->repository->getMetaValue($account, 'interest'), 4);
|
||||
$account->interest = Steam::bcround($this->repository->getMetaValue($account, 'interest'), 4);
|
||||
$account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->current_debt = '0';
|
||||
@@ -153,9 +156,11 @@ class IndexController extends Controller
|
||||
$start->subDay();
|
||||
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$startBalances = app('steam')->finalAccountsBalance($accounts, $start);
|
||||
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
||||
$activities = app('steam')->getLastActivities($ids);
|
||||
Log::debug(sprintf('index start: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('index end: finalAccountsBalance("%s")', $end->format('Y-m-d H:i:s')));
|
||||
$startBalances = Steam::finalAccountsBalance($accounts, $start);
|
||||
$endBalances = Steam::finalAccountsBalance($accounts, $end);
|
||||
$activities = Steam::getLastActivities($ids);
|
||||
|
||||
|
||||
$accounts->each(
|
||||
@@ -168,7 +173,7 @@ class IndexController extends Controller
|
||||
$account->endBalances = Steam::filterAccountBalance($endBalances[$account->id] ?? [], $account, $this->convertToNative, $currency);
|
||||
$account->differences = $this->subtract($account->startBalances, $account->endBalances);
|
||||
$account->lastActivityDate = $this->isInArrayDate($activities, $account->id);
|
||||
$account->interest = app('steam')->bcround($interest, 4);
|
||||
$account->interest = Steam::bcround($interest, 4);
|
||||
$account->interestPeriod = (string) trans(
|
||||
sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))
|
||||
);
|
||||
|
||||
@@ -39,6 +39,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
@@ -108,11 +109,17 @@ class ReconcileController extends Controller
|
||||
if ($end->lt($start)) {
|
||||
[$start, $end] = [$end, $start];
|
||||
}
|
||||
// move dates to end of day and start of day:
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
$startDate = clone $start;
|
||||
$startDate->subDay();
|
||||
$startBalance = Steam::finalAccountBalance($account, $startDate)['balance'];
|
||||
$endBalance = Steam::finalAccountBalance($account, $end)['balance'];
|
||||
$startDate->subDay()->endOfDay(); // this is correct, subday endofday ends at 23:59:59
|
||||
// both are validated and are correct.
|
||||
Log::debug(sprintf('reconcile: Call finalAccountBalance with date/time "%s"', $startDate->toIso8601String()));
|
||||
Log::debug(sprintf('reconcile2: Call finalAccountBalance with date/time "%s"', $end->toIso8601String()));
|
||||
$startBalance = Steam::bcround(Steam::finalAccountBalance($account, $startDate)['balance'], $currency->decimal_places);
|
||||
$endBalance = Steam::bcround(Steam::finalAccountBalance($account, $end)['balance'], $currency->decimal_places);
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
|
||||
$subTitle = (string) trans('firefly.reconcile_account', ['account' => $account->name]);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
@@ -93,6 +94,11 @@ class ShowController extends Controller
|
||||
if ($end->lt($start)) {
|
||||
[$start, $end] = [$end, $start];
|
||||
}
|
||||
|
||||
// make sure dates are end of day and start of day:
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
$location = $this->repository->getLocation($account);
|
||||
$attachments = $this->repository->getAttachments($account);
|
||||
$today = today(config('app.timezone'));
|
||||
@@ -115,12 +121,7 @@ class ShowController extends Controller
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector
|
||||
->setAccounts(new Collection([$account]))
|
||||
->setLimit($pageSize)
|
||||
->setPage($page)->withAccountInformation()->withCategoryInformation()
|
||||
->setRange($start, $end)
|
||||
;
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation()->setRange($start, $end);
|
||||
|
||||
// this search will not include transaction groups where this asset account (or liability)
|
||||
// is just part of ONE of the journals. To force this:
|
||||
@@ -130,7 +131,14 @@ class ShowController extends Controller
|
||||
|
||||
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
$showAll = false;
|
||||
$balances = Steam::filterAccountBalance(Steam::finalAccountBalance($account, $end), $account, $this->convertToNative, $accountCurrency);
|
||||
// correct
|
||||
$now = today()->endOfDay();
|
||||
if ($now->gt($end) || $now->lt($start)) {
|
||||
$now = $end;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('show: Call finalAccountBalance with date/time "%s"', $now->toIso8601String()));
|
||||
$balances = Steam::filterAccountBalance(Steam::finalAccountBalance($account, $now), $account, $this->convertToNative, $accountCurrency);
|
||||
|
||||
return view(
|
||||
'accounts.show',
|
||||
@@ -181,6 +189,8 @@ class ShowController extends Controller
|
||||
$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$periods = new Collection();
|
||||
|
||||
$end->endOfDay();
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation();
|
||||
@@ -193,6 +203,8 @@ class ShowController extends Controller
|
||||
$groups->setPath(route('accounts.show.all', [$account->id]));
|
||||
$chartUrl = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
$showAll = true;
|
||||
// correct
|
||||
Log::debug(sprintf('showAll: Call finalAccountBalance with date/time "%s"', $end->toIso8601String()));
|
||||
$balances = Steam::filterAccountBalance(Steam::finalAccountBalance($account, $end), $account, $this->convertToNative, $accountCurrency);
|
||||
|
||||
return view(
|
||||
|
||||
@@ -109,8 +109,10 @@ class AccountController extends Controller
|
||||
$accountNames = $this->extractNames($accounts);
|
||||
|
||||
// grab all balances
|
||||
$startBalances = app('steam')->finalAccountsBalance($accounts, $start);
|
||||
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
||||
Log::debug(sprintf('expenseAccounts: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('expenseAccounts: finalAccountsBalance("%s")', $end->format('Y-m-d H:i:s')));
|
||||
$startBalances = Steam::finalAccountsBalance($accounts, $start);
|
||||
$endBalances = Steam::finalAccountsBalance($accounts, $end);
|
||||
|
||||
// loop the accounts, then check for balance and currency info.
|
||||
foreach ($accounts as $account) {
|
||||
@@ -139,6 +141,7 @@ class AccountController extends Controller
|
||||
}
|
||||
// Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance));
|
||||
$searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key;
|
||||
$searchCode = 'balance' === $searchCode || 'native_balance' === $searchCode ? $this->defaultCurrency->code : $searchCode;
|
||||
// Log::debug(sprintf('Search code is %s', $searchCode));
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
@@ -334,7 +337,7 @@ class AccountController extends Controller
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$defaultSet = $repository->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value])->pluck('id')->toArray();
|
||||
Log::debug('Default set is ', $defaultSet);
|
||||
// Log::debug('Default set is ', $defaultSet);
|
||||
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
|
||||
$frontpageArray = !is_array($frontpage->data) ? [] : $frontpage->data;
|
||||
Log::debug('Frontpage preference set is ', $frontpageArray);
|
||||
@@ -344,6 +347,9 @@ class AccountController extends Controller
|
||||
}
|
||||
$accounts = $repository->getAccountsById($frontpageArray);
|
||||
|
||||
// move to end of day for $end.
|
||||
$end->endOfDay();
|
||||
|
||||
return response()->json($this->accountBalanceChart($accounts, $start, $end));
|
||||
}
|
||||
|
||||
@@ -416,8 +422,10 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function period(Account $account, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
Log::debug(sprintf('Now in period("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
$chartData = [];
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
// TODO not sure if these date ranges will work as expected.
|
||||
Log::debug(sprintf('Now in period("%s", "%s")', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty('chart.account.period');
|
||||
$cache->addProperty($start);
|
||||
@@ -431,7 +439,7 @@ class AccountController extends Controller
|
||||
// collect and filter balances for the entire period.
|
||||
$step = $this->calculateStep($start, $end);
|
||||
Log::debug(sprintf('Step is %s', $step));
|
||||
$locale = app('steam')->getLocale();
|
||||
$locale = Steam::getLocale();
|
||||
$return = [];
|
||||
|
||||
// fix for issue https://github.com/firefly-iii/firefly-iii/issues/8041
|
||||
@@ -442,14 +450,11 @@ class AccountController extends Controller
|
||||
$format = (string) trans('config.month_and_day_js', [], $locale);
|
||||
$accountCurrency = $this->accountRepository->getAccountCurrency($account);
|
||||
|
||||
Log::debug('One');
|
||||
$range = Steam::finalAccountBalanceInRange($account, $start, $end, $this->convertToNative);
|
||||
Log::debug('Two');
|
||||
$range = Steam::filterAccountBalances($range, $account, $this->convertToNative, $accountCurrency);
|
||||
Log::debug('Three');
|
||||
|
||||
// temp, get end balance.
|
||||
Log::debug('temp get end balance');
|
||||
Log::debug(sprintf('period: Call finalAccountBalance with date/time "%s"', $end->toIso8601String()));
|
||||
Steam::finalAccountBalance($account, $end);
|
||||
Log::debug('END temp get end balance done');
|
||||
|
||||
@@ -462,25 +467,32 @@ class AccountController extends Controller
|
||||
Log::debug('Balances exist at:');
|
||||
foreach ($range as $key => $value) {
|
||||
$newRange[] = ['date' => $key, 'info' => $value];
|
||||
Log::debug(sprintf(' - %s', $key));
|
||||
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, json_encode($value)));
|
||||
}
|
||||
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date']);
|
||||
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date'])->endOfDay();
|
||||
Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s')));
|
||||
while ($end->gte($current)) {
|
||||
$momentBalance = $previous;
|
||||
$theDate = $current->format('Y-m-d');
|
||||
while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) {
|
||||
$momentBalance = $newRange[$expectedIndex]['info'];
|
||||
Log::debug(sprintf('Expected index is %d!, date is %s, current is %s', $expectedIndex, $carbon->format('Y-m-d'), $current->format('Y-m-d')));
|
||||
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date']);
|
||||
++$expectedIndex;
|
||||
}
|
||||
// $theDate = $current->format('Y-m-d');
|
||||
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), json_encode($momentBalance)));
|
||||
|
||||
// loop over the array with balances, find one that is earlier or on the same day.
|
||||
while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) {
|
||||
Log::debug(sprintf('[a] Expected index is %d, $carbon is %s, current is %s', $expectedIndex, $carbon->format('Y-m-d H:i:s'), $current->format('Y-m-d H:i:s')));
|
||||
|
||||
// grab the balance from that particular $expectedIndex
|
||||
$momentBalance = $newRange[$expectedIndex]['info'];
|
||||
++$expectedIndex;
|
||||
|
||||
// make new carbon based on the next found date. this should stop the loop.
|
||||
if (array_key_exists($expectedIndex, $newRange)) {
|
||||
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date'])->endOfDay();
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('momentBalance is now %s', json_encode($momentBalance)));
|
||||
$return = $this->updateChartKeys($return, $momentBalance);
|
||||
$previous = $momentBalance;
|
||||
|
||||
Log::debug(sprintf('Now at %s', $theDate), $momentBalance);
|
||||
|
||||
|
||||
// process each balance thing.
|
||||
foreach ($momentBalance as $key => $amount) {
|
||||
$label = $current->isoFormat($format);
|
||||
@@ -489,15 +501,13 @@ class AccountController extends Controller
|
||||
$current = app('navigation')->addPeriod($current, $step, 0);
|
||||
// here too, to fix #8041, the data is corrected to the end of the period.
|
||||
$current = app('navigation')->endOfX($current, $step, null);
|
||||
Log::debug(sprintf('Next moment is %s', $current->format('Y-m-d')));
|
||||
|
||||
}
|
||||
Log::debug('End of chart loop.');
|
||||
// second loop (yes) to create nice array with info! Yay!
|
||||
$chartData = [];
|
||||
|
||||
foreach ($return as $key => $info) {
|
||||
if (3 === strlen($key)) {
|
||||
if ('balance' !== $key && 'native_balance' !== $key) {
|
||||
// assume it's a currency:
|
||||
$setCurrency = $this->currencyRepository->findByCode($key);
|
||||
$info['currency_symbol'] = $setCurrency->symbol;
|
||||
@@ -567,8 +577,10 @@ class AccountController extends Controller
|
||||
$accountNames = $this->extractNames($accounts);
|
||||
|
||||
// grab all balances
|
||||
$startBalances = app('steam')->finalAccountsBalance($accounts, $start);
|
||||
$endBalances = app('steam')->finalAccountsBalance($accounts, $end);
|
||||
Log::debug(sprintf('revAccounts: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('revAccounts: finalAccountsBalance("%s")', $end->format('Y-m-d H:i:s')));
|
||||
$startBalances = Steam::finalAccountsBalance($accounts, $start);
|
||||
$endBalances = Steam::finalAccountsBalance($accounts, $end);
|
||||
|
||||
|
||||
// loop the accounts, then check for balance and currency info.
|
||||
@@ -598,6 +610,7 @@ class AccountController extends Controller
|
||||
}
|
||||
// Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance));
|
||||
$searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key;
|
||||
$searchCode = 'balance' === $searchCode || 'native_balance' === $searchCode ? $this->defaultCurrency->code : $searchCode;
|
||||
// Log::debug(sprintf('Search code is %s', $searchCode));
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
|
||||
@@ -168,15 +168,14 @@ class BudgetController extends Controller
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
$entries = [];
|
||||
$amount = $budgetLimit->amount;
|
||||
$amount = $budgetLimit->amount ?? '0';
|
||||
$budgetCollection = new Collection([$budget]);
|
||||
$currency = $budgetLimit->transactionCurrency;
|
||||
if ($this->convertToNative) {
|
||||
$amount = $budgetLimit->native_amount;
|
||||
$amount = $budgetLimit->native_amount ?? '0';
|
||||
$currency = $this->defaultCurrency;
|
||||
}
|
||||
|
||||
|
||||
while ($start <= $end) {
|
||||
$current = clone $start;
|
||||
$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $budgetLimit->transactionCurrency);
|
||||
|
||||
@@ -100,7 +100,10 @@ class ReportController extends Controller
|
||||
|
||||
while ($current < $end) {
|
||||
// get balances by date, grouped by currency.
|
||||
$result = $helper->byAccounts($filtered, $current);
|
||||
$balanceCurrent = clone $current;
|
||||
$balanceCurrent->subDay()->endOfDay(); // go to correct moment.
|
||||
Log::debug(sprintf('Call byAccounts("%s")', $balanceCurrent->format('Y-m-d H:i:s')));
|
||||
$result = $helper->byAccounts($filtered, $balanceCurrent);
|
||||
|
||||
// loop result, add to array.
|
||||
/** @var array $netWorthItem */
|
||||
|
||||
@@ -259,7 +259,7 @@ class DebugController extends Controller
|
||||
$system = $this->getSystemInformation();
|
||||
$docker = $this->getBuildInfo();
|
||||
$app = $this->getAppInfo();
|
||||
$user = $this->getuserInfo();
|
||||
$user = $this->getUserInfo();
|
||||
|
||||
return (string) view('partials.debug-table', compact('system', 'docker', 'app', 'user'));
|
||||
}
|
||||
@@ -381,6 +381,7 @@ class DebugController extends Controller
|
||||
'user_count' => User::count(),
|
||||
'user_flags' => $userFlags,
|
||||
'user_agent' => $userAgent,
|
||||
'native' => Amount::getNativeCurrency(),
|
||||
'convert_to_native' => Amount::convertToNative(),
|
||||
'locale_attempts' => $localeAttempts,
|
||||
'locale' => Steam::getLocale(),
|
||||
|
||||
@@ -189,20 +189,29 @@ class ReconcileController extends Controller
|
||||
if ($end->lt($start)) {
|
||||
[$end, $start] = [$start, $end];
|
||||
}
|
||||
$start->endOfDay();
|
||||
$end->endOfDay();
|
||||
$startDate = clone $start;
|
||||
$startDate->subDay();
|
||||
$end->endOfDay();
|
||||
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$startBalance = Steam::finalAccountBalance($account, $startDate)['balance'];
|
||||
$endBalance = Steam::finalAccountBalance($account, $end)['balance'];
|
||||
// correct
|
||||
Log::debug(sprintf('transactions: Call finalAccountBalance with date/time "%s"', $startDate->toIso8601String()));
|
||||
Log::debug(sprintf('transactions2: Call finalAccountBalance with date/time "%s"', $end->toIso8601String()));
|
||||
$startBalance = Steam::bcround(Steam::finalAccountBalance($account, $startDate)['balance'], $currency->decimal_places);
|
||||
$endBalance = Steam::bcround(Steam::finalAccountBalance($account, $end)['balance'], $currency->decimal_places);
|
||||
|
||||
// get the transactions
|
||||
$selectionStart = clone $start;
|
||||
$selectionStart->startOfDay();
|
||||
$selectionStart->subDays(3);
|
||||
$selectionEnd = clone $end;
|
||||
$selectionEnd->endOfDay();
|
||||
$selectionEnd->addDays(3);
|
||||
|
||||
// to make sure the bar is in the right place:
|
||||
$start->startOfDay();
|
||||
|
||||
// grab transactions:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
@@ -68,14 +68,16 @@ class AmountController extends Controller
|
||||
*/
|
||||
public function add(PiggyBank $piggyBank)
|
||||
{
|
||||
/** @var Carbon $date */
|
||||
$date = session('end', today(config('app.timezone')));
|
||||
$accounts = [];
|
||||
$total = '0';
|
||||
$totalSaved = $this->piggyRepos->getCurrentAmount($piggyBank);
|
||||
$leftToSave = bcsub($piggyBank->target_amount, $totalSaved);
|
||||
foreach ($piggyBank->accounts as $account) {
|
||||
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $account, today(config('app.timezone'))->endOfDay());
|
||||
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $account, $date);
|
||||
$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank, $account);
|
||||
$maxAmount = 0 === bccomp($piggyBank->target_amount, '0') ? $leftToSave : min($leftOnAccount, $leftToSave);
|
||||
$leftToSave = bcsub($piggyBank->target_amount, $savedSoFar);
|
||||
$maxAmount = 0 === bccomp($piggyBank->target_amount, '0') ? $leftOnAccount : min($leftOnAccount, $leftToSave);
|
||||
$accounts[] = [
|
||||
'account' => $account,
|
||||
'left_on_account' => $leftOnAccount,
|
||||
@@ -105,12 +107,13 @@ class AmountController extends Controller
|
||||
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $account, $date);
|
||||
$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank, $account);
|
||||
$leftToSave = bcsub($piggyBank->target_amount, $savedSoFar);
|
||||
$maxAmount = 0 === bccomp($piggyBank->target_amount, '0') ? $leftOnAccount : min($leftOnAccount, $leftToSave);
|
||||
$accounts[] = [
|
||||
'account' => $account,
|
||||
'left_on_account' => $leftOnAccount,
|
||||
'saved_so_far' => $savedSoFar,
|
||||
'left_to_save' => $leftToSave,
|
||||
'max_amount' => 0 === bccomp($piggyBank->target_amount, '0') ? $leftOnAccount : min($leftOnAccount, $leftToSave),
|
||||
'max_amount' => $maxAmount,
|
||||
];
|
||||
$total = bcadd($total, $leftOnAccount);
|
||||
}
|
||||
|
||||
29
app/Http/Controllers/Preferences/NotificationsController.php
Normal file
29
app/Http/Controllers/Preferences/NotificationsController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* NotificationsController.php
|
||||
* Copyright (c) 2025 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Preferences;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
|
||||
class NotificationsController extends Controller {}
|
||||
@@ -120,7 +120,7 @@ class PreferencesController extends Controller
|
||||
$pushoverUserToken = (string) Preferences::getEncrypted('pushover_user_token', '')->data;
|
||||
$ntfyServer = Preferences::getEncrypted('ntfy_server', 'https://ntfy.sh')->data;
|
||||
$ntfyTopic = (string) Preferences::getEncrypted('ntfy_topic', '')->data;
|
||||
$ntfyAuth = Preferences::get('ntfy_auth', false)->data;
|
||||
$ntfyAuth = '1' === Preferences::get('ntfy_auth', false)->data;
|
||||
$ntfyUser = Preferences::getEncrypted('ntfy_user', '')->data;
|
||||
$ntfyPass = (string) Preferences::getEncrypted('ntfy_pass', '')->data;
|
||||
$channels = config('notifications.channels');
|
||||
@@ -264,6 +264,7 @@ class PreferencesController extends Controller
|
||||
if ($convertToNative && !$this->convertToNative) {
|
||||
// set to true!
|
||||
Log::debug('User sets convertToNative to true.');
|
||||
Preferences::set('convert_to_native', $convertToNative);
|
||||
event(new UserGroupChangedDefaultCurrency(auth()->user()->userGroup));
|
||||
}
|
||||
Preferences::set('convert_to_native', $convertToNative);
|
||||
|
||||
@@ -83,6 +83,8 @@ class ReportController extends Controller
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
$start->endOfDay(); // end of day so the final balance is at the end of that day.
|
||||
$end->endOfDay();
|
||||
|
||||
app('view')->share(
|
||||
'subTitle',
|
||||
@@ -114,6 +116,8 @@ class ReportController extends Controller
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
$start->endOfDay(); // end of day so the final balance is at the end of that day.
|
||||
$end->endOfDay();
|
||||
|
||||
app('view')->share(
|
||||
'subTitle',
|
||||
@@ -146,6 +150,8 @@ class ReportController extends Controller
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
$start->endOfDay(); // end of day so the final balance is at the end of that day.
|
||||
$end->endOfDay();
|
||||
|
||||
app('view')->share(
|
||||
'subTitle',
|
||||
@@ -179,6 +185,8 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
$this->repository->cleanupBudgets();
|
||||
$start->endOfDay(); // end of day so the final balance is at the end of that day.
|
||||
$end->endOfDay();
|
||||
|
||||
app('view')->share(
|
||||
'subTitle',
|
||||
@@ -211,6 +219,8 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
$this->repository->cleanupBudgets();
|
||||
$start->endOfDay(); // end of day so the final balance is at the end of that day.
|
||||
$end->endOfDay();
|
||||
|
||||
app('view')->share(
|
||||
'subTitle',
|
||||
@@ -367,6 +377,8 @@ class ReportController extends Controller
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
$start->endOfDay(); // end of day so the final balance is at the end of that day.
|
||||
$end->endOfDay();
|
||||
|
||||
app('view')->share(
|
||||
'subTitle',
|
||||
|
||||
@@ -43,6 +43,7 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
@@ -223,7 +224,9 @@ class ConvertController extends Controller
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = Steam::finalAccountBalance($account, today()->endOfDay())['balance'];
|
||||
$date = today()->endOfDay();
|
||||
Log::debug(sprintf('getLiabilities: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date)['balance'];
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$role = 'l_'.$account->accountType->type;
|
||||
$key = (string) trans('firefly.opt_group_'.$role);
|
||||
@@ -245,7 +248,9 @@ class ConvertController extends Controller
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = Steam::finalAccountBalance($account, today()->endOfDay())['balance'];
|
||||
$date = today()->endOfDay();
|
||||
Log::debug(sprintf('getAssetAccounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date)['balance'];
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
|
||||
if ('' === $role) {
|
||||
|
||||
@@ -419,9 +419,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
/** @var RecurrenceTransaction $transaction */
|
||||
foreach ($transactions as $index => $transaction) {
|
||||
$single = [
|
||||
'type' => null === $transaction?->transactionType?->type ?
|
||||
strtolower($recurrence->transactionType->type) :
|
||||
strtolower($transaction->transactionType->type),
|
||||
'type' => null === $transaction?->transactionType?->type ? strtolower($recurrence->transactionType->type) : strtolower($transaction->transactionType->type), // @phpstan-ignore-line
|
||||
'date' => $date,
|
||||
'user' => $recurrence->user_id,
|
||||
'currency_id' => $transaction->transaction_currency_id,
|
||||
|
||||
@@ -112,6 +112,11 @@ class TransactionJournal extends Model
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function userGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(UserGroup::class);
|
||||
}
|
||||
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Support\Facades\FireflyConfig;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ReturnsSettings
|
||||
{
|
||||
@@ -42,6 +43,7 @@ class ReturnsSettings
|
||||
|
||||
private static function getNtfySettings(string $type, ?User $user): array
|
||||
{
|
||||
Log::debug(sprintf('Getting Ntfy settings for %s and user #%d', $type, $user?->id));
|
||||
$settings = [
|
||||
'ntfy_server' => 'https://ntfy.sh',
|
||||
'ntfy_topic' => '',
|
||||
@@ -56,6 +58,7 @@ class ReturnsSettings
|
||||
$settings['ntfy_auth'] = Preferences::getForUser($user, 'ntfy_auth', false)->data;
|
||||
$settings['ntfy_user'] = Preferences::getEncryptedForUser($user, 'ntfy_user', '')->data;
|
||||
$settings['ntfy_pass'] = Preferences::getEncryptedForUser($user, 'ntfy_pass', '')->data;
|
||||
Log::debug(sprintf('Auth is %s, user = "%s"', var_export($settings['ntfy_auth'], true), $settings['ntfy_user']));
|
||||
}
|
||||
if ('owner' === $type) {
|
||||
$settings['ntfy_server'] = FireflyConfig::getEncrypted('ntfy_server', 'https://ntfy.sh')->data;
|
||||
@@ -63,6 +66,7 @@ class ReturnsSettings
|
||||
$settings['ntfy_auth'] = FireflyConfig::get('ntfy_auth', false)->data;
|
||||
$settings['ntfy_user'] = FireflyConfig::getEncrypted('ntfy_user', '')->data;
|
||||
$settings['ntfy_pass'] = FireflyConfig::getEncrypted('ntfy_pass', '')->data;
|
||||
Log::debug(sprintf('Auth is %s, user = "%s"', var_export($settings['ntfy_auth'], true), $settings['ntfy_user']));
|
||||
}
|
||||
|
||||
// overrule config.
|
||||
@@ -74,7 +78,9 @@ class ReturnsSettings
|
||||
config(['ntfy-notification-channel.authentication.enabled' => true]);
|
||||
config(['ntfy-notification-channel.authentication.username' => $settings['ntfy_user']]);
|
||||
config(['ntfy-notification-channel.authentication.password' => $settings['ntfy_pass']]);
|
||||
Log::debug('Authentication enabled for Ntfy.');
|
||||
}
|
||||
Log::debug('Return ntfy settings.');
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
@@ -169,16 +169,11 @@ class EventServiceProvider extends ServiceProvider
|
||||
|
||||
// is a Transaction Journal related event.
|
||||
StoredTransactionGroup::class => [
|
||||
'FireflyIII\Handlers\Events\StoredGroupEventHandler@processRules',
|
||||
'FireflyIII\Handlers\Events\StoredGroupEventHandler@recalculateCredit',
|
||||
'FireflyIII\Handlers\Events\StoredGroupEventHandler@triggerWebhooks',
|
||||
'FireflyIII\Handlers\Events\StoredGroupEventHandler@runAllHandlers',
|
||||
],
|
||||
// is a Transaction Journal related event.
|
||||
UpdatedTransactionGroup::class => [
|
||||
'FireflyIII\Handlers\Events\UpdatedGroupEventHandler@unifyAccounts',
|
||||
'FireflyIII\Handlers\Events\UpdatedGroupEventHandler@processRules',
|
||||
'FireflyIII\Handlers\Events\UpdatedGroupEventHandler@recalculateCredit',
|
||||
'FireflyIII\Handlers\Events\UpdatedGroupEventHandler@triggerWebhooks',
|
||||
'FireflyIII\Handlers\Events\UpdatedGroupEventHandler@runAllHandlers',
|
||||
],
|
||||
DestroyedTransactionGroup::class => [
|
||||
'FireflyIII\Handlers\Events\DestroyedGroupEventHandler@triggerWebhooks',
|
||||
|
||||
@@ -40,6 +40,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
@@ -51,7 +52,7 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class AccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
private User $user;
|
||||
use UserGroupTrait;
|
||||
|
||||
/**
|
||||
* Moved here from account CRUD.
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -149,6 +150,8 @@ interface AccountRepositoryInterface
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
public function store(array $data): Account;
|
||||
|
||||
public function update(Account $account, array $data): Account;
|
||||
|
||||
@@ -29,9 +29,11 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class AccountTasker.
|
||||
@@ -46,10 +48,13 @@ class AccountTasker implements AccountTaskerInterface
|
||||
public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$yesterday = clone $start;
|
||||
$yesterday->subDay();
|
||||
$startSet = app('steam')->finalAccountsBalance($accounts, $yesterday);
|
||||
$endSet = app('steam')->finalAccountsBalance($accounts, $end);
|
||||
app('log')->debug('Start of accountreport');
|
||||
$yesterday->subDay()->endOfDay(); // exactly up until $start but NOT including.
|
||||
$end->endOfDay(); // needs to be end of day to be correct.
|
||||
Log::debug(sprintf('getAccountReport: finalAccountsBalance("%s")', $yesterday->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('getAccountReport: finalAccountsBalance("%s")', $end->format('Y-m-d H:i:s')));
|
||||
$startSet = Steam::finalAccountsBalance($accounts, $yesterday);
|
||||
$endSet = Steam::finalAccountsBalance($accounts, $end);
|
||||
Log::debug('Start of accountreport');
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
@@ -90,10 +95,10 @@ class AccountTasker implements AccountTaskerInterface
|
||||
$entry['end_balance'] = $endSet[$account->id]['balance'] ?? '0';
|
||||
|
||||
// first journal exists, and is on start, then this is the actual opening balance:
|
||||
if (null !== $first && $first->date->isSameDay($start) && TransactionTypeEnum::OPENING_BALANCE->value === $first->transactionType->type) {
|
||||
app('log')->debug(sprintf('Date of first journal for %s is %s', $account->name, $first->date->format('Y-m-d')));
|
||||
if (null !== $first && $first->date->isSameDay($yesterday) && TransactionTypeEnum::OPENING_BALANCE->value === $first->transactionType->type) {
|
||||
Log::debug(sprintf('Date of first journal for %s is %s', $account->name, $first->date->format('Y-m-d')));
|
||||
$entry['start_balance'] = $first->transactions()->where('account_id', $account->id)->first()->amount;
|
||||
app('log')->debug(sprintf('Account %s was opened on %s, so opening balance is %f', $account->name, $start->format('Y-m-d'), $entry['start_balance']));
|
||||
Log::debug(sprintf('Account %s was opened on %s, so opening balance is %f', $account->name, $yesterday->format('Y-m-d'), $entry['start_balance']));
|
||||
}
|
||||
$return['sums'][$currency->id]['start'] = bcadd($return['sums'][$currency->id]['start'], $entry['start_balance']);
|
||||
$return['sums'][$currency->id]['end'] = bcadd($return['sums'][$currency->id]['end'], $entry['end_balance']);
|
||||
@@ -173,7 +178,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
];
|
||||
$report['accounts'][$key]['sum'] = bcadd($report['accounts'][$key]['sum'], $journal['amount']);
|
||||
|
||||
app('log')->debug(sprintf('Sum for %s is now %s', $journal['destination_account_name'], $report['accounts'][$key]['sum']));
|
||||
Log::debug(sprintf('Sum for %s is now %s', $journal['destination_account_name'], $report['accounts'][$key]['sum']));
|
||||
|
||||
++$report['accounts'][$key]['count'];
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ use FireflyIII\Services\Internal\Destroy\BillDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\BillUpdateService;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -51,8 +50,7 @@ use Illuminate\Support\Facades\Log;
|
||||
class BillRepository implements BillRepositoryInterface
|
||||
{
|
||||
use CreatesObjectGroups;
|
||||
|
||||
private User $user;
|
||||
use UserGroupTrait;
|
||||
|
||||
public function billEndsWith(string $query, int $limit): Collection
|
||||
{
|
||||
@@ -294,13 +292,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
||||
public function getPaginator(int $size): LengthAwarePaginator
|
||||
{
|
||||
return $this->user->bills()
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Repositories\Bill;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
@@ -40,6 +41,8 @@ interface BillRepositoryInterface
|
||||
|
||||
public function billStartsWith(string $query, int $limit): Collection;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
/**
|
||||
* Add correct order to bills.
|
||||
*/
|
||||
|
||||
@@ -41,8 +41,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\BudgetDestroyService;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -52,7 +51,7 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
private User $user;
|
||||
use UserGroupTrait;
|
||||
|
||||
public function budgetEndsWith(string $query, int $limit): Collection
|
||||
{
|
||||
@@ -154,13 +153,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
||||
public function getActiveBudgets(): Collection
|
||||
{
|
||||
return $this->user->budgets()->where('active', true)
|
||||
|
||||
@@ -27,6 +27,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\AutoBudget;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -40,6 +41,8 @@ interface BudgetRepositoryInterface
|
||||
|
||||
public function budgetStartsWith(string $query, int $limit): Collection;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
/**
|
||||
* Returns the amount that is budgeted in a period.
|
||||
*/
|
||||
|
||||
@@ -214,7 +214,6 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
Log::debug(sprintf('Start of %s.', __METHOD__));
|
||||
// this collector excludes all transfers TO liabilities (which are also withdrawals)
|
||||
// because those expenses only become expenses once they move from the liability to the friend.
|
||||
|
||||
// 2024-12-24 disable the exclusion for now.
|
||||
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
@@ -245,7 +244,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
}
|
||||
if (null !== $currency) {
|
||||
Log::debug(sprintf('Limit to currency %s', $currency->code));
|
||||
$collector->setNormalCurrency($currency);
|
||||
$collector->setCurrency($currency);
|
||||
}
|
||||
$collector->setBudgets($budgets);
|
||||
$journals = $collector->getExtractedJournals();
|
||||
|
||||
@@ -33,6 +33,7 @@ use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Services\Internal\Destroy\CategoryDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\CategoryUpdateService;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -43,7 +44,7 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
class CategoryRepository implements CategoryRepositoryInterface
|
||||
{
|
||||
private User $user;
|
||||
use UserGroupTrait;
|
||||
|
||||
public function categoryEndsWith(string $query, int $limit): Collection
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Repositories\Category;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -88,6 +89,8 @@ interface CategoryRepositoryInterface
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*/
|
||||
public function getCompleteSet(): Collection
|
||||
{
|
||||
return TransactionCurrency::orderBy('code', 'ASC')->get();
|
||||
return TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -48,7 +49,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
{
|
||||
use ModifiesPiggyBanks;
|
||||
|
||||
private User $user;
|
||||
use UserGroupTrait;
|
||||
|
||||
public function destroyAll(): void
|
||||
{
|
||||
@@ -370,6 +371,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
public function leftOnAccount(PiggyBank $piggyBank, Account $account, Carbon $date): string
|
||||
{
|
||||
Log::debug(sprintf('leftOnAccount("%s","%s","%s")', $piggyBank->name, $account->name, $date->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('leftOnAccount: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date)['balance'];
|
||||
|
||||
Log::debug(sprintf('Balance is: %s', $balance));
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -137,6 +138,8 @@ interface PiggyBankRepositoryInterface
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
/**
|
||||
* Store new piggy bank.
|
||||
*
|
||||
|
||||
@@ -93,7 +93,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all of the user's recurring transactions.
|
||||
* Returns all the user's recurring transactions.
|
||||
*/
|
||||
public function get(): Collection
|
||||
{
|
||||
|
||||
@@ -43,8 +43,7 @@ use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\GroupUpdateService;
|
||||
use FireflyIII\Support\NullArrayObject;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -53,7 +52,7 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
{
|
||||
private User $user;
|
||||
use UserGroupTrait;
|
||||
|
||||
public function countAttachments(int $journalId): int
|
||||
{
|
||||
@@ -163,13 +162,6 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the note text for a journal (by ID).
|
||||
*/
|
||||
@@ -408,7 +400,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
{
|
||||
/** @var TransactionGroupFactory $factory */
|
||||
$factory = app(TransactionGroupFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
$factory->setUser($data['user']);
|
||||
$factory->setUserGroup($data['user_group']);
|
||||
|
||||
try {
|
||||
return $factory->create($data);
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Support\NullArrayObject;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
@@ -99,6 +100,8 @@ interface TransactionGroupRepositoryInterface
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
/**
|
||||
* Create a new transaction group.
|
||||
*
|
||||
|
||||
@@ -108,6 +108,6 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
|
||||
#[\Override]
|
||||
public function getAll(): Collection
|
||||
{
|
||||
return $this->userGroup->currencyExchangeRates()->get();
|
||||
return $this->userGroup->currencyExchangeRates()->orderBy('date', 'ASC')->get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,9 +659,10 @@ trait AccountServiceTrait
|
||||
|
||||
// submit to factory:
|
||||
$submission = [
|
||||
'group_title' => null,
|
||||
'user' => $account->user_id,
|
||||
'transactions' => [
|
||||
'group_title' => null,
|
||||
'user' => $account->user,
|
||||
'user_group' => $account->user->userGroup,
|
||||
'transactions' => [
|
||||
[
|
||||
'type' => 'Opening balance',
|
||||
'date' => $openingBalanceDate,
|
||||
@@ -669,7 +670,8 @@ trait AccountServiceTrait
|
||||
'source_name' => $sourceName,
|
||||
'destination_id' => $destId,
|
||||
'destination_name' => $destName,
|
||||
'user' => $account->user_id,
|
||||
'user' => $account->user,
|
||||
'user_group' => $account->user->userGroup,
|
||||
'currency_id' => $currency->id,
|
||||
'order' => 0,
|
||||
'amount' => $amount,
|
||||
|
||||
@@ -203,8 +203,7 @@ class FrontpageChartGenerator
|
||||
$amount = $limit->native_amount;
|
||||
Log::debug(sprintf('Amount is now "%s".', $amount));
|
||||
}
|
||||
|
||||
|
||||
$amount = null === $amount ? '0' : $amount;
|
||||
$sumSpent = bcmul($entry['sum'], '-1'); // spent
|
||||
$data[0]['entries'][$title] ??= '0';
|
||||
$data[1]['entries'][$title] ??= '0';
|
||||
|
||||
@@ -513,7 +513,7 @@ class ExportDataGenerator
|
||||
'currency_code', 'foreign_currency_code', 'source_name', 'source_type', 'destination_name', 'destination_type', 'amount', 'foreign_amount', 'category', 'budget', 'piggy_bank', 'tags',
|
||||
];
|
||||
$records = [];
|
||||
$recurrences = $recurringRepos->getAll();
|
||||
$recurrences = $recurringRepos->get();
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
foreach ($recurrences as $recurrence) {
|
||||
|
||||
@@ -88,6 +88,11 @@ class ExchangeRateConverter
|
||||
|
||||
return '1';
|
||||
}
|
||||
if ($from->id === $to->id) {
|
||||
Log::debug('ExchangeRateConverter: From and to are the same, return "1".');
|
||||
|
||||
return '1';
|
||||
}
|
||||
$rate = $this->getRate($from, $to, $date);
|
||||
|
||||
return '0' === $rate ? '1' : $rate;
|
||||
@@ -103,7 +108,7 @@ class ExchangeRateConverter
|
||||
|
||||
// find in cache
|
||||
if (null !== $res) {
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return cached rate from #%d to #%d on %s.', $from->id, $to->id, $date->format('Y-m-d')));
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return cached rate from %s to %s on %s.', $from->code, $to->code, $date->format('Y-m-d')));
|
||||
|
||||
return $res;
|
||||
}
|
||||
@@ -112,7 +117,7 @@ class ExchangeRateConverter
|
||||
$rate = $this->getFromDB($from->id, $to->id, $date->format('Y-m-d'));
|
||||
if (null !== $rate) {
|
||||
Cache::forever($key, $rate);
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return DB rate from #%d to #%d on %s.', $from->id, $to->id, $date->format('Y-m-d')));
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return DB rate from %s to %s on %s.', $from->code, $to->code, $date->format('Y-m-d')));
|
||||
|
||||
return $rate;
|
||||
}
|
||||
@@ -122,7 +127,7 @@ class ExchangeRateConverter
|
||||
if (null !== $rate) {
|
||||
$rate = bcdiv('1', $rate);
|
||||
Cache::forever($key, $rate);
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return inverse DB rate from #%d to #%d on %s.', $from->id, $to->id, $date->format('Y-m-d')));
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return inverse DB rate from %s to %s on %s.', $from->code, $to->code, $date->format('Y-m-d')));
|
||||
|
||||
return $rate;
|
||||
}
|
||||
@@ -133,14 +138,14 @@ class ExchangeRateConverter
|
||||
|
||||
// combined (if present), they can be used to calculate the necessary conversion rate.
|
||||
if (0 === bccomp('0', $first) || 0 === bccomp('0', $second)) {
|
||||
Log::warning(sprintf('$first is "%s" and $second is "%s"', $first, $second));
|
||||
Log::warning(sprintf('There is not enough information to convert %s to %s on date %s', $from->code, $to->code, $date->format('Y-m-d')));
|
||||
|
||||
return '1';
|
||||
}
|
||||
|
||||
$second = bcdiv('1', $second);
|
||||
$rate = bcmul($first, $second);
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return DB rate from #%d to #%d on %s.', $from->id, $to->id, $date->format('Y-m-d')));
|
||||
Log::debug(sprintf('ExchangeRateConverter: Return DB rate from %s to %s on %s.', $from->code, $to->code, $date->format('Y-m-d')));
|
||||
Cache::forever($key, $rate);
|
||||
|
||||
return $rate;
|
||||
@@ -154,6 +159,8 @@ class ExchangeRateConverter
|
||||
private function getFromDB(int $from, int $to, string $date): ?string
|
||||
{
|
||||
if ($from === $to) {
|
||||
Log::debug('ExchangeRateConverter: From and to are the same, return "1".');
|
||||
|
||||
return '1';
|
||||
}
|
||||
$key = sprintf('cer-%d-%d-%s', $from, $to, $date);
|
||||
@@ -173,7 +180,7 @@ class ExchangeRateConverter
|
||||
if ('' === $rate) {
|
||||
return null;
|
||||
}
|
||||
Log::debug(sprintf('ExchangeRateConverter: Found !cached! rate from #%d to #%d on %s.', $from, $to, $date));
|
||||
Log::debug(sprintf('ExchangeRateConverter: Found cached rate from #%d to #%d on %s.', $from, $to, $date));
|
||||
|
||||
return $rate;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
trait ValidatesUserGroupTrait
|
||||
{
|
||||
protected ?UserGroup $userGroup = null;
|
||||
|
||||
/**
|
||||
* An "undocumented" filter
|
||||
*
|
||||
@@ -59,7 +61,7 @@ trait ValidatesUserGroupTrait
|
||||
$user = auth()->user();
|
||||
$groupId = 0;
|
||||
if (!$request->has('user_group_id')) {
|
||||
$groupId = $user->user_group_id;
|
||||
$groupId = (int) $user->user_group_id;
|
||||
Log::debug(sprintf('validateUserGroup: no user group submitted, use default group #%d.', $groupId));
|
||||
}
|
||||
if ($request->has('user_group_id')) {
|
||||
@@ -98,6 +100,7 @@ trait ValidatesUserGroupTrait
|
||||
foreach ($roles as $role) {
|
||||
if ($user->hasRoleInGroupOrOwner($group, $role)) {
|
||||
Log::debug(sprintf('validateUserGroup: User has role "%s" in group #%d, return the group.', $role->value, $groupId));
|
||||
$this->userGroup = $group;
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Trait ChartGeneration
|
||||
@@ -57,7 +58,7 @@ trait ChartGeneration
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
app('log')->debug('Regenerate chart.account.account-balance-chart from scratch.');
|
||||
Log::debug('Regenerate chart.account.account-balance-chart from scratch.');
|
||||
$locale = app('steam')->getLocale();
|
||||
|
||||
/** @var GeneratorInterface $generator */
|
||||
@@ -69,12 +70,16 @@ trait ChartGeneration
|
||||
$default = app('amount')->getNativeCurrency();
|
||||
$chartData = [];
|
||||
|
||||
Log::debug(sprintf('Start of accountBalanceChart(list, %s, %s)', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
Log::debug(sprintf('Now at account #%d ("%s)', $account->id, $account->name));
|
||||
$currency = $accountRepos->getAccountCurrency($account) ?? $default;
|
||||
$useNative = $convertToNative && $default->id !== $currency->id;
|
||||
$field = $useNative ? 'native_balance' : 'balance';
|
||||
$field = $convertToNative ? 'native_balance' : 'balance';
|
||||
$currency = $useNative ? $default : $currency;
|
||||
Log::debug(sprintf('Will use field %s', $field));
|
||||
$currentSet = [
|
||||
'label' => $account->name,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
@@ -82,8 +87,9 @@ trait ChartGeneration
|
||||
];
|
||||
|
||||
$currentStart = clone $start;
|
||||
$range = Steam::finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);
|
||||
$range = Steam::finalAccountBalanceInRange($account, clone $start, clone $end, $this->convertToNative);
|
||||
$previous = array_values($range)[0];
|
||||
Log::debug(sprintf('Start balance for account #%d ("%s) is', $account->id, $account->name), $previous);
|
||||
while ($currentStart <= $end) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
$label = trim($currentStart->isoFormat((string) trans('config.month_and_day_js', [], $locale)));
|
||||
|
||||
@@ -203,11 +203,10 @@ trait PeriodOverview
|
||||
$currencySymbol = $journal['currency_symbol'];
|
||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||
$foreignCurrencyId = $journal['foreign_currency_id'];
|
||||
$amount = $journal['amount'];
|
||||
|
||||
$amount = $journal['amount'] ?? '0';
|
||||
|
||||
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId !== $this->defaultCurrency->id) {
|
||||
$amount = $journal['native_amount'];
|
||||
$amount = $journal['native_amount'] ?? '0';
|
||||
$currencyId = $this->defaultCurrency->id;
|
||||
$currencyCode = $this->defaultCurrency->code;
|
||||
$currencyName = $this->defaultCurrency->name;
|
||||
@@ -220,7 +219,7 @@ trait PeriodOverview
|
||||
$currencyName = $journal['foreign_currency_name'];
|
||||
$currencySymbol = $journal['foreign_currency_symbol'];
|
||||
$currencyDecimalPlaces = $journal['foreign_currency_decimal_places'];
|
||||
$amount = $journal['foreign_amount'];
|
||||
$amount = $journal['foreign_amount'] ?? '0';
|
||||
}
|
||||
$return[$currencyId] ??= [
|
||||
'amount' => '0',
|
||||
|
||||
@@ -51,6 +51,7 @@ class TransactionSummarizer
|
||||
|
||||
public function groupByCurrencyId(array $journals, string $method = 'negative'): array
|
||||
{
|
||||
Log::debug(sprintf('Now in groupByCurrencyId(array, "%s")', $method));
|
||||
$array = [];
|
||||
foreach ($journals as $journal) {
|
||||
$field = 'amount';
|
||||
@@ -61,6 +62,10 @@ class TransactionSummarizer
|
||||
$currencySymbol = $journal['currency_symbol'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||
|
||||
// prepare foreign currency info:
|
||||
$foreignCurrencyId = 0;
|
||||
|
||||
if ($this->convertToNative) {
|
||||
// if convert to native, use the native amount yes or no?
|
||||
$useNative = $this->default->id !== (int) $journal['currency_id'];
|
||||
@@ -85,8 +90,18 @@ class TransactionSummarizer
|
||||
}
|
||||
}
|
||||
if (!$this->convertToNative) {
|
||||
// default to the normal amount, but also
|
||||
Log::debug(sprintf('Journal #%d also includes foreign amount (foreign is %s)', $journal['transaction_journal_id'], $journal['foreign_currency_code']));
|
||||
// use foreign amount?
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$foreignCurrencyName = $journal['foreign_currency_name'];
|
||||
$foreignCurrencySymbol = $journal['foreign_currency_symbol'];
|
||||
$foreignCurrencyCode = $journal['foreign_currency_code'];
|
||||
$foreignCurrencyDecimalPlaces = $journal['foreign_currency_decimal_places'];
|
||||
}
|
||||
}
|
||||
|
||||
// first process normal amount
|
||||
$amount = (string) ($journal[$field] ?? '0');
|
||||
$array[$currencyId] ??= [
|
||||
'sum' => '0',
|
||||
@@ -96,12 +111,34 @@ class TransactionSummarizer
|
||||
'currency_code' => $currencyCode,
|
||||
'currency_decimal_places' => $currencyDecimalPlaces,
|
||||
];
|
||||
|
||||
if ('positive' === $method) {
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->positive($amount));
|
||||
}
|
||||
if ('negative' === $method) {
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($amount));
|
||||
}
|
||||
|
||||
// then process foreign amount, if it exists.
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$amount = (string) ($journal['foreign_amount'] ?? '0');
|
||||
$array[$foreignCurrencyId] ??= [
|
||||
'sum' => '0',
|
||||
'currency_id' => $foreignCurrencyId,
|
||||
'currency_name' => $foreignCurrencyName,
|
||||
'currency_symbol' => $foreignCurrencySymbol,
|
||||
'currency_code' => $foreignCurrencyCode,
|
||||
'currency_decimal_places' => $foreignCurrencyDecimalPlaces,
|
||||
];
|
||||
|
||||
if ('positive' === $method) {
|
||||
$array[$foreignCurrencyId]['sum'] = bcadd($array[$foreignCurrencyId]['sum'], app('steam')->positive($amount));
|
||||
}
|
||||
if ('negative' === $method) {
|
||||
$array[$foreignCurrencyId]['sum'] = bcadd($array[$foreignCurrencyId]['sum'], app('steam')->negative($amount));
|
||||
}
|
||||
}
|
||||
|
||||
// $array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->{$method}($amount));
|
||||
// Log::debug(sprintf('Journal #%d adds amount %s %s', $journal['transaction_journal_id'], $currencyCode, $amount));
|
||||
}
|
||||
|
||||
@@ -24,30 +24,48 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Repositories\UserGroup;
|
||||
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\GroupMembership;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Trait UserGroupTrait
|
||||
*/
|
||||
trait UserGroupTrait
|
||||
{
|
||||
protected User $user;
|
||||
protected UserGroup $userGroup;
|
||||
protected ?User $user = null;
|
||||
protected ?UserGroup $userGroup = null;
|
||||
|
||||
public function getUserGroup(): UserGroup
|
||||
{
|
||||
return $this->userGroup;
|
||||
}
|
||||
|
||||
public function checkUserGroupAccess(UserRoleEnum $role): bool
|
||||
{
|
||||
$result = $this->user->hasRoleInGroupOrOwner($this->userGroup, $role);
|
||||
if ($result) {
|
||||
Log::debug(sprintf('User #%d has role %s in group #%d or is owner/full.', $this->user->id, $role->value, $this->userGroup->id));
|
||||
|
||||
return true;
|
||||
}
|
||||
Log::warning(sprintf('User #%d DOES NOT have role %s in group #%d.', $this->user->id, $role->value, $this->userGroup->id));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO This method does not check if the user has access to this particular user group.
|
||||
*/
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
if (null === $this->user) {
|
||||
Log::warning(sprintf('User is not set in repository %s', static::class));
|
||||
}
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
|
||||
@@ -62,7 +80,11 @@ trait UserGroupTrait
|
||||
throw new FireflyException(sprintf('User #%d has no user group.', $user->id));
|
||||
}
|
||||
$this->userGroup = $user->userGroup;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new FireflyException(sprintf('Object is of class %s, not User.', get_class($user)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +92,7 @@ trait UserGroupTrait
|
||||
*/
|
||||
public function setUserGroupById(int $userGroupId): void
|
||||
{
|
||||
$memberships = GroupMembership::where('user_id', $this->user->id)
|
||||
$memberships = GroupMembership::where('user_id', $this->user->id)
|
||||
->where('user_group_id', $userGroupId)
|
||||
->count()
|
||||
;
|
||||
@@ -79,10 +101,10 @@ trait UserGroupTrait
|
||||
}
|
||||
|
||||
/** @var null|UserGroup $userGroup */
|
||||
$userGroup = UserGroup::find($userGroupId);
|
||||
$userGroup = UserGroup::find($userGroupId);
|
||||
if (null === $userGroup) {
|
||||
throw new FireflyException(sprintf('Cannot find administration for user #%d', $this->user->id));
|
||||
}
|
||||
$this->userGroup = $userGroup;
|
||||
$this->setUserGroup($userGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,4 +55,36 @@ abstract class Node
|
||||
return $this->prohibited;
|
||||
|
||||
}
|
||||
|
||||
public function equals(self $compare): bool
|
||||
{
|
||||
if ($compare->isProhibited(false) !== $this->isProhibited(false)) {
|
||||
Log::debug('Return false because prohibited status is different');
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($compare instanceof NodeGroup && $this instanceof NodeGroup) {
|
||||
if (count($compare->getNodes()) !== count($this->getNodes())) {
|
||||
Log::debug(sprintf('Return false because node count is different. Original is %d, compare is %d', count($this->getNodes()), count($compare->getNodes())));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int $index
|
||||
* @var Node $node
|
||||
*/
|
||||
foreach ($this->getNodes() as $index => $node) {
|
||||
if (false === $node->equals($compare->getNodes()[$index])) {
|
||||
Log::debug('Return false because nodes are different!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ class QueryParser implements QueryParserInterface
|
||||
|
||||
while ($this->position < strlen($this->query)) {
|
||||
$char = $this->query[$this->position];
|
||||
// Log::debug(sprintf('Char #%d: %s', $this->position, $char));
|
||||
|
||||
// If we're in a quoted string, we treat all characters except another quote as ordinary characters
|
||||
if ($inQuotes) {
|
||||
@@ -150,15 +151,19 @@ class QueryParser implements QueryParserInterface
|
||||
|
||||
|
||||
case ':':
|
||||
if ('' !== $tokenUnderConstruction) {
|
||||
$skipNext = false;
|
||||
if ('' === $tokenUnderConstruction) {
|
||||
// In any other location, it's just a normal character
|
||||
$tokenUnderConstruction .= $char;
|
||||
$skipNext = true;
|
||||
}
|
||||
if ('' !== $tokenUnderConstruction && !$skipNext) { // @phpstan-ignore-line
|
||||
Log::debug(sprintf('Turns out that "%s" is a field name. Reset the token.', $tokenUnderConstruction));
|
||||
// If we meet a colon with a left-hand side string, we know we're in a field and are about to set up the value
|
||||
$fieldName = $tokenUnderConstruction;
|
||||
$tokenUnderConstruction = '';
|
||||
}
|
||||
if ('' === $tokenUnderConstruction) { // @phpstan-ignore-line
|
||||
// In any other location, it's just a normal character
|
||||
$tokenUnderConstruction .= $char;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -28,10 +28,11 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
|
||||
/**
|
||||
* Class Steam.
|
||||
@@ -58,8 +59,8 @@ class Steam
|
||||
public function finalAccountBalanceInRange(Account $account, Carbon $start, Carbon $end, bool $convertToNative): array
|
||||
{
|
||||
// expand period.
|
||||
$start->subDay()->startOfDay();
|
||||
$end->addDay()->endOfDay();
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
Log::debug(sprintf('finalAccountBalanceInRange(#%d, %s, %s)', $account->id, $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
// set up cache
|
||||
@@ -67,6 +68,7 @@ class Steam
|
||||
$cache->addProperty($account->id);
|
||||
$cache->addProperty('final-balance-in-range');
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($convertToNative);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
@@ -74,101 +76,100 @@ class Steam
|
||||
|
||||
$balances = [];
|
||||
$formatted = $start->format('Y-m-d');
|
||||
$startBalance = $this->finalAccountBalance($account, $start);
|
||||
$defaultCurrency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
|
||||
/*
|
||||
* To make sure the start balance is correct, we need to get the balance at the exact end of the previous day.
|
||||
* Since we just did "startOfDay" we can do subDay()->endOfDay() to get the correct moment.
|
||||
* THAT will be the start balance.
|
||||
*/
|
||||
$request = clone $start;
|
||||
$request->subDay()->endOfDay();
|
||||
Log::debug(sprintf('finalAccountBalanceInRange: Call finalAccountBalance with date/time "%s"', $request->toIso8601String()));
|
||||
$startBalance = $this->finalAccountBalance($account, $request);
|
||||
$nativeCurrency = app('amount')->getNativeCurrencyByUserGroup($account->user->userGroup);
|
||||
$accountCurrency = $this->getAccountCurrency($account);
|
||||
$hasCurrency = null !== $accountCurrency;
|
||||
$currency = $accountCurrency ?? $defaultCurrency;
|
||||
$currency = $accountCurrency ?? $nativeCurrency;
|
||||
Log::debug(sprintf('Currency is %s', $currency->code));
|
||||
|
||||
|
||||
// set start balances:
|
||||
$startBalance[$currency->code] ??= '0';
|
||||
if ($hasCurrency) {
|
||||
$startBalance[$accountCurrency->code] ??= '0';
|
||||
}
|
||||
if (!$hasCurrency) {
|
||||
Log::debug(sprintf('Also set start balance in %s', $defaultCurrency->code));
|
||||
$startBalance[$defaultCurrency->code] ??= '0';
|
||||
Log::debug(sprintf('Also set start balance in %s', $nativeCurrency->code));
|
||||
$startBalance[$nativeCurrency->code] ??= '0';
|
||||
}
|
||||
$currencies = [
|
||||
$currency->id => $currency,
|
||||
$defaultCurrency->id => $defaultCurrency,
|
||||
$currency->id => $currency,
|
||||
$nativeCurrency->id => $nativeCurrency,
|
||||
];
|
||||
|
||||
|
||||
$startBalance[$currency->code] ??= '0';
|
||||
$balances[$formatted] = $startBalance;
|
||||
Log::debug('Final start balance: ', $startBalance);
|
||||
|
||||
|
||||
// sums up the balance changes per day, for foreign, native and normal amounts.
|
||||
// sums up the balance changes per day.
|
||||
Log::debug(sprintf('Date >= %s and <= %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
$set = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d H:i:s'))
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d H:i:s'))
|
||||
->groupBy('transaction_journals.date')
|
||||
->groupBy('transactions.transaction_currency_id')
|
||||
->groupBy('transactions.foreign_currency_id')
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->get(
|
||||
[ // @phpstan-ignore-line
|
||||
'transaction_journals.date',
|
||||
'transactions.transaction_currency_id',
|
||||
DB::raw('SUM(transactions.amount) AS modified'),
|
||||
'transactions.foreign_currency_id',
|
||||
DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
|
||||
DB::raw('SUM(transactions.native_amount) AS modified_native'),
|
||||
DB::raw('SUM(transactions.amount) AS sum_of_day'),
|
||||
]
|
||||
)
|
||||
;
|
||||
|
||||
$currentBalance = $startBalance;
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
|
||||
/** @var Transaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
// normal, native and foreign amount
|
||||
$carbon = new Carbon($entry->date, $entry->date_tz);
|
||||
$modified = (string) (null === $entry->modified ? '0' : $entry->modified);
|
||||
$foreignModified = (string) (null === $entry->modified_foreign ? '0' : $entry->modified_foreign);
|
||||
$nativeModified = (string) (null === $entry->modified_native ? '0' : $entry->modified_native);
|
||||
// get date object
|
||||
$carbon = new Carbon($entry->date, $entry->date_tz);
|
||||
$carbonKey = $carbon->format('Y-m-d');
|
||||
// make sure sum is a string:
|
||||
$sumOfDay = (string) (null === $entry->sum_of_day ? '0' : $entry->sum_of_day);
|
||||
|
||||
// find currency of this entry.
|
||||
// find currency of this entry, does not have to exist.
|
||||
$currencies[$entry->transaction_currency_id] ??= TransactionCurrency::find($entry->transaction_currency_id);
|
||||
|
||||
// make sure this $entry has its own $entryCurrency
|
||||
/** @var TransactionCurrency $entryCurrency */
|
||||
$entryCurrency = $currencies[$entry->transaction_currency_id];
|
||||
$entryCurrency = $currencies[$entry->transaction_currency_id];
|
||||
|
||||
Log::debug(sprintf('Processing transaction(s) on date %s', $carbon->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('Processing transaction(s) on moment %s', $carbon->format('Y-m-d H:i:s')));
|
||||
|
||||
// if convert to native, if NOT convert to native.
|
||||
if ($convertToNative) {
|
||||
Log::debug(sprintf('Amount is %s %s, foreign amount is %s, native amount is %s', $entryCurrency->code, $this->bcround($modified, 2), $this->bcround($foreignModified, 2), $this->bcround($nativeModified, 2)));
|
||||
// if the currency is the default currency add to native balance + currency balance
|
||||
if ($entry->transaction_currency_id === $defaultCurrency->id) {
|
||||
Log::debug('Add amount to native.');
|
||||
$currentBalance['native_balance'] = bcadd($currentBalance['native_balance'], $modified);
|
||||
}
|
||||
// add amount to current balance in currency code.
|
||||
$currentBalance[$entryCurrency->code] ??= '0';
|
||||
$currentBalance[$entryCurrency->code] = bcadd($sumOfDay, $currentBalance[$entryCurrency->code]);
|
||||
|
||||
// add to native balance.
|
||||
if ($entry->foreign_currency_id !== $defaultCurrency->id) {
|
||||
// this check is not necessary, because if the foreign currency is the same as the default currency, the native amount is zero.
|
||||
// so adding this would mean nothing.
|
||||
$currentBalance['native_balance'] = bcadd($currentBalance['native_balance'], $nativeModified);
|
||||
}
|
||||
if ($entry->foreign_currency_id === $defaultCurrency->id) {
|
||||
$currentBalance['native_balance'] = bcadd($currentBalance['native_balance'], $foreignModified);
|
||||
}
|
||||
// add to balance if is the same.
|
||||
if ($entry->transaction_currency_id === $accountCurrency?->id) {
|
||||
$currentBalance['balance'] = bcadd($currentBalance['balance'], $modified);
|
||||
}
|
||||
// add currency balance
|
||||
$currentBalance[$entryCurrency->code] = bcadd($currentBalance[$entryCurrency->code] ?? '0', $modified);
|
||||
}
|
||||
// if not convert to native, add the amount to "balance", do nothing else.
|
||||
if (!$convertToNative) {
|
||||
Log::debug(sprintf('Amount is %s %s, foreign amount is %s, native amount is %s', $entryCurrency->code, $modified, $foreignModified, $nativeModified));
|
||||
// add to balance, as expected.
|
||||
$currentBalance['balance'] = bcadd($currentBalance['balance'] ?? '0', $modified);
|
||||
// add to GBP, as expected.
|
||||
$currentBalance[$entryCurrency->code] = bcadd($currentBalance[$entryCurrency->code] ?? '0', $modified);
|
||||
$currentBalance['balance'] = bcadd($currentBalance['balance'], $sumOfDay);
|
||||
}
|
||||
$balances[$carbon->format('Y-m-d')] = $currentBalance;
|
||||
Log::debug('Updated entry', $currentBalance);
|
||||
// if convert to native add the converted amount to "native_balance".
|
||||
// if there is a request to convert, convert to "native_balance" and use "balance" for whichever amount is in the native currency.
|
||||
if ($convertToNative) {
|
||||
$nativeSumOfDay = $converter->convert($entryCurrency, $nativeCurrency, $carbon, $sumOfDay);
|
||||
$currentBalance['native_balance'] = bcadd($currentBalance['native_balance'], $nativeSumOfDay);
|
||||
if ($currency->id === $entryCurrency->id) {
|
||||
$currentBalance['balance'] = bcadd($currentBalance['balance'], $sumOfDay);
|
||||
}
|
||||
|
||||
}
|
||||
// just set it.
|
||||
$balances[$carbonKey] = $currentBalance;
|
||||
Log::debug(sprintf('Updated entry [%s]', $carbonKey), $currentBalance);
|
||||
}
|
||||
$cache->store($balances);
|
||||
Log::debug('End of method');
|
||||
@@ -178,6 +179,7 @@ class Steam
|
||||
|
||||
public function finalAccountsBalance(Collection $accounts, Carbon $date): array
|
||||
{
|
||||
Log::debug(sprintf('finalAccountsBalance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balances = [];
|
||||
foreach ($accounts as $account) {
|
||||
$balances[$account->id] = $this->finalAccountBalance($account, $date);
|
||||
@@ -274,117 +276,80 @@ class Steam
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns smaller than or equal to, so be careful with END OF DAY.
|
||||
*
|
||||
* Returns the balance of an account at exact moment given. Array with at least one value.
|
||||
* Always returns:
|
||||
* "balance": balance in the account's currency OR user's native currency if the account has no currency
|
||||
* "EUR": balance in EUR (or whatever currencies the account has balance in)
|
||||
*
|
||||
* "balance" the balance in whatever currency the account has, so the sum of all transaction that happen to have
|
||||
* THAT currency.
|
||||
* "native_balance" the balance according to the "native_amount" + "native_foreign_amount" fields.
|
||||
* "ABC" the balance in this particular currency code (may repeat for each found currency).
|
||||
*
|
||||
* Het maakt niet uit of de native currency wel of niet gelijk is aan de account currency.
|
||||
* Optelsom zou hetzelfde moeten zijn. Als het EUR is en de rekening ook is native_amount 0.
|
||||
* Zo niet is amount 0 en native_amount het bedrag.
|
||||
*
|
||||
* Eerst een som van alle transacties in de native currency. Alle EUR bij elkaar opgeteld.
|
||||
* Om te weten wat er nog meer op de rekening gebeurt, pak alles waar currency niet EUR is, en de foreign ook niet,
|
||||
* en tel native_amount erbij op.
|
||||
* Daarna pak je alle transacties waar currency niet EUR is, en de foreign wel, en tel foreign_amount erbij op.
|
||||
*
|
||||
* Wil je niks weten van native currencies, pak je:
|
||||
*
|
||||
* Eerst een som van alle transacties gegroepeerd op currency. Einde.
|
||||
* If the user has $convertToNative:
|
||||
* "balance": balance in the account's currency OR user's native currency if the account has no currency
|
||||
* --> "native_balance": balance in the user's native balance, with all amounts converted to native.
|
||||
* "EUR": balance in EUR (or whatever currencies the account has balance in)
|
||||
*/
|
||||
public function finalAccountBalance(Account $account, Carbon $date): array
|
||||
{
|
||||
$cache = new CacheProperties();
|
||||
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($account->id);
|
||||
$cache->addProperty($date);
|
||||
if ($cache->has()) {
|
||||
// Log::debug(sprintf('CACHED finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s')));
|
||||
return $cache->get();
|
||||
}
|
||||
Log::debug(sprintf('finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s')));
|
||||
|
||||
Log::debug(sprintf('Now in finalAccountBalance(#%d, "%s", "%s")', $account->id, $account->name, $date->format('Y-m-d H:i:s')));
|
||||
|
||||
$native = Amount::getNativeCurrencyByUserGroup($account->user->userGroup);
|
||||
$convertToNative = Amount::convertToNative($account->user);
|
||||
$accountCurrency = $this->getAccountCurrency($account);
|
||||
$hasCurrency = null !== $accountCurrency;
|
||||
$currency = $hasCurrency ? $accountCurrency : $native;
|
||||
$return = [];
|
||||
|
||||
// first, the "balance", as described earlier.
|
||||
if ($convertToNative) {
|
||||
// normal balance
|
||||
$return['balance'] = (string) $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||
->where('transactions.transaction_currency_id', $native->id)
|
||||
->sum('transactions.amount')
|
||||
;
|
||||
// plus virtual balance, if the account has a virtual_balance in the native currency
|
||||
if ($native->id === $accountCurrency?->id) {
|
||||
$return['balance'] = bcadd('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance, $return['balance']);
|
||||
}
|
||||
// Log::debug(sprintf('balance is (%s only) %s (with virtual balance)', $native->code, $this->bcround($return['balance'], 2)));
|
||||
|
||||
// native balance
|
||||
$return['native_balance'] = (string) $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||
->whereNot('transactions.transaction_currency_id', $native->id)
|
||||
->sum('transactions.native_amount')
|
||||
;
|
||||
// plus native virtual balance.
|
||||
$return['native_balance'] = bcadd('' === (string) $account->native_virtual_balance ? '0' : $account->native_virtual_balance, $return['native_balance']);
|
||||
// Log::debug(sprintf('native_balance is (all transactions to %s) %s (with virtual balance)', $native->code, $this->bcround($return['native_balance'])));
|
||||
|
||||
// plus foreign transactions in THIS currency.
|
||||
$sum = (string) $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||
->whereNot('transactions.transaction_currency_id', $native->id)
|
||||
->where('transactions.foreign_currency_id', $native->id)
|
||||
->sum('transactions.foreign_amount')
|
||||
;
|
||||
$return['native_balance'] = bcadd($return['native_balance'], $sum);
|
||||
|
||||
// Log::debug(sprintf('Foreign amount transactions add (%s only) %s, total native_balance is now %s', $native->code, $this->bcround($sum), $this->bcround($return['native_balance'])));
|
||||
}
|
||||
|
||||
// balance(s) in other (all) currencies.
|
||||
$array = $account->transactions()
|
||||
$native = Amount::getNativeCurrencyByUserGroup($account->user->userGroup);
|
||||
$convertToNative = Amount::convertToNative($account->user);
|
||||
$accountCurrency = $this->getAccountCurrency($account);
|
||||
$hasCurrency = null !== $accountCurrency;
|
||||
$currency = $hasCurrency ? $accountCurrency : $native;
|
||||
$return = [
|
||||
'native_balance' => '0',
|
||||
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
|
||||
];
|
||||
// balance(s) in all currencies.
|
||||
$array = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d H:i:s'))
|
||||
->get(['transaction_currencies.code', 'transactions.amount'])->toArray()
|
||||
;
|
||||
$others = $this->groupAndSumTransactions($array, 'code', 'amount');
|
||||
$others = $this->groupAndSumTransactions($array, 'code', 'amount');
|
||||
// Log::debug('All balances are (joined)', $others);
|
||||
// if the account has no own currency preference, drop balance in favor of native balance
|
||||
if ($hasCurrency && !$convertToNative) {
|
||||
$return['balance'] = $others[$currency->code] ?? '0';
|
||||
$return['native_balance'] = $others[$currency->code] ?? '0';
|
||||
// Log::debug(sprintf('Set balance + native_balance to %s', $return['balance']));
|
||||
// if there is no request to convert, take this as "balance" and "native_balance".
|
||||
$return['balance'] = $others[$currency->code] ?? '0';
|
||||
if (!$convertToNative) {
|
||||
unset($return['native_balance']);
|
||||
// Log::debug(sprintf('Set balance to %s, unset native_balance', $return['balance']));
|
||||
}
|
||||
// if there is a request to convert, convert to "native_balance" and use "balance" for whichever amount is in the native currency.
|
||||
if ($convertToNative) {
|
||||
$return['native_balance'] = $this->convertAllBalances($others, $native, $date); // todo sum all and convert.
|
||||
// Log::debug(sprintf('Set native_balance to %s', $return['native_balance']));
|
||||
}
|
||||
|
||||
// if the currency is the same as the native currency, set the native_balance to the balance for consistency.
|
||||
// if($currency->id === $native->id) {
|
||||
// $return['native_balance'] = $return['balance'];
|
||||
// }
|
||||
// either way, the balance is always combined with the virtual balance:
|
||||
$virtualBalance = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
|
||||
|
||||
if (!$hasCurrency && array_key_exists('balance', $return)) {
|
||||
// Log::debug('Account has no currency preference, dropping balance in favor of native balance.');
|
||||
$sum = bcadd($return['balance'], $return['native_balance']);
|
||||
// Log::debug(sprintf('%s + %s = %s', $return['balance'], $return['native_balance'], $sum));
|
||||
$return['native_balance'] = $sum;
|
||||
unset($return['balance']);
|
||||
if ($convertToNative) {
|
||||
// the native balance is combined with a converted virtual_balance:
|
||||
$converter = new ExchangeRateConverter();
|
||||
$nativeVirtualBalance = $converter->convert($currency, $native, $date, $virtualBalance);
|
||||
$return['native_balance'] = bcadd($nativeVirtualBalance, $return['native_balance']);
|
||||
// Log::debug(sprintf('Native virtual balance makes the native total %s', $return['native_balance']));
|
||||
}
|
||||
$final = array_merge($return, $others);
|
||||
// Log::debug('Return is', $final);
|
||||
if (!$convertToNative) {
|
||||
// if not, also increase the balance + native balance for consistency.
|
||||
$return['balance'] = bcadd($return['balance'], $virtualBalance);
|
||||
// Log::debug(sprintf('Virtual balance makes the (native) total %s', $return['balance']));
|
||||
}
|
||||
$final = array_merge($return, $others);
|
||||
Log::debug('Final balance is', $final);
|
||||
$cache->store($final);
|
||||
|
||||
return array_merge($return, $others);
|
||||
// Log::debug('Return is', $final);
|
||||
return $final;
|
||||
}
|
||||
|
||||
public function filterAccountBalances(array $total, Account $account, bool $convertToNative, ?TransactionCurrency $currency = null): array
|
||||
@@ -410,17 +375,18 @@ class Steam
|
||||
$defaultCurrency = app('amount')->getNativeCurrency();
|
||||
if ($convertToNative) {
|
||||
if ($defaultCurrency->id === $currency?->id) {
|
||||
Log::debug(sprintf('Unset "native_balance" and "%s" for account #%d', $defaultCurrency->code, $account->id));
|
||||
unset($set['native_balance'], $set[$defaultCurrency->code]);
|
||||
Log::debug(sprintf('Unset [%s] for account #%d (no longer unset "native_balance")', $defaultCurrency->code, $account->id));
|
||||
unset($set[$defaultCurrency->code]);
|
||||
}
|
||||
// todo rethink this logic.
|
||||
if (null !== $currency && $defaultCurrency->id !== $currency->id) {
|
||||
Log::debug(sprintf('Unset balance for account #%d', $account->id));
|
||||
unset($set['balance']);
|
||||
}
|
||||
|
||||
if (null === $currency) {
|
||||
Log::debug(sprintf('TEMP DO NOT Drop defaultCurrency balance for account #%d', $account->id));
|
||||
// unset($set[$this->defaultCurrency->code]);
|
||||
Log::debug(sprintf('Unset balance for account #%d', $account->id));
|
||||
unset($set['balance']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,16 +394,15 @@ class Steam
|
||||
if (null === $currency) {
|
||||
Log::debug(sprintf('Unset native_balance and make defaultCurrency balance the balance for account #%d', $account->id));
|
||||
$set['balance'] = $set[$defaultCurrency->code] ?? '0';
|
||||
unset($set['native_balance'], $set[$defaultCurrency->code]);
|
||||
unset($set[$defaultCurrency->code]);
|
||||
}
|
||||
|
||||
if (null !== $currency) {
|
||||
Log::debug(sprintf('Unset native_balance + defaultCurrency + currencyCode balance for account #%d', $account->id));
|
||||
unset($set['native_balance'], $set[$defaultCurrency->code], $set[$currency->code]);
|
||||
Log::debug(sprintf('Unset [%s] + [%s] balance for account #%d', $defaultCurrency->code, $currency->code, $account->id));
|
||||
unset($set[$defaultCurrency->code], $set[$currency->code]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// put specific value first in array.
|
||||
if (array_key_exists('native_balance', $set)) {
|
||||
$set = ['native_balance' => $set['native_balance']] + $set;
|
||||
@@ -687,4 +652,21 @@ class Steam
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
private function convertAllBalances(array $others, TransactionCurrency $native, Carbon $date): string
|
||||
{
|
||||
$total = '0';
|
||||
$converter = new ExchangeRateConverter();
|
||||
foreach ($others as $key => $amount) {
|
||||
$currency = TransactionCurrency::where('code', $key)->first();
|
||||
if (null === $currency) {
|
||||
continue;
|
||||
}
|
||||
$current = $converter->convert($currency, $native, $date, $amount);
|
||||
Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $native->code, $current));
|
||||
$total = bcadd($current, $total);
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace FireflyIII\Support\Twig;
|
||||
use FireflyIII\Models\Account as AccountModel;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
@@ -112,8 +114,13 @@ class AmountFormat extends AbstractExtension
|
||||
static function (string $amount, string $code, ?bool $coloured = null): string {
|
||||
$coloured ??= true;
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
/** @var null|TransactionCurrency $currency */
|
||||
$currency = TransactionCurrency::whereCode($code)->first();
|
||||
if (null === $currency) {
|
||||
Log::error(sprintf('Could not find currency with code "%s". Fallback to native currency.', $code));
|
||||
$currency = Amount::getNativeCurrency();
|
||||
Log::error(sprintf('Fallback currency is "%s".', $currency->code));
|
||||
}
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
},
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Search\OperatorQuerySearch;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use League\CommonMark\GithubFlavoredMarkdownConverter;
|
||||
use Route;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
@@ -67,11 +68,13 @@ class General extends AbstractExtension
|
||||
|
||||
/** @var Carbon $date */
|
||||
$date = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
Log::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$info = Steam::finalAccountBalance($account, $date);
|
||||
$currency = Steam::getAccountCurrency($account);
|
||||
$default = Amount::getNativeCurrency();
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$useNative = $convertToNative && $default->id !== $currency->id;
|
||||
$currency = null === $currency ? $default : $currency;
|
||||
$strings = [];
|
||||
foreach ($info as $key => $balance) {
|
||||
if ('balance' === $key) {
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
@@ -106,6 +107,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
$order = null;
|
||||
}
|
||||
// balance, native balance, virtual balance, native virtual balance?
|
||||
Log::debug(sprintf('transform: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$finalBalance = Steam::finalAccountBalance($account, $date);
|
||||
if ($convertToNative) {
|
||||
$finalBalance['balance'] = $finalBalance[$currencyCode] ?? '0';
|
||||
|
||||
@@ -54,7 +54,7 @@ class PiggyBankEventTransformer extends AbstractTransformer
|
||||
public function transform(PiggyBankEvent $event): array
|
||||
{
|
||||
// get account linked to piggy bank
|
||||
$account = $event->piggyBank->account;
|
||||
$account = $event->piggyBank->accounts()->first();
|
||||
|
||||
// set up repositories.
|
||||
$this->repository->setUser($account->user);
|
||||
|
||||
@@ -99,10 +99,8 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
'id' => (string) $piggyBank->id,
|
||||
'created_at' => $piggyBank->created_at->toAtomString(),
|
||||
'updated_at' => $piggyBank->updated_at->toAtomString(),
|
||||
'accounts' => $this->renderAccounts($piggyBank),
|
||||
// 'account_id' => (string)$piggyBank->account_id,
|
||||
// 'account_name' => $piggyBank->account->name,
|
||||
'name' => $piggyBank->name,
|
||||
'accounts' => $this->renderAccounts($piggyBank),
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
@@ -134,9 +132,10 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
$return = [];
|
||||
foreach ($piggyBank->accounts()->get() as $account) {
|
||||
$return[] = [
|
||||
'id' => $account->id,
|
||||
'name' => $account->name,
|
||||
'current_amount' => (string) $account->pivot->current_amount,
|
||||
'id' => (string) $account->id,
|
||||
'name' => $account->name,
|
||||
'current_amount' => (string) $account->pivot->current_amount,
|
||||
'native_current_amount' => (string) $account->pivot->native_current_amount,
|
||||
// TODO add balance, add left to save.
|
||||
];
|
||||
}
|
||||
|
||||
@@ -183,6 +183,8 @@ class AccountTransformer extends AbstractTransformer
|
||||
$bEnd = [];
|
||||
|
||||
try {
|
||||
Log::debug(sprintf('v2 transformer: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('v2 transformer: finalAccountsBalance("%s")', $end->format('Y-m-d H:i:s')));
|
||||
$bStart = app('steam')->finalAccountsBalance($accounts, $start);
|
||||
$bEnd = app('steam')->finalAccountsBalance($accounts, $end);
|
||||
} catch (FireflyException $e) {
|
||||
|
||||
101
changelog.md
101
changelog.md
@@ -3,7 +3,106 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 6.2.0 - 2025-01-26 (or later)
|
||||
## 6.2.6 - 2025-02-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Issue 9797](https://github.com/firefly-iii/firefly-iii/issues/9797) (All account charts show a horizontal line) reported by @avee87
|
||||
- [Issue 9806](https://github.com/firefly-iii/firefly-iii/issues/9806) (Exchange Rates table fails to load when language is not English) reported by @polter-rnd
|
||||
- [Issue 9807](https://github.com/firefly-iii/firefly-iii/issues/9807) (Start Date of Reconciliation Period Incorrectly Excludes Transactions for That Day) reported by @pwschattenberg
|
||||
- [Issue 9808](https://github.com/firefly-iii/firefly-iii/issues/9808) (Default financial report line graph shows a different balance than the text) reported by @mtaygur
|
||||
- [Issue 9810](https://github.com/firefly-iii/firefly-iii/issues/9810) (Foreign amount not taken into consideration for budget spent/leaving) reported by @M4xS0ch
|
||||
- [Issue 9821](https://github.com/firefly-iii/firefly-iii/issues/9821) (piggy events api 500 error) reported by @4e868df3
|
||||
- [Issue 9826](https://github.com/firefly-iii/firefly-iii/issues/9826) (Wrong account balance) reported by @fabienfitoussi
|
||||
|
||||
## 6.2.5 - 2025-02-08
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Issue 9736](https://github.com/firefly-iii/firefly-iii/issues/9736) (Wrong `finalAccountBalance` result) reported by @gthbusrr
|
||||
- [Issue 9747](https://github.com/firefly-iii/firefly-iii/issues/9747) (Data entry issues with exchange rates) reported by @Azmodeszer
|
||||
- [Issue 9769](https://github.com/firefly-iii/firefly-iii/issues/9769) ("Your accounts" graph shows changes at wrong dates - not fixed by v6.2.4) reported by @SteffoSpieler
|
||||
- [Discussion 9780](https://github.com/orgs/firefly-iii/discussions/9780) (Rules or webhook precedence?) started by @joeshmoe57
|
||||
- [Issue 9781](https://github.com/firefly-iii/firefly-iii/issues/9781) (Search key `has_any_external_url:false` returns all transactions) reported by @joeshmoe57
|
||||
- [Issue 9783](https://github.com/firefly-iii/firefly-iii/issues/9783) (Subscriptions: Make "Not expected this period" and "expected x days from now" different colors) reported by @SteffoSpieler
|
||||
- [Issue 9784](https://github.com/firefly-iii/firefly-iii/issues/9784) (Transfers with external currency not considered for account balance?) reported by @pvieira84
|
||||
- [Issue 9786](https://github.com/firefly-iii/firefly-iii/issues/9786) (The error 500 information page has non-clickable links to github and the debug page) reported by @tjmv
|
||||
- [Issue 9787](https://github.com/firefly-iii/firefly-iii/issues/9787) (Twig general template error formatting TransactionCurrency on main page) reported by @tjmv
|
||||
- [Issue 9789](https://github.com/firefly-iii/firefly-iii/issues/9789) (Can't open expense and revenue accounts view) reported by @puffer-duck
|
||||
|
||||
## 6.2.4 - 2025-02-05
|
||||
|
||||
> ⚠️ _Most pressing issues are fixed. Please open [an issue here](https://github.com/firefly-iii/firefly-iii/issues/new?template=bug.yml) if you run into problems._
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Issue 9327](https://github.com/firefly-iii/firefly-iii/issues/9327) (Add Link to Search-Page to the help file) reported by @nottheend
|
||||
- [Issue 9713](https://github.com/firefly-iii/firefly-iii/issues/9713) (Many decimal points in amounts) reported by @memo-567
|
||||
- [Issue 9736](https://github.com/firefly-iii/firefly-iii/issues/9736) (Wrong `finalAccountBalance` result) reported by @gthbusrr
|
||||
- [Discussion 9737](https://github.com/orgs/firefly-iii/discussions/9737) (API returns 0 as current balance) started by @eps90
|
||||
- [Issue 9745](https://github.com/firefly-iii/firefly-iii/issues/9745) (Type mismatch in period overview) reported by @electrofloat
|
||||
- [Issue 9747](https://github.com/firefly-iii/firefly-iii/issues/9747) (Data entry issues with exchange rates) reported by @Azmodeszer
|
||||
- [Issue 9751](https://github.com/firefly-iii/firefly-iii/issues/9751) (Net worth changes since 6.2 update) reported by @ahmaddxb
|
||||
- [Issue 9754](https://github.com/firefly-iii/firefly-iii/issues/9754) (Deleting account - Attachments remain) reported by @memo-567
|
||||
- [Issue 9762](https://github.com/firefly-iii/firefly-iii/issues/9762) (Piggy bank show: start/target date not displayed) reported by @Simeam
|
||||
- Various other balance related fixes.
|
||||
- Hotfix for account charts.
|
||||
|
||||
## 6.2.3 - 2025-02-05
|
||||
|
||||
> ⚠️ _Most pressing issues are fixed. Please open [an issue here](https://github.com/firefly-iii/firefly-iii/issues/new?template=bug.yml) if you run into problems._
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Issue 9327](https://github.com/firefly-iii/firefly-iii/issues/9327) (Add Link to Search-Page to the help file) reported by @nottheend
|
||||
- [Issue 9713](https://github.com/firefly-iii/firefly-iii/issues/9713) (Many decimal points in amounts) reported by @memo-567
|
||||
- [Issue 9736](https://github.com/firefly-iii/firefly-iii/issues/9736) (Wrong `finalAccountBalance` result) reported by @gthbusrr
|
||||
- [Discussion 9737](https://github.com/orgs/firefly-iii/discussions/9737) (API returns 0 as current balance) started by @eps90
|
||||
- [Issue 9745](https://github.com/firefly-iii/firefly-iii/issues/9745) (Type mismatch in period overview) reported by @electrofloat
|
||||
- [Issue 9747](https://github.com/firefly-iii/firefly-iii/issues/9747) (Data entry issues with exchange rates) reported by @Azmodeszer
|
||||
- [Issue 9751](https://github.com/firefly-iii/firefly-iii/issues/9751) (Net worth changes since 6.2 update) reported by @ahmaddxb
|
||||
- [Issue 9754](https://github.com/firefly-iii/firefly-iii/issues/9754) (Deleting account - Attachments remain) reported by @memo-567
|
||||
- [Issue 9762](https://github.com/firefly-iii/firefly-iii/issues/9762) (Piggy bank show: start/target date not displayed) reported by @Simeam
|
||||
- Various other balance related fixes.
|
||||
|
||||
## 6.2.2 - 2025-02-02
|
||||
|
||||
> ⚠️ _This release comes with many changes, small and large. I expect you will run into issue, and I appreciate your feedback and your patience as I fix them. I've tested many things, but I'm 100% sure I've missed things. Please open [an issue here](https://github.com/firefly-iii/firefly-iii/issues/new?template=bug.yml) if you run into problems._
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Issue 9713](https://github.com/firefly-iii/firefly-iii/issues/9713) (Many decimal points in amounts) reported by @memo-567
|
||||
- [Discussion 9727](https://github.com/orgs/firefly-iii/discussions/9727) (Odd behavior from graphs) started by @jbrandwi
|
||||
- [Issue 9729](https://github.com/firefly-iii/firefly-iii/issues/9729) (Type mismatch in transaction collector) reported by @electrofloat
|
||||
- [Issue 9730](https://github.com/firefly-iii/firefly-iii/issues/9730) (API: `PiggyBankAccountRead.id` should return string, returns int) reported by @dreautall
|
||||
- [Issue 9731](https://github.com/firefly-iii/firefly-iii/issues/9731) ($userGroup must not be accessed before initialization) reported by @Azmodeszer
|
||||
- [Issue 9732](https://github.com/firefly-iii/firefly-iii/issues/9732) (Editing dates of a piggy bank does not save) reported by @Simeam
|
||||
- [Issue 9736](https://github.com/firefly-iii/firefly-iii/issues/9736) (Wrong `finalAccountBalance` result) reported by @gthbusrr
|
||||
- [Issue 9738](https://github.com/firefly-iii/firefly-iii/issues/9738) (Missing pagination controls on exchange rate page) reported by @dicksonleong
|
||||
- [Discussion 9744](https://github.com/orgs/firefly-iii/discussions/9744) (Downloading exchange rates results in 404 error) started by @electrofloat
|
||||
|
||||
### Added
|
||||
|
||||
- [PR 9743](https://github.com/firefly-iii/firefly-iii/pull/9743) (Feature nordic currencies) reported by @mansehr
|
||||
|
||||
|
||||
## 6.2.1 - 2025-02-01
|
||||
|
||||
> ⚠️ _This release comes with many changes, small and large. I expect you will run into issue, and I appreciate your feedback and your patience as I fix them. I've tested many things, but I'm 100% sure I've missed things. Please open [an issue here](https://github.com/firefly-iii/firefly-iii/issues/new?template=bug.yml) if you run into problems._
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Issue 9714](https://github.com/firefly-iii/firefly-iii/issues/9714) (current transaction is aborted, commands ignored until end of transaction block) reported by @captainark
|
||||
- [Issue 9717](https://github.com/firefly-iii/firefly-iii/issues/9717) (API api/v1/accounts broken) reported by @brot
|
||||
- [Issue 9719](https://github.com/firefly-iii/firefly-iii/issues/9719) (A couple of TODOs left in resources/views/list/groups.twig) reported by @lostfocus
|
||||
- [Issue 9720](https://github.com/firefly-iii/firefly-iii/issues/9720) (Piggy Bank with no Target amount: unable to add money) reported by @maxsmooth
|
||||
- [Issue 9721](https://github.com/firefly-iii/firefly-iii/issues/9721) (Documentation on exchange-rates page leads to non-existent page) reported by @electrofloat
|
||||
- [Issue 9722](https://github.com/firefly-iii/firefly-iii/issues/9722) (Error 500 on tags page after enabling native currency) reported by @lostfocus
|
||||
- [Issue 9723](https://github.com/firefly-iii/firefly-iii/issues/9723) (Convert to native routine is not called when convert to native is activated) reported by @JC5
|
||||
- [Issue 9726](https://github.com/firefly-iii/firefly-iii/issues/9726) (Postgres cannot deal with "virtual_balance" column) reported by @dicksonleong
|
||||
|
||||
## 6.2.0 - 2025-01-31
|
||||
|
||||
> ⚠️ _This release comes with many changes, small and large. I expect you will run into issue, and I appreciate your feedback and your patience as I fix them. I've tested many things, but I'm 100% sure I've missed things. Please open [an issue here](https://github.com/firefly-iii/firefly-iii/issues/new?template=bug.yml) if you run into problems._
|
||||
|
||||
|
||||
158
composer.lock
generated
158
composer.lock
generated
@@ -1571,16 +1571,16 @@
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/uri-template",
|
||||
"version": "v1.0.3",
|
||||
"version": "v1.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/uri-template.git",
|
||||
"reference": "ecea8feef63bd4fef1f037ecb288386999ecc11c"
|
||||
"reference": "30e286560c137526eccd4ce21b2de477ab0676d2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/uri-template/zipball/ecea8feef63bd4fef1f037ecb288386999ecc11c",
|
||||
"reference": "ecea8feef63bd4fef1f037ecb288386999ecc11c",
|
||||
"url": "https://api.github.com/repos/guzzle/uri-template/zipball/30e286560c137526eccd4ce21b2de477ab0676d2",
|
||||
"reference": "30e286560c137526eccd4ce21b2de477ab0676d2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1637,7 +1637,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/uri-template/issues",
|
||||
"source": "https://github.com/guzzle/uri-template/tree/v1.0.3"
|
||||
"source": "https://github.com/guzzle/uri-template/tree/v1.0.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -1653,7 +1653,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-12-03T19:50:20+00:00"
|
||||
"time": "2025-02-03T10:55:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jc5/google2fa-laravel",
|
||||
@@ -1874,16 +1874,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v11.41.3",
|
||||
"version": "v11.42.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "3ef433d5865f30a19b6b1be247586068399b59cc"
|
||||
"reference": "006375ba67e830e87daa7b52ab65163ba3508d26"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/3ef433d5865f30a19b6b1be247586068399b59cc",
|
||||
"reference": "3ef433d5865f30a19b6b1be247586068399b59cc",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/006375ba67e830e87daa7b52ab65163ba3508d26",
|
||||
"reference": "006375ba67e830e87daa7b52ab65163ba3508d26",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1991,11 +1991,11 @@
|
||||
"league/flysystem-read-only": "^3.25.1",
|
||||
"league/flysystem-sftp-v3": "^3.25.1",
|
||||
"mockery/mockery": "^1.6.10",
|
||||
"orchestra/testbench-core": "^9.6",
|
||||
"orchestra/testbench-core": "^9.9.4",
|
||||
"pda/pheanstalk": "^5.0.6",
|
||||
"php-http/discovery": "^1.15",
|
||||
"phpstan/phpstan": "^1.11.5",
|
||||
"phpunit/phpunit": "^10.5.35|^11.3.6",
|
||||
"phpstan/phpstan": "^2.0",
|
||||
"phpunit/phpunit": "^10.5.35|^11.3.6|^12.0.1",
|
||||
"predis/predis": "^2.3",
|
||||
"resend/resend-php": "^0.10.0",
|
||||
"symfony/cache": "^7.0.3",
|
||||
@@ -2027,7 +2027,7 @@
|
||||
"mockery/mockery": "Required to use mocking (^1.6).",
|
||||
"pda/pheanstalk": "Required to use the beanstalk queue driver (^5.0).",
|
||||
"php-http/discovery": "Required to use PSR-7 bridging features (^1.15).",
|
||||
"phpunit/phpunit": "Required to use assertions and run tests (^10.5|^11.0).",
|
||||
"phpunit/phpunit": "Required to use assertions and run tests (^10.5.35|^11.3.6|^12.0.1).",
|
||||
"predis/predis": "Required to use the predis connector (^2.3).",
|
||||
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0).",
|
||||
@@ -2085,7 +2085,7 @@
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2025-01-30T13:25:22+00:00"
|
||||
"time": "2025-02-11T17:17:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/passport",
|
||||
@@ -2165,16 +2165,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/prompts",
|
||||
"version": "v0.3.4",
|
||||
"version": "v0.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/prompts.git",
|
||||
"reference": "abeaa2ba4294247d5409490d1ca1bc6248087011"
|
||||
"reference": "57b8f7efe40333cdb925700891c7d7465325d3b1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/prompts/zipball/abeaa2ba4294247d5409490d1ca1bc6248087011",
|
||||
"reference": "abeaa2ba4294247d5409490d1ca1bc6248087011",
|
||||
"url": "https://api.github.com/repos/laravel/prompts/zipball/57b8f7efe40333cdb925700891c7d7465325d3b1",
|
||||
"reference": "57b8f7efe40333cdb925700891c7d7465325d3b1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2218,9 +2218,9 @@
|
||||
"description": "Add beautiful and user-friendly forms to your command-line applications.",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/prompts/issues",
|
||||
"source": "https://github.com/laravel/prompts/tree/v0.3.4"
|
||||
"source": "https://github.com/laravel/prompts/tree/v0.3.5"
|
||||
},
|
||||
"time": "2025-01-24T15:41:01+00:00"
|
||||
"time": "2025-02-11T13:34:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/sanctum",
|
||||
@@ -2288,16 +2288,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
"version": "v2.0.2",
|
||||
"version": "v2.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/serializable-closure.git",
|
||||
"reference": "2e1a362527783bcab6c316aad51bf36c5513ae44"
|
||||
"reference": "f379c13663245f7aa4512a7869f62eb14095f23f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/2e1a362527783bcab6c316aad51bf36c5513ae44",
|
||||
"reference": "2e1a362527783bcab6c316aad51bf36c5513ae44",
|
||||
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f379c13663245f7aa4512a7869f62eb14095f23f",
|
||||
"reference": "f379c13663245f7aa4512a7869f62eb14095f23f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2345,7 +2345,7 @@
|
||||
"issues": "https://github.com/laravel/serializable-closure/issues",
|
||||
"source": "https://github.com/laravel/serializable-closure"
|
||||
},
|
||||
"time": "2025-01-24T15:42:37+00:00"
|
||||
"time": "2025-02-11T15:03:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/slack-notification-channel",
|
||||
@@ -3703,16 +3703,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "3.8.4",
|
||||
"version": "3.8.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/CarbonPHP/carbon.git",
|
||||
"reference": "129700ed449b1f02d70272d2ac802357c8c30c58"
|
||||
"reference": "b1a53a27898639579a67de42e8ced5d5386aa9a4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/129700ed449b1f02d70272d2ac802357c8c30c58",
|
||||
"reference": "129700ed449b1f02d70272d2ac802357c8c30c58",
|
||||
"url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/b1a53a27898639579a67de42e8ced5d5386aa9a4",
|
||||
"reference": "b1a53a27898639579a67de42e8ced5d5386aa9a4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3788,8 +3788,8 @@
|
||||
],
|
||||
"support": {
|
||||
"docs": "https://carbon.nesbot.com/docs",
|
||||
"issues": "https://github.com/briannesbitt/Carbon/issues",
|
||||
"source": "https://github.com/briannesbitt/Carbon"
|
||||
"issues": "https://github.com/CarbonPHP/carbon/issues",
|
||||
"source": "https://github.com/CarbonPHP/carbon"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -3805,7 +3805,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-12-27T09:25:35+00:00"
|
||||
"time": "2025-02-11T16:28:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nette/schema",
|
||||
@@ -6196,16 +6196,16 @@
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-html",
|
||||
"version": "3.11.1",
|
||||
"version": "3.11.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-html.git",
|
||||
"reference": "167e5b8243103072155b562e5cc396c90a3c1055"
|
||||
"reference": "248508f3ed50e6538707fc54a4b3b23fb53e8045"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-html/zipball/167e5b8243103072155b562e5cc396c90a3c1055",
|
||||
"reference": "167e5b8243103072155b562e5cc396c90a3c1055",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-html/zipball/248508f3ed50e6538707fc54a4b3b23fb53e8045",
|
||||
"reference": "248508f3ed50e6538707fc54a4b3b23fb53e8045",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -6262,7 +6262,7 @@
|
||||
"spatie"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/spatie/laravel-html/tree/3.11.1"
|
||||
"source": "https://github.com/spatie/laravel-html/tree/3.11.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -6270,7 +6270,7 @@
|
||||
"type": "custom"
|
||||
}
|
||||
],
|
||||
"time": "2024-10-18T14:37:21+00:00"
|
||||
"time": "2025-02-05T08:27:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-ignition",
|
||||
@@ -6365,27 +6365,27 @@
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-package-tools",
|
||||
"version": "1.18.3",
|
||||
"version": "1.19.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-package-tools.git",
|
||||
"reference": "ba67eee37d86ed775dab7dad58a7cbaf9a6cfe78"
|
||||
"reference": "1c9c30ac6a6576b8d15c6c37b6cf23d748df2faa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/ba67eee37d86ed775dab7dad58a7cbaf9a6cfe78",
|
||||
"reference": "ba67eee37d86ed775dab7dad58a7cbaf9a6cfe78",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/1c9c30ac6a6576b8d15c6c37b6cf23d748df2faa",
|
||||
"reference": "1c9c30ac6a6576b8d15c6c37b6cf23d748df2faa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "^9.28|^10.0|^11.0",
|
||||
"illuminate/contracts": "^9.28|^10.0|^11.0|^12.0",
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.5",
|
||||
"orchestra/testbench": "^7.7|^8.0|^9.0",
|
||||
"pestphp/pest": "^1.22|^2",
|
||||
"phpunit/phpunit": "^9.5.24|^10.5",
|
||||
"orchestra/testbench": "^7.7|^8.0|^9.0|^10.0",
|
||||
"pestphp/pest": "^1.23|^2.1|^3.1",
|
||||
"phpunit/phpunit": "^9.5.24|^10.5|^11.5",
|
||||
"spatie/pest-plugin-test-time": "^1.1|^2.2"
|
||||
},
|
||||
"type": "library",
|
||||
@@ -6413,7 +6413,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/laravel-package-tools/issues",
|
||||
"source": "https://github.com/spatie/laravel-package-tools/tree/1.18.3"
|
||||
"source": "https://github.com/spatie/laravel-package-tools/tree/1.19.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -6421,7 +6421,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-01-22T08:51:18+00:00"
|
||||
"time": "2025-02-06T14:58:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/period",
|
||||
@@ -10398,16 +10398,16 @@
|
||||
},
|
||||
{
|
||||
"name": "composer/class-map-generator",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/class-map-generator.git",
|
||||
"reference": "4b0a223cf5be7c9ee7e0ef1bc7db42b4a97c9915"
|
||||
"reference": "ffe442c5974c44a9343e37a0abcb1cc37319f5b9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/class-map-generator/zipball/4b0a223cf5be7c9ee7e0ef1bc7db42b4a97c9915",
|
||||
"reference": "4b0a223cf5be7c9ee7e0ef1bc7db42b4a97c9915",
|
||||
"url": "https://api.github.com/repos/composer/class-map-generator/zipball/ffe442c5974c44a9343e37a0abcb1cc37319f5b9",
|
||||
"reference": "ffe442c5974c44a9343e37a0abcb1cc37319f5b9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -10451,7 +10451,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/composer/class-map-generator/issues",
|
||||
"source": "https://github.com/composer/class-map-generator/tree/1.5.0"
|
||||
"source": "https://github.com/composer/class-map-generator/tree/1.6.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -10467,7 +10467,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-25T16:11:06+00:00"
|
||||
"time": "2025-02-05T10:05:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/pcre",
|
||||
@@ -10664,16 +10664,16 @@
|
||||
},
|
||||
{
|
||||
"name": "larastan/larastan",
|
||||
"version": "v3.0.2",
|
||||
"version": "v3.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/larastan/larastan.git",
|
||||
"reference": "b2e24e1605cff1d1097ccb6fb8af3bbd1dfe1c6f"
|
||||
"reference": "b394eba5805727423071fac9b53ea50dd7e920f4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/larastan/larastan/zipball/b2e24e1605cff1d1097ccb6fb8af3bbd1dfe1c6f",
|
||||
"reference": "b2e24e1605cff1d1097ccb6fb8af3bbd1dfe1c6f",
|
||||
"url": "https://api.github.com/repos/larastan/larastan/zipball/b394eba5805727423071fac9b53ea50dd7e920f4",
|
||||
"reference": "b394eba5805727423071fac9b53ea50dd7e920f4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -10687,7 +10687,7 @@
|
||||
"illuminate/support": "^11.15.0",
|
||||
"php": "^8.2",
|
||||
"phpmyadmin/sql-parser": "^5.9.0",
|
||||
"phpstan/phpstan": "^2.0.2"
|
||||
"phpstan/phpstan": "^2.1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^12.0",
|
||||
@@ -10745,7 +10745,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/larastan/larastan/issues",
|
||||
"source": "https://github.com/larastan/larastan/tree/v3.0.2"
|
||||
"source": "https://github.com/larastan/larastan/tree/v3.0.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -10753,7 +10753,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-26T23:15:21+00:00"
|
||||
"time": "2025-02-06T21:03:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel-json-api/testing",
|
||||
@@ -10973,16 +10973,16 @@
|
||||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.12.1",
|
||||
"version": "1.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845"
|
||||
"reference": "024473a478be9df5fdaca2c793f2232fe788e414"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845",
|
||||
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414",
|
||||
"reference": "024473a478be9df5fdaca2c793f2232fe788e414",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -11021,7 +11021,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.1"
|
||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -11029,7 +11029,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-08T17:47:46+00:00"
|
||||
"time": "2025-02-12T12:17:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
@@ -11344,16 +11344,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "2.1.2",
|
||||
"version": "2.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "7d08f569e582ade182a375c366cbd896eccadd3a"
|
||||
"reference": "8f99e18eb775dbaf6460c95fa0b65312da9c746a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7d08f569e582ade182a375c366cbd896eccadd3a",
|
||||
"reference": "7d08f569e582ade182a375c366cbd896eccadd3a",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/8f99e18eb775dbaf6460c95fa0b65312da9c746a",
|
||||
"reference": "8f99e18eb775dbaf6460c95fa0b65312da9c746a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -11398,7 +11398,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-01-21T14:54:06+00:00"
|
||||
"time": "2025-02-10T08:25:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-deprecation-rules",
|
||||
@@ -11820,16 +11820,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "11.5.6",
|
||||
"version": "11.5.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "3c3ae14c90f244cdda95028c3e469028e8d1c02c"
|
||||
"reference": "e1cb706f019e2547039ca2c839898cd5f557ee5d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3c3ae14c90f244cdda95028c3e469028e8d1c02c",
|
||||
"reference": "3c3ae14c90f244cdda95028c3e469028e8d1c02c",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e1cb706f019e2547039ca2c839898cd5f557ee5d",
|
||||
"reference": "e1cb706f019e2547039ca2c839898cd5f557ee5d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -11901,7 +11901,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.6"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.7"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -11917,7 +11917,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-01-31T07:03:30+00:00"
|
||||
"time": "2025-02-06T16:10:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
||||
@@ -81,7 +81,7 @@ return [
|
||||
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
||||
// see cer.php for exchange rates feature flag.
|
||||
],
|
||||
'version' => '6.2.0',
|
||||
'version' => '6.2.6',
|
||||
'api_version' => '2.1.0', // field is no longer used.
|
||||
'db_version' => 25,
|
||||
|
||||
|
||||
@@ -24,234 +24,239 @@ declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'operators' => [
|
||||
'user_action' => ['alias' => false, 'needs_context' => true],
|
||||
'account_id' => ['alias' => false, 'needs_context' => true],
|
||||
'reconciled' => ['alias' => false, 'needs_context' => false],
|
||||
'source_account_id' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_account_id' => ['alias' => false, 'needs_context' => true],
|
||||
'transaction_type' => ['alias' => false, 'needs_context' => true],
|
||||
'type' => ['alias' => true, 'alias_for' => 'transaction_type', 'needs_context' => true],
|
||||
'tag_is' => ['alias' => false, 'needs_context' => true],
|
||||
'tag_is_not' => ['alias' => false, 'needs_context' => true],
|
||||
'tag' => ['alias' => true, 'alias_for' => 'tag_is', 'needs_context' => true],
|
||||
'tag_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'tag_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'tag_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'description_is' => ['alias' => false, 'needs_context' => true],
|
||||
'description' => ['alias' => true, 'alias_for' => 'description_is', 'needs_context' => true],
|
||||
'description_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'description_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'description_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_is' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_are' => ['alias' => true, 'alias_for' => 'notes_is', 'needs_context' => true],
|
||||
'notes_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_contain' => ['alias' => true, 'alias_for' => 'notes_contains', 'needs_context' => true],
|
||||
'notes' => ['alias' => true, 'alias_for' => 'notes_contains', 'needs_context' => true],
|
||||
'notes_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_end' => ['alias' => true, 'alias_for' => 'notes_ends', 'needs_context' => true],
|
||||
'notes_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_start' => ['alias' => true, 'alias_for' => 'notes_starts', 'needs_context' => true],
|
||||
'source_account_is' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_is' => ['alias' => true, 'alias_for' => 'source_account_is', 'needs_context' => true],
|
||||
'source_account_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'source' => ['alias' => true, 'alias_for' => 'source_account_contains', 'needs_context' => true],
|
||||
'from' => ['alias' => true, 'alias_for' => 'source_account_contains', 'needs_context' => true],
|
||||
'from_account_contains' => ['alias' => true, 'alias_for' => 'source_account_contains', 'needs_context' => true],
|
||||
'source_account_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_ends' => ['alias' => true, 'alias_for' => 'source_account_ends', 'needs_context' => true],
|
||||
'source_account_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_starts' => ['alias' => true, 'alias_for' => 'source_account_starts', 'needs_context' => true],
|
||||
'source_account_nr_is' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_is' => ['alias' => true, 'alias_for' => 'source_account_nr_is', 'needs_context' => true],
|
||||
'source_account_nr_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_contains' => ['alias' => true, 'alias_for' => 'source_account_nr_contains', 'needs_context' => true],
|
||||
'source_account_nr_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_ends' => ['alias' => true, 'alias_for' => 'source_account_nr_ends', 'needs_context' => true],
|
||||
'source_account_nr_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_starts' => ['alias' => true, 'alias_for' => 'source_account_nr_starts', 'needs_context' => true],
|
||||
'destination_account_is' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_is' => ['alias' => true, 'alias_for' => 'destination_account_is', 'needs_context' => true],
|
||||
'destination_account_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'destination' => ['alias' => true, 'alias_for' => 'destination_account_contains', 'needs_context' => true],
|
||||
'to' => ['alias' => true, 'alias_for' => 'destination_account_contains', 'needs_context' => true],
|
||||
'to_account_contains' => ['alias' => true, 'alias_for' => 'destination_account_contains', 'needs_context' => true],
|
||||
'destination_account_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_ends' => ['alias' => true, 'alias_for' => 'destination_account_ends', 'needs_context' => true],
|
||||
'destination_account_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_starts' => ['alias' => true, 'alias_for' => 'destination_account_starts', 'needs_context' => true],
|
||||
'destination_account_nr_is' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_is' => ['alias' => true, 'alias_for' => 'destination_account_nr_is', 'needs_context' => true],
|
||||
'destination_account_nr_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_contains' => ['alias' => true, 'alias_for' => 'destination_account_nr_contains', 'needs_context' => true],
|
||||
'destination_account_nr_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_ends' => ['alias' => true, 'alias_for' => 'destination_account_nr_ends', 'needs_context' => true],
|
||||
'destination_account_nr_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_starts' => ['alias' => true, 'alias_for' => 'destination_account_nr_starts', 'needs_context' => true],
|
||||
'account_is' => ['alias' => false, 'needs_context' => true],
|
||||
'account_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'account_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'account_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_is' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'category_is' => ['alias' => false, 'needs_context' => true],
|
||||
'category_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'category' => ['alias' => true, 'alias_for' => 'category_contains', 'needs_context' => true],
|
||||
'category_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'category_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'budget_is' => ['alias' => false, 'needs_context' => true],
|
||||
'budget_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'budget' => ['alias' => true, 'alias_for' => 'budget_contains', 'needs_context' => true],
|
||||
'budget_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'budget_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'bill_is' => ['alias' => false, 'needs_context' => true],
|
||||
'bill_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'bill' => ['alias' => true, 'alias_for' => 'bill_contains', 'needs_context' => true],
|
||||
'bill_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'bill_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'external_id_is' => ['alias' => false, 'needs_context' => true],
|
||||
'external_id_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'external_id' => ['alias' => true, 'alias_for' => 'external_id_contains', 'needs_context' => true],
|
||||
'external_id_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'external_id_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference_is' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference' => ['alias' => true, 'alias_for' => 'internal_reference_contains', 'needs_context' => true],
|
||||
'internal_reference_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url_is' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url' => ['alias' => true, 'alias_for' => 'external_url_contains', 'needs_context' => true],
|
||||
'external_url_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'has_attachments' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_category' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_budget' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_bill' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_tag' => ['alias' => false, 'needs_context' => false],
|
||||
'any_notes' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],
|
||||
'has_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],
|
||||
'any_external_url' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_external_url' => ['alias' => true, 'alias_for' => 'any_external_url', 'needs_context' => false],
|
||||
'has_no_attachments' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_category' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_budget' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_bill' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_tag' => ['alias' => false, 'needs_context' => false],
|
||||
'no_notes' => ['alias' => false, 'needs_context' => false],
|
||||
'no_external_url' => ['alias' => false, 'needs_context' => false],
|
||||
'source_is_cash' => ['alias' => false, 'needs_context' => false],
|
||||
'destination_is_cash' => ['alias' => false, 'needs_context' => false],
|
||||
'account_is_cash' => ['alias' => false, 'needs_context' => false],
|
||||
'currency_is' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_currency_is' => ['alias' => false, 'needs_context' => true],
|
||||
'id' => ['alias' => false, 'trigger_class' => '', 'needs_context' => true],
|
||||
'journal_id' => ['alias' => false, 'trigger_class' => '', 'needs_context' => true],
|
||||
'recurrence_id' => ['alias' => false, 'trigger_class' => '', 'needs_context' => true],
|
||||
'date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'date' => ['alias' => true, 'alias_for' => 'date_on', 'needs_context' => true],
|
||||
'date_is' => ['alias' => true, 'alias_for' => 'date_on', 'needs_context' => true],
|
||||
'on' => ['alias' => true, 'alias_for' => 'date_on', 'needs_context' => true],
|
||||
'date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'before' => ['alias' => true, 'alias_for' => 'date_before', 'needs_context' => true],
|
||||
'date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'after' => ['alias' => true, 'alias_for' => 'date_after', 'needs_context' => true],
|
||||
'interest_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'interest_date' => ['alias' => true, 'alias_for' => 'interest_date_on', 'needs_context' => true],
|
||||
'interest_date_is' => ['alias' => true, 'alias_for' => 'interest_date_on', 'needs_context' => true],
|
||||
'interest_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'interest_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'book_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'book_date' => ['alias' => true, 'alias_for' => 'book_date_on', 'needs_context' => true],
|
||||
'book_date_is' => ['alias' => true, 'alias_for' => 'book_date_on', 'needs_context' => true],
|
||||
'book_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'book_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'process_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'process_date' => ['alias' => true, 'alias_for' => 'process_date_on', 'needs_context' => true],
|
||||
'process_date_is' => ['alias' => true, 'alias_for' => 'process_date_on', 'needs_context' => true],
|
||||
'process_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'process_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'due_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'due_date' => ['alias' => true, 'alias_for' => 'due_date_on', 'needs_context' => true],
|
||||
'due_date_is' => ['alias' => true, 'alias_for' => 'due_date_on', 'needs_context' => true],
|
||||
'due_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'due_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'payment_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'payment_date' => ['alias' => true, 'alias_for' => 'payment_date_on', 'needs_context' => true],
|
||||
'payment_date_is' => ['alias' => true, 'alias_for' => 'payment_date_on', 'needs_context' => true],
|
||||
'payment_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'payment_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'invoice_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'invoice_date' => ['alias' => true, 'alias_for' => 'invoice_date_on', 'needs_context' => true],
|
||||
'invoice_date_is' => ['alias' => true, 'alias_for' => 'invoice_date_on', 'needs_context' => true],
|
||||
'invoice_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'invoice_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'created_at_on' => ['alias' => false, 'needs_context' => true],
|
||||
'created_at' => ['alias' => true, 'alias_for' => 'created_at_on', 'needs_context' => true],
|
||||
'created_at_is' => ['alias' => true, 'alias_for' => 'created_at_on', 'needs_context' => true],
|
||||
'created_at_before' => ['alias' => false, 'needs_context' => true],
|
||||
'created_at_after' => ['alias' => false, 'needs_context' => true],
|
||||
'updated_at_on' => ['alias' => false, 'needs_context' => true],
|
||||
'updated_at' => ['alias' => true, 'alias_for' => 'updated_at_on', 'needs_context' => true],
|
||||
'updated_at_is' => ['alias' => true, 'alias_for' => 'updated_at_on', 'needs_context' => true],
|
||||
'updated_at_before' => ['alias' => false, 'needs_context' => true],
|
||||
'updated_at_after' => ['alias' => false, 'needs_context' => true],
|
||||
'created_on_on' => ['alias' => true, 'alias_for' => 'created_at_on', 'needs_context' => true],
|
||||
'created_on' => ['alias' => true, 'alias_for' => 'created_at', 'needs_context' => true],
|
||||
'created_on_before' => ['alias' => true, 'alias_for' => 'created_at_before', 'needs_context' => true],
|
||||
'created_on_after' => ['alias' => true, 'alias_for' => 'created_at_after', 'needs_context' => true],
|
||||
'updated_on_on' => ['alias' => true, 'alias_for' => 'updated_at_on', 'needs_context' => true],
|
||||
'updated_on' => ['alias' => true, 'alias_for' => 'updated_at', 'needs_context' => true],
|
||||
'updated_on_before' => ['alias' => true, 'alias_for' => 'updated_at_before', 'needs_context' => true],
|
||||
'updated_on_after' => ['alias' => true, 'alias_for' => 'updated_at_after', 'needs_context' => true],
|
||||
'amount_is' => ['alias' => false, 'needs_context' => true],
|
||||
'amount' => ['alias' => true, 'alias_for' => 'amount_is', 'needs_context' => true],
|
||||
'amount_exactly' => ['alias' => true, 'alias_for' => 'amount_is', 'needs_context' => true],
|
||||
'amount_less' => ['alias' => false, 'needs_context' => true],
|
||||
'amount_max' => ['alias' => true, 'alias_for' => 'amount_less', 'needs_context' => true],
|
||||
'less' => ['alias' => true, 'alias_for' => 'amount_less', 'needs_context' => true],
|
||||
'amount_more' => ['alias' => false, 'needs_context' => true],
|
||||
'amount_min' => ['alias' => true, 'alias_for' => 'amount_more', 'needs_context' => true],
|
||||
'more' => ['alias' => true, 'alias_for' => 'amount_more', 'needs_context' => true],
|
||||
'foreign_amount_is' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_amount' => ['alias' => true, 'alias_for' => 'foreign_amount_is', 'needs_context' => true],
|
||||
'foreign_amount_less' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_amount_max' => ['alias' => true, 'alias_for' => 'foreign_amount_less', 'needs_context' => true],
|
||||
'foreign_amount_more' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_amount_min' => ['alias' => true, 'alias_for' => 'foreign_amount_more', 'needs_context' => true],
|
||||
'attachment_name_is' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment' => ['alias' => true, 'alias_for' => 'attachment_name_is', 'needs_context' => true],
|
||||
'attachment_is' => ['alias' => true, 'alias_for' => 'attachment_name_is', 'needs_context' => true],
|
||||
'attachment_name' => ['alias' => true, 'alias_for' => 'attachment_name_is', 'needs_context' => true],
|
||||
'attachment_name_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_name_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_name_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes' => ['alias' => true, 'alias_for' => 'attachment_notes_are', 'needs_context' => true],
|
||||
'attachment_notes_are' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_contain' => ['alias' => true, 'alias_for' => 'attachment_notes_contains', 'needs_context' => true],
|
||||
'attachment_notes_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_start' => ['alias' => true, 'alias_for' => 'attachment_notes_starts', 'needs_context' => true],
|
||||
'attachment_notes_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_end' => ['alias' => true, 'alias_for' => 'attachment_notes_ends', 'needs_context' => true],
|
||||
'exists' => ['alias' => false, 'needs_context' => false],
|
||||
'sepa_ct_is' => ['alias' => false, 'needs_context' => true],
|
||||
'no_external_id' => ['alias' => false, 'needs_context' => false],
|
||||
'any_external_id' => ['alias' => false, 'needs_context' => false],
|
||||
'user_action' => ['alias' => false, 'needs_context' => true],
|
||||
'account_id' => ['alias' => false, 'needs_context' => true],
|
||||
'reconciled' => ['alias' => false, 'needs_context' => false],
|
||||
'source_account_id' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_account_id' => ['alias' => false, 'needs_context' => true],
|
||||
'transaction_type' => ['alias' => false, 'needs_context' => true],
|
||||
'type' => ['alias' => true, 'alias_for' => 'transaction_type', 'needs_context' => true],
|
||||
'tag_is' => ['alias' => false, 'needs_context' => true],
|
||||
'tag_is_not' => ['alias' => false, 'needs_context' => true],
|
||||
'tag' => ['alias' => true, 'alias_for' => 'tag_is', 'needs_context' => true],
|
||||
'tag_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'tag_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'tag_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'description_is' => ['alias' => false, 'needs_context' => true],
|
||||
'description' => ['alias' => true, 'alias_for' => 'description_is', 'needs_context' => true],
|
||||
'description_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'description_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'description_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_is' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_are' => ['alias' => true, 'alias_for' => 'notes_is', 'needs_context' => true],
|
||||
'notes_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_contain' => ['alias' => true, 'alias_for' => 'notes_contains', 'needs_context' => true],
|
||||
'notes' => ['alias' => true, 'alias_for' => 'notes_contains', 'needs_context' => true],
|
||||
'notes_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_end' => ['alias' => true, 'alias_for' => 'notes_ends', 'needs_context' => true],
|
||||
'notes_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'notes_start' => ['alias' => true, 'alias_for' => 'notes_starts', 'needs_context' => true],
|
||||
'source_account_is' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_is' => ['alias' => true, 'alias_for' => 'source_account_is', 'needs_context' => true],
|
||||
'source_account_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'source' => ['alias' => true, 'alias_for' => 'source_account_contains', 'needs_context' => true],
|
||||
'from' => ['alias' => true, 'alias_for' => 'source_account_contains', 'needs_context' => true],
|
||||
'from_account_contains' => ['alias' => true, 'alias_for' => 'source_account_contains', 'needs_context' => true],
|
||||
'source_account_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_ends' => ['alias' => true, 'alias_for' => 'source_account_ends', 'needs_context' => true],
|
||||
'source_account_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_starts' => ['alias' => true, 'alias_for' => 'source_account_starts', 'needs_context' => true],
|
||||
'source_account_nr_is' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_is' => ['alias' => true, 'alias_for' => 'source_account_nr_is', 'needs_context' => true],
|
||||
'source_account_nr_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_contains' => ['alias' => true, 'alias_for' => 'source_account_nr_contains', 'needs_context' => true],
|
||||
'source_account_nr_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_ends' => ['alias' => true, 'alias_for' => 'source_account_nr_ends', 'needs_context' => true],
|
||||
'source_account_nr_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'from_account_nr_starts' => ['alias' => true, 'alias_for' => 'source_account_nr_starts', 'needs_context' => true],
|
||||
'destination_account_is' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_is' => ['alias' => true, 'alias_for' => 'destination_account_is', 'needs_context' => true],
|
||||
'destination_account_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'destination' => ['alias' => true, 'alias_for' => 'destination_account_contains', 'needs_context' => true],
|
||||
'to' => ['alias' => true, 'alias_for' => 'destination_account_contains', 'needs_context' => true],
|
||||
'to_account_contains' => ['alias' => true, 'alias_for' => 'destination_account_contains', 'needs_context' => true],
|
||||
'destination_account_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_ends' => ['alias' => true, 'alias_for' => 'destination_account_ends', 'needs_context' => true],
|
||||
'destination_account_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_starts' => ['alias' => true, 'alias_for' => 'destination_account_starts', 'needs_context' => true],
|
||||
'destination_account_nr_is' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_is' => ['alias' => true, 'alias_for' => 'destination_account_nr_is', 'needs_context' => true],
|
||||
'destination_account_nr_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_contains' => ['alias' => true, 'alias_for' => 'destination_account_nr_contains', 'needs_context' => true],
|
||||
'destination_account_nr_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_ends' => ['alias' => true, 'alias_for' => 'destination_account_nr_ends', 'needs_context' => true],
|
||||
'destination_account_nr_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'to_account_nr_starts' => ['alias' => true, 'alias_for' => 'destination_account_nr_starts', 'needs_context' => true],
|
||||
'account_is' => ['alias' => false, 'needs_context' => true],
|
||||
'account_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'account_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'account_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_is' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'account_nr_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'category_is' => ['alias' => false, 'needs_context' => true],
|
||||
'category_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'category' => ['alias' => true, 'alias_for' => 'category_contains', 'needs_context' => true],
|
||||
'category_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'category_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'budget_is' => ['alias' => false, 'needs_context' => true],
|
||||
'budget_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'budget' => ['alias' => true, 'alias_for' => 'budget_contains', 'needs_context' => true],
|
||||
'budget_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'budget_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'bill_is' => ['alias' => false, 'needs_context' => true],
|
||||
'bill_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'bill' => ['alias' => true, 'alias_for' => 'bill_contains', 'needs_context' => true],
|
||||
'bill_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'bill_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'subscription_is' => ['alias' => true, 'alias_for' => 'bill_is', 'needs_context' => true],
|
||||
'subscription_contains' => ['alias' => true, 'alias_for' => 'bill_contains', 'needs_context' => true],
|
||||
'subscription' => ['alias' => true, 'alias_for' => 'bill_contains', 'needs_context' => true],
|
||||
'subscription_ends' => ['alias' => true, 'alias_for' => 'bill_ends', 'needs_context' => true],
|
||||
'subscription_starts' => ['alias' => true, 'alias_for' => 'bill_starts', 'needs_context' => true],
|
||||
'external_id_is' => ['alias' => false, 'needs_context' => true],
|
||||
'external_id_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'external_id' => ['alias' => true, 'alias_for' => 'external_id_contains', 'needs_context' => true],
|
||||
'external_id_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'external_id_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference_is' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference' => ['alias' => true, 'alias_for' => 'internal_reference_contains', 'needs_context' => true],
|
||||
'internal_reference_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'internal_reference_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url_is' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url' => ['alias' => true, 'alias_for' => 'external_url_contains', 'needs_context' => true],
|
||||
'external_url_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'external_url_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'has_attachments' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_category' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_budget' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_bill' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_tag' => ['alias' => false, 'needs_context' => false],
|
||||
'any_notes' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],
|
||||
'has_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],
|
||||
'any_external_url' => ['alias' => false, 'needs_context' => false],
|
||||
'has_any_external_url' => ['alias' => true, 'alias_for' => 'any_external_url', 'needs_context' => false],
|
||||
'has_no_attachments' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_category' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_budget' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_bill' => ['alias' => false, 'needs_context' => false],
|
||||
'has_no_tag' => ['alias' => false, 'needs_context' => false],
|
||||
'no_notes' => ['alias' => false, 'needs_context' => false],
|
||||
'no_external_url' => ['alias' => false, 'needs_context' => false],
|
||||
'source_is_cash' => ['alias' => false, 'needs_context' => false],
|
||||
'destination_is_cash' => ['alias' => false, 'needs_context' => false],
|
||||
'account_is_cash' => ['alias' => false, 'needs_context' => false],
|
||||
'currency_is' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_currency_is' => ['alias' => false, 'needs_context' => true],
|
||||
'id' => ['alias' => false, 'trigger_class' => '', 'needs_context' => true],
|
||||
'journal_id' => ['alias' => false, 'trigger_class' => '', 'needs_context' => true],
|
||||
'recurrence_id' => ['alias' => false, 'trigger_class' => '', 'needs_context' => true],
|
||||
'date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'date' => ['alias' => true, 'alias_for' => 'date_on', 'needs_context' => true],
|
||||
'date_is' => ['alias' => true, 'alias_for' => 'date_on', 'needs_context' => true],
|
||||
'on' => ['alias' => true, 'alias_for' => 'date_on', 'needs_context' => true],
|
||||
'date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'before' => ['alias' => true, 'alias_for' => 'date_before', 'needs_context' => true],
|
||||
'date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'after' => ['alias' => true, 'alias_for' => 'date_after', 'needs_context' => true],
|
||||
'interest_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'interest_date' => ['alias' => true, 'alias_for' => 'interest_date_on', 'needs_context' => true],
|
||||
'interest_date_is' => ['alias' => true, 'alias_for' => 'interest_date_on', 'needs_context' => true],
|
||||
'interest_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'interest_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'book_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'book_date' => ['alias' => true, 'alias_for' => 'book_date_on', 'needs_context' => true],
|
||||
'book_date_is' => ['alias' => true, 'alias_for' => 'book_date_on', 'needs_context' => true],
|
||||
'book_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'book_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'process_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'process_date' => ['alias' => true, 'alias_for' => 'process_date_on', 'needs_context' => true],
|
||||
'process_date_is' => ['alias' => true, 'alias_for' => 'process_date_on', 'needs_context' => true],
|
||||
'process_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'process_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'due_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'due_date' => ['alias' => true, 'alias_for' => 'due_date_on', 'needs_context' => true],
|
||||
'due_date_is' => ['alias' => true, 'alias_for' => 'due_date_on', 'needs_context' => true],
|
||||
'due_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'due_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'payment_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'payment_date' => ['alias' => true, 'alias_for' => 'payment_date_on', 'needs_context' => true],
|
||||
'payment_date_is' => ['alias' => true, 'alias_for' => 'payment_date_on', 'needs_context' => true],
|
||||
'payment_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'payment_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'invoice_date_on' => ['alias' => false, 'needs_context' => true],
|
||||
'invoice_date' => ['alias' => true, 'alias_for' => 'invoice_date_on', 'needs_context' => true],
|
||||
'invoice_date_is' => ['alias' => true, 'alias_for' => 'invoice_date_on', 'needs_context' => true],
|
||||
'invoice_date_before' => ['alias' => false, 'needs_context' => true],
|
||||
'invoice_date_after' => ['alias' => false, 'needs_context' => true],
|
||||
'created_at_on' => ['alias' => false, 'needs_context' => true],
|
||||
'created_at' => ['alias' => true, 'alias_for' => 'created_at_on', 'needs_context' => true],
|
||||
'created_at_is' => ['alias' => true, 'alias_for' => 'created_at_on', 'needs_context' => true],
|
||||
'created_at_before' => ['alias' => false, 'needs_context' => true],
|
||||
'created_at_after' => ['alias' => false, 'needs_context' => true],
|
||||
'updated_at_on' => ['alias' => false, 'needs_context' => true],
|
||||
'updated_at' => ['alias' => true, 'alias_for' => 'updated_at_on', 'needs_context' => true],
|
||||
'updated_at_is' => ['alias' => true, 'alias_for' => 'updated_at_on', 'needs_context' => true],
|
||||
'updated_at_before' => ['alias' => false, 'needs_context' => true],
|
||||
'updated_at_after' => ['alias' => false, 'needs_context' => true],
|
||||
'created_on_on' => ['alias' => true, 'alias_for' => 'created_at_on', 'needs_context' => true],
|
||||
'created_on' => ['alias' => true, 'alias_for' => 'created_at', 'needs_context' => true],
|
||||
'created_on_before' => ['alias' => true, 'alias_for' => 'created_at_before', 'needs_context' => true],
|
||||
'created_on_after' => ['alias' => true, 'alias_for' => 'created_at_after', 'needs_context' => true],
|
||||
'updated_on_on' => ['alias' => true, 'alias_for' => 'updated_at_on', 'needs_context' => true],
|
||||
'updated_on' => ['alias' => true, 'alias_for' => 'updated_at', 'needs_context' => true],
|
||||
'updated_on_before' => ['alias' => true, 'alias_for' => 'updated_at_before', 'needs_context' => true],
|
||||
'updated_on_after' => ['alias' => true, 'alias_for' => 'updated_at_after', 'needs_context' => true],
|
||||
'amount_is' => ['alias' => false, 'needs_context' => true],
|
||||
'amount' => ['alias' => true, 'alias_for' => 'amount_is', 'needs_context' => true],
|
||||
'amount_exactly' => ['alias' => true, 'alias_for' => 'amount_is', 'needs_context' => true],
|
||||
'amount_less' => ['alias' => false, 'needs_context' => true],
|
||||
'amount_max' => ['alias' => true, 'alias_for' => 'amount_less', 'needs_context' => true],
|
||||
'less' => ['alias' => true, 'alias_for' => 'amount_less', 'needs_context' => true],
|
||||
'amount_more' => ['alias' => false, 'needs_context' => true],
|
||||
'amount_min' => ['alias' => true, 'alias_for' => 'amount_more', 'needs_context' => true],
|
||||
'more' => ['alias' => true, 'alias_for' => 'amount_more', 'needs_context' => true],
|
||||
'foreign_amount_is' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_amount' => ['alias' => true, 'alias_for' => 'foreign_amount_is', 'needs_context' => true],
|
||||
'foreign_amount_less' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_amount_max' => ['alias' => true, 'alias_for' => 'foreign_amount_less', 'needs_context' => true],
|
||||
'foreign_amount_more' => ['alias' => false, 'needs_context' => true],
|
||||
'foreign_amount_min' => ['alias' => true, 'alias_for' => 'foreign_amount_more', 'needs_context' => true],
|
||||
'attachment_name_is' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment' => ['alias' => true, 'alias_for' => 'attachment_name_is', 'needs_context' => true],
|
||||
'attachment_is' => ['alias' => true, 'alias_for' => 'attachment_name_is', 'needs_context' => true],
|
||||
'attachment_name' => ['alias' => true, 'alias_for' => 'attachment_name_is', 'needs_context' => true],
|
||||
'attachment_name_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_name_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_name_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes' => ['alias' => true, 'alias_for' => 'attachment_notes_are', 'needs_context' => true],
|
||||
'attachment_notes_are' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_contains' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_contain' => ['alias' => true, 'alias_for' => 'attachment_notes_contains', 'needs_context' => true],
|
||||
'attachment_notes_starts' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_start' => ['alias' => true, 'alias_for' => 'attachment_notes_starts', 'needs_context' => true],
|
||||
'attachment_notes_ends' => ['alias' => false, 'needs_context' => true],
|
||||
'attachment_notes_end' => ['alias' => true, 'alias_for' => 'attachment_notes_ends', 'needs_context' => true],
|
||||
'exists' => ['alias' => false, 'needs_context' => false],
|
||||
'sepa_ct_is' => ['alias' => false, 'needs_context' => true],
|
||||
'no_external_id' => ['alias' => false, 'needs_context' => false],
|
||||
'any_external_id' => ['alias' => false, 'needs_context' => false],
|
||||
|
||||
// based on source or destination balance. Very heavy search.
|
||||
'source_balance_gte' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_gt' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_lte' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_lt' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_is' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_gte' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_gt' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_lte' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_lt' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_is' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_gte' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_gt' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_lte' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_lt' => ['alias' => false, 'needs_context' => true],
|
||||
'source_balance_is' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_gte' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_gt' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_lte' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_lt' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_is' => ['alias' => false, 'needs_context' => true],
|
||||
],
|
||||
/**
|
||||
* Which query parser to use - 'new' or 'legacy'
|
||||
|
||||
@@ -155,6 +155,8 @@ return [
|
||||
'is_reconciled',
|
||||
'split',
|
||||
'single_split',
|
||||
'not_enough_currencies',
|
||||
'not_enough_currencies_enabled',
|
||||
'transaction_stored_link',
|
||||
'webhook_stored_link',
|
||||
'webhook_updated_link',
|
||||
|
||||
@@ -25,8 +25,8 @@ declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
@@ -37,8 +37,9 @@ return new class () extends Migration {
|
||||
// make account_id nullable and the relation also nullable.
|
||||
try {
|
||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||
// 1. drop index
|
||||
$table->dropForeign('piggy_banks_account_id_foreign');
|
||||
if (self::hasForeign('piggy_banks', 'piggy_banks_account_id_foreign')) {
|
||||
$table->dropForeign('piggy_banks_account_id_foreign');
|
||||
}
|
||||
});
|
||||
} catch (RuntimeException $e) {
|
||||
Log::error('Could not drop foreign key "piggy_banks_account_id_foreign". Probably not an issue.');
|
||||
@@ -49,42 +50,70 @@ return new class () extends Migration {
|
||||
});
|
||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||
// 3. add currency
|
||||
$table->integer('transaction_currency_id', false, true)->after('account_id')->nullable();
|
||||
$table->foreign('transaction_currency_id', 'unique_currency')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
if (!Schema::hasColumn('piggy_banks', 'transaction_currency_id')) {
|
||||
$table->integer('transaction_currency_id', false, true)->after('account_id')->nullable();
|
||||
}
|
||||
if (!self::hasForeign('piggy_banks', 'unique_currency')) {
|
||||
$table->foreign('transaction_currency_id', 'unique_currency')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
}
|
||||
});
|
||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||
// 4. rename columns
|
||||
$table->renameColumn('targetamount', 'target_amount');
|
||||
$table->renameColumn('startdate', 'start_date');
|
||||
$table->renameColumn('targetdate', 'target_date');
|
||||
$table->renameColumn('startdate_tz', 'start_date_tz');
|
||||
$table->renameColumn('targetdate_tz', 'target_date_tz');
|
||||
if (Schema::hasColumn('piggy_banks', 'targetamount') && !Schema::hasColumn('piggy_banks', 'target_amount')) {
|
||||
$table->renameColumn('targetamount', 'target_amount');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_banks', 'startdate') && !Schema::hasColumn('piggy_banks', 'start_date')) {
|
||||
$table->renameColumn('startdate', 'start_date');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_banks', 'targetdate') && !Schema::hasColumn('piggy_banks', 'target_date')) {
|
||||
$table->renameColumn('targetdate', 'target_date');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_banks', 'targetdate') && !Schema::hasColumn('startdate_tz', 'start_date_tz')) {
|
||||
$table->renameColumn('startdate_tz', 'start_date_tz');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_banks', 'targetdate_tz') && !Schema::hasColumn('target_date_tz', 'start_date_tz')) {
|
||||
$table->renameColumn('targetdate_tz', 'target_date_tz');
|
||||
}
|
||||
});
|
||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||
// 5. add new index
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('set null');
|
||||
if (!self::hasForeign('piggy_banks', 'piggy_banks_account_id_foreign')) {
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('set null');
|
||||
}
|
||||
});
|
||||
|
||||
// rename some fields in piggy bank reps.
|
||||
Schema::table('piggy_bank_repetitions', static function (Blueprint $table): void {
|
||||
// 6. rename columns
|
||||
$table->renameColumn('currentamount', 'current_amount');
|
||||
$table->renameColumn('startdate', 'start_date');
|
||||
$table->renameColumn('targetdate', 'target_date');
|
||||
$table->renameColumn('startdate_tz', 'start_date_tz');
|
||||
$table->renameColumn('targetdate_tz', 'target_date_tz');
|
||||
if (Schema::hasColumn('piggy_bank_repetitions', 'currentamount') && !Schema::hasColumn('piggy_bank_repetitions', 'current_amount')) {
|
||||
$table->renameColumn('currentamount', 'current_amount');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_bank_repetitions', 'startdate') && !Schema::hasColumn('piggy_bank_repetitions', 'start_date')) {
|
||||
$table->renameColumn('startdate', 'start_date');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_bank_repetitions', 'targetdate') && !Schema::hasColumn('piggy_bank_repetitions', 'target_date')) {
|
||||
$table->renameColumn('targetdate', 'target_date');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_bank_repetitions', 'startdate_tz') && !Schema::hasColumn('piggy_bank_repetitions', 'start_date_tz')) {
|
||||
$table->renameColumn('startdate_tz', 'start_date_tz');
|
||||
}
|
||||
if (Schema::hasColumn('piggy_bank_repetitions', 'targetdate_tz') && !Schema::hasColumn('piggy_bank_repetitions', 'target_date_tz')) {
|
||||
$table->renameColumn('targetdate_tz', 'target_date_tz');
|
||||
}
|
||||
});
|
||||
|
||||
// create table account_piggy_bank
|
||||
Schema::create('account_piggy_bank', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->integer('account_id', false, true);
|
||||
$table->integer('piggy_bank_id', false, true);
|
||||
$table->decimal('current_amount', 32, 12)->default('0');
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||
$table->unique(['account_id', 'piggy_bank_id'], 'unique_piggy_save');
|
||||
});
|
||||
if (!Schema::hasTable('account_piggy_bank')) {
|
||||
Schema::create('account_piggy_bank', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->integer('account_id', false, true);
|
||||
$table->integer('piggy_bank_id', false, true);
|
||||
$table->decimal('current_amount', 32, 12)->default('0');
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||
$table->unique(['account_id', 'piggy_bank_id'], 'unique_piggy_save');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -105,7 +134,9 @@ return new class () extends Migration {
|
||||
$table->renameColumn('target_date_tz', 'targetdate_tz');
|
||||
|
||||
// 3. drop currency again + index
|
||||
$table->dropForeign('unique_currency');
|
||||
if (self::hasForeign('piggy_banks', 'unique_currency')) {
|
||||
$table->dropForeign('unique_currency');
|
||||
}
|
||||
$table->dropColumn('transaction_currency_id');
|
||||
|
||||
// 2. make column non-nullable.
|
||||
@@ -127,4 +158,17 @@ return new class () extends Migration {
|
||||
|
||||
Schema::dropIfExists('account_piggy_bank');
|
||||
}
|
||||
|
||||
protected static function hasForeign(string $table, string $column): bool
|
||||
{
|
||||
|
||||
$foreignKeysDefinitions = Schema::getForeignKeys($table);
|
||||
foreach ($foreignKeysDefinitions as $foreignKeyDefinition) {
|
||||
if ($foreignKeyDefinition['name'] === $column) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,8 +41,6 @@ return new class () extends Migration {
|
||||
'piggy_banks' => ['native_target_amount'], // works
|
||||
'transactions' => ['native_amount', 'native_foreign_amount'], // works
|
||||
|
||||
// TODO button to recalculate all native amounts on selected pages?
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -52,9 +50,11 @@ return new class () extends Migration {
|
||||
{
|
||||
foreach ($this->tables as $table => $fields) {
|
||||
foreach ($fields as $field) {
|
||||
Schema::table($table, static function (Blueprint $table) use ($field): void {
|
||||
Schema::table($table, static function (Blueprint $tableObject) use ($table, $field): void {
|
||||
// add amount column
|
||||
$table->decimal($field, 32, 12)->nullable();
|
||||
if (!Schema::hasColumn($table, $field)) {
|
||||
$tableObject->decimal($field, 32, 12)->nullable();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ class TransactionCurrencySeeder extends Seeder
|
||||
$currencies[] = ['code' => 'PLN', 'name' => 'Polish złoty', 'symbol' => 'zł', 'decimal_places' => 2];
|
||||
$currencies[] = ['code' => 'TRY', 'name' => 'Turkish lira', 'symbol' => '₺', 'decimal_places' => 2];
|
||||
$currencies[] = ['code' => 'DKK', 'name' => 'Dansk krone', 'symbol' => 'kr.', 'decimal_places' => 2];
|
||||
$currencies[] = ['code' => 'ISK', 'name' => 'Íslensk króna', 'symbol' => 'kr.', 'decimal_places' => 2];
|
||||
$currencies[] = ['code' => 'NOK', 'name' => 'Norsk krone', 'symbol' => 'kr.', 'decimal_places' => 2];
|
||||
$currencies[] = ['code' => 'SEK', 'name' => 'Svensk krona', 'symbol' => 'kr.', 'decimal_places' => 2];
|
||||
$currencies[] = ['code' => 'RON', 'name' => 'Romanian leu', 'symbol' => 'lei', 'decimal_places' => 2];
|
||||
|
||||
// american currencies
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user