[freeside-commits] freeside/FS/FS cust_main.pm, 1.271.2.67, 1.271.2.68 Conf.pm, 1.180.2.43, 1.180.2.44
Ivan,,,
ivan at wavetail.420.am
Mon Apr 27 21:13:55 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv17940
Modified Files:
Tag: FREESIDE_1_7_BRANCH
cust_main.pm Conf.pm
Log Message:
add cancelled_cust-noevents flag to emulate SG billing-daily -r behavior
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.180.2.43
retrieving revision 1.180.2.44
diff -u -d -r1.180.2.43 -r1.180.2.44
--- Conf.pm 26 Apr 2009 23:09:40 -0000 1.180.2.43
+++ Conf.pm 28 Apr 2009 04:13:53 -0000 1.180.2.44
@@ -2457,6 +2457,13 @@
'type' => 'text',
},
+ {
+ 'key' => 'cancelled_cust-noevents',
+ 'section' => 'billing',
+ 'description' => "Don't run events for cancelled customers",
+ 'type' => 'checkbox',
+ },
+
);
1;
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.271.2.67
retrieving revision 1.271.2.68
diff -u -d -r1.271.2.67 -r1.271.2.68
--- cust_main.pm 20 Apr 2009 16:58:08 -0000 1.271.2.67
+++ cust_main.pm 28 Apr 2009 04:13:53 -0000 1.271.2.68
@@ -1935,18 +1935,36 @@
sub bill_and_collect {
my( $self, %options ) = @_;
- ###
- # cancel packages
- ###
-
#$options{actual_time} not $options{time} because freeside-daily -d is for
#pre-printing invoices
- my @cancel_pkgs = grep { $_->expire && $_->expire <= $options{actual_time} }
+ $self->cancel_expired_pkgs( $options{actual_time} );
+ $self->suspend_adjourned_pkgs( $options{actual_time} );
+
+ my $error = $self->bill( %options );
+ warn "Error billing, custnum ". $self->custnum. ": $error" if $error;
+
+ $self->apply_payments_and_credits;
+
+ unless ( $conf->config('cancelled_cust-noevents')
+ && ! $self->num_ncancelled_pkgs
+ ) {
+
+ $error = $self->collect( %options );
+ warn "Error collecting, custnum". $self->custnum. ": $error" if $error;
+
+ }
+
+}
+
+sub cancel_expired_pkgs {
+ my ( $self, $time ) = @_;
+
+ my @cancel_pkgs = grep { $_->expire && $_->expire <= $time }
$self->ncancelled_pkgs;
foreach my $cust_pkg ( @cancel_pkgs ) {
my $cpr = $cust_pkg->last_cust_pkg_reason('expire');
- my $error = $cust_pkg->cancel($cpr ? ( 'reason' => $cpr->reasonnum,
+ my $error = $cust_pkg->cancel($cpr ? ( 'reason' => $cpr->reasonnum,
'reason_otaker' => $cpr->otaker
)
: ()
@@ -1956,20 +1974,19 @@
if $error;
}
- ###
- # suspend packages
- ###
+}
+
+sub suspend_adjourned_pkgs {
+ my ( $self, $time ) = @_;
- #$options{actual_time} not $options{time} because freeside-daily -d is for
- #pre-printing invoices
my @susp_pkgs =
grep { ! $_->susp
&& ( ( $_->part_pkg->is_prepaid
&& $_->bill
- && $_->bill < $options{actual_time}
+ && $_->bill < $time
)
|| ( $_->adjourn
- && $_->adjourn <= $options{actual_time}
+ && $_->adjourn <= $time
)
)
}
@@ -1989,18 +2006,6 @@
if $error;
}
- ###
- # bill and collect
- ###
-
- my $error = $self->bill( %options );
- warn "Error billing, custnum ". $self->custnum. ": $error" if $error;
-
- $self->apply_payments_and_credits;
-
- $error = $self->collect( %options );
- warn "Error collecting, custnum". $self->custnum. ": $error" if $error;
-
}
=item bill OPTIONS
More information about the freeside-commits
mailing list