aboutsummaryrefslogtreecommitdiffstats
path: root/mktreasurer
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-05-16 20:26:38 +0000
committerNicolas Vigier <boklm@mageia.org>2013-05-16 20:26:38 +0000
commit2d2e3f24176d4580e7c17434e7fb03d05e0dcbb8 (patch)
tree59be17daaeba4cd7dc9ee6ba95a4a5e2d87c61f2 /mktreasurer
parente165fa3a7e0ae3ef1c1d2ec67447e0ed3a070a7f (diff)
downloadmgatres-2d2e3f24176d4580e7c17434e7fb03d05e0dcbb8.tar
mgatres-2d2e3f24176d4580e7c17434e7fb03d05e0dcbb8.tar.gz
mgatres-2d2e3f24176d4580e7c17434e7fb03d05e0dcbb8.tar.bz2
mgatres-2d2e3f24176d4580e7c17434e7fb03d05e0dcbb8.tar.xz
mgatres-2d2e3f24176d4580e7c17434e7fb03d05e0dcbb8.zip
mktreasurer: add start_balance and end_balance
git-svn-id: svn+ssh://svn.mageia.org/svn/soft/mga-treasurer/trunk@8278 5b7c3c08-40e5-403b-9995-ace06908e4af
Diffstat (limited to 'mktreasurer')
-rwxr-xr-xmktreasurer21
1 files changed, 17 insertions, 4 deletions
diff --git a/mktreasurer b/mktreasurer
index fa41ae0..25b4999 100755
--- a/mktreasurer
+++ b/mktreasurer
@@ -125,10 +125,23 @@ sub transactions_infos {
push @{$res{by_account}->{$tra->{ac}}->{transactions}}, $tra;
$res{balance} += new Math::BigFloat $tra->{amount};
}
- foreach my $t (values %{$res{by_account}}) {
- $t->{balance} = new Math::BigFloat 0;
- foreach my $tra (@{$t->{transactions}}) {
- $t->{balance} += new Math::BigFloat $tra->{amount};
+ foreach my $by ('by_account', 'by_year', 'by_month') {
+ foreach my $t (values %{$res{$by}}) {
+ $t->{balance} = new Math::BigFloat 0;
+ foreach my $tra (@{$t->{transactions}}) {
+ $t->{balance} += new Math::BigFloat $tra->{amount};
+ }
+ }
+ }
+ foreach my $by ('by_year', 'by_month') {
+ my ($prev, $start_balance);
+ foreach my $b (sort keys %{$res{$by}}) {
+ my $y = $res{$by}->{$b};
+ $y->{start_balance} = $start_balance ? $start_balance : new Math::BigFloat 0;
+ $y->{end_balance} = $y->{balance} + new Math::BigFloat $y->{start_balance};
+ $start_balance = $y->{end_balance};
+ $y->{prev} = $prev if $prev;
+ $prev = $b;
}
}
return \%res;