summaryrefslogtreecommitdiff
path: root/FS/FS/cust_bill_pkg_detail.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2018-02-04 17:47:57 -0800
committerIvan Kohler <ivan@freeside.biz>2018-02-04 17:47:57 -0800
commite4aff0c0af3139118b4ae02e814ba7d0d8f46774 (patch)
tree1e6befdd61805ef7b697f032d5fdf20886ba411c /FS/FS/cust_bill_pkg_detail.pm
parent889eafade02f1b7463cc47202020ddb8c5d8394f (diff)
option to reprocess CDRs when voiding an invoice, RT#79001
Diffstat (limited to 'FS/FS/cust_bill_pkg_detail.pm')
-rw-r--r--FS/FS/cust_bill_pkg_detail.pm20
1 files changed, 18 insertions, 2 deletions
diff --git a/FS/FS/cust_bill_pkg_detail.pm b/FS/FS/cust_bill_pkg_detail.pm
index dd118c1..19b15f7 100644
--- a/FS/FS/cust_bill_pkg_detail.pm
+++ b/FS/FS/cust_bill_pkg_detail.pm
@@ -106,21 +106,37 @@ sub insert {
'';
}
-=item delete
+=item delete [ ARG => VALUE ... ]
Delete this record from the database.
+If the "reprocess_cdrs" argument is set to true, resets the status of any
+related CDRs (and deletes their associated cdr_termination records, if any).
+
=cut
sub delete {
- my $self = shift;
+ my( $self, %args ) = @_;
+
my $error = $self->SUPER::delete;
return $error if $error;
+
foreach my $cdr (qsearch('cdr', { detailnum => $self->detailnum })) {
+
$cdr->set('detailnum', '');
+ $cdr->set('freesidestatus', '') if $args{'reprocess_cdrs'};
$error = $cdr->replace;
return "error unlinking CDR #" . $cdr->acctid . ": $error" if $error;
+
+ #well, technically this could have been on other invoices / termination
+ # partners... separate flag?
+ $self->scalar_sql( 'DELETE FROM cdr_termination WHERE acctid = ?',
+ $cdr->acctid )
+ if $args{'reprocess_cdrs'};
+
}
+
+ '';
}
=item replace OLD_RECORD