1 package Finance::Bank::BR::Santander::Spreadsheet;
6 use Spreadsheet::ParseExcel::Simple;
8 use DateTime::Format::Strptime qw(strptime);
10 our $VERSION = '0.01';
17 if ($self->load(@_)) {
26 $self->{statement} = [];
32 my @sheets = $xls->sheets;
33 my $sheet = $sheets[0];
34 if ($sheet->has_data) {
35 my @header = $sheet->next_row;
37 while ($sheet->has_data) {
38 my @line = $sheet->next_row;
40 'date' => strptime("%d/%m/%Y", $line[0]),
44 'balance' => $line[5],
46 push @{$self->{statement}}, $obj;
47 $self->{balance} = $line[5];
54 if (defined($filename)) {
55 my $xls = Spreadsheet::ParseExcel::Simple->read($filename);
66 return $self->{balance};
71 return @{$self->{statement}};
80 Finance::Bank::BR::Santander::Spreadsheet - Parse statement exported from Brazilian branch of Santander Internet Banking
84 use Finance::Bank::BR::Santander::Spreadsheet;
86 my $spreadsheet = Finance::Bank::BR::Santander::Spreadsheet->new($filename);
87 my $balance = $spreadsheet->balance;
88 my @data = $spreadsheet->statement;
89 foreach my $transaction (@data) {
90 say "$transaction->{date}, $transaction->{name}, $transaction->{extra}, $transaction->{value}, $transaction->{balance}";
95 This module is an object-oriented interface that parses statements exported as XLS from the Internet Banking for the Brazilian branch of Santander.
101 The C<new()> method creates a new Spreadsheet object containing the data parsed from C<$filename>.
103 If an error occurs while loading the file, C<new()> returns C<undef>.
107 The C<balance()> method returns the last balance found in the sheet.
111 The C<statement()> method returns an array of transactions, described as below.
115 The transaction is a hash containing the following keys:
119 A string with a name describing the transaction.
123 A floating number containing the credit (positive) or debit (negative) of the transaction.
127 A DateTime object representing the date when the transaction occurred.
131 A floating number containing the balance resulting from the transaction.
135 Data provided by the bank identifying the transaction. In this case, a number specific to the type of transaction. It can be used to help uniquely identify the transaction.
137 =head1 COPYRIGHT AND LICENSE
139 Copyright (C) 2015 Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
141 This program is free software; you can redistribute it and/or modify it under
142 the terms of the GNU General Public License; either version 2 of the License,
143 or (at your option) any later version.
145 This program is distributed in the hope that it will be useful, but WITHOUT
146 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
147 FOR A PARTICULAR PURPOSE.