X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=56da5c77de86ecc8e148a4d3710be594e0180ff1;hp=5705ac2c6de7e976db4b00bd58c19b6797a96a24;hb=e4ae5122522f2d45c68a38eaef337a82029f2fc1;hpb=fcc0d3d4015c5aae07d853b3b9f928ab9f2b12ef diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 5705ac2c6..56da5c77d 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -376,6 +376,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'); + if ($error) { + $dbh->rollback if $oldAutoCommit; + return "Error crediting customer for service remaining: $error"; + } + } + unless ( $self->getfield('cancel') ) { my %hash = $self->hash; $hash{'cancel'} = time; @@ -592,6 +602,30 @@ sub calc_recur { $self->part_pkg->calc_recur($self, @_); } +=item calc_remain + +Calls the I of the FS::part_pkg object associated with this +billing item. + +=cut + +sub calc_recur { + my $self = shift; + $self->part_pkg->calc_remain($self, @_); +} + +=item calc_cancel + +Calls the I of the FS::part_pkg object associated with this +billing item. + +=cut + +sub calc_cancel { + my $self = shift; + $self->part_pkg->calc_cancel($self, @_); +} + =item cust_svc [ SVCPART ] Returns the services for this package, as FS::cust_svc objects (see