mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
ifinal fixes ???
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@175 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d6e8e07f3b
commit
0828fc4766
130
src/QIFIO.c
130
src/QIFIO.c
@ -148,30 +148,32 @@ char * xaccReadQIFCategory (int fd, Account * acc)
|
|||||||
/* scan for account name, description, type */
|
/* scan for account name, description, type */
|
||||||
while (qifline) {
|
while (qifline) {
|
||||||
|
|
||||||
|
/* N == Name */
|
||||||
if ('N' == qifline [0]) {
|
if ('N' == qifline [0]) {
|
||||||
XACC_PREP_STRING (acc->accountName);
|
XACC_PREP_STRING (acc->accountName);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
|
/* D == Description */
|
||||||
if ('D' == qifline [0]) {
|
if ('D' == qifline [0]) {
|
||||||
XACC_PREP_STRING (acc->description);
|
XACC_PREP_STRING (acc->description);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
|
/* T == Taxable -- this income is taxable */
|
||||||
if ('T' == qifline [0]) {
|
if ('T' == qifline [0]) {
|
||||||
if ('\r' != qifline[1]) {
|
|
||||||
printf ("QIF Parse: Unsupported category type %s \n", &qifline[1]);
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
|
/* E == Expense Category */
|
||||||
if ('E' == qifline [0]) {
|
if ('E' == qifline [0]) {
|
||||||
acc->type = EXPENSE;
|
acc->type = EXPENSE;
|
||||||
} else
|
} else
|
||||||
|
|
||||||
|
/* I == Income Category */
|
||||||
if ('I' == qifline [0]) {
|
if ('I' == qifline [0]) {
|
||||||
acc->type = INCOME;
|
acc->type = INCOME;
|
||||||
} else
|
} else
|
||||||
|
|
||||||
|
/* R == Tax Rate Indicator; -- some number ... */
|
||||||
if ('R' == qifline [0]) {
|
if ('R' == qifline [0]) {
|
||||||
/* hack alert -- some number that I don't understand */
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
/* check for end-of-transaction marker */
|
/* check for end-of-transaction marker */
|
||||||
@ -229,12 +231,19 @@ char * xaccReadQIFAccount (int fd, Account * acc)
|
|||||||
if (!strcmp (&qifline[1], "Cash\r\n")) {
|
if (!strcmp (&qifline[1], "Cash\r\n")) {
|
||||||
acc -> type = CASH;
|
acc -> type = CASH;
|
||||||
} else
|
} else
|
||||||
|
if (!strcmp (&qifline[1], "CCard\r\n")) {
|
||||||
|
acc -> type = CREDIT;
|
||||||
|
} else
|
||||||
if (!strcmp (&qifline[1], "Invst\r\n")) {
|
if (!strcmp (&qifline[1], "Invst\r\n")) {
|
||||||
acc -> type = STOCK;
|
acc -> type = STOCK;
|
||||||
} else
|
} else
|
||||||
if (!strcmp (&qifline[1], "Oth A\r\n")) {
|
if (!strcmp (&qifline[1], "Oth A\r\n")) {
|
||||||
acc -> type = ASSET;
|
acc -> type = ASSET;
|
||||||
} else {
|
} else
|
||||||
|
if (!strcmp (&qifline[1], "Oth L\r\n")) {
|
||||||
|
acc -> type = LIABILITY;
|
||||||
|
} else
|
||||||
|
{
|
||||||
printf ("QIF Parse: Unsupported account type %s \n", &qifline[1]);
|
printf ("QIF Parse: Unsupported account type %s \n", &qifline[1]);
|
||||||
acc -> type = -1; /* hack alert -- */
|
acc -> type = -1; /* hack alert -- */
|
||||||
}
|
}
|
||||||
@ -544,6 +553,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
int got_share_quantity = 0;
|
int got_share_quantity = 0;
|
||||||
int share_xfer = 0;
|
int share_xfer = 0;
|
||||||
int is_security = 0;
|
int is_security = 0;
|
||||||
|
int is_split = 0;
|
||||||
Account *sub_acc = 0x0;
|
Account *sub_acc = 0x0;
|
||||||
Account *xfer_acc = 0x0;
|
Account *xfer_acc = 0x0;
|
||||||
double adjust = 0.0;
|
double adjust = 0.0;
|
||||||
@ -581,28 +591,32 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
|
|
||||||
/* scan for transaction date, description, type */
|
/* scan for transaction date, description, type */
|
||||||
while (qifline) {
|
while (qifline) {
|
||||||
|
/* D == date */
|
||||||
|
if ('D' == qifline [0]) {
|
||||||
|
xaccParseQIFDate (&(trans->date), &qifline[1]);
|
||||||
|
} else
|
||||||
|
|
||||||
|
/* E == memo for split */
|
||||||
|
if ('E' == qifline [0]) {
|
||||||
|
/* hack alert */
|
||||||
|
} else
|
||||||
|
|
||||||
|
/* I == share price */
|
||||||
|
if ('I' == qifline [0]) {
|
||||||
|
trans -> share_price = xaccParseQIFAmount (&qifline[1]);
|
||||||
|
} else
|
||||||
|
|
||||||
|
/* L == name of acount from which transfer occured */
|
||||||
|
if ('L' == qifline [0]) {
|
||||||
|
/* locate the transfer account */
|
||||||
|
xfer_acc = xaccGetXferQIFAccount (acc, qifline);
|
||||||
|
} else
|
||||||
|
|
||||||
/* M == memo field */
|
/* M == memo field */
|
||||||
if ('M' == qifline [0]) {
|
if ('M' == qifline [0]) {
|
||||||
XACC_PREP_STRING (trans->memo);
|
XACC_PREP_STRING (trans->memo);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
/* P == Payee, for Bank accounts */
|
|
||||||
if ('P' == qifline [0]) {
|
|
||||||
XACC_PREP_STRING (trans->description);
|
|
||||||
} else
|
|
||||||
|
|
||||||
/* Y == Name of Security */
|
|
||||||
if ('Y' == qifline [0]) {
|
|
||||||
XACC_PREP_STRING (trans->description);
|
|
||||||
|
|
||||||
is_security = 1;
|
|
||||||
if (share_xfer) {
|
|
||||||
/* locate or create the sub-account account */
|
|
||||||
sub_acc = xaccGetSecurityQIFAccount (acc, qifline);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
|
||||||
|
|
||||||
/* N == check numbers for Banks, but Action for portfolios */
|
/* N == check numbers for Banks, but Action for portfolios */
|
||||||
if ('N' == qifline [0]) {
|
if ('N' == qifline [0]) {
|
||||||
|
|
||||||
@ -625,12 +639,40 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if ('D' == qifline [0]) { /* D == date */
|
/* O == adjustments */
|
||||||
xaccParseQIFDate (&(trans->date), &qifline[1]);
|
/* hack alert -- sometimes adjustments are quite large.
|
||||||
|
* I have no clue why, and what to do about it. For what
|
||||||
|
* its worth, I can prove that Quicken version 3.0 makes
|
||||||
|
* math errors ... */
|
||||||
|
if ('O' == qifline [0]) {
|
||||||
|
double pute;
|
||||||
|
adjust = xaccParseQIFAmount (&qifline[1]);
|
||||||
|
pute = (trans->damount) * (trans->share_price);
|
||||||
|
if (isneg) pute = -pute;
|
||||||
|
|
||||||
|
printf ("QIF Warning: Adjustment of %.2f to amount %.2f not handled \n", adjust, pute);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if ('T' == qifline [0]) { /* T == total */
|
/* P == Payee, for Bank accounts */
|
||||||
|
if ('P' == qifline [0]) {
|
||||||
|
XACC_PREP_STRING (trans->description);
|
||||||
|
} else
|
||||||
|
|
||||||
|
/* Q == number of shares */
|
||||||
|
if ('Q' == qifline [0]) {
|
||||||
|
trans -> damount = xaccParseQIFAmount (&qifline[1]);
|
||||||
|
if (isneg) trans -> damount = - (trans->damount);
|
||||||
|
got_share_quantity = 1;
|
||||||
|
} else
|
||||||
|
|
||||||
|
/* S == split */
|
||||||
|
if ('S' == qifline [0]) {
|
||||||
|
/* hack alert -- splits not supported */
|
||||||
|
is_split = 1;
|
||||||
|
} else
|
||||||
|
|
||||||
|
/* T == total */
|
||||||
|
if ('T' == qifline [0]) {
|
||||||
/* ignore T for stock transactions, since T is a dollar amount */
|
/* ignore T for stock transactions, since T is a dollar amount */
|
||||||
if (0 == got_share_quantity) {
|
if (0 == got_share_quantity) {
|
||||||
trans -> damount = xaccParseQIFAmount (&qifline[1]);
|
trans -> damount = xaccParseQIFAmount (&qifline[1]);
|
||||||
@ -638,24 +680,23 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if ('I' == qifline [0]) { /* I == share price */
|
/* Y == Name of Security */
|
||||||
trans -> share_price = xaccParseQIFAmount (&qifline[1]);
|
if ('Y' == qifline [0]) {
|
||||||
} else
|
XACC_PREP_STRING (trans->description);
|
||||||
|
|
||||||
if ('Q' == qifline [0]) { /* Q == number of shares */
|
is_security = 1;
|
||||||
trans -> damount = xaccParseQIFAmount (&qifline[1]);
|
if (share_xfer) {
|
||||||
if (isneg) trans -> damount = - (trans->damount);
|
/* locate or create the sub-account account */
|
||||||
got_share_quantity = 1;
|
sub_acc = xaccGetSecurityQIFAccount (acc, qifline);
|
||||||
} else
|
}
|
||||||
|
|
||||||
/* L == name of acount from which transfer occured */
|
|
||||||
if ('L' == qifline [0]) {
|
|
||||||
/* locate the transfer account */
|
|
||||||
xfer_acc = xaccGetXferQIFAccount (acc, qifline);
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
/* $ == dollar amount -- always preceeded by 'L' */
|
/* $ == dollar amount -- always preceeded by 'L' */
|
||||||
if ('$' == qifline [0]) {
|
if ('$' == qifline [0]) {
|
||||||
|
/* for splits, $ records the part of the total for each split */
|
||||||
|
/* hack alert -- splits not supported */
|
||||||
|
if (!is_split) {
|
||||||
/* Currently, it appears that the $ amount is a redundant
|
/* Currently, it appears that the $ amount is a redundant
|
||||||
* number that we can safely ignore. To get fancy,
|
* number that we can safely ignore. To get fancy,
|
||||||
* we use it to double-check the above work, since it
|
* we use it to double-check the above work, since it
|
||||||
@ -673,20 +714,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
if (wanted != got) {
|
if (wanted != got) {
|
||||||
printf ("QIF Parse Error: wanted %f got %f \n", parse, pute);
|
printf ("QIF Parse Error: wanted %f got %f \n", parse, pute);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
|
||||||
/* O == adjustments */
|
|
||||||
/* hack alert -- sometimes adjustments are quite large.
|
|
||||||
* I have no clue why, and what to do about it. For what
|
|
||||||
* its worth, I can prove that Quicken version 3.0 makes
|
|
||||||
* math errors ... */
|
|
||||||
if ('O' == qifline [0]) {
|
|
||||||
double pute;
|
|
||||||
adjust = xaccParseQIFAmount (&qifline[1]);
|
|
||||||
pute = (trans->damount) * (trans->share_price);
|
|
||||||
if (isneg) pute = -pute;
|
|
||||||
|
|
||||||
printf ("QIF Warning: Adjustment of %.2f to amount %.2f not handled \n", adjust, pute);
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
/* check for end-of-transaction marker */
|
/* check for end-of-transaction marker */
|
||||||
|
Loading…
Reference in New Issue
Block a user