Generate the proposed list of splits.
This is used to display the proposal to the user in the last page of the assistant and to select on which entries to call create_split
.
1315 if (!m_txn_types || !m_txn_type)
1316 return {
false,
"Error: txn_type not initialized", {} };
1319 m_list_of_splits.clear();
1328 if (
const auto& splits = xaccAccountGetSplits (m_acct); !splits.empty())
1329 check_txn_date(splits.back(), m_transaction_date, m_logger);
1331 if (m_stock_entry->enabled() || m_stock_entry->has_amount())
1333 m_stock_entry->validate_amount(m_logger);
1334 m_list_of_splits.push_back(m_stock_entry.get());
1336 auto price{m_stock_entry->calculate_price()};
1341 auto tmpl = N_(
"A price of 1 %s = %s on %s will be recorded.");
1343 auto price_msg = g_strdup_printf
1346 m_stock_entry->print_price(), date_str);
1347 m_logger.info(price_msg);
1353 if (m_stock_entry->marker_split())
1354 m_list_of_splits.push_back(m_stock_entry.get());
1356 if (m_cash_entry->enabled())
1358 m_cash_entry->validate_amount(m_logger);
1359 m_list_of_splits.push_back (m_cash_entry.get());
1362 if (m_fees_entry->enabled())
1364 m_fees_entry->validate_amount(m_logger);
1365 if (m_fees_entry->do_capitalize())
1366 m_fees_entry->set_account(m_acct);
1367 m_list_of_splits.push_back (m_fees_entry.get());
1370 if (m_dividend_entry->enabled())
1372 m_dividend_entry->validate_amount(m_logger);
1373 m_list_of_splits.push_back (m_dividend_entry.get());
1376 if (m_capgains_entry->enabled())
1379 std::make_unique<StockTransactionStockCapGainsEntry>(m_capgains_entry.get(),
1380 m_stock_entry.get());
1381 m_stock_cg_entry->validate_amount(m_logger);
1382 m_capgains_entry->validate_amount(m_logger);
1383 m_list_of_splits.push_back(m_stock_cg_entry.get());
1384 m_list_of_splits.push_back (m_capgains_entry.get());
1387 std::for_each(m_list_of_splits.begin(), m_list_of_splits.end(),
1388 [&debit, &credit](
auto& entry) {
1389 if (entry->debit_side())
1390 debit += entry->value();
1392 credit += entry->value();
1397 const char *err_act = NULL, *err_reason = NULL;
1411 auto err_str = g_strdup_printf (N_(
"Transaction can't balance, %s is error value %s"), err_act, err_reason);
1412 m_logger.error(err_str);
1417 auto imbalance_str = N_(
"Total Debits of %s does not balance with total Credits of %s.");
1418 auto pinfo{gnc_commodity_print_info (m_currency,
true)};
1421 auto error_str = g_strdup_printf (_(imbalance_str), debit_str, credit_str);
1422 m_logger.error (error_str);
1424 g_free (credit_str);
1431 m_ready_to_create = !m_logger.has_errors();
1432 return { m_ready_to_create, m_logger.
report(), m_list_of_splits };
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
std::string report()
Compose all of the logged messages into a bullet list, errors first, then warnings, infos last.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
The primary numeric class for representing amounts and values.
char * qof_print_date(time64 secs)
Convenience; calls through to qof_print_date_dmy_buff().
const char * gnc_numeric_errorCode_to_string(GNCNumericErrorCode error_code)
Returns a string representation of the given GNCNumericErrorCode.
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
GNCNumericErrorCode gnc_numeric_check(gnc_numeric in)
Check for error signal in value.