diff options
author | ivan <ivan> | 2002-02-10 02:16:47 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-02-10 02:16:47 +0000 |
commit | c828daa905491e65deb30a2ed34af609cdb96b99 (patch) | |
tree | 3716828b64701eceeea4e2f95ba44a3ff60c49cf /FS | |
parent | 298b8d9a262265fe7106da1ff552ce6778237034 (diff) |
pro-rating w/ web interface, tested (closes: Bug#313).
view/cust_bill.cgi invoice view shows invoice events!
fix bug where adding events with no name silently failed instead of giving
an error
add new comission plans
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 16 | ||||
-rw-r--r-- | FS/FS/cust_bill_event.pm | 13 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 32 |
4 files changed, 60 insertions, 8 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 873ee75a9..da6bf72ce 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -716,6 +716,13 @@ httemplate/docs/config.html 'type' => 'textarea', }, + { + 'key' => 'safe-part_pkg', + 'section' => 'UI', + 'description' => 'Validates package definition setup and recur expressions against a preset list. Useful for webdemos, annoying to powerusers.', + 'type' => 'checkbox', + }, + ); 1; diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index ad2ae82d1..4306ea477 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -19,6 +19,7 @@ use FS::cust_pay; use FS::cust_pkg; use FS::cust_credit_bill; use FS::cust_pay_batch; +use FS::cust_bill_event; @ISA = qw( FS::Record ); @@ -251,6 +252,19 @@ sub cust_bill_pkg { qsearch( 'cust_bill_pkg', { 'invnum' => $self->invnum } ); } +=item cust_bill_event + +Returns the completed invoice events (see L<FS::cust_bill_event>) for this +invoice. + +=cut + +sub cust_bill_event { + my $self = shift; + qsearch( 'cust_bill_event', { 'invnum' => $self->invnum } ); +} + + =item cust_main Returns the customer (see L<FS::cust_main>) for this invoice. @@ -864,7 +878,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.17 2002-02-06 15:50:54 ivan Exp $ +$Id: cust_bill.pm,v 1.18 2002-02-10 02:16:46 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_bill_event.pm b/FS/FS/cust_bill_event.pm index 910b4dead..cc9ce7cb8 100644 --- a/FS/FS/cust_bill_event.pm +++ b/FS/FS/cust_bill_event.pm @@ -3,6 +3,7 @@ package FS::cust_bill_event; use strict; use vars qw( @ISA ); use FS::Record qw( qsearch qsearchs ); +use FS::part_bill_event; @ISA = qw(FS::Record); @@ -117,6 +118,18 @@ sub check { ''; #no error } +=item part_bill_event + +Returns the invoice event definition (see L<FS::part_bill_event>) for this +completed invoice event. + +=cut + +sub part_bill_event { + my $self = shift; + qsearchs( 'part_bill_event', { 'eventpart' => $self->eventpart } ); +} + =back =head1 BUGS diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 94fd97f39..5cc6cfdfd 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -913,6 +913,9 @@ sub bill { }; $recur_prog = $1; + # shared with $recur_prog + $sdate = $cust_pkg->bill || $cust_pkg->setup || $time; + #my $cpt = new Safe; ##$cpt->permit(); #what is necessary? #$cpt->share(qw( $cust_pkg )); #can $cpt now use $cust_pkg methods? @@ -925,11 +928,14 @@ sub bill { } #change this bit to use Date::Manip? CAREFUL with timezones (see # mailing list archive) - #$sdate=$cust_pkg->bill || time; - #$sdate=$cust_pkg->bill || $time; - $sdate = $cust_pkg->bill || $cust_pkg->setup || $time; my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($sdate) )[0,1,2,3,4,5]; + + #pro-rating magic - if $recur_prog fiddles $sdate, want to use that + # only for figuring next bill date, nothing else, so, reset $sdate again + # here + $sdate = $cust_pkg->bill || $cust_pkg->setup || $time; + $mon += $part_pkg->getfield('freq'); until ( $mon < 12 ) { $mon -= 12; $year++; } $cust_pkg->setfield('bill', @@ -1118,7 +1124,7 @@ sub collect { sort { $a->seconds <=> $b->seconds || $a->weight <=> $b->weight || $a->eventpart <=> $b->eventpart } - grep { $_->seconds > ( $invoice_time - ( $cust_bill->_date || 0 ) ) + grep { $_->seconds <= ( $invoice_time - $cust_bill->_date ) && ! qsearchs( 'cust_bill_event', { 'invnum' => $cust_bill->invnum, 'eventpart' => $_->eventpart } ) @@ -1518,11 +1524,23 @@ sub referral_cust_main { @cust_main; } +=item referral_cust_main_ncancelled + +Same as referral_cust_main, except only returns customers with uncancelled +packages. + +=cut + +sub referral_cust_main_ncancelled { + my $self = shift; + grep { scalar($_->ncancelled_pkgs) } $self->referral_cust_main; +} + =item referral_cust_pkg [ DEPTH ] -Like referral_cust_main, except returns a flat list of all unsuspended packages -for each customer. The number of items in this list may be useful for -comission calculations (perhaps after a grep). +Like referral_cust_main, except returns a flat list of all unsuspended (and +uncancelled) packages for each customer. The number of items in this list may +be useful for comission calculations (perhaps after a C<grep { my $pkgpart = $_->pkgpart; grep { $_ == $pkgpart } @commission_worthy_pkgparts> } $cust_main-> ). =cut |