mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix amount sign of imported bank transfers (e.g. from DTAUS file).
Usually an imported DTAUS file describes debit notes, which means "our account" is credited (and the other debited). But DTAUS can also contain transfers, which means "our account" is debited. In the DTAUS case, the value would still be positive, so we have to query the transaction type for this case as well. This is now fixed. (Needs aqbanking-4.1.10 though because the earlier versions forgot to set the TypeTransfer.) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18402 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
eac59d32d1
commit
06eeaebb2a
@ -346,8 +346,6 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
|
||||
const char *custref;
|
||||
gchar *description;
|
||||
Split *split;
|
||||
const AB_VALUE *ab_value;
|
||||
gnc_numeric gnc_amount;
|
||||
gchar *memo;
|
||||
|
||||
g_return_val_if_fail(ab_trans && gnc_acc, NULL);
|
||||
@ -400,15 +398,25 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
|
||||
if (fitid && *fitid)
|
||||
gnc_import_set_split_online_id(split, fitid);
|
||||
|
||||
{
|
||||
/* Amount into the split */
|
||||
ab_value = AB_Transaction_GetValue(ab_trans);
|
||||
const AB_VALUE *ab_value = AB_Transaction_GetValue(ab_trans);
|
||||
double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
|
||||
AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
|
||||
gnc_numeric gnc_amount;
|
||||
|
||||
printf("Transaction with value %f has type %d\n", d_value, ab_type);
|
||||
if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
|
||||
d_value = -d_value;
|
||||
|
||||
gnc_amount = double_to_gnc_numeric(
|
||||
ab_value ? AB_Value_GetValueAsDouble(ab_value) : 0.0,
|
||||
d_value,
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_RND_ROUND);
|
||||
if (!ab_value)
|
||||
g_warning("transaction_cb: Oops, value was NULL. Using 0");
|
||||
xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
|
||||
}
|
||||
|
||||
/* Memo in the Split. */
|
||||
memo = gnc_ab_memo_to_gnc(ab_trans);
|
||||
|
@ -321,8 +321,19 @@ AB_TRANSACTION *gnc_hbci_trans_list_cb(AB_TRANSACTION *h_trans, void *user_data)
|
||||
{
|
||||
/* Amount into the split */
|
||||
const AB_VALUE *h_value = AB_Transaction_GetValue (h_trans);
|
||||
gnc_numeric gnc_amount = double_to_gnc_numeric
|
||||
(h_value ? AB_Value_GetValue (h_value) : 0.0,
|
||||
double d_value = h_value ? AB_Value_GetValue (h_value) : 0.0;
|
||||
AB_TRANSACTION_TYPE h_type = AB_Transaction_GetType (h_trans);
|
||||
gnc_numeric gnc_amount;
|
||||
|
||||
/*printf("Transaction with value %f has type %d\n", d_value, h_type);*/
|
||||
/* If the value is positive, but the transaction type says the
|
||||
money is transferred away from our account (Transfer instead of
|
||||
DebitNote), we switch the value to negative. */
|
||||
if (d_value > 0.0 && h_type == AB_Transaction_TypeTransfer)
|
||||
d_value = -d_value;
|
||||
|
||||
gnc_amount = double_to_gnc_numeric
|
||||
(d_value,
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_RND_ROUND);
|
||||
if (!h_value)
|
||||
|
Loading…
Reference in New Issue
Block a user