mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add additional check before creating splits or transactions
This allows the code following the check to make certain assumptions about the state of the prop objects.
This commit is contained in:
parent
d2597ef1e2
commit
2492931094
@ -267,6 +267,16 @@ Transaction* GncPreTrans::create_trans (QofBook* book, gnc_commodity* currency)
|
||||
if (created)
|
||||
return nullptr;
|
||||
|
||||
/* Gently refuse to create the transaction if the basics are not set correctly
|
||||
* This should have been tested before calling this function though!
|
||||
*/
|
||||
auto check = verify_essentials();
|
||||
if (!check.empty())
|
||||
{
|
||||
PWARN ("Refusing to create transaction because essentials not set properly: %s", check.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto trans = xaccMallocTransaction (book);
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
@ -402,6 +412,16 @@ boost::optional<gnc_numeric> GncPreSplit::create_split (Transaction* trans)
|
||||
if (created)
|
||||
return boost::none;
|
||||
|
||||
/* Gently refuse to create the split if the basics are not set correctly
|
||||
* This should have been tested before calling this function though!
|
||||
*/
|
||||
auto check = verify_essentials();
|
||||
if (!check.empty())
|
||||
{
|
||||
PWARN ("Refusing to create split because essentials not set properly: %s", check.c_str());
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
Account *account = nullptr;
|
||||
Account *taccount = nullptr;
|
||||
bool amount_set = false;
|
||||
|
Loading…
Reference in New Issue
Block a user