Annotation of RT/Invoicing/report_income.pl, Revision 1.1
1.1 ! afresh1 1: #!/usr/bin/perl
! 2: use strict;
! 3: use warnings;
! 4: use 5.010;
! 5:
! 6: use lib 'lib';
! 7: use RTI::State;
! 8:
! 9: use YAML::XS qw/ Dump /;
! 10:
! 11: my $state = RTI::State->new('rt_invoice.state');
! 12:
! 13: my %income;
! 14: while (my ($id, $i) = each %{ $state->{invoice} }) {
! 15: next if $i->{void};
! 16: next unless $i->{custid};
! 17: #next unless $i->{custid} eq 'WireFree';
! 18: #next unless $i->{custid} eq 'speakman';
! 19: #next unless $i->{custid} eq 'jscherz@itc-home.com';
! 20:
! 21: my $unpaid = $state->unpaid_invoices($i->{custid});
! 22:
! 23: my $date = $i->{end} || $i->{invdate};
! 24: my ($y, $m) = split /-/, $date;
! 25:
! 26: foreach my $mk ('', "$i->{custid} ") {
! 27: foreach my $sk ($y, 'Total') {
! 28: my $k = "$mk$sk";
! 29: $income{$k} //= { billed => 0, unpaid => 0 };
! 30: $income{$k}{billed} += $i->{total};
! 31: $income{$k}{unpaid} += $unpaid->{ $id } if $unpaid->{$id};
! 32: }
! 33: }
! 34: }
! 35:
! 36: print Dump \%income;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>