mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-26 08:51:12 -06:00
Fix #1442
This commit is contained in:
parent
f1fe90fce0
commit
34fd8cf751
@ -29,8 +29,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\SplitJournalFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
@ -100,22 +98,18 @@ class SplitController extends Controller
|
||||
if ($this->isOpeningBalance($journal)) {
|
||||
return $this->redirectToAccount($journal); // @codeCoverageIgnore
|
||||
}
|
||||
// basic fields:
|
||||
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
||||
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
|
||||
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
||||
$currencies = $this->currencies->get();
|
||||
// lists and collections
|
||||
$currencies = $this->currencies->get();
|
||||
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
|
||||
// other fields
|
||||
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
$preFilled = $this->arrayFromJournal($request, $journal);
|
||||
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
$accountList = $this->accounts->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
||||
$accountArray = [];
|
||||
// account array to display currency info:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$accountArray[$account->id] = $account;
|
||||
$accountArray[$account->id]['currency_id'] = (int)$this->accounts->getMetaValue($account, 'currency_id');
|
||||
}
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('transactions.edit-split.fromUpdate')) {
|
||||
@ -126,7 +120,7 @@ class SplitController extends Controller
|
||||
return view(
|
||||
'transactions.split.edit', compact(
|
||||
'subTitleIcon', 'currencies', 'optionalFields', 'preFilled', 'subTitle', 'uploadSize', 'budgets',
|
||||
'journal', 'accountArray'
|
||||
'journal'
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -146,8 +140,7 @@ class SplitController extends Controller
|
||||
|
||||
// keep current bill:
|
||||
$data['bill_id'] = $journal->bill_id;
|
||||
|
||||
$journal = $this->repository->update($journal, $data);
|
||||
$journal = $this->repository->update($journal, $data);
|
||||
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
@ -283,9 +276,9 @@ class SplitController extends Controller
|
||||
}
|
||||
// take some info from first transaction, that should at least exist.
|
||||
$array[$index] = $row;
|
||||
$array[$index]['currency_id'] = $array[0]['transaction_currency_id'];
|
||||
$array[$index]['currency_code'] = $array[0]['transaction_currency_code'] ?? '';
|
||||
$array[$index]['currency_symbol'] = $array[0]['transaction_currency_symbol'] ?? '';
|
||||
$array[$index]['currency_id'] = $array[0]['currency_id'];
|
||||
$array[$index]['currency_code'] = $array[0]['currency_code'] ?? '';
|
||||
$array[$index]['currency_symbol'] = $array[0]['currency_symbol'] ?? '';
|
||||
$array[$index]['foreign_amount'] = round($array[0]['foreign_destination_amount'] ?? '0', 12);
|
||||
$array[$index]['foreign_currency_id'] = $array[0]['foreign_currency_id'];
|
||||
$array[$index]['foreign_currency_code'] = $array[0]['foreign_currency_code'];
|
||||
|
@ -109,23 +109,23 @@ class SplitJournalFormRequest extends Request
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'what' => 'required|in:withdrawal,deposit,transfer',
|
||||
'journal_description' => 'required|between:1,255',
|
||||
'id' => 'numeric|belongsToUser:transaction_journals,id',
|
||||
'journal_source_account_id' => 'numeric|belongsToUser:accounts,id',
|
||||
'journal_source_account_name.*' => 'between:1,255',
|
||||
'journal_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'date' => 'required|date',
|
||||
'interest_date' => 'date|nullable',
|
||||
'book_date' => 'date|nullable',
|
||||
'process_date' => 'date|nullable',
|
||||
'transactions.*.transaction_description' => 'required|between:1,255',
|
||||
'transactions.*.destination_account_id' => 'numeric|belongsToUser:accounts,id',
|
||||
'transactions.*.destination_name' => 'between:1,255|nullable',
|
||||
'transactions.*.amount' => 'required|numeric',
|
||||
'transactions.*.budget_id' => 'belongsToUser:budgets,id',
|
||||
'transactions.*.category_name' => 'between:1,255|nullable',
|
||||
'transactions.*.piggy_bank_id' => 'between:1,255|nullable',
|
||||
'what' => 'required|in:withdrawal,deposit,transfer',
|
||||
'journal_description' => 'required|between:1,255',
|
||||
'id' => 'numeric|belongsToUser:transaction_journals,id',
|
||||
'journal_source_account_id' => 'numeric|belongsToUser:accounts,id',
|
||||
'journal_source_account_name.*' => 'between:1,255',
|
||||
'journal_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'date' => 'required|date',
|
||||
'interest_date' => 'date|nullable',
|
||||
'book_date' => 'date|nullable',
|
||||
'process_date' => 'date|nullable',
|
||||
'transactions.*.transaction_description' => 'required|between:1,255',
|
||||
'transactions.*.destination_account_id' => 'numeric|belongsToUser:accounts,id',
|
||||
'transactions.*.destination_name' => 'between:1,255|nullable',
|
||||
'transactions.*.amount' => 'required|numeric',
|
||||
'transactions.*.budget_id' => 'belongsToUser:budgets,id',
|
||||
'transactions.*.category_name' => 'between:1,255|nullable',
|
||||
'transactions.*.piggy_bank_id' => 'between:1,255|nullable',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ use FireflyIII\Models\Attachment;
|
||||
* Class TransactionJournal.
|
||||
*
|
||||
* @property User $user
|
||||
* @property int $bill_id
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
|
12
public/js/ff/transactions/split/edit.js
vendored
12
public/js/ff/transactions/split/edit.js
vendored
@ -33,12 +33,12 @@ $(document).ready(function () {
|
||||
|
||||
$.getJSON('json/expense-accounts').done(function (data) {
|
||||
destAccounts = data;
|
||||
$('input[name$="destination_account_name]"]').typeahead({source: destAccounts, autoSelect: false});
|
||||
$('input[name$="destination_name]"]').typeahead({source: destAccounts, autoSelect: false});
|
||||
});
|
||||
|
||||
$.getJSON('json/revenue-accounts').done(function (data) {
|
||||
srcAccounts = data;
|
||||
$('input[name$="source_account_name]"]').typeahead({source: srcAccounts, autoSelect: false});
|
||||
$('input[name$="source_name]"]').typeahead({source: srcAccounts, autoSelect: false});
|
||||
});
|
||||
|
||||
$.getJSON('json/categories').done(function (data) {
|
||||
@ -123,11 +123,11 @@ function cloneDivRow() {
|
||||
source.find('input[name$="][amount]"]').val("").on('change', calculateBothSums);
|
||||
source.find('input[name$="][foreign_amount]"]').val("").on('change', calculateBothSums);
|
||||
if (destAccounts.length > 0) {
|
||||
source.find('input[name$="destination_account_name]"]').typeahead({source: destAccounts, autoSelect: false});
|
||||
source.find('input[name$="destination_name]"]').typeahead({source: destAccounts, autoSelect: false});
|
||||
}
|
||||
|
||||
if (srcAccounts.length > 0) {
|
||||
source.find('input[name$="source_account_name]"]').typeahead({source: srcAccounts, autoSelect: false});
|
||||
source.find('input[name$="source_name]"]').typeahead({source: srcAccounts, autoSelect: false});
|
||||
}
|
||||
if (categories.length > 0) {
|
||||
source.find('input[name$="category_name]"]').typeahead({source: categories, autoSelect: false});
|
||||
@ -186,12 +186,12 @@ function resetDivSplits() {
|
||||
input.attr('name', 'transactions[' + i + '][transaction_description]');
|
||||
});
|
||||
// ends with ][destination_account_name]
|
||||
$.each($('input[name$="][destination_account_name]"]'), function (i, v) {
|
||||
$.each($('input[name$="][destination_name]"]'), function (i, v) {
|
||||
var input = $(v);
|
||||
input.attr('name', 'transactions[' + i + '][destination_account_name]');
|
||||
});
|
||||
// ends with ][source_account_name]
|
||||
$.each($('input[name$="][source_account_name]"]'), function (i, v) {
|
||||
$.each($('input[name$="][source_name]"]'), function (i, v) {
|
||||
var input = $(v);
|
||||
input.attr('name', 'transactions[' + i + '][source_account_name]');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user