summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2005-03-02 00:03:48 +0000
committerivan <ivan>2005-03-02 00:03:48 +0000
commitc2829eb15ff44d34ce82ae02c88810a321614ce9 (patch)
tree0d605e89d78e3fc2aa4509a1b77ab6a2632b17d8
parentcb38d7ab32143a95126b07ed06bb64320b863387 (diff)
prevent bug causing 'Error crediting customer for service remaining: FS::cust_pkg=HASH(0x9958c60)' error on package cancellations where the part_pkg record didn't have a plan, closes: Bug#1153
-rw-r--r--FS/FS/cust_pkg.pm12
-rw-r--r--FS/FS/part_pkg.pm5
2 files changed, 13 insertions, 4 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index a6115a0a0..cd808d4fa 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -396,12 +396,16 @@ sub cancel {
}
# Add a credit for remaining service
- my $remaining_value= $self->calc_remain();
- if ($remaining_value > 0) {
- my $error = $self->credit($remaining_value, 'Credit for service remaining');
+ my $remaining_value = $self->calc_remain();
+ if ( $remaining_value > 0 ) {
+ my $error = $self->cust_main->credit(
+ $remaining_value,
+ 'Credit for unused time on'. $self->part_pkg->pkg,
+ );
if ($error) {
$dbh->rollback if $oldAutoCommit;
- return "Error crediting customer for service remaining: $error";
+ return "Error crediting customer \$$remaining_value for unused time on".
+ $self->part_pkg->pkg. ": $error";
}
}
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index a0683c822..faaf485e5 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -672,6 +672,11 @@ sub _calc_eval {
$value;
}
+#fallback that return 0 for old legacy packages with no plan
+
+sub calc_remain { 0; }
+sub calc_cancel { 0; }
+
=back
=head1 SUBROUTINES