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.
1318 if (!m_txn_types || !m_txn_type)
1319 return {
false,
"Error: txn_type not initialized", {} };
1322 m_list_of_splits.clear();
1331 if (
const auto& splits = xaccAccountGetSplits (m_acct); !splits.empty())
1332 check_txn_date(splits.back(), m_transaction_date, m_logger);
1334 if (m_stock_entry->enabled() || m_stock_entry->has_amount())
1336 m_stock_entry->validate_amount(m_logger);
1337 m_list_of_splits.push_back(m_stock_entry.get());
1339 auto price{m_stock_entry->calculate_price()};
1344 auto tmpl = N_(
"A price of 1 %s = %s on %s will be recorded.");
1346 auto price_msg = g_strdup_printf
1349 m_stock_entry->print_price(), date_str);
1350 m_logger.info(price_msg);
1356 if (m_stock_entry->marker_split())
1357 m_list_of_splits.push_back(m_stock_entry.get());
1359 if (m_cash_entry->enabled())
1361 m_cash_entry->validate_amount(m_logger);
1362 m_list_of_splits.push_back (m_cash_entry.get());
1365 if (m_fees_entry->enabled())
1367 m_fees_entry->validate_amount(m_logger);
1368 if (m_fees_entry->do_capitalize())
1369 m_fees_entry->set_account(m_acct);
1370 m_list_of_splits.push_back (m_fees_entry.get());
1373 if (m_dividend_entry->enabled())
1375 m_dividend_entry->validate_amount(m_logger);
1376 m_list_of_splits.push_back (m_dividend_entry.get());
1379 if (m_capgains_entry->enabled())
1382 std::make_unique<StockTransactionStockCapGainsEntry>(m_capgains_entry.get(),
1383 m_stock_entry.get());
1384 m_stock_cg_entry->validate_amount(m_logger);
1385 m_capgains_entry->validate_amount(m_logger);
1386 m_list_of_splits.push_back(m_stock_cg_entry.get());
1387 m_list_of_splits.push_back (m_capgains_entry.get());
1390 std::for_each(m_list_of_splits.begin(), m_list_of_splits.end(),
1391 [&debit, &credit](
auto& entry) {
1392 if (entry->debit_side())
1393 debit += entry->value();
1395 credit += entry->value();
1400 const char *err_act = NULL, *err_reason = NULL;
1414 auto err_str = g_strdup_printf (N_(
"Transaction can't balance, %s is error value %s"), err_act, err_reason);
1415 m_logger.error(err_str);
1420 auto imbalance_str = N_(
"Total Debits of %s does not balance with total Credits of %s.");
1421 auto pinfo{gnc_commodity_print_info (m_currency,
true)};
1424 auto error_str = g_strdup_printf (_(imbalance_str), debit_str, credit_str);
1425 m_logger.error (error_str);
1427 g_free (credit_str);
1434 m_ready_to_create = !m_logger.has_errors();
1435 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 a)
Check for error signal in value.