mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
fixed #406
This commit is contained in:
parent
6506e70a91
commit
a319264428
@ -510,20 +510,28 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
private function storeDepositAccounts(array $data): array
|
private function storeDepositAccounts(array $data): array
|
||||||
{
|
{
|
||||||
|
Log::debug('Now in storeDepositAccounts().');
|
||||||
$destinationAccount = Account::where('user_id', $this->user->id)->where('id', $data['destination_account_id'])->first(['accounts.*']);
|
$destinationAccount = Account::where('user_id', $this->user->id)->where('id', $data['destination_account_id'])->first(['accounts.*']);
|
||||||
|
|
||||||
|
Log::debug(sprintf('Destination account is #%d ("%s")', $destinationAccount->id, $destinationAccount->name));
|
||||||
|
|
||||||
if (strlen($data['source_account_name']) > 0) {
|
if (strlen($data['source_account_name']) > 0) {
|
||||||
$sourceType = AccountType::where('type', 'Revenue account')->first();
|
$sourceType = AccountType::where('type', 'Revenue account')->first();
|
||||||
$sourceAccount = Account::firstOrCreateEncrypted(
|
$sourceAccount = Account::firstOrCreateEncrypted(
|
||||||
['user_id' => $this->user->id, 'account_type_id' => $sourceType->id, 'name' => $data['source_account_name'], 'active' => 1]
|
['user_id' => $this->user->id, 'account_type_id' => $sourceType->id, 'name' => $data['source_account_name'], 'active' => 1]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Log::debug(sprintf('source account name is "%s", account is %d', $data['source_account_name'], $sourceAccount->id));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'source' => $sourceAccount,
|
'source' => $sourceAccount,
|
||||||
'destination' => $destinationAccount,
|
'destination' => $destinationAccount,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$sourceType = AccountType::where('type', 'Cash account')->first();
|
|
||||||
|
Log::debug('source_account_name is empty, so default to cash account!');
|
||||||
|
|
||||||
|
$sourceType = AccountType::where('type', AccountType::CASH)->first();
|
||||||
$sourceAccount = Account::firstOrCreateEncrypted(
|
$sourceAccount = Account::firstOrCreateEncrypted(
|
||||||
['user_id' => $this->user->id, 'account_type_id' => $sourceType->id, 'name' => 'Cash account', 'active' => 1]
|
['user_id' => $this->user->id, 'account_type_id' => $sourceType->id, 'name' => 'Cash account', 'active' => 1]
|
||||||
);
|
);
|
||||||
@ -618,8 +626,11 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
private function storeWithdrawalAccounts(array $data): array
|
private function storeWithdrawalAccounts(array $data): array
|
||||||
{
|
{
|
||||||
|
Log::debug('Now in storeWithdrawalAccounts().');
|
||||||
$sourceAccount = Account::where('user_id', $this->user->id)->where('id', $data['source_account_id'])->first(['accounts.*']);
|
$sourceAccount = Account::where('user_id', $this->user->id)->where('id', $data['source_account_id'])->first(['accounts.*']);
|
||||||
|
|
||||||
|
Log::debug(sprintf('Source account is #%d ("%s")', $sourceAccount->id, $sourceAccount->name));
|
||||||
|
|
||||||
if (strlen($data['destination_account_name']) > 0) {
|
if (strlen($data['destination_account_name']) > 0) {
|
||||||
$destinationType = AccountType::where('type', AccountType::EXPENSE)->first();
|
$destinationType = AccountType::where('type', AccountType::EXPENSE)->first();
|
||||||
$destinationAccount = Account::firstOrCreateEncrypted(
|
$destinationAccount = Account::firstOrCreateEncrypted(
|
||||||
@ -631,12 +642,15 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Log::debug(sprintf('destination account name is "%s", account is %d', $data['destination_account_name'], $destinationAccount->id));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'source' => $sourceAccount,
|
'source' => $sourceAccount,
|
||||||
'destination' => $destinationAccount,
|
'destination' => $destinationAccount,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$destinationType = AccountType::where('type', 'Cash account')->first();
|
Log::debug('destination_account_name is empty, so default to cash account!');
|
||||||
|
$destinationType = AccountType::where('type', AccountType::CASH)->first();
|
||||||
$destinationAccount = Account::firstOrCreateEncrypted(
|
$destinationAccount = Account::firstOrCreateEncrypted(
|
||||||
['user_id' => $this->user->id, 'account_type_id' => $destinationType->id, 'name' => 'Cash account', 'active' => 1]
|
['user_id' => $this->user->id, 'account_type_id' => $destinationType->id, 'name' => 'Cash account', 'active' => 1]
|
||||||
);
|
);
|
||||||
|
@ -148,7 +148,7 @@ function resetSplits() {
|
|||||||
// ends with ][source_account_name]
|
// ends with ][source_account_name]
|
||||||
$.each($('input[name$="][source_account_name]"]'), function (i, v) {
|
$.each($('input[name$="][source_account_name]"]'), function (i, v) {
|
||||||
var input = $(v);
|
var input = $(v);
|
||||||
input.attr('name', 'transaction[' + i + '][source_account_name]');
|
input.attr('name', 'transactions[' + i + '][source_account_name]');
|
||||||
console.log('source_account_name is now ' + input.attr('name'));
|
console.log('source_account_name is now ' + input.attr('name'));
|
||||||
});
|
});
|
||||||
// ends with ][amount]
|
// ends with ][amount]
|
||||||
|
Loading…
Reference in New Issue
Block a user