Finance-Bank-ID-BCA
view release on metacpan or search on metacpan
lib/Finance/Bank/ID/BCA.pm view on Meta::CPAN
$stmt->{_num_debit_tx_in_stmt} = $3 if $3;
"";
}
sub _ps_get_transactions {
require DateTime;
my ($self, $page, $stmt) = @_;
my @e;
# text version
while ($page =~ m!^
(\d\d/\d\d|\s?PEND|\s?NEXT) # 1) date
(?:\s*\t\s*|\n)+
((?:[^\t]|\n)*?) # 2) description
(?:\s*\t\s*|\n)+
(\d{4}) # 3) branch code
(?:\s*\t\s*|\n)+
([0-9,]+)\.(\d\d) # 4+5) amount
(?:\s*\t?\s*|\n)+
(CR|DB) # 6)
(?:\s*\t\s*|\n)+
([0-9,]+)\.(\d\d) # 7+8) balance
!mxg) {
push @e, {date=>$1, desc=>$2, br=>$3, amt=>$4, amtf=>$5, crdb=>$6, bal=>$7, balf=>$8};
}
if (!@e) {
# HTML version
while ($page =~ m!^
<tr>\s*
<td[^>]+>(?:\s*<[^>]+>\s*)* (\d\d/\d\d|\s?PEND|\s?NEXT) (?:\s*<[^>]+>\s*)*</td>\s*
<td[^>]+>(?:\s*<[^>]+>\s*)* ((?:[^\t]|\n)*?) (?:\s*<[^>]+>\s*)*</td>\s*
<td[^>]+>(?:\s*<[^>]+>\s*)* (\d{4}) (?:\s*<[^>]+>\s*)*</td>\s*
<td[^>]+>(?:\s*<[^>]+>\s*)* ([0-9,]+)\.(\d\d) (?:\s*<[^>]+>\s*)*</td>\s*
<td[^>]+>(?:\s*<[^>]+>\s*)* (CR|DB) (?:\s*<[^>]+>\s*)*</td>\s*
<td[^>]+>(?:\s*<[^>]+>\s*)* ([0-9,]+)\.(\d\d) (?:\s*<[^>]+>\s*)*</td>\s*
</tr>
!smxg) {
push @e, {date=>$1, desc=>$2, br=>$3, amt=>$4, amtf=>$5, crdb=>$6, bal=>$7, balf=>$8};
}
for (@e) { $_->{desc} =~ s!<br ?/?>!\n!ig }
}
my @tx;
my @skipped_tx;
my $last_date;
my $seq;
my $i = 0;
for my $e (@e) {
$i++;
my $tx = {};
#$tx->{stmt_start_date} = $stmt->{start_date};
if ($e->{date} =~ /NEXT/) {
$tx->{date} = $stmt->{end_date};
$tx->{is_next} = 1;
} elsif ($e->{date} =~ /PEND/) {
$tx->{date} = $stmt->{end_date};
$tx->{is_pending} = 1;
} else {
my ($day, $mon) = split m!/!, $e->{date};
my $last_nonpend_date = DateTime->new(
year => ($mon < $stmt->{start_date}->month ?
$stmt->{end_date}->year :
$stmt->{start_date}->year),
month => $mon,
day => $day);
$tx->{date} = $last_nonpend_date;
$tx->{is_pending} = 0;
}
$tx->{description} = $e->{desc};
$tx->{branch} = $e->{br};
$tx->{amount} = ($e->{crdb} =~ /CR/ ? 1 : -1) * ($self->_stripD($e->{amt}) + 0.01*$e->{amtf});
$tx->{balance} = ($self->_stripD($e->{bal}) + 0.01*$e->{balf});
if (!$last_date || DateTime->compare($last_date, $tx->{date})) {
$seq = 1;
$last_date = $tx->{date};
} else {
$seq++;
}
$tx->{seq} = $seq;
if ($self->_variant eq 'perorangan' &&
$tx->{date}->dow =~ /6|7/ &&
$tx->{description} !~ /^(BIAYA ADM|BUNGA|(CR|DR) KOREKSI BUNGA|PAJAK BUNGA)\s*$/) {
return "check failed in tx#$i: In KlikBCA Perorangan, all ".
"transactions must not be in Sat/Sun except for Interest and ".
"Admin Fee: <$tx->{description}> ($tx->{date})";
# note: in Tahapan perorangan, BIAYA ADM is set on
# Fridays, but for Tapres (?) on last day of the month
}
if ($self->_variant eq 'bisnis' &&
$tx->{date}->dow =~ /6|7/ &&
$tx->{description} !~ /^(BIAYA ADM|BUNGA|(CR|DR) KOREKSI BUNGA|PAJAK BUNGA)\s*$/) {
return "check failed in tx#$i: In KlikBCA Bisnis, all ".
"transactions must not be in Sat/Sun except for Interest and ".
"Admin Fee: <$tx->{description}> ($tx->{date})";
# note: in KlikBCA bisnis, BIAYA ADM is set on the last day of the
# month, regardless of whether it's Sat/Sun or not
}
push @tx, $tx;
}
$stmt->{transactions} = \@tx;
$stmt->{skipped_transactions} = \@skipped_tx;
"";
}
sub get_estatement {
my ($self, %args) = @_;
my $s = $self->site;
$self->login;
$self->_menu;
$self->_menu_estatement;
$self->logger->info(
( run in 0.677 second using v1.01-cache-2.11-cpan-71847e10f99 )