freeside/httemplate/search report_prepaid_income.cgi,1.1.2.4,1.1.2.5 report_prepaid_income.html,1.1.2.1,1.1.2.2
ivan
ivan at pouncequick.420.am
Sat Apr 10 18:50:50 PDT 2004
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory pouncequick:/tmp/cvs-serv28839/httemplate/search
Modified Files:
Tag: FREESIDE_1_4_BRANCH
report_prepaid_income.cgi report_prepaid_income.html
Log Message:
update unearned revenue report based on feedback from kevin
Index: report_prepaid_income.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_prepaid_income.html,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- report_prepaid_income.html 23 Jan 2004 11:20:46 -0000 1.1.2.1
+++ report_prepaid_income.html 11 Apr 2004 01:50:48 -0000 1.1.2.2
@@ -9,7 +9,29 @@
<BODY BGCOLOR="#e8e8e8">
<H1>Prepaid Income (Unearned Revenue) Report</H1>
<FORM ACTION="report_prepaid_income.cgi" METHOD="post">
- Prepaid income (unearned revenue) as of <INPUT TYPE="text" NAME="date" VALUE="now">
+ <TABLE>
+ <TR>
+ <TD>Prepaid income (unearned revenue) as of </TD>
+ <TD>
+ <INPUT TYPE="text" NAME="date" ID="date_text" VALUE="now">
+ <IMG SRC="../images/calendar.png" ID="date_button" STYLE="cursor: pointer" TITLE="Select date">
+ </TD>
+ </TR>
+ <TR>
+ <TD>
+ </TD>
+ <TD><i>m/d/y</i></TD>
+ </TR>
+ </TABLE>
+<SCRIPT TYPE="text/javascript">
+ Calendar.setup({
+ inputField: "date_text",
+ ifFormat: "%m/%d/%Y",
+ button: "date_button",
+ align: "BR"
+ });
+</SCRIPT>
+
<INPUT TYPE="submit" VALUE="Generate report">
</BODY>
</HTML>
Index: report_prepaid_income.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_prepaid_income.cgi,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -d -r1.1.2.4 -r1.1.2.5
--- report_prepaid_income.cgi 23 Jan 2004 11:20:46 -0000 1.1.2.4
+++ report_prepaid_income.cgi 11 Apr 2004 01:50:48 -0000 1.1.2.5
@@ -5,11 +5,13 @@
#needs to be re-written in sql for efficiency
- my $now = $cgi->param('date') && str2time($cgi->param('date')) || time;
+ my $time = time;
+
+ my $now = $cgi->param('date') && str2time($cgi->param('date')) || $time;
$now =~ /^(\d+)$/ or die "unparsable date?";
$now = $1;
- my %prepaid;
+ my( $total, $total_legacy ) = ( 0, 0 );
my @cust_bill_pkg =
grep { $_->cust_pkg && $_->cust_pkg->part_pkg->freq !~ /^([01]|\d+[dw])$/ }
@@ -18,58 +20,67 @@
'edate' => { op=>'>', value=>$now },
}, );
- foreach my $cust_bill_pkg ( @cust_bill_pkg ) {
+ my @cust_pkg =
+ grep { $_->part_pkg->recur != 0
+ && $_->part_pkg->freq !~ /^([01]|\d+[dw])$/
+ }
+ qsearch ( 'cust_pkg', {
+ 'bill' => { op=>'>', value=>$now }
+ } );
- #conceptual false laziness w/texas tax exempt_amount stuff in
- #FS::cust_main::bill
+ foreach my $cust_bill_pkg ( @cust_bill_pkg) {
+ my $period = $cust_bill_pkg->edate - $cust_bill_pkg->sdate;
- my $freq = $cust_bill_pkg->cust_pkg->part_pkg->freq;
- my $per_month = sprintf("%.2f", $cust_bill_pkg->recur / $freq);
+ my $elapsed = $now - $cust_bill_pkg->sdate;
+ $elapsed = 0 if $elapsed < 0;
- my($mon, $year) = (localtime($cust_bill_pkg->sdate) )[4,5];
- $mon+=2; $year+=1900;
+ my $remaining = 1 - $elapsed/$period;
- foreach my $which_month ( 2 .. $freq ) {
- until ( $mon < 13 ) { $mon -= 12; $year++; }
- $prepaid{"$year-$mon"} += $per_month;
- $mon++;
- }
+ my $unearned = $remaining * $cust_bill_pkg->recur;
+ $total += $unearned;
}
- my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
-
-%>
-
-<%= header( 'Prepaid Income (Unearned Revenue) Report',
- menubar( 'Main Menu'=>$p, ) ) %>
-<%= table() %>
-<%
+ foreach my $cust_pkg ( @cust_pkg ) {
+ my $period = $cust_pkg->bill - $cust_pkg->last_bill;
- my $total = 0;
+ my $elapsed = $now - $cust_pkg->last_bill;
+ $elapsed = 0 if $elapsed < 0;
- my ($now_mon, $now_year) = (localtime($now))[4,5];
- $now_mon+=2; $now_year+=1900;
- until ( $now_mon < 13 ) { $now_mon -= 12; $now_year++; }
+ my $remaining = 1 - $elapsed/$period;
- my $subseq = 0;
- for my $year ( $now_year .. 2037 ) {
- for my $mon ( ( $subseq++ ? 1 : $now_mon ) .. 12 ) {
- if ( $prepaid{"$year-$mon"} ) {
- $total += $prepaid{"$year-$mon"};
- %> <TR><TD ALIGN="right"><%= $mon[$mon-1]. ' '. $year %></TD>
- <TD ALIGN="right">
- <%= sprintf("%.2f", $prepaid{"$year-$mon"} ) %>
- </TD>
- </TR>
- <%
- }
- }
+ my $unearned = $remaining * $cust_pkg->part_pkg->recur; #!! only works for flat/legacy
+ $total_legacy += $unearned;
}
+ $total = sprintf('%.2f', $total);
+ $total_legacy = sprintf('%.2f', $total_legacy);
+
%>
-<TR><TH>Total</TH><TD ALIGN="right"><%= sprintf("%.2f", $total) %></TD></TR>
+
+<%= header( 'Prepaid Income (Unearned Revenue) Report',
+ menubar( 'Main Menu'=>$p, ) ) %>
+<%= table() %>
+ <TR>
+ <TH>Actual Unearned Revenue</TH>
+ <TH>Legacy Unearned Revenue</TH>
+ </TR>
+ <TR>
+ <TD ALIGN="right">$<%= $total %>
+ <TD ALIGN="right">
+ <%= $now == $time ? "\$$total_legacy" : '<i>N/A</i>'%>
+ </TD>
+ </TR>
+
</TABLE>
+<BR>
+Actual unearned revenue is the amount of unearned revenue Freeside has
+actually invoiced for packages with longer-than monthly terms.
+<BR><BR>
+Legacy unearned revenue is the amount of unearned revenue represented by
+customer packages. This number may be larger than actual unearned
+revenue if you have imported longer-than monthly customer packages from
+a previous billing system.
</BODY>
</HTML>
More information about the freeside-commits
mailing list