1 package FS::cust_bill_pay_pkg;
2 use base qw( FS::cust_main_Mixin FS::Record );
6 use FS::Record qw( qsearch qsearchs );
12 FS::cust_bill_pay_pkg - Object methods for cust_bill_pay_pkg records
16 use FS::cust_bill_pay_pkg;
18 $record = new FS::cust_bill_pay_pkg \%hash;
19 $record = new FS::cust_bill_pay_pkg { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::cust_bill_pay_pkg object represents application of a payment (see
32 L<FS::cust_bill_pay>) to a specific line item within an invoice (see
33 L<FS::cust_bill_pkg>). FS::cust_bill_pay_pkg inherits from FS::Record. The
34 following fields are currently supported:
38 =item billpaypkgnum - primary key
40 =item billpaynum - Payment application to the overall invoice (see L<FS::cust_bill_pay>)
42 =item billpkgnum - Line item to which payment is applied (see L<FS::cust_bill_pkg>)
44 =item amount - Amount of the payment applied to this line item.
46 =item setuprecur - 'setup' or 'recur', designates whether the payment was applied to the setup or recurring portion of the line item.
48 =item sdate - starting date of recurring fee
50 =item edate - ending date of recurring fee
54 sdate and edate are specified as UNIX timestamps; see L<perlfunc/"time">. Also
55 see L<Time::Local> and L<Date::Parse> for conversion functions.
63 Creates a new record. To add the record to the database, see L<"insert">.
65 Note that this stores the hash reference, not a distinct copy of the hash it
66 points to. You can ask the object for a copy with the I<hash> method.
70 # the new method can be inherited from FS::Record, if a table method is defined
72 sub table { 'cust_bill_pay_pkg'; }
76 Adds this record to the database. If there is an error, returns the error,
77 otherwise returns false.
82 my($self, %options) = @_;
84 #local $SIG{HUP} = 'IGNORE';
85 #local $SIG{INT} = 'IGNORE';
86 #local $SIG{QUIT} = 'IGNORE';
87 #local $SIG{TERM} = 'IGNORE';
88 #local $SIG{TSTP} = 'IGNORE';
89 #local $SIG{PIPE} = 'IGNORE';
91 #my $oldAutoCommit = $FS::UID::AutoCommit;
92 #local $FS::UID::AutoCommit = 0;
95 my $error = $self->SUPER::insert;
97 #$dbh->rollback if $oldAutoCommit;
98 return "error inserting $self: $error";
102 my $conf = new FS::Conf;
104 $conf->config('payment_receipt-trigger',
105 $self->cust_bill_pay->cust_bill->cust_main->agentnum,
108 if ( $trigger eq 'cust_bill_pay_pkg' ) {
109 my $error = $self->send_receipt(
110 'manual' => $options{'manual'},
112 warn "can't send payment receipt/statement: $error" if $error;
121 Delete this record from the database.
125 # the delete method can be inherited from FS::Record
127 =item replace OLD_RECORD
129 Replaces the OLD_RECORD with this one in the database. If there is an error,
130 returns the error, otherwise returns false.
134 # the replace method can be inherited from FS::Record
138 Checks all fields to make sure this is a valid payment application. If there
139 is an error, returns the error, otherwise returns false. Called by the insert
144 # the check method should currently be supplied - FS::Record contains some
145 # data checking routines
151 $self->ut_numbern('billpaypkgnum')
152 || $self->ut_foreign_key('billpaynum', 'cust_bill_pay', 'billpaynum' )
153 || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum' )
154 || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
155 || $self->ut_foreign_keyn('billpkgtaxlocationnum',
156 'cust_bill_pkg_tax_location',
157 'billpkgtaxlocationnum')
158 || $self->ut_foreign_keyn('billpkgtaxratelocationnum',
159 'cust_bill_pkg_tax_rate_location',
160 'billpkgtaxratelocationnum')
161 || $self->ut_money('amount')
162 || $self->ut_enum('setuprecur', [ 'setup', 'recur' ] )
163 || $self->ut_numbern('sdate')
164 || $self->ut_numbern('edate')
166 return $error if $error;
173 Returns the FS::cust_bill_pay object (payment application to the overall
180 qsearchs('cust_bill_pay', { 'billpaynum' => $self->billpaynum } );
185 Returns the FS::cust_bill_pkg object (line item to which payment is applied).
191 qsearchs('cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } );
196 Sends a payment receipt for the associated payment, against this specific
197 invoice and packages. If there is an error, returns the error, otherwise
204 my $opt = ref($_[0]) ? shift : { @_ };
205 $self->cust_bill_pay->send_receipt(
206 'cust_pkg' => scalar($self->cust_bill_pkg->cust_pkg),
216 B<setuprecur> field is a kludge to compensate for cust_bill_pkg having separate
217 setup and recur fields. It should be removed once that's fixed.
221 L<FS::Record>, schema.html from the base documentation.