summaryrefslogtreecommitdiff
path: root/FS/FS/cust_bill_pkg_detail.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-10-31 15:45:50 -0700
committerMark Wells <mark@freeside.biz>2014-10-31 15:45:50 -0700
commit7516e3da0f17eeecba27219ef96a8b5f46af2083 (patch)
tree772fe13627910a7d0774871633697f2a4d1c6faf /FS/FS/cust_bill_pkg_detail.pm
parentf31a9212ab3835b815aa87a86cca3b19babcaaff (diff)
tax engine refactoring for Avalara and Billsoft tax vendors, #25718
Diffstat (limited to 'FS/FS/cust_bill_pkg_detail.pm')
-rw-r--r--FS/FS/cust_bill_pkg_detail.pm37
1 files changed, 37 insertions, 0 deletions
diff --git a/FS/FS/cust_bill_pkg_detail.pm b/FS/FS/cust_bill_pkg_detail.pm
index d0cbdbe..dd118c1 100644
--- a/FS/FS/cust_bill_pkg_detail.pm
+++ b/FS/FS/cust_bill_pkg_detail.pm
@@ -86,15 +86,52 @@ sub table { 'cust_bill_pkg_detail'; }
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
+=cut
+
+sub insert {
+ my $self = shift;
+ my $error = $self->SUPER::insert(@_);
+ return $error if $error;
+
+ # link CDRs
+ my $acctids = $self->get('acctid') or return '';
+ $acctids = [ $acctids ] unless ref $acctids;
+ foreach my $acctid ( @$acctids ) {
+ my $cdr = FS::cdr->by_key($acctid);
+ $cdr->set('detailnum', $self->detailnum);
+ $error = $cdr->replace;
+ # this should never happen
+ return "error linking CDR #$acctid: $error" if $error;
+ }
+ '';
+}
+
=item delete
Delete this record from the database.
+=cut
+
+sub delete {
+ my $self = shift;
+ my $error = $self->SUPER::delete;
+ return $error if $error;
+ foreach my $cdr (qsearch('cdr', { detailnum => $self->detailnum })) {
+ $cdr->set('detailnum', '');
+ $error = $cdr->replace;
+ return "error unlinking CDR #" . $cdr->acctid . ": $error" if $error;
+ }
+}
+
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
+=cut
+
+# the replace method can be inherited from FS::Record (doesn't touch CDRs)
+
=item check
Checks all fields to make sure this is a valid line item detail. If there is