X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pay_pkg.pm;h=ccfa49258adaa4892cdb4ef945d6dd3d8240a14b;hp=cdbace96010c46e583fcfbf3e6c763aba1033945;hb=5372897f367498972c96f5494e142e6e11b29eb8;hpb=685ebecc66bd944f82f997b990fe4a668360d8ed diff --git a/FS/FS/cust_bill_pay_pkg.pm b/FS/FS/cust_bill_pay_pkg.pm index cdbace960..ccfa49258 100644 --- a/FS/FS/cust_bill_pay_pkg.pm +++ b/FS/FS/cust_bill_pay_pkg.pm @@ -1,10 +1,8 @@ package FS::cust_bill_pay_pkg; +use base qw( FS::cust_main_Mixin FS::Record ); use strict; -use vars qw( @ISA ); -use FS::Record qw( qsearch qsearchs ); - -@ISA = qw(FS::Record); +use FS::Conf; =head1 NAME @@ -77,7 +75,43 @@ otherwise returns false. =cut -# the insert method can be inherited from FS::Record +sub insert { + my($self, %options) = @_; + + #local $SIG{HUP} = 'IGNORE'; + #local $SIG{INT} = 'IGNORE'; + #local $SIG{QUIT} = 'IGNORE'; + #local $SIG{TERM} = 'IGNORE'; + #local $SIG{TSTP} = 'IGNORE'; + #local $SIG{PIPE} = 'IGNORE'; + # + #my $oldAutoCommit = $FS::UID::AutoCommit; + #local $FS::UID::AutoCommit = 0; + #my $dbh = dbh; + + my $error = $self->SUPER::insert; + if ( $error ) { + #$dbh->rollback if $oldAutoCommit; + return "error inserting $self: $error"; + } + + #payment receipt + my $conf = new FS::Conf; + my $trigger = + $conf->config('payment_receipt-trigger', + $self->cust_bill_pay->cust_bill->cust_main->agentnum, + ) + || 'cust_pay'; + if ( $trigger eq 'cust_bill_pay_pkg' ) { + my $error = $self->send_receipt( + 'manual' => $options{'manual'}, + ); + warn "can't send payment receipt/statement: $error" if $error; + } + + ''; + +} =item delete @@ -114,6 +148,13 @@ sub check { $self->ut_numbern('billpaypkgnum') || $self->ut_foreign_key('billpaynum', 'cust_bill_pay', 'billpaynum' ) || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum' ) + || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum') + || $self->ut_foreign_keyn('billpkgtaxlocationnum', + 'cust_bill_pkg_tax_location', + 'billpkgtaxlocationnum') + || $self->ut_foreign_keyn('billpkgtaxratelocationnum', + 'cust_bill_pkg_tax_rate_location', + 'billpkgtaxratelocationnum') || $self->ut_money('amount') || $self->ut_enum('setuprecur', [ 'setup', 'recur' ] ) || $self->ut_numbern('sdate') @@ -124,6 +165,33 @@ sub check { $self->SUPER::check; } +=item cust_bill_pay + +Returns the FS::cust_bill_pay object (payment application to the overall +invoice). + +=item cust_bill_pkg + +Returns the FS::cust_bill_pkg object (line item to which payment is applied). + +=item send_receipt + +Sends a payment receipt for the associated payment, against this specific +invoice and packages. If there is an error, returns the error, otherwise +returns false. + +=cut + +sub send_receipt { + my $self = shift; + my $opt = ref($_[0]) ? shift : { @_ }; + $self->cust_bill_pay->send_receipt( + 'cust_pkg' => scalar($self->cust_bill_pkg->cust_pkg), + %$opt, + ); +} + + =back =head1 BUGS