aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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>.