1 package Finance::Bank::BR::Santander::Spreadsheet;
6 use Spreadsheet::ParseExcel::Simple;
8 use DateTime::Format::Strptime qw(strptime);
10 our $VERSION = '0.01';
24 $self->{statement} = [];
30 my @sheets = $xls->sheets;
31 my $sheet = $sheets[0];
32 if ($sheet->has_data) {
33 my @header = $sheet->next_row;
35 while ($sheet->has_data) {
36 my @line = $sheet->next_row;
38 'date' => strptime("%d/%m/%Y", $line[0]),
42 'balance' => $line[5],
44 push @{$self->{statement}}, $obj;
45 $self->{balance} = $line[5];
52 if (defined($filename)) {
53 my $xls = Spreadsheet::ParseExcel::Simple->read($filename);
63 return $self->{balance};
68 return $self->{statement};
77 Finance::Bank::BR::Santander::Spreadsheet - Parse statement exported from Brazilian branch of Santander Internet Banking
81 use Finance::Bank::BR::Santander::Spreadsheet;
83 my $spreadsheet = Finance::Bank::BR::Santander::Spreadsheet->new($filename);
84 my $balance = $spreadsheet->balance;
85 my $data = $spreadsheet->statement;
86 foreach my $transaction (@{$data}) {
87 say "$transaction->{date}, $transaction->{name}, $transaction->{extra}, $transaction->{value}, $transaction->{balance}";
92 This module is an object-oriented interface that parses statements exported as XLS from the Internet Banking for the Brazilian branch of Santander.
98 The C<new()> method creates a new Spreadsheet object containing the data parsed from C<$filename>.
100 If an error occurs while loading the file, C<new()> returns C<undef>.
104 The C<balance()> method returns the last balance found in the sheet.
108 The C<statement()> method returns a reference to an array of transactions, described as below.
112 The transaction is a hash containing the following keys:
116 A string with a name describing the transaction.
120 A floating number containing the credit (positive) or debit (negative) of the transaction.
124 A DateTime object representing the date when the transaction occurred.
128 A floating number containing the balance resulting from the transaction.
132 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.
134 =head1 COPYRIGHT AND LICENSE
136 Copyright (C) 2015 Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
138 This program is free software; you can redistribute it and/or modify it under
139 the terms of the GNU General Public License; either version 2 of the License,
140 or (at your option) any later version.
142 This program is distributed in the hope that it will be useful, but WITHOUT
143 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
144 FOR A PARTICULAR PURPOSE.