The QIF load code leaves the currency of the accounts NULL, which
really throws the engine for a loop.  This patch sets the currency of
all acounts created by the QIF load process to "USD".

I'm sure the Canadian version of Quicken can generate QIF files.  I'm
not sure if there is a way to tell if a QIF is Canadian or not, or if
QIF files contain currency information.



Index: QIFIO.c
===================================================================
RCS file: /home/cvs/cvsroot/xacc/src/engine/QIFIO.c,v
retrieving revision 1.29
diff -u -r1.29 QIFIO.c
--- QIFIO.c     1998/12/06 07:43:13     1.29
+++ QIFIO.c     1999/03/18 06:39:57
@@ -59,6 +59,29 @@
 
 /*******************************************************/
 
+/********************************************************************\
+ * xaccMallocQIFAccount                                             * 
+ *   xaccMallocAccount + set currency                               *
+ *                                                                  * 
+ * Args:   none                                                     * 
+ * Return: a new Account with its currency set to USD               * 
+\********************************************************************/
+Account*
+xaccMallocQIFAccount (void)
+{
+  Account* acc = xaccMallocAccount();
+
+  /* There is a Canadian version of Quicken.  I'm not sure if
+     you can distinguish canadian .QIF files from US .QIF
+     files.  For now, they're always USD. */
+  if (acc)
+    {
+      xaccAccountSetCurrency (acc, "USD");
+    }
+
+  return acc;
+}
+
 int 
 xaccGetQIFIOError (void)
 {
@@ -329,7 +352,7 @@
 
    if (!grp) return 0x0;
    do { 
-      acc = xaccMallocAccount();
+      acc = xaccMallocQIFAccount();
       if (cat) { 
          qifline = xaccReadQIFCategory (fd, acc);
       } else {
@@ -497,7 +520,7 @@
 
    /* if not, create it */
    if (!xfer_acc) {
-      xfer_acc = xaccMallocAccount ();
+      xfer_acc = xaccMallocQIFAccount ();
       xaccAccountSetName (xfer_acc, qifline);
       xaccAccountSetDescription (xfer_acc, "");
       xaccAccountSetNotes (xfer_acc, "");
@@ -582,7 +605,7 @@
 
    /* if not, create it */
    if (!xfer_acc) {
-      xfer_acc = xaccMallocAccount ();
+      xfer_acc = xaccMallocQIFAccount ();
       xaccAccountSetName (xfer_acc, qifline);
       xaccAccountSetDescription (xfer_acc, "");
       xaccAccountSetNotes (xfer_acc, "");
@@ -1013,7 +1036,7 @@
         
      if (name) {
         int bogus_acc_name = 1;
-        Account * acc = xaccMallocAccount();
+        Account * acc = xaccMallocQIFAccount();
         xaccAccountSetType (acc, typo);
         xaccAccountSetName (acc, name);
 
@@ -1068,7 +1091,7 @@
            /* read account name, followed by dollar data ... */
            char * acc_name;
            Account *preexisting;
-           Account *acc   = xaccMallocAccount();
+           Account *acc   = xaccMallocQIFAccount();
            int guess_acc_name = 0;
 
            DEBUG ("got account\n");


-- 
Matt

----- %< -------------------------------------------- >% ------
The GnuCash / X-Accountant Mailing List
To unsubscribe, send mail to [EMAIL PROTECTED] and
put "unsubscribe gnucash-devel [EMAIL PROTECTED]" in the body

Reply via email to