mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Various code changes.
This commit is contained in:
24
.ci/phpmd/composer.lock
generated
24
.ci/phpmd/composer.lock
generated
@@ -470,16 +470,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/dependency-injection",
|
"name": "symfony/dependency-injection",
|
||||||
"version": "v7.0.1",
|
"version": "v7.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/dependency-injection.git",
|
"url": "https://github.com/symfony/dependency-injection.git",
|
||||||
"reference": "f6667642954bce638733f254c39e5b5700b47ba4"
|
"reference": "bd25ef7c937b9da12510bdc4f1c66728f19620e3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f6667642954bce638733f254c39e5b5700b47ba4",
|
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/bd25ef7c937b9da12510bdc4f1c66728f19620e3",
|
||||||
"reference": "f6667642954bce638733f254c39e5b5700b47ba4",
|
"reference": "bd25ef7c937b9da12510bdc4f1c66728f19620e3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -530,7 +530,7 @@
|
|||||||
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
|
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/dependency-injection/tree/v7.0.1"
|
"source": "https://github.com/symfony/dependency-injection/tree/v7.0.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -546,7 +546,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-12-01T15:10:06+00:00"
|
"time": "2023-12-28T19:18:20+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/deprecation-contracts",
|
"name": "symfony/deprecation-contracts",
|
||||||
@@ -927,16 +927,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/var-exporter",
|
"name": "symfony/var-exporter",
|
||||||
"version": "v7.0.1",
|
"version": "v7.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/var-exporter.git",
|
"url": "https://github.com/symfony/var-exporter.git",
|
||||||
"reference": "a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3"
|
"reference": "345c62fefe92243c3a06fc0cc65f2ec1a47e0764"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3",
|
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/345c62fefe92243c3a06fc0cc65f2ec1a47e0764",
|
||||||
"reference": "a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3",
|
"reference": "345c62fefe92243c3a06fc0cc65f2ec1a47e0764",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -981,7 +981,7 @@
|
|||||||
"serialize"
|
"serialize"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/var-exporter/tree/v7.0.1"
|
"source": "https://github.com/symfony/var-exporter/tree/v7.0.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -997,7 +997,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-11-30T11:38:21+00:00"
|
"time": "2023-12-27T08:42:13+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
@@ -64,11 +64,11 @@ class StoreRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => 'required|between:1,255|uniquePiggyBankForUser',
|
'name' => 'required|between:1,255|uniquePiggyBankForUser',
|
||||||
'current_amount' => ['numeric', 'gte:0', 'lte:target_amount','max:1000000000'],
|
'current_amount' => ['numeric', 'gte:0', 'lte:target_amount', 'max:1000000000'],
|
||||||
'account_id' => 'required|numeric|belongsToUser:accounts,id',
|
'account_id' => 'required|numeric|belongsToUser:accounts,id',
|
||||||
'object_group_id' => 'numeric|belongsToUser:object_groups,id',
|
'object_group_id' => 'numeric|belongsToUser:object_groups,id',
|
||||||
'object_group_title' => 'between:1,255',
|
'object_group_title' => 'between:1,255',
|
||||||
'target_amount' => ['numeric', 'gte:0', 'lte:target_amount', 'required','max:1000000000'],
|
'target_amount' => ['numeric', 'gte:0', 'lte:target_amount', 'required', 'max:1000000000'],
|
||||||
'start_date' => 'date|nullable',
|
'start_date' => 'date|nullable',
|
||||||
'target_date' => 'date|nullable|after:start_date',
|
'target_date' => 'date|nullable|after:start_date',
|
||||||
'notes' => 'max:65000',
|
'notes' => 'max:65000',
|
||||||
|
@@ -69,7 +69,7 @@ class UpdateRequest extends FormRequest
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => 'between:1,255|uniquePiggyBankForUser:'.$piggyBank->id,
|
'name' => 'between:1,255|uniquePiggyBankForUser:'.$piggyBank->id,
|
||||||
'current_amount' => ['numeric', 'gte:0', new LessThanPiggyTarget(),'max:1000000000'],
|
'current_amount' => ['numeric', 'gte:0', new LessThanPiggyTarget(), 'max:1000000000'],
|
||||||
'target_amount' => 'numeric|gte:0|max:1000000000',
|
'target_amount' => 'numeric|gte:0|max:1000000000',
|
||||||
'start_date' => 'date|nullable',
|
'start_date' => 'date|nullable',
|
||||||
'target_date' => 'date|nullable|after:start_date',
|
'target_date' => 'date|nullable|after:start_date',
|
||||||
|
@@ -171,7 +171,7 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$data = $request->getAccountData();
|
$data = $request->getAccountData();
|
||||||
$this->repository->update($account, $data);
|
$this->repository->update($account, $data);
|
||||||
|
Log::channel('audit')->info(sprintf('Updated account #%d.', $account->id), $data);
|
||||||
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
||||||
|
|
||||||
// store new attachment(s):
|
// store new attachment(s):
|
||||||
|
@@ -117,6 +117,8 @@ class EditController extends Controller
|
|||||||
$billData = $request->getBillData();
|
$billData = $request->getBillData();
|
||||||
$bill = $this->repository->update($bill, $billData);
|
$bill = $this->repository->update($bill, $billData);
|
||||||
|
|
||||||
|
Log::channel('audit')->info(sprintf('Updated bill #%d.', $bill->id), $billData);
|
||||||
|
|
||||||
$request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));
|
$request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
@@ -246,7 +246,18 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
|
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int)$journal['currency_id'];
|
$found = false;
|
||||||
|
|
||||||
|
/** @var array $localTag */
|
||||||
|
foreach ($journal['tags'] as $localTag) {
|
||||||
|
if ($localTag['id'] === $tag->id) {
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (false === $found) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$sums[$currencyId] ??= [
|
$sums[$currencyId] ??= [
|
||||||
'currency_id' => $currencyId,
|
'currency_id' => $currencyId,
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
@@ -260,7 +271,7 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
];
|
];
|
||||||
|
|
||||||
// add amount to correct type:
|
// add amount to correct type:
|
||||||
$amount = app('steam')->positive((string)$journal['amount']);
|
$amount = app('steam')->positive((string) $journal['amount']);
|
||||||
$type = $journal['transaction_type_type'];
|
$type = $journal['transaction_type_type'];
|
||||||
if (TransactionType::WITHDRAWAL === $type) {
|
if (TransactionType::WITHDRAWAL === $type) {
|
||||||
$amount = bcmul($amount, '-1');
|
$amount = bcmul($amount, '-1');
|
||||||
@@ -281,7 +292,7 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
TransactionType::OPENING_BALANCE => '0',
|
TransactionType::OPENING_BALANCE => '0',
|
||||||
];
|
];
|
||||||
// add foreign amount to correct type:
|
// add foreign amount to correct type:
|
||||||
$amount = app('steam')->positive((string)$journal['foreign_amount']);
|
$amount = app('steam')->positive((string) $journal['foreign_amount']);
|
||||||
if (TransactionType::WITHDRAWAL === $type) {
|
if (TransactionType::WITHDRAWAL === $type) {
|
||||||
$amount = bcmul($amount, '-1');
|
$amount = bcmul($amount, '-1');
|
||||||
}
|
}
|
||||||
|
@@ -347,7 +347,7 @@ trait PeriodOverview
|
|||||||
$cache->addProperty('tag-period-entries');
|
$cache->addProperty('tag-period-entries');
|
||||||
$cache->addProperty($tag->id);
|
$cache->addProperty($tag->id);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
// return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $dates */
|
/** @var array $dates */
|
||||||
@@ -378,6 +378,11 @@ trait PeriodOverview
|
|||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
$transferSet = $collector->getExtractedJournals();
|
$transferSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
|
// filer all of them:
|
||||||
|
$earnedSet = $this->filterJournalsByTag($earnedSet, $tag);
|
||||||
|
$spentSet = $this->filterJournalsByTag($spentSet, $tag);
|
||||||
|
$transferSet = $this->filterJournalsByTag($transferSet, $tag);
|
||||||
|
|
||||||
foreach ($dates as $currentDate) {
|
foreach ($dates as $currentDate) {
|
||||||
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
|
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
|
||||||
$earned = $this->filterJournalsByDate($earnedSet, $currentDate['start'], $currentDate['end']);
|
$earned = $this->filterJournalsByDate($earnedSet, $currentDate['start'], $currentDate['end']);
|
||||||
@@ -485,7 +490,7 @@ trait PeriodOverview
|
|||||||
|
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
if ($account->id === (int)$journal['source_account_id']) {
|
if ($account->id === (int) $journal['source_account_id']) {
|
||||||
$return[] = $journal;
|
$return[] = $journal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -502,7 +507,7 @@ trait PeriodOverview
|
|||||||
|
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
if ($account->id === (int)$journal['destination_account_id']) {
|
if ($account->id === (int) $journal['destination_account_id']) {
|
||||||
$return[] = $journal;
|
$return[] = $journal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -516,7 +521,7 @@ trait PeriodOverview
|
|||||||
|
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int)$journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$foreignCurrencyId = $journal['foreign_currency_id'];
|
$foreignCurrencyId = $journal['foreign_currency_id'];
|
||||||
if (!array_key_exists($currencyId, $return)) {
|
if (!array_key_exists($currencyId, $return)) {
|
||||||
$return[$currencyId] = [
|
$return[$currencyId] = [
|
||||||
@@ -537,7 +542,7 @@ trait PeriodOverview
|
|||||||
$return[$foreignCurrencyId] = [
|
$return[$foreignCurrencyId] = [
|
||||||
'amount' => '0',
|
'amount' => '0',
|
||||||
'count' => 0,
|
'count' => 0,
|
||||||
'currency_id' => (int)$foreignCurrencyId,
|
'currency_id' => (int) $foreignCurrencyId,
|
||||||
'currency_name' => $journal['foreign_currency_name'],
|
'currency_name' => $journal['foreign_currency_name'],
|
||||||
'currency_code' => $journal['foreign_currency_code'],
|
'currency_code' => $journal['foreign_currency_code'],
|
||||||
'currency_symbol' => $journal['foreign_currency_symbol'],
|
'currency_symbol' => $journal['foreign_currency_symbol'],
|
||||||
@@ -551,4 +556,25 @@ trait PeriodOverview
|
|||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function filterJournalsByTag(array $set, Tag $tag): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
foreach ($set as $entry) {
|
||||||
|
$found = false;
|
||||||
|
|
||||||
|
/** @var array $localTag */
|
||||||
|
foreach ($entry['tags'] as $localTag) {
|
||||||
|
if ($localTag['id'] === $tag->id) {
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (false === $found) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$return[] = $entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user