[BACK]Return to pta_import.pl CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / pta

Diff for /pta/pta_import.pl between version 1.10 and 1.11

version 1.10, 2020/11/12 21:54:23 version 1.11, 2020/11/17 14:13:31
Line 55  sub import_account ($$$$$) {
Line 55  sub import_account ($$$$$) {
                             $description) =                              $description) =
                             import_optum_hsa($account,                              import_optum_hsa($account,
                             $csv_account, $line);                              $csv_account, $line);
                   } elsif ($account_name eq "sparkasse_camt") {
                           ($date, $amount, $debit, $credit,
                               $description) =
                               import_sparkasse_camt($account,
                               $csv_account, $line);
                 } else {                  } else {
                         die "undefined format: $account_name";                          die "undefined format: $account_name";
                 }                  }
Line 105  sub import_optum_hsa ($$$) {
Line 110  sub import_optum_hsa ($$$) {
         return ($date, $amount, $debit, $credit, $description);          return ($date, $amount, $debit, $credit, $description);
 }  }
   
   sub import_sparkasse_camt ($$$) {
           my ($account, $csv_account, $line) = @_;
           my @fields;
           $_ = $line;
           push @fields, $1 while s/"([^"]*)";?//;
           $_ eq "" or die "CAMT parse error before $_ in $line";
           @fields == 17 or die "not 17 but @fields fields: $line";
           $fields[1] =~ s/^(\d\d)\.(\d\d)\.(\d\d)$/20$3$2$1/
               or die "date parse error: $line";
           $fields[14] =~ s/,/./;
           return $fields[1],
               get_accounts_by_amount_sign($fields[14], $account, $csv_account),
               (join ' ', $fields[11], $fields[4]);
   }
   
 sub get_accounts_by_amount_sign ($$$) {  sub get_accounts_by_amount_sign ($$$) {
         my ($amount, $account, $csv_account) = @_;          my ($amount, $account, $csv_account) = @_;
         my ($debit, $credit);          my ($debit, $credit);
Line 159  while (<$in>) {
Line 179  while (<$in>) {
                 $csv_account = $1;                  $csv_account = $1;
                 next;                  next;
         }          }
         s/^(.*),\s+(\d+)\s+(\S+)// or          /^(.*)[,;]\s+(\d+)\s+(\S+)$/ or
             die "$fn import parse error: $line";              die "$fn import parse error: $line";
         my ($reg, $account, $booking) = ($1, $2, $3);          my ($reg, $account, $booking) = ($1, $2, $3);
         $reg =~ s/(?:^|(?<=,))(?:$|(?=,))/[^,]*/g;          if ($account_name eq 'sparkasse_camt') {
                   $reg =~ s/(?:^|(?<=;))(?:$|(?=;))/"[^"]*"/g;
           } else {
                   $reg =~ s/(?:^|(?<=,))(?:$|(?=,))/[^,]*/g;
           }
         $reg = qr/$reg/;          $reg = qr/$reg/;
         push @compiled, $reg;          push @compiled, $reg;
         $bookings{$reg} = $booking;          $bookings{$reg} = $booking;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

CVSweb