Caught a nasty bug thanks to an alert Tweakers.net user. This fix will make the account-edit screen inconsistent for a select number of users. This will be detailed on the wiki.

This commit is contained in:
James Cole 2015-08-15 21:45:29 +02:00
parent 7fbd0b2ffc
commit 28c753523f
2 changed files with 13 additions and 2 deletions

View File

@ -136,6 +136,12 @@ class TransactionController extends Controller
*/
public function edit(AccountRepositoryInterface $repository, TransactionJournal $journal)
{
// cannot edit opening balance
if ($journal->transactionType->type == 'Opening balance') {
return view('error')->with('message', 'Cannot edit this transaction. Edit the account instead!');
}
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes(ini_get('post_max_size'));
$uploadSize = min($maxFileSize, $maxPostSize);
@ -333,6 +339,11 @@ class TransactionController extends Controller
public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att, TransactionJournal $journal)
{
// cannot edit opening balance
if ($journal->transactionType->type == 'Opening balance') {
return view('error')->with('message', 'Cannot edit this transaction. Edit the account instead!');
}
$journalData = $request->getJournalData();
$repository->update($journal, $journalData);

View File

@ -375,6 +375,7 @@ class AccountRepository implements AccountRepositoryInterface
return TransactionJournal
::orderBy('transaction_journals.date', 'ASC')
->accountIs($account)
->transactionTypes(['Opening balance'])
->orderBy('created_at', 'ASC')
->first(['transaction_journals.*']);
}
@ -394,10 +395,9 @@ class AccountRepository implements AccountRepositoryInterface
// continue with the opposing account:
if ($data['openingBalance'] != 0) {
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
$opposingData = [
'user' => $data['user'],
'accountType' => $type,
'accountType' => 'initial',
'virtualBalance' => 0,
'name' => $data['name'] . ' initial balance',
'active' => false,