gnc_numeric
gnc_split_register_debcred_cell_value (SplitRegister *reg)
{
    PriceCell *cell;
    gnc_numeric new_amount;
    gnc_numeric credit;
    gnc_numeric debit;

    cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
            CRED_CELL);
    credit = gnc_price_cell_get_value (cell);

    cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
            DEBT_CELL);
    debit  = gnc_price_cell_get_value (cell);

    new_amount = gnc_numeric_sub_fixed (debit, credit);

    return new_amount;
}
예제 #2
0
static void set_value_price_cell(BasicCell *cell, gnc_numeric new_value)
{
    PriceCell *pcell = (PriceCell*) cell;
    if (!cell)
        return;
    if (gnc_numeric_equal (new_value, gnc_price_cell_get_value(pcell)))
        return;

    gnc_price_cell_set_value (pcell, new_value);
    gnc_basic_cell_set_changed (cell, TRUE);
}
static gnc_numeric
gnc_split_register_get_rate_cell (SplitRegister *reg, const char *cell_name)
{
    PriceCell *rate_cell;

    rate_cell = (PriceCell*) gnc_table_layout_get_cell (reg->table->layout,
                cell_name);
    if (rate_cell)
        return gnc_price_cell_get_value (rate_cell);

    /* Uhh, just return '1' */
    return gnc_numeric_create (100, 100);
}
static void
gnc_split_register_save_shares_cell (BasicCell * bcell,
                                     gpointer save_data,
                                     gpointer user_data)
{
    SRSaveData *sd = save_data;
    PriceCell *cell = (PriceCell *) bcell;
    gnc_numeric amount;

    g_return_if_fail (gnc_basic_cell_has_name (bcell, SHRS_CELL));

    amount = gnc_price_cell_get_value (cell);

    DEBUG ("SHRS");

    xaccSplitSetAmount (sd->split, amount);

    sd->do_scrub = TRUE;
}
static void
gnc_split_register_save_price_cell (BasicCell * bcell,
                                    gpointer save_data,
                                    gpointer user_data)
{
    SRSaveData *sd = save_data;
    PriceCell *cell = (PriceCell *) bcell;
    gnc_numeric price;

    g_return_if_fail (gnc_basic_cell_has_name (bcell, PRIC_CELL));

    price = gnc_price_cell_get_value (cell);

    DEBUG ("PRIC");

    /* If we handled the Debcred cell then don't set the share price! */
    if (!sd->handled_dc)
        xaccSplitSetSharePrice (sd->split, price);

    sd->do_scrub = TRUE;
}