mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add check -- cap gains not possible is value and amount are in the same
currency git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10171 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -192,7 +192,8 @@ xaccAccountFindEarliestOpenLot (Account *acc, gnc_numeric sign,
|
||||
|
||||
lot = xaccAccountFindOpenLot (acc, sign, currency,
|
||||
10000000LL * ((long long) LONG_MAX), earliest_pred);
|
||||
LEAVE ("found lot=%p %s", lot, gnc_lot_get_title (lot));
|
||||
LEAVE ("found lot=%p %s baln=%s", lot, gnc_lot_get_title (lot),
|
||||
gnc_num_dbg_to_string(gnc_lot_get_balance(lot)));
|
||||
return lot;
|
||||
}
|
||||
|
||||
@@ -488,7 +489,7 @@ xaccSplitAssignToLot (Split *split, GNCLot *lot)
|
||||
val_a = gnc_numeric_mul (frac, val_tot,
|
||||
gnc_numeric_denom(val_tot),
|
||||
GNC_HOW_RND_ROUND| GNC_HOW_DENOM_EXACT);
|
||||
|
||||
|
||||
val_b = gnc_numeric_sub_fixed (val_tot, val_a);
|
||||
if (gnc_numeric_check(val_a))
|
||||
{
|
||||
@@ -608,7 +609,8 @@ xaccSplitAssign (Split *split)
|
||||
*/
|
||||
while (split)
|
||||
{
|
||||
PINFO ("have split amount=%s", gnc_num_dbg_to_string (split->amount));
|
||||
PINFO ("have split %p amount=%s", split,
|
||||
gnc_num_dbg_to_string (split->amount));
|
||||
split->gains |= GAINS_STATUS_VDIRTY;
|
||||
lot = pcy->PolicyGetLot (pcy, split);
|
||||
if (!lot)
|
||||
@@ -674,6 +676,16 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
|
||||
|
||||
/* Make sure the status flags and pointers are initialized */
|
||||
if (GAINS_STATUS_UNKNOWN == split->gains) xaccSplitDetermineGainStatus(split);
|
||||
|
||||
/* Not possible to have gains if the transaction currency and
|
||||
* account commodity are identical. */
|
||||
if (gnc_commodity_equal (currency,
|
||||
xaccAccountGetCommodity(split->acc)))
|
||||
{
|
||||
LEAVE ("Currency transfer, gains not possible, returning.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pcy->PolicyIsOpeningSplit (pcy, lot, split))
|
||||
{
|
||||
#if MOVE_THIS_TO_A_DATA_INTEGRITY_SCRUBBER
|
||||
@@ -928,6 +940,7 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
|
||||
* just in case someone screwed with it! */
|
||||
if (FALSE == gnc_commodity_equiv(currency,trans->common_currency))
|
||||
{
|
||||
PWARN ("Resetting the transaction currency!");
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
}
|
||||
}
|
||||
@@ -955,7 +968,7 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
|
||||
|
||||
xaccTransCommitEdit (trans);
|
||||
}
|
||||
LEAVE ("(lot=%s)", kvp_frame_get_string (gnc_lot_get_slots (lot), "/title"));
|
||||
LEAVE ("(lot=%s)", gnc_lot_get_title(lot));
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
Reference in New Issue
Block a user