git ssb

0+

cel / ledger-scripts



Tree: f1521af2d73e96acaa4e96dfc60dbfc50373845a

Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / dwolla2ledger

1144 bytesRaw
1#!/usr/bin/env perl
2
3use strict;
4
5my $dwolla_account = 'Assets:Broker:Dwolla';
6my $dwolla_fee_account = 'Expenses:Broker:Dwolla';
7
8while (<>) {
9 my ($type, $date, $time, $amount, $id, $original_id, $transaction_type,
10 $other_entity, $other_entity_id, $comments, $address1, $address2, $city,
11 $state, $zip, $email_address) = map { s/^"(.*)"$/$1/; $_ } split ',';
12
13 next if $type eq "Type";
14
15 my ($month, $day, $year) = $date =~ /([0-9]{2})\/([0-9]{2})\/([0-9]{4})/;
16 $date = "$year/$month/$day";
17
18 my $other_account = ($transaction_type eq 'deposit' or
19 $transaction_type eq 'withdraw') ? 'Assets' :
20 $transaction_type eq 'transfer' ?
21 ($type eq 'debit' ? 'Expenses' :
22 $type eq 'credit' ? 'Income' :
23 $dwolla_account) :
24 $type eq 'fee' ? $dwolla_fee_account :
25 $dwolla_account;
26
27 printf "%s %s\n", $date, $other_entity;
28 printf " %s %27s\n", $dwolla_account, (sprintf "\$%.02f", -$amount);
29 printf " %s\n\n", $other_account;
30}
31

Built with git-ssb-web