1 package FS::cust_bill_pay_pkg;
6 use FS::Record qw( qsearch qsearchs );
10 @ISA = qw(FS::Record);
14 FS::cust_bill_pay_pkg - Object methods for cust_bill_pay_pkg records
18 use FS::cust_bill_pay_pkg;
20 $record = new FS::cust_bill_pay_pkg \%hash;
21 $record = new FS::cust_bill_pay_pkg { 'column' => 'value' };
23 $error = $record->insert;
25 $error = $new_record->replace($old_record);
27 $error = $record->delete;
29 $error = $record->check;
33 An FS::cust_bill_pay_pkg object represents application of a payment (see
34 L<FS::cust_bill_pay>) to a specific line item within an invoice (see
35 L<FS::cust_bill_pkg>). FS::cust_bill_pay_pkg inherits from FS::Record. The
36 following fields are currently supported:
40 =item billpaypkgnum - primary key
42 =item billpaynum - Payment application to the overall invoice (see L<FS::cust_bill_pay>)
44 =item billpkgnum - Line item to which payment is applied (see L<FS::cust_bill_pkg>)
46 =item amount - Amount of the payment applied to this line item.
48 =item setuprecur - 'setup' or 'recur', designates whether the payment was applied to the setup or recurring portion of the line item.
50 =item sdate - starting date of recurring fee
52 =item edate - ending date of recurring fee
56 sdate and edate are specified as UNIX timestamps; see L<perlfunc/"time">. Also
57 see L<Time::Local> and L<Date::Parse> for conversion functions.
65 Creates a new record. To add the record to the database, see L<"insert">.
67 Note that this stores the hash reference, not a distinct copy of the hash it
68 points to. You can ask the object for a copy with the I<hash> method.
72 # the new method can be inherited from FS::Record, if a table method is defined
74 sub table { 'cust_bill_pay_pkg'; }
78 Adds this record to the database. If there is an error, returns the error,
79 otherwise returns false.
84 my($self, %options) = @_;
86 #local $SIG{HUP} = 'IGNORE';
87 #local $SIG{INT} = 'IGNORE';
88 #local $SIG{QUIT} = 'IGNORE';
89 #local $SIG{TERM} = 'IGNORE';
90 #local $SIG{TSTP} = 'IGNORE';
91 #local $SIG{PIPE} = 'IGNORE';
93 #my $oldAutoCommit = $FS::UID::AutoCommit;
94 #local $FS::UID::AutoCommit = 0;
97 my $error = $self->SUPER::insert;
99 #$dbh->rollback if $oldAutoCommit;
100 return "error inserting $self: $error";
104 my $conf = new FS::Conf;
106 $conf->config('payment_receipt-trigger',
107 $self->cust_bill_pay->cust_bill->cust_main->agentnum,
110 if ( $trigger eq 'cust_bill_pay_pkg' ) {
111 my $error = $self->send_receipt(
112 'manual' => $options{'manual'},
114 warn "can't send payment receipt/statement: $error" if $error;
123 Delete this record from the database.
127 # the delete method can be inherited from FS::Record
129 =item replace OLD_RECORD
131 Replaces the OLD_RECORD with this one in the database. If there is an error,
132 returns the error, otherwise returns false.
136 # the replace method can be inherited from FS::Record
140 Checks all fields to make sure this is a valid payment application. If there
141 is an error, returns the error, otherwise returns false. Called by the insert
146 # the check method should currently be supplied - FS::Record contains some
147 # data checking routines
153 $self->ut_numbern('billpaypkgnum')
154 || $self->ut_foreign_key('billpaynum', 'cust_bill_pay', 'billpaynum' )
155 || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum' )
156 || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
157 || $self->ut_foreign_keyn('billpkgtaxlocationnum',
158 'cust_bill_pkg_tax_location',
159 'billpkgtaxlocationnum')
160 || $self->ut_foreign_keyn('billpkgtaxratelocationnum',
161 'cust_bill_pkg_tax_rate_location',
162 'billpkgtaxratelocationnum')
163 || $self->ut_money('amount')
164 || $self->ut_enum('setuprecur', [ 'setup', 'recur' ] )
165 || $self->ut_numbern('sdate')
166 || $self->ut_numbern('edate')
168 return $error if $error;
175 Returns the FS::cust_bill_pay object (payment application to the overall
182 qsearchs('cust_bill_pay', { 'billpaynum' => $self->billpaynum } );
187 Returns the FS::cust_bill_pkg object (line item to which payment is applied).
193 qsearchs('cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } );
198 Sends a payment receipt for the associated payment, against this specific
199 invoice and packages. If there is an error, returns the error, otherwise
206 my $opt = ref($_[0]) ? shift : { @_ };
207 $self->cust_bill_pay->send_receipt(
208 'cust_pkg' => scalar($self->cust_bill_pkg->cust_pkg),
218 B<setuprecur> field is a kludge to compensate for cust_bill_pkg having separate
219 setup and recur fields. It should be removed once that's fixed.
223 L<FS::Record>, schema.html from the base documentation.