Compare commits

..

27 Commits

Author SHA1 Message Date
github-actions[bot]
33668a3688 Merge pull request #10171 from firefly-iii/release-1745205809
🤖 Automatically merge the PR into the develop branch.
2025-04-21 05:23:36 +02:00
JC5
5414a70abb 🤖 Auto commit for release 'develop' on 2025-04-21 2025-04-21 05:23:29 +02:00
github-actions[bot]
ad09c851f6 Merge pull request #10169 from firefly-iii/release-1745176916
🤖 Automatically merge the PR into the develop branch.
2025-04-20 21:22:04 +02:00
JC5
c57f36820b 🤖 Auto commit for release 'v6.2.12' on 2025-04-20 2025-04-20 21:21:56 +02:00
github-actions[bot]
6bb2702e07 Merge pull request #10168 from firefly-iii/release-1745176354
🤖 Automatically merge the PR into the develop branch.
2025-04-20 21:12:43 +02:00
JC5
b1dbd3ee17 🤖 Auto commit for release 'develop' on 2025-04-20 2025-04-20 21:12:34 +02:00
James Cole
2d41db349a Merge pull request #10167 from firefly-iii/update-changelog2
Update changelog
2025-04-20 21:07:06 +02:00
James Cole
6b73b9327a Update changelog 2025-04-20 21:06:27 +02:00
James Cole
e3ea54329d Merge pull request #10166 from firefly-iii/add-events
Add some piggy bank events.
2025-04-20 21:04:27 +02:00
James Cole
686a76f32c Merge pull request #10165 from firefly-iii/fix-10162
Fix #10162
2025-04-20 21:04:07 +02:00
James Cole
cdafb82a49 Merge pull request #10164 from firefly-iii/fix-10068-2
Fix #10068
2025-04-20 21:03:52 +02:00
James Cole
0075f10f98 Fix #10162 2025-04-20 21:02:54 +02:00
James Cole
b70c0e4ab3 Add some piggy bank events. 2025-04-20 21:01:23 +02:00
James Cole
01aca092a1 Fix #10068 2025-04-20 21:00:43 +02:00
James Cole
8e6449ec12 Merge pull request #10161 from firefly-iii/fix-9755
Fix #9755
2025-04-20 12:59:11 +02:00
James Cole
984c4e2449 Fix #9755 2025-04-20 12:58:45 +02:00
James Cole
002c5485f5 Merge pull request #10160 from firefly-iii/fix-9867
Fix #9867
2025-04-20 12:47:35 +02:00
James Cole
12d74f15c0 Fix #9867 2025-04-20 12:47:13 +02:00
James Cole
2e87e179f0 Merge pull request #10159 from firefly-iii/fix-9878
Fix #9878
2025-04-20 12:42:20 +02:00
James Cole
a861126c0f Fix #9878 2025-04-20 12:41:46 +02:00
github-actions[bot]
8f5e58e8ad Merge pull request #10158 from firefly-iii/develop
🤖 Automatically merge the PR into the main branch.
2025-04-20 08:28:36 +02:00
github-actions[bot]
6c26f1f677 Merge pull request #10157 from firefly-iii/release-1745130504
🤖 Automatically merge the PR into the develop branch.
2025-04-20 08:28:32 +02:00
JC5
d7caaca5e4 🤖 Auto commit for release 'v6.2.11' on 2025-04-20 2025-04-20 08:28:25 +02:00
James Cole
835c81f329 Merge pull request #10156 from firefly-iii/jumble
Intentional code jumbling. This needs improvement in the action.
2025-04-20 08:24:36 +02:00
James Cole
1615b0cb29 Intentional code jumbling. This needs improvement in the action. 2025-04-20 08:24:16 +02:00
github-actions[bot]
c07a279c81 Merge pull request #10154 from firefly-iii/release-1745129634
🤖 Automatically merge the PR into the develop branch.
2025-04-20 08:14:00 +02:00
JC5
1478dae316 🤖 Auto commit for release 'v6.2.11' on 2025-04-20 2025-04-20 08:13:54 +02:00
13 changed files with 100 additions and 34 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Factory;
use FireflyIII\Events\Model\PiggyBank\ChangedAmount;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\TransactionCurrency;
@@ -237,20 +238,46 @@ class PiggyBankFactory
}
}
/** @var array $info */
foreach ($accounts as $info) {
$account = $this->accountRepository->find((int) ($info['account_id'] ?? 0));
if (null === $account) {
Log::debug(sprintf('Account #%d not found, skipping.', (int) ($info['account_id'] ?? 0)));
continue;
}
if (array_key_exists('current_amount', $info) && null !== $info['current_amount']) {
// an amount is set, first check out if there is a difference with the previous amount.
$previous = $toBeLinked[$account->id]['current_amount'] ?? '0';
$diff = bcsub($info['current_amount'], $previous);
// create event for difference.
if (0 !== bccomp($diff, '0')) {
Log::debug(sprintf('[a] Will save event for difference %s (previous value was %s)', $diff, $previous));
event(new ChangedAmount($piggyBank, $diff, null, null));
}
$toBeLinked[$account->id] = ['current_amount' => $info['current_amount']];
Log::debug(sprintf('[a] Will link account #%d with amount %s', $account->id, $info['current_amount']));
}
if (array_key_exists('current_amount', $info) && null === $info['current_amount']) {
// an amount is set, first check out if there is a difference with the previous amount.
$previous = $toBeLinked[$account->id]['current_amount'] ?? '0';
$diff = bcsub('0', $previous);
// create event for difference.
if (0 !== bccomp($diff, '0')) {
Log::debug(sprintf('[b] Will save event for difference %s (previous value was %s)', $diff, $previous));
event(new ChangedAmount($piggyBank, $diff, null, null));
}
// no amount set, use previous amount or go to ZERO.
$toBeLinked[$account->id] = ['current_amount' => $toBeLinked[$account->id]['current_amount'] ?? '0'];
Log::debug(sprintf('[b] Will link account #%d with amount %s', $account->id, $toBeLinked[$account->id]['current_amount'] ?? '0'));
// create event:
Log::debug('linkToAccountIds: Trigger change for positive amount [b].');
event(new ChangedAmount($piggyBank, $toBeLinked[$account->id]['current_amount'], null, null));
}
if (!array_key_exists('current_amount', $info)) {
$toBeLinked[$account->id] ??= [];
@@ -258,6 +285,11 @@ class PiggyBankFactory
}
}
Log::debug(sprintf('Link information: %s', json_encode($toBeLinked)));
$piggyBank->accounts()->sync($toBeLinked);
if (0 !== count($toBeLinked)) {
$piggyBank->accounts()->sync($toBeLinked);
}
if (0 === count($toBeLinked)) {
Log::warning('No accounts to link to piggy bank, will not change whatever is there now.');
}
}
}

