Пример #1
0
gchar *
qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
{
    KvpFrame *kvp;
    KvpValue *value;
    gint64 counter;
    gchar* format;
    gchar* result;

    if (!book)
    {
        PWARN ("No book!!!");
        return NULL;
    }

    if (!counter_name || *counter_name == '\0')
    {
        PWARN ("Invalid counter name.");
        return NULL;
    }

    /* Get the current counter value from the KVP in the book. */
    counter = qof_book_get_counter(book, counter_name);

    /* Check if an error occurred */
    if (counter < 0)
        return NULL;

    /* Increment the counter */
    counter++;

    /* Get the KVP from the current book */
    kvp = qof_instance_get_slots (QOF_INSTANCE (book));

    if (!kvp)
    {
        PWARN ("Book has no KVP_Frame");
        return NULL;
    }

    /* Save off the new counter */
    qof_book_begin_edit(book);
    value = new KvpValue(counter);
    delete kvp->set_path({"counters", counter_name}, value);
    qof_instance_set_dirty (QOF_INSTANCE (book));
    qof_book_commit_edit(book);

    format = qof_book_get_counter_format(book, counter_name);

    if (!format)
    {
        PWARN("Cannot get format for counter");
        return NULL;
    }

    /* Generate a string version of the counter */
    result = g_strdup_printf(format, counter);
    g_free (format);
    return result;
}
Пример #2
0
void gncCustomerDestroy (GncCustomer *cust)
{
    if (!cust) return;
    qof_instance_set_destroying(cust, TRUE);
    qof_instance_set_dirty (&cust->inst);
    gncCustomerCommitEdit (cust);
}
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;
    kvp_frame *kvpf;
    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);
    kvpf = xaccSplitGetSlots (sd->split);
    kvp_frame_set_slot_path (kvpf, kvp_value_new_guid(acctGUID),
                             GNC_SX_ID, GNC_SX_ACCOUNT, 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);
    qof_instance_set_dirty (QOF_INSTANCE (sd->split));
}
Пример #4
0
void
xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays )
{
    gnc_sx_begin_edit(sx);
    sx->advanceCreateDays = createDays;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #5
0
void
xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays )
{
    gnc_sx_begin_edit(sx);
    sx->advanceRemindDays = reminderDays;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #6
0
void
gncTaxTableDestroy (GncTaxTable *table)
{
    if (!table) return;
    qof_instance_set_destroying(table, TRUE);
    qof_instance_set_dirty (&table->inst);
    gncTaxTableCommitEdit (table);
}
Пример #7
0
void
xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled)
{
    gnc_sx_begin_edit(sx);
    sx->enabled = newEnabled;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #8
0
void
qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val)
{
    qof_book_begin_edit(book);
    auto frame = qof_instance_get_slots(QOF_INSTANCE(book));
    delete frame->set(opt_name, new KvpValue(opt_val));
    qof_instance_set_dirty (QOF_INSTANCE (book));
    qof_book_commit_edit(book);
}
Пример #9
0
void
qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr)
{
    KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
    qof_book_begin_edit (book);
    delete frame->set_path({GNC_FEATURES, key}, new KvpValue(descr));
    qof_instance_set_dirty (QOF_INSTANCE (book));
    qof_book_commit_edit (book);
}
Пример #10
0
void
gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
{
    g_return_if_fail(sx);
    gnc_sx_begin_edit(sx);
    sx->schedule = schedule;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #11
0
void gncBillTermDestroy (GncBillTerm *term)
{
    if (!term) return;
    DEBUG("destroying bill term %s (%p)",
          guid_to_string(qof_instance_get_guid(&term->inst)), term);
    qof_instance_set_destroying(term, TRUE);
    qof_instance_set_dirty (&term->inst);
    gncBillTermCommitEdit (term);
}
Пример #12
0
/* Used several places in a transaction edit where many other
 * parameters are also being set, so individual commits wouldn't be
 * appropriate. */
void gnc_import_set_split_online_id(Split * split,
                                    const gchar * string_value)
{
    kvp_frame * frame;
    xaccTransBeginEdit (xaccSplitGetParent (split));
    frame = xaccSplitGetSlots(split);
    kvp_frame_set_str (frame, "online_id", string_value);
    qof_instance_set_dirty (QOF_INSTANCE (split));
}
Пример #13
0
void
xaccSchedXactionSetNumOccur(SchedXaction *sx, gint new_num)
{
    if (sx->num_occurances_total == new_num)
        return;
    gnc_sx_begin_edit(sx);
    sx->num_occurances_remain = sx->num_occurances_total = new_num;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #14
0
void gncBillTermDestroy (GncBillTerm *term)
{
    gchar guidstr[GUID_ENCODING_LENGTH+1];
    if (!term) return;
    guid_to_string_buff(qof_instance_get_guid(&term->inst),guidstr);
    DEBUG("destroying bill term %s (%p)", guidstr, term);
    qof_instance_set_destroying(term, TRUE);
    qof_instance_set_dirty (&term->inst);
    gncBillTermCommitEdit (term);
}
Пример #15
0
/* Not actually used */
void gnc_import_set_trans_online_id(Transaction * transaction,
                                    const gchar * string_value)
{
    kvp_frame * frame;
    xaccTransBeginEdit (transaction);
    frame = xaccTransGetSlots(transaction);
    kvp_frame_set_str (frame, "online_id", string_value);
    qof_instance_set_dirty (QOF_INSTANCE (transaction));
    xaccTransCommitEdit (transaction);
}
Пример #16
0
/* Used in the midst of editing a transaction; make it save the
 * account data. */
void gnc_import_set_acc_online_id(Account * account,
                                  const gchar * string_value)
{
    kvp_frame * frame;
    g_return_if_fail (account != NULL);
    frame = xaccAccountGetSlots(account);
    xaccAccountBeginEdit (account);
    kvp_frame_set_str(frame, "online_id", string_value);
    qof_instance_set_dirty (QOF_INSTANCE (account));
    xaccAccountCommitEdit (account);
}
Пример #17
0
void
gnc_sx_set_instance_count(SchedXaction *sx, gint instance_num)
{
    g_return_if_fail(sx);
    if (sx->instance_num == instance_num)
        return;
    gnc_sx_begin_edit(sx);
    sx->instance_num = instance_num;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #18
0
static void
xaccAccountDeleteOldData (Account *account)
{
    if (!account) return;
    xaccAccountBeginEdit (account);
    qof_instance_set_kvp (QOF_INSTANCE (account), "old-currency", NULL);
    qof_instance_set_kvp (QOF_INSTANCE (account), "old-security", NULL);
    qof_instance_set_kvp (QOF_INSTANCE (account), "old-currency-scu", NULL);
    qof_instance_set_kvp (QOF_INSTANCE (account), "old-security-scu", NULL);
    qof_instance_set_dirty (QOF_INSTANCE (account));
    xaccAccountCommitEdit (account);
}
Пример #19
0
void
qof_instance_set (QofInstance *inst, const gchar *first_prop, ...)
{
    va_list ap;
    QofInstancePrivate *priv = GET_PRIVATE(inst);
    g_return_if_fail (QOF_IS_INSTANCE (inst));

    qof_instance_set_dirty (inst);
    va_start (ap, first_prop);
    g_object_set_valist (G_OBJECT (inst), first_prop, ap);
    va_end (ap);
}
Пример #20
0
void
qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val)
{
    qof_book_begin_edit(book);
    auto frame = qof_instance_get_slots(QOF_INSTANCE(book));
    if (opt_val && (*opt_val != '\0'))
        delete frame->set(opt_name, new KvpValue(g_strdup(opt_val)));
    else
        delete frame->set(opt_name, nullptr);
    qof_instance_set_dirty (QOF_INSTANCE (book));
    qof_book_commit_edit(book);
}
Пример #21
0
void
qof_book_set_option (QofBook *book, KvpValue *value, GSList *path)
{
    KvpFrame *root = qof_instance_get_slots (QOF_INSTANCE (book));
    Path path_v {KVP_OPTION_PATH};
    for (auto item = path; item != nullptr; item = g_slist_next(item))
        path_v.push_back(static_cast<const char*>(item->data));
    qof_book_begin_edit (book);
    delete root->set_path(path_v, value);
    qof_instance_set_dirty (QOF_INSTANCE (book));
    qof_book_commit_edit (book);
}
Пример #22
0
static void
qof_instance_set_property (GObject         *object,
                           guint            prop_id,
                           const GValue    *value,
                           GParamSpec      *pspec)
{
    QofInstance *inst;
    QofInstancePrivate *priv;
    Timespec *ts;

    g_return_if_fail(QOF_IS_INSTANCE(object));

    inst = QOF_INSTANCE(object);
    priv = GET_PRIVATE(inst);

    switch (prop_id)
    {
    case PROP_GUID:
        qof_instance_set_guid(inst, g_value_get_boxed(value));
        break;
    case PROP_COLLECTION:
        qof_instance_set_collection(inst, g_value_get_pointer(value));
        break;
    case PROP_BOOK:
        qof_instance_set_book(inst, g_value_get_object(value));
        break;
    case PROP_KVP_DATA:
        qof_instance_set_slots(inst, g_value_get_pointer(value));
        break;
    case PROP_LAST_UPDATE:
        ts = g_value_get_pointer(value);
        qof_instance_set_last_update(inst, *ts);
        break;
    case PROP_DESTROYING:
        qof_instance_set_destroying(inst, g_value_get_boolean(value));
        break;
    case PROP_DIRTY:
        qof_instance_set_dirty(inst);
        break;
    case PROP_VERSION:
        qof_instance_set_version(inst, g_value_get_int(value));
        break;
    case PROP_VERSION_CHECK:
        qof_instance_set_version_check(inst, g_value_get_uint(value));
        break;
    case PROP_IDATA:
        qof_instance_set_idata(inst, g_value_get_uint(value));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        break;
    }
}
Пример #23
0
void
xaccSchedXactionSetLastOccurDate(SchedXaction *sx, const GDate* new_last_occur)
{
    g_return_if_fail (new_last_occur != NULL);
    if (g_date_valid(&sx->last_date)
            && g_date_compare(&sx->last_date, new_last_occur) == 0)
        return;
    gnc_sx_begin_edit(sx);
    sx->last_date = *new_last_occur;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #24
0
static void
sxtg_book_begin (QofBook *book)
{
    Account *root;

    root = xaccMallocAccount(book);
    xaccAccountBeginEdit(root);
    xaccAccountSetType(root, ACCT_TYPE_ROOT);
    xaccAccountSetName(root, "Template Root");
    qof_instance_set_dirty (QOF_INSTANCE (root));
    xaccAccountCommitEdit(root);
    gnc_book_set_template_root (book, root);
}
Пример #25
0
void
xaccSchedXactionSetAutoCreate( SchedXaction *sx,
                               gboolean newAutoCreate,
                               gboolean newNotify )
{

    gnc_sx_begin_edit(sx);
    sx->autoCreateOption = newAutoCreate;
    sx->autoCreateNotify = newNotify;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
    return;
}
Пример #26
0
void
xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName )
{
    g_return_if_fail( newName != NULL );
    gnc_sx_begin_edit(sx);
    if ( sx->name != NULL )
    {
        g_free( sx->name );
        sx->name = NULL;
    }
    sx->name = g_strdup( newName );
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #27
0
void
xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart )
{
    if ( newStart == NULL || !g_date_valid( newStart ))
    {
        /* XXX: I reject the bad data - is this the right
         * thing to do <rgmerk>.
         * This warning is only human readable - the caller
         * doesn't know the call failed.  This is bad
         */
        g_critical("Invalid Start Date");
        return;
    }
    gnc_sx_begin_edit(sx);
    sx->start_date = *newStart;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}
Пример #28
0
void
xaccSchedXactionSetRemOccur(SchedXaction *sx, gint num_remain)
{
    /* FIXME This condition can be tightened up */
    if (num_remain > sx->num_occurances_total)
    {
        g_warning("number remaining [%d] > total occurrences [%d]",
                  num_remain, sx->num_occurances_total);
    }
    else
    {
        if (num_remain == sx->num_occurances_remain)
            return;
        gnc_sx_begin_edit(sx);
        sx->num_occurances_remain = num_remain;
        qof_instance_set_dirty(&sx->inst);
        gnc_sx_commit_edit(sx);
    }
}
Пример #29
0
void gnc_ofx_kvp_set_assoc_account(Account* investment_account,
                                   const Account *income_account)
{
    kvp_frame * acc_frame;
    kvp_value * kvp_val;
    const GncGUID * income_acc_guid;

    g_assert(investment_account);
    g_assert(income_account);

    acc_frame = xaccAccountGetSlots(investment_account);
    g_assert(acc_frame); // Must not be NULL, but the QofInstance doc is unclear about this
    income_acc_guid = xaccAccountGetGUID(income_account);
    kvp_val = kvp_value_new_guid(income_acc_guid);
    xaccAccountBeginEdit(investment_account);
    kvp_frame_set_slot_nc(acc_frame, KEY_ASSOC_INCOME_ACCOUNT,
                          kvp_val);
    qof_instance_set_dirty(QOF_INSTANCE (investment_account));
    xaccAccountCommitEdit(investment_account);
}
Пример #30
0
void
xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate *newEnd )
{
/* Note that an invalid GDate IS a permissable value: It means that
 * the SX is to run "forever". See gnc_sxed_save_sx() and
 * schedXact_editor_populate() in dialog-sx-editor.c.
 */
    if (newEnd == NULL || 
        (g_date_valid(newEnd) && g_date_compare( newEnd, &sx->start_date ) < 0 ))
    {
        /* XXX: I reject the bad data - is this the right
         * thing to do <rgmerk>.
         * This warning is only human readable - the caller
         * doesn't know the call failed.  This is bad
         */
        g_critical("Bad End Date: Invalid or before Start Date");
        return;
    }

    gnc_sx_begin_edit(sx);
    sx->end_date = *newEnd;
    qof_instance_set_dirty(&sx->inst);
    gnc_sx_commit_edit(sx);
}