Example for creating split-transaction in Perl Finance::QIF

156 Views Asked by At

I need to import my bank-exported transactions (CSV) into GNUcash. I am almost finished with the perl script using Finance::QIF

I parse the CSV and write it out like this:

my $record = {
header      => "Type:Bank",
date        => $outdatum,
memo        => $outtext,
transaction => $outbetrag,
};
$out->header( $record->{header} );
$out->write($record);
....

But my problem is creating a split. http://finance-qif.sourceforge.net/ says " If the transaction contains splits this will be defined and consist of an array of hash references. With each split potentially having the following values." - so I tried this:

my $record = {
header      => "Type:Bank",
date        => $outdatum,
memo        => $outtext,
transaction => $outbetrag,
@splits = (
  {
    category => "Gesundheit:Arzt:Kind1",
    memo => "L",
    amount => "-161,66"
  },
  {         
    category => "Gesundheit:Arzt:Kind2",
    memo => "F",
    amount => "-162,66"
  }
)
};

This leads to the error:

Unsupported field 'HASH(0x221c9e8)' found in record ignored in file '>_TESTqif.qif' line 22 at convert_bank_CSV.pl line 195.

Unfortunately, I nowhere found an example for creating a split, just for a normal transaction.

Can someone please help how Finance::QIF can be used to create split-transactions?

1

There are 1 best solutions below

1
On BEST ANSWER

I know nothing about Finance::QIF but your @splits code makes no sense.

Try this instead:

my $record = {
    header      => "Type:Bank",
    date        => $outdatum,
    memo        => $outtext,
    transaction => $outbetrag,
    splits      => [
      {
        category => "Gesundheit:Arzt:Kind1",
        memo => "L",
        amount => "-161,66",
      },
      {         
        category => "Gesundheit:Arzt:Kind2",
        memo => "F",
        amount => "-162,66",
      }
    ],    
};

See perldoc perlreftut for more information about references and data structures in Perl.