64563eafb6f0d7118eb3f753b84cb4025858eda2
[cascardo/Finance-Bank-BR-Santander-Spreadsheet.git] / examples / santander.pl
1 #!/usr/bin/env perl
2
3 =head1 SUMMARY
4
5 B<santander.pl FILE.xls>
6
7 B<santander.pl> parses F<FILE.xls> and outputs statements and balance.
8
9 =head1 COPYRIGHT AND LICENSE
10
11   Copyright (C) 2015 Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
12
13   This program is free software; you can redistribute it and/or modify it under
14   the terms of the GNU General Public License; either version 2 of the License,
15   or (at your option) any later version.
16
17   This program is distributed in the hope that it will be useful, but WITHOUT
18   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19   FOR A PARTICULAR PURPOSE.
20
21 =cut
22
23 use strict;
24 use warnings;
25 use feature qw(say);
26
27 use Finance::Bank::BR::Santander::Spreadsheet;
28
29 if (@ARGV != 1) {
30     print STDERR "santander.pl FILE.xls\n";
31     exit 1;
32 }
33
34 my $spreadsheet = Finance::Bank::BR::Santander::Spreadsheet->new($ARGV[0]);
35
36 my $balance = $spreadsheet->balance;
37
38 my $data = $spreadsheet->statement;
39
40 foreach my $transaction (@{$data}) {
41     say "$transaction->{date}, $transaction->{name}, $transaction->{extra}, $transaction->{value}, $transaction->{balance}";
42 }
43
44 say $balance;