aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-05-16 20:26:46 +0000
committerNicolas Vigier <boklm@mageia.org>2013-05-16 20:26:46 +0000
commit05141c021dc9e20b7cd473762ae33612d89d1b48 (patch)
tree148b50790f73f6cdc2d28dc823c939b33c01a9e6
parent40130e7b43aebd6277592ee5a2f119fabfb8386d (diff)
downloadmgatres-05141c021dc9e20b7cd473762ae33612d89d1b48.tar
mgatres-05141c021dc9e20b7cd473762ae33612d89d1b48.tar.gz
mgatres-05141c021dc9e20b7cd473762ae33612d89d1b48.tar.bz2
mgatres-05141c021dc9e20b7cd473762ae33612d89d1b48.tar.xz
mgatres-05141c021dc9e20b7cd473762ae33612d89d1b48.zip
Sort transactions by category
git-svn-id: svn+ssh://svn.mageia.org/svn/soft/mga-treasurer/trunk@8281 5b7c3c08-40e5-403b-9995-ace06908e4af
-rw-r--r--NEWS2
-rwxr-xr-xmktreasurer17
-rw-r--r--tmpl/index.html8
3 files changed, 26 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index a03feee..8fae572 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- sort transactions by category
+
Version 0.2
- add per person donation pages
diff --git a/mktreasurer b/mktreasurer
index ce3fbd4..4c44e50 100755
--- a/mktreasurer
+++ b/mktreasurer
@@ -30,6 +30,11 @@ sub party_name {
$Nb == 0 ? '' : (grep { $_->{Nb} == $Nb } @{$r->{Party}})[0]->{Na};
}
+sub cat_name {
+ my ($r, $Nb) = @_;
+ $Nb == 0 ? '' : (grep { $_->{Nb} == $Nb } @{$r->{Category}})[0]->{Na};
+}
+
sub subcat_name {
my ($r, $Nb, $Nbc) = @_;
(grep { $_->{Nb} == $Nb && $_->{Nbc} == $Nbc }
@@ -62,6 +67,7 @@ sub transactions_list {
account => account_name($r, $tra->{Ac}),
$tra->{Trt} != 0 ? (trt => $tra->{Trt}) : (),
$tra->{Sca} != 0 ? (sc_name => subcat_name($r, $tra->{Sca}, $tra->{Ca})) : (),
+ $tra->{Ca} != 0 ? (c_name => cat_name($r, $tra->{Ca}), ca => $tra->{Ca}) : (),
$tra->{No} ne '(null)' ? (notes => $tra->{No}) : (),
);
push @res, \%d;
@@ -110,6 +116,7 @@ sub transactions_infos {
by_year => {},
by_pa => {},
by_account => {},
+ by_ca => {},
balance => new Math::BigFloat 0,
);
foreach my $tra (@{$res{transactions}}) {
@@ -124,9 +131,13 @@ sub transactions_infos {
push @{$res{by_year}->{$year}->{months}}, $month;
push @{$res{by_pa}->{$tra->{pa}}->{transactions}}, $tra;
push @{$res{by_account}->{$tra->{ac}}->{transactions}}, $tra;
+ if ($tra->{ca}) {
+ push @{$res{by_ca}->{$tra->{ca}}->{transactions}}, $tra;
+ $res{by_ca}->{$tra->{ca}}->{c_name} = $tra->{c_name};
+ }
$res{balance} += $tra->{amount};
}
- foreach my $by ('by_account', 'by_year', 'by_month') {
+ foreach my $by ('by_account', 'by_year', 'by_month', 'by_ca') {
foreach my $t (values %{$res{$by}}) {
$t->{balance} = new Math::BigFloat 0;
foreach my $tra (@{$t->{transactions}}) {
@@ -144,6 +155,10 @@ sub transactions_infos {
my ($prev, $start_balance);
foreach my $b (sort keys %{$res{$by}}) {
my $y = $res{$by}->{$b};
+ foreach my $tra (@{$y->{transactions}}) {
+ next unless $tra->{ca};
+ $y->{ca_balance}->{$tra->{ca}} += $tra->{amount};
+ }
$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};
diff --git a/tmpl/index.html b/tmpl/index.html
index 2920516..af713fa 100644
--- a/tmpl/index.html
+++ b/tmpl/index.html
@@ -36,6 +36,14 @@
More details coming soon.
+ <h3>Expenses and revenues by category</h3>
+
+ <ul>
+ [%- FOR ca IN transactions.by_ca.keys.sort %]
+ <li><b>[% transactions.by_ca.$ca.c_name %]</b>: [% transactions.by_ca.$ca.balance %] Euros</li>
+ [%- END -%]
+ </ul>
+
<h3>Grisbi</h3>
<p>
Mageia.Org accounts are managed using <a href="http://grisbi.org/">grisbi</a>.