I released Finance::Bank::HDFC version 0.14 recently. The latest release has the all important get_mini_statement() method implemented. Yes! Check your mini account statement (last 20 transactions) from the command line!
The Template::Extract module from CPAN was extremely helpful here. The account statements were available as JavaScript code in the source HTML file.
dattxn[l_count] = '10 Apr 2008';
txndesc[l_count] = "Description blah blah";
refchqnbr[l_count] = '000003009168';
datvalue[l_count] = '11 Apr 2008';
amttxn[l_count] = '0.01';
balaftertxn[l_count] = '999999.99';
coddrcr[l_count] = 'D';
l_count ++;
dattxn[l_count] = '01 Apr 2008';
txndesc[l_count] = "A millionaire?";
refchqnbr[l_count] = '037103902179';
datvalue[l_count] = '01 Apr 2008';
amttxn[l_count] = '1000000.00';
balaftertxn[l_count] = '1000000.00';
coddrcr[l_count] = 'C';
l_count ++;
Looks just like a template right? Correct. Enter Template::Extract.
Template::Extract - Use TT2 syntax to extract data from documents
This is the template code I used
# template for extracting mini statements
Readonly my $TEMPLATE_MINI_STATEMENT => <<'EOF';
[% FOREACH record %]
[% ... %]dattxn[l_count] = '[% date_transaction %]';
[% ... %]txndesc[l_count] = "[% description %]";
[% ... %]refchqnbr[l_count] = '[% ref_chq_num %]';
[% ... %]datvalue[l_count] = '[% date_value %]';
[% ... %]amttxn[l_count] = '[% amount %]';
[% ... %]balaftertxn[l_count] = '[% balance %]';
[% ... %]coddrcr[l_count] = '[% type %]';
[% END %]
EOF
After using the extract() method:
my $template = Template::Extract->new;
my $ref = $template->extract($TEMPLATE_MINI_STATEMENT, $response->content);
This is the resulting arrayref. Use it the way you want.
$ref = [
{
'amount' => '0.01',
'balance' => '999999.99',
'ref_chq_num' => '000003009168',
'date_transaction' => '10 Apr 2008',
'type' => 'D',
'date_value' => '11 Apr 2008',
'description' => 'Description blah blah'
},
{
'amount' => '1000000.00',
'balance' => '1000000.00',
'ref_chq_num' => '037103902179',
'date_transaction' => '01 Apr 2008',
'type' => 'C',
'date_value' => '01 Apr 2008',
'description' => 'A millionaire?'
}
];
For example:
foreach my $stmt_ref (@$ref) {
print "Amount: " . $stmt_ref->{amount} . "\n";
print "Balance: " . $stmt_ref->{balance} . "\n";
}