Skip to content

Commit

Permalink
Fix editing amount of a transaction
Browse files Browse the repository at this point in the history
Only validate split items if the SplitView is actually shown, which
makes the transaction a "split-transaction". Only then the original
amount cannot be different that the split-total.

When the SplitView is shown, disable the Amount text field.

When hiding the SplitView, resize window.

Fixes #100
  • Loading branch information
humdingerb committed Aug 19, 2024
1 parent 275730a commit f78c975
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/SplitView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,13 @@ SplitView::MessageReceived(BMessage* msg)
if (!fAmount->Validate())
break;

if (fSplitContainer->IsHidden())
if (fSplitContainer->IsHidden()) {
if (!fCategory->Validate())
break;

if (!ValidateSplitItems())
break;
} else {
if (!ValidateSplitItems())
break;
}
Account* account = fTransaction.GetAccount();
if (!account)
ShowBug("NULL transaction account in SplitView::M_ENTER_TRANSACTION");
Expand Down Expand Up @@ -765,16 +766,20 @@ SplitView::ToggleSplit(void)
fCategory->SetText(
B_TRANSLATE_ALL("Split", "CommonTerms", "The noun 'split', as in 'a split-category'"));
fCategoryButton->SetEnabled(false);
fAmount->SetEnabled(false);
fMemo->SetEnabled(false);
if (fCategory->ChildAt(0)->IsFocus())
fMemo->MakeFocus();
} else {
fSplit->SetValue(B_CONTROL_OFF);

fSplitContainer->Hide();
Window()->ResizeToPreferred();

fCategory->SetEnabled(true);
fCategory->SetText(fTransaction.NameAt(0));
fCategoryButton->SetEnabled(true);
fAmount->SetEnabled(true);
fMemo->SetEnabled(true);
}
}
Expand Down

0 comments on commit f78c975

Please sign in to comment.