View File

@@ -82,13 +82,16 @@ class AccountController extends Controller
*/
public function expenseAccounts(): JsonResponse
{
Log::debug('RevenueAccounts');
Log::debug('ExpenseAccounts');
/** @var Carbon $start */
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $end */
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
$start->startOfDay();
$end->endOfDay();
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
@@ -97,7 +100,6 @@ class AccountController extends Controller
if ($cache->has()) {
return response()->json($cache->get());
}
$start->subDay();
// prep some vars:
$currencies = [];
@@ -557,6 +559,10 @@ class AccountController extends Controller
/** @var Carbon $end */
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
$start->startOfDay();
$end->endOfDay();
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
@@ -565,7 +571,6 @@ class AccountController extends Controller
if ($cache->has()) {
return response()->json($cache->get());
}
$start->subDay();
// prep some vars:
$currencies = [];

View File

@@ -78,13 +78,14 @@ class EditController extends Controller
$startDate = $piggyBank->start_date?->format('Y-m-d');
$preFilled = [
'name' => $piggyBank->name,
'target_amount' => app('steam')->bcround($piggyBank->target_amount, $piggyBank->transactionCurrency->decimal_places),
'target_date' => $targetDate,
'start_date' => $startDate,
'accounts' => [],
'object_group' => null !== $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '',
'notes' => null === $note ? '' : $note->text,
'name' => $piggyBank->name,
'transaction_currency_id' => (int) $piggyBank->transaction_currency_id,
'target_amount' => app('steam')->bcround($piggyBank->target_amount, $piggyBank->transactionCurrency->decimal_places),
'target_date' => $targetDate,
'start_date' => $startDate,
'accounts' => [],
'object_group' => null !== $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '',
'notes' => null === $note ? '' : $note->text,
];
foreach ($piggyBank->accounts as $account) {
$preFilled['accounts'][] = $account->id;

View File

@@ -32,11 +32,11 @@ use Symfony\Component\HttpFoundation\Request;
class TrustProxies extends Middleware
{
// After...
protected $headers
= Request::HEADER_X_FORWARDED_FOR
protected $headers = Request::HEADER_X_FORWARDED_FOR
| Request::HEADER_X_FORWARDED_HOST
| Request::HEADER_X_FORWARDED_PORT
| Request::HEADER_X_FORWARDED_PROTO
| Request::HEADER_X_FORWARDED_PREFIX
| Request::HEADER_X_FORWARDED_AWS_ELB;
/**

View File

@@ -49,12 +49,13 @@ class PiggyBankUpdateRequest extends FormRequest
{
$accounts = $this->get('accounts');
$data = [
'name' => $this->convertString('name'),
'start_date' => $this->getCarbonDate('start_date'),
'target_amount' => trim($this->convertString('target_amount')),
'target_date' => $this->getCarbonDate('target_date'),
'notes' => $this->stringWithNewlines('notes'),
'object_group_title' => $this->convertString('object_group'),
'name' => $this->convertString('name'),
'start_date' => $this->getCarbonDate('start_date'),
'target_amount' => trim($this->convertString('target_amount')),
'target_date' => $this->getCarbonDate('target_date'),
'transaction_currency_id' => $this->convertInteger('transaction_currency_id'),
'notes' => $this->stringWithNewlines('notes'),
'object_group_title' => $this->convertString('object_group'),
];
if (!is_array($accounts)) {
$accounts = [];
@@ -75,15 +76,16 @@ class PiggyBankUpdateRequest extends FormRequest
$piggy = $this->route()->parameter('piggyBank');
return [
'name' => sprintf('required|min:1|max:255|uniquePiggyBankForUser:%d', $piggy->id),
'accounts' => 'required|array',
'accounts.*' => 'required|belongsToUser:accounts',
'target_amount' => ['nullable', new IsValidPositiveAmount()],
'start_date' => 'date',
'target_date' => 'date|nullable',
'order' => 'integer|max:32768|min:1',
'object_group' => 'min:0|max:255',
'notes' => 'min:1|max:32768|nullable',
'name' => sprintf('required|min:1|max:255|uniquePiggyBankForUser:%d', $piggy->id),
'accounts' => 'required|array',
'accounts.*' => 'required|belongsToUser:accounts',
'target_amount' => ['nullable', new IsValidPositiveAmount()],
'start_date' => 'date',
'transaction_currency_id' => 'exists:transaction_currencies,id',
'target_date' => 'date|nullable',
'order' => 'integer|max:32768|min:1',
'object_group' => 'min:0|max:255',
'notes' => 'min:1|max:32768|nullable',
];
}

View File

@@ -31,6 +31,7 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\Note;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
@@ -223,6 +224,8 @@ trait ModifiesPiggyBanks
$factory = new PiggyBankFactory();
$factory->user = $this->user;
// the piggy bank currency is set or updated FIRST, if it exists.
$factory->linkToAccountIds($piggyBank, $data['accounts'] ?? []);
@@ -280,6 +283,13 @@ trait ModifiesPiggyBanks
if (array_key_exists('name', $data) && '' !== $data['name']) {
$piggyBank->name = $data['name'];
}
if (array_key_exists('transaction_currency_id', $data) && is_int($data['transaction_currency_id'])) {
$currency = TransactionCurrency::find($data['transaction_currency_id']);
if (null !== $currency) {
$piggyBank->transaction_currency_id = $currency->id;
}
}
if (array_key_exists('target_amount', $data) && '' !== $data['target_amount']) {
$piggyBank->target_amount = $data['target_amount'];
}

View File

@@ -57,6 +57,7 @@ use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use League\Csv\CannotInsertRecord;
use League\Csv\Exception;
use League\Csv\Writer;

View File

@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 6.2.12 - 2025-04-21
### Fixed
- [Issue 9755](https://github.com/firefly-iii/firefly-iii/issues/9755) (Unable to create transactions with non-native currency accounts when "display amounts in native currency" is enabled) reported by @dicksonleong
- [Issue 9867](https://github.com/firefly-iii/firefly-iii/issues/9867) (Transactions from Jan 31 being counted in February) reported by @edbingo
- [Issue 9878](https://github.com/firefly-iii/firefly-iii/issues/9878) (Piggy bank currency - wrong setting displayed or setting not saved) reported by @dethegeek
- [Issue 10068](https://github.com/firefly-iii/firefly-iii/issues/10068) (Export Data isn't exporting all transactions in the data) reported by @firsttiger
- [Discussion 10162](https://github.com/orgs/firefly-iii/discussions/10162) (Reverse proxy and `X-Forwarded-Prefix` header) started by @frenchu
## 6.2.11 - 2025-04-21
### Added

View File

@@ -78,7 +78,7 @@ return [
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2025-04-20',
'version' => 'develop/2025-04-21',
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 25,

View File

@@ -216,7 +216,7 @@ export default {
}
},
selectedItem: function (e) {
console.log('In SelectedItem()');
// console.log('In SelectedItem()');
if (typeof this.name === 'undefined') {
// console.log('Is undefined');
return;

View File

@@ -540,12 +540,18 @@ export default {
allowed_types: window.expectedSourceTypes.destination[this.ucFirst(transaction.type)]
}
};
// console.log('Destination currency id is ' + result.destination_account.currency_id);
// if transaction type is transfer, the destination currency_id etc. MUST match the actual account currency info.
if ('transfer' === transaction.type && null !== transaction.foreign_currency_code) {
// OR if the transaction type is a withdrawal, and the destination account is a liability account, same as above.
if (
('transfer' === transaction.type && null !== transaction.foreign_currency_code) ||
('withdrawal' === transaction.type && ['Loan', 'Debt', 'Mortgage'].includes(transaction.destination_type) && null !== transaction.foreign_currency_code)
) {
result.destination_account.currency_id = transaction.foreign_currency_id;
result.destination_account.currency_name = transaction.foreign_currency_name;
result.destination_account.currency_code = transaction.foreign_currency_code;
result.destination_account.currency_decimal_places = transaction.foreign_currency_decimal_places;
// console.log('Set destination currency_id to ' + result.destination_account.currency_id);
}

View File

@@ -137,7 +137,6 @@ export default {
// lock dropdown list on currencyID of destination.
for (const key in this.currencies) {
if (this.currencies.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
if (
parseInt(this.currencies[key].id) === parseInt(this.destination.currency_id)
) {

View File

@@ -23,7 +23,7 @@
<div class="box-body">
{{ ExpandedForm.text('name') }}
{{ ExpandedForm.amountNoCurrency('target_amount') }}
{{ CurrencyForm.currencyList('transaction_currency_id', null, {helpText:'piggy_default_currency'|_}) }}
{{ CurrencyForm.currencyList('transaction_currency_id', preFilled.transaction_currency_id, {helpText:'piggy_default_currency'|_}) }}
{{ AccountForm.assetLiabilityMultiAccountList('accounts', preFilled.accounts, {label: 'saveOnAccounts'|_, helpText: 'piggy_account_currency_match'|_ }) }}
</div>