本文整理汇总了C++中xaccSplitGetAccount函数的典型用法代码示例。如果您正苦于以下问题:C++ xaccSplitGetAccount函数的具体用法?C++ xaccSplitGetAccount怎么用?C++ xaccSplitGetAccount使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xaccSplitGetAccount函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gnc_transaction_balance_trading_more_splits
/** Balance the transaction by adding more trading splits. This shouldn't
* ordinarily be necessary.
* @param trans the transaction to balance
* @param root the root account
*/
static void
gnc_transaction_balance_trading_more_splits (Transaction *trans, Account *root)
{
/* Copy the split list so we don't see the splits we're adding */
GList *splits_dup = g_list_copy(trans->splits), *splits = NULL;
const gnc_commodity *txn_curr = xaccTransGetCurrency (trans);
for (splits = splits_dup; splits; splits = splits->next)
{
Split *split = splits->data;
if (! xaccTransStillHasSplit(trans, split)) continue;
if (!gnc_numeric_zero_p(xaccSplitGetValue(split)) &&
gnc_numeric_zero_p(xaccSplitGetAmount(split)))
{
gnc_commodity *commodity;
gnc_numeric old_value, new_value;
Split *balance_split;
Account *account = NULL;
commodity = xaccAccountGetCommodity(xaccSplitGetAccount(split));
if (!commodity)
{
PERR("Split has no commodity");
continue;
}
balance_split = get_trading_split(trans, root, commodity);
if (!balance_split)
{
/* Error already logged */
LEAVE("");
return;
}
account = xaccSplitGetAccount(balance_split);
xaccTransBeginEdit (trans);
old_value = xaccSplitGetValue (balance_split);
new_value = gnc_numeric_sub (old_value, xaccSplitGetValue(split),
gnc_commodity_get_fraction(txn_curr),
GNC_HOW_RND_ROUND_HALF_UP);
xaccSplitSetValue (balance_split, new_value);
/* Don't change the balance split's amount since the amount
is zero in the split we're working on */
xaccSplitScrub (balance_split);
xaccTransCommitEdit (trans);
}
}
g_list_free(splits_dup);
}
示例2: gnc_ui_payment_new_with_txn
PaymentWindow * gnc_ui_payment_new_with_txn (GncOwner *owner, Transaction *txn)
{
SplitList *slist;
Split *assetaccount_split;
Split *postaccount_split;
gnc_numeric amount;
PaymentWindow *pw;
if (!txn)
return NULL;
// We require the txn to have one split in an Asset account.
slist = xaccTransGetSplitList(txn);
if (!slist)
return NULL;
if (countAssetAccounts(slist) == 0)
{
g_message("No asset splits in txn \"%s\"; cannot use this for assigning a payment.",
xaccTransGetDescription(txn));
return NULL;
}
assetaccount_split = getFirstAssetAccountSplit(slist);
postaccount_split = getFirstAPARAccountSplit(slist); // watch out: Might be NULL
amount = xaccSplitGetValue(assetaccount_split);
pw = gnc_ui_payment_new(owner,
qof_instance_get_book(QOF_INSTANCE(txn)));
g_assert(assetaccount_split); // we can rely on this because of the countAssetAccounts() check above
g_debug("Amount=%s", gnc_numeric_to_string(amount));
// Fill in the values from the given txn
pw->pre_existing_txn = txn;
gnc_ui_payment_window_set_num(pw, gnc_get_num_action(txn, assetaccount_split));
gnc_ui_payment_window_set_memo(pw, xaccTransGetDescription(txn));
{
GDate txn_date = xaccTransGetDatePostedGDate (txn);
gnc_ui_payment_window_set_date(pw, &txn_date);
}
gnc_ui_payment_window_set_amount(pw, amount);
gnc_ui_payment_window_set_xferaccount(pw, xaccSplitGetAccount(assetaccount_split));
if (postaccount_split)
gnc_ui_payment_window_set_postaccount(pw, xaccSplitGetAccount(postaccount_split));
return pw;
}
示例3: run_test
static void
run_test (void)
{
Account *act1;
Account *act2;
//Split *spl;
QofSession *session;
QofBook *book;
session = qof_session_new ();
book = qof_session_get_book (session);
act1 = get_random_account(book);
do_test(act1 != NULL, "random account created");
act2 = get_random_account(book);
do_test(act2 != NULL, "random account created");
#if 0
spl = get_random_split(book, act1, NULL);
do_test(spl != NULL, "random split created");
do_test(act1 == xaccSplitGetAccount(spl), "xaccAccountInsertSplit()");
#endif
//FIXME
//xaccSplitSetAccount (spl, NULL);
//do_test(xaccSplitGetAccount(spl) == NULL, "xaccAccountRemoveSplit()");
}
示例4: add_account_name
// Account Name short or Long
static gchar*
add_account_name (gchar *so_far, Account *acc, Split *split, gboolean full, CsvExportInfo *info)
{
gchar *name = NULL;
gchar *conv;
gchar *result;
Account *account = NULL;
if (split == NULL)
{
if (acc == NULL)
name = g_strdup (" ");
else
account = acc;
}
else
account = xaccSplitGetAccount (split);
if (account != NULL)
{
if (full)
name = gnc_account_get_full_name (account);
else
name = g_strdup (xaccAccountGetName (account));
}
conv = csv_txn_test_field_string (info, name);
result = g_strconcat (so_far, conv, info->mid_sep, NULL);
g_free (name);
g_free (conv);
g_free (so_far);
return result;
}
示例5: gtu_sr_use_security
/* Is current split a security account */
static gboolean
gtu_sr_use_security (GncTreeViewSplitReg *view)
{
RowDepth depth;
Account *account = NULL;
Split *split;
split = gnc_tree_view_split_reg_get_current_split (view);
depth = gnc_tree_view_reg_get_selected_row_depth (view);
if (!split)
return TRUE;
if (depth != SPLIT3)
return TRUE;
if (!account)
account = xaccSplitGetAccount (split);
if (!account)
return TRUE;
if (xaccTransUseTradingAccounts (xaccSplitGetParent (split)))
{
if (!gnc_commodity_is_iso (xaccAccountGetCommodity (account)))
return TRUE;
}
return xaccAccountIsPriced (account);
}
示例6: gnc_tree_util_split_reg_needs_amount
gboolean
gnc_tree_util_split_reg_needs_amount (GncTreeViewSplitReg *view, Split *split)
{
Transaction *txn = xaccSplitGetParent (split);
Account *acc = xaccSplitGetAccount (split);
return gnc_tree_util_split_reg_needs_conv_rate (view, txn, acc);
}
示例7: gnc_split_register_split_needs_amount
gboolean
gnc_split_register_split_needs_amount (SplitRegister *reg, Split *split)
{
Transaction *txn = xaccSplitGetParent (split);
Account *acc = xaccSplitGetAccount (split);
return gnc_split_register_needs_conv_rate (reg, txn, acc);
}
示例8: increment_if_asset_account
// ////////////////////////////////////////////////////////////
static void increment_if_asset_account (gpointer data,
gpointer user_data)
{
int *r = user_data;
const Split *split = data;
const Account *account = xaccSplitGetAccount(split);
if (xaccAccountIsAssetLiabType(xaccAccountGetType(account)))
++(*r);
}
示例9: predicate_is_apar_account
static gint predicate_is_apar_account(gconstpointer a,
gconstpointer user_data)
{
const Split *split = a;
const Account *account = xaccSplitGetAccount(split);
if (xaccAccountIsAPARType(xaccAccountGetType(account)))
return 0;
else
return -1;
}
示例10: gnc_transaction_adjust_trading_splits
static gnc_numeric
gnc_transaction_adjust_trading_splits (Transaction* trans, Account *root)
{
GList* splits;
gnc_numeric imbalance = gnc_numeric_zero();
for (splits = trans->splits; splits; splits = splits->next)
{
Split *split = splits->data;
Split *balance_split = NULL;
gnc_numeric value, amount;
gnc_commodity *commodity, *txn_curr = xaccTransGetCurrency (trans);
if (! xaccTransStillHasSplit (trans, split)) continue;
commodity = xaccAccountGetCommodity (xaccSplitGetAccount(split));
if (!commodity)
{
PERR("Split has no commodity");
continue;
}
balance_split = find_trading_split (trans, root, commodity);
if (balance_split != split)
/* this is not a trading split */
imbalance = gnc_numeric_add(imbalance, xaccSplitGetValue (split),
GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
/* Ignore splits where value or amount is zero */
value = xaccSplitGetValue (split);
amount = xaccSplitGetAmount (split);
if (gnc_numeric_zero_p(amount) || gnc_numeric_zero_p(value))
continue;
if (balance_split && balance_split != split)
{
gnc_numeric convrate = gnc_numeric_div (amount, value,
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
gnc_numeric old_value, new_value;
old_value = xaccSplitGetValue(balance_split);
new_value = gnc_numeric_div (xaccSplitGetAmount(balance_split),
convrate,
gnc_commodity_get_fraction(txn_curr),
GNC_HOW_RND_ROUND_HALF_UP);
if (! gnc_numeric_equal (old_value, new_value))
{
xaccTransBeginEdit (trans);
xaccSplitSetValue (balance_split, new_value);
xaccSplitScrub (balance_split);
xaccTransCommitEdit (trans);
}
}
}
return imbalance;
}
示例11: gtu_sr_get_amount_denom
/* Returns the amount denom */
static int
gtu_sr_get_amount_denom (Split *split)
{
int denom;
denom = xaccAccountGetCommoditySCU (xaccSplitGetAccount (split));
if (denom == 0)
{
gnc_commodity *commodity = gnc_default_currency ();
denom = gnc_commodity_get_fraction (commodity);
if (denom == 0)
denom = 100;
}
return denom;
}
示例12: gnc_split_register_save_mxfrm_cell
static void
gnc_split_register_save_mxfrm_cell (BasicCell * cell,
gpointer save_data,
gpointer user_data)
{
SRSaveData *sd = save_data;
SplitRegister *reg = user_data;
Split * other_split;
g_return_if_fail (gnc_basic_cell_has_name (cell, MXFRM_CELL));
other_split = xaccSplitGetOtherSplit (sd->split);
/* other_split may be null for two very different reasons:
* (1) the parent transaction has three or more splits in it,
* and so the "other" split is ambiguous, and thus null.
* (2) the parent transaction has only this one split as a child.
* and "other" is null because there is no other.
*
* In the case (2), we want to create the other split, so that
* the user's request to transfer actually works out. */
if (!other_split)
{
other_split = xaccTransGetSplit (sd->trans, 1);
if (!other_split)
{
other_split = xaccMallocSplit (gnc_get_current_book ());
xaccTransAppendSplit (sd->trans, other_split);
}
}
if (other_split)
{
Account *old_acc;
Account *new_acc;
/* Do some reparenting. Insertion into new account
* will automatically delete from the old account. */
old_acc = xaccSplitGetAccount (other_split);
new_acc = gnc_split_register_get_account (reg, MXFRM_CELL);
if ((new_acc != NULL) && (old_acc != new_acc))
xaccAccountInsertSplit (new_acc, other_split);
}
}
示例13: gnc_tree_util_split_reg_set_value_for
void
gnc_tree_util_split_reg_set_value_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input, gboolean force)
{
GncTreeModelSplitReg *model;
GtkWidget *window;
Account *anchor;
Account *acct = xaccSplitGetAccount (split);
gnc_commodity *currency;
gnc_numeric value, amount, rate;
ENTER("set_value_for trans %p and split %p input %s force %d", trans, split, gnc_numeric_to_string (input), force);
currency = xaccTransGetCurrency (trans);
model = gnc_tree_view_split_reg_get_model_from_view (view);
anchor = gnc_tree_model_split_reg_get_anchor (model);
if (gnc_numeric_zero_p (input))
{
xaccSplitSetValue (split, input);
xaccSplitSetAmount (split, input);
LEAVE("input is zero");
return;
}
window = gnc_tree_view_split_reg_get_parent (view);
if (gtu_sr_needs_exchange_rate (view, trans, split))
{
if (gtu_sr_handle_exchange_rate (view, input, trans, split, force))
{
; //FIXME ??????
}
else
{
gnc_error_dialog (window, "%s",
_("Exchange Rate Canceled, using existing rate or default 1 to 1 rate if this is a new transaction."));
}
LEAVE("used exchange rate");
return;
}
gnc_tree_util_split_reg_save_amount_values (view, trans, split, input);
LEAVE(" ");
}
示例14: merge_splits
static void
merge_splits (Split *sa, Split *sb)
{
Account *act;
Transaction *txn;
gnc_numeric amt, val;
act = xaccSplitGetAccount (sb);
xaccAccountBeginEdit (act);
txn = sa->parent;
xaccTransBeginEdit (txn);
/* Remove the guid of sb from the 'gemini' of sa */
remove_guids (sa, sb);
/* Add amount of sb into sa, ditto for value. */
amt = xaccSplitGetAmount (sa);
amt = gnc_numeric_add_fixed (amt, xaccSplitGetAmount (sb));
xaccSplitSetAmount (sa, amt);
val = xaccSplitGetValue (sa);
val = gnc_numeric_add_fixed (val, xaccSplitGetValue (sb));
xaccSplitSetValue (sa, val);
/* Set reconcile to no; after this much violence,
* no way its reconciled. */
xaccSplitSetReconcile (sa, NREC);
/* If sb has associated gains splits, trash them. */
if ((sb->gains_split) &&
(sb->gains_split->gains & GAINS_STATUS_GAINS))
{
Transaction *t = sb->gains_split->parent;
xaccTransBeginEdit (t);
xaccTransDestroy (t);
xaccTransCommitEdit (t);
}
/* Finally, delete sb */
xaccSplitDestroy(sb);
xaccTransCommitEdit (txn);
xaccAccountCommitEdit (act);
}
示例15: find_appropriate_node
static xmlNodePtr
find_appropriate_node (xmlNodePtr node, Split* spl)
{
xmlNodePtr mark;
for (mark = node->xmlChildrenNode; mark; mark = mark->next)
{
gboolean account_guid_good = FALSE;
gboolean amount_good = FALSE;
xmlNodePtr mark2;
for (mark2 = mark->xmlChildrenNode; mark2; mark2 = mark2->next)
{
if (g_strcmp0 ((char*)mark2->name, "split:value") == 0)
{
gnc_numeric* num = dom_tree_to_gnc_numeric (mark2);
if (gnc_numeric_equal (*num, xaccSplitGetValue (spl)))
{
amount_good = TRUE;
}
g_free (num);
}
else if (g_strcmp0 ((char*)mark2->name, "split:account") == 0)
{
GncGUID* accid = dom_tree_to_guid (mark2);
Account* account = xaccSplitGetAccount (spl);
if (guid_equal (accid, xaccAccountGetGUID (account)))
{
account_guid_good = TRUE;
}
g_free (accid);
}
if (account_guid_good && amount_good)
{
return mark;
}
}
}
return NULL;
}