static void gnc_template_register_save_xfrm_cell (BasicCell * cell, gpointer save_data, gpointer user_data) { SRSaveData *sd = save_data; SplitRegister *reg = user_data; SRInfo *info = gnc_split_register_get_info (reg); Account *template_acc; const GncGUID *acctGUID; Account *acct; g_return_if_fail (gnc_basic_cell_has_name (cell, XFRM_CELL)); /* save the account GncGUID into the kvp_data. */ acct = gnc_split_register_get_account (reg, XFRM_CELL); if (!acct) { PERR ("unknown account"); return; } acctGUID = xaccAccountGetGUID (acct); qof_instance_set (QOF_INSTANCE (sd->split), "sx-account", acctGUID, NULL); template_acc = xaccAccountLookup (&info->template_account, gnc_get_current_book ()); /* set the actual account to the fake account for these templates */ xaccAccountInsertSplit (template_acc, sd->split); }
static Split * pack_split_info (TTSplitInfo *s_info, Account *parent_acct, Transaction *parent_trans, QofBook *book) { Split *split; const gchar *credit_formula; const gchar *debit_formula; const GncGUID *acc_guid; split = xaccMallocSplit(book); xaccSplitSetMemo(split, gnc_ttsplitinfo_get_memo(s_info)); /* Set split-action with gnc_set_num_action which is the same as * xaccSplitSetAction with these arguments */ gnc_set_num_action(NULL, split, NULL, gnc_ttsplitinfo_get_action(s_info)); xaccAccountInsertSplit(parent_acct, split); credit_formula = gnc_ttsplitinfo_get_credit_formula(s_info); debit_formula = gnc_ttsplitinfo_get_debit_formula(s_info); acc_guid = qof_entity_get_guid(QOF_INSTANCE(gnc_ttsplitinfo_get_account(s_info))); qof_instance_set (QOF_INSTANCE (split), "sx-credit-formula", credit_formula, "sx-debit-formula", debit_formula, "sx-account", acc_guid, NULL); return split; }
static void gnc_template_register_save_debcred_cell (BasicCell * cell, gpointer save_data, gpointer user_data) { SRSaveData *sd = save_data; SplitRegister *reg = user_data; const char *credit_formula, *debit_formula; char *error_loc; gnc_numeric credit_amount, debit_amount; gboolean parse_result; g_return_if_fail (gnc_basic_cell_has_name (cell, FDEBT_CELL) || gnc_basic_cell_has_name (cell, FCRED_CELL)); if (sd->handled_dc) return; /* amountStr = gnc_numeric_to_string (new_amount); */ credit_formula = gnc_table_layout_get_cell_value (reg->table->layout, FCRED_CELL); /* If the value can be parsed into a numeric result (without any * further variable definitions), store that numeric value * additionally in the kvp. Otherwise store a zero numeric * there.*/ parse_result = gnc_exp_parser_parse_separate_vars(credit_formula, &credit_amount, &error_loc, NULL); if (!parse_result) credit_amount = gnc_numeric_zero(); debit_formula = gnc_table_layout_get_cell_value (reg->table->layout, FDEBT_CELL); /* If the value can be parsed into a numeric result, store that * numeric value additionally. See above comment.*/ parse_result = gnc_exp_parser_parse_separate_vars(debit_formula, &debit_amount, &error_loc, NULL); if (!parse_result) debit_amount = gnc_numeric_zero(); qof_instance_set (QOF_INSTANCE (sd->split), "sx-credit-formula", credit_formula, "sx-credit-numeric", &credit_amount, "sx-debit-formula", debit_formula, "sx-debit-numeric", &debit_amount, NULL); /* set the amount to an innocuous value */ /* Note that this marks the split dirty */ xaccSplitSetValue (sd->split, gnc_numeric_create (0, 1)); sd->handled_dc = TRUE; }
void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot) { if (!owner || !lot) return; gnc_lot_begin_edit (lot); qof_instance_set (QOF_INSTANCE (lot), "owner-type", (gint64)gncOwnerGetType (owner), "owner-guid", gncOwnerGetGUID (owner), NULL); gnc_lot_commit_edit (lot); }
static void gnc_payment_dialog_remember_account (PaymentWindow *pw, Account *acc) { QofInstance *owner = qofOwnerGetOwner (&pw->owner); const GncGUID *guid; if (!acc) return; guid = xaccAccountGetGUID(acc); qof_begin_edit (owner); qof_instance_set (owner, "payment-last-account", guid, NULL); qof_commit_edit (owner); }
static void gnc_template_register_save_shares_cell (BasicCell * cell, gpointer save_data, gpointer user_data) { SRSaveData *sd = save_data; char *sharesStr = "(x + y)/42"; g_return_if_fail (gnc_basic_cell_has_name (cell, SHRS_CELL)); /* FIXME: shares cells are numeric by definition. */ qof_instance_set (QOF_INSTANCE (sd->split), "sx-shares", sharesStr, NULL); /* set the shares to an innocuous value */ /* Note that this marks the split dirty */ xaccSplitSetSharePriceAndAmount (sd->split, gnc_numeric_create (0, 1), gnc_numeric_create (0, 1)); }