1 package FS::cust_bill_pay_pkg;
2 use base qw( FS::cust_main_Mixin FS::Record );
9 FS::cust_bill_pay_pkg - Object methods for cust_bill_pay_pkg records
13 use FS::cust_bill_pay_pkg;
15 $record = new FS::cust_bill_pay_pkg \%hash;
16 $record = new FS::cust_bill_pay_pkg { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::cust_bill_pay_pkg object represents application of a payment (see
29 L<FS::cust_bill_pay>) to a specific line item within an invoice (see
30 L<FS::cust_bill_pkg>). FS::cust_bill_pay_pkg inherits from FS::Record. The
31 following fields are currently supported:
35 =item billpaypkgnum - primary key
37 =item billpaynum - Payment application to the overall invoice (see L<FS::cust_bill_pay>)
39 =item billpkgnum - Line item to which payment is applied (see L<FS::cust_bill_pkg>)
41 =item amount - Amount of the payment applied to this line item.
43 =item setuprecur - 'setup' or 'recur', designates whether the payment was applied to the setup or recurring portion of the line item.
45 =item sdate - starting date of recurring fee
47 =item edate - ending date of recurring fee
51 sdate and edate are specified as UNIX timestamps; see L<perlfunc/"time">. Also
52 see L<Time::Local> and L<Date::Parse> for conversion functions.
60 Creates a new record. To add the record to the database, see L<"insert">.
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to. You can ask the object for a copy with the I<hash> method.
67 # the new method can be inherited from FS::Record, if a table method is defined
69 sub table { 'cust_bill_pay_pkg'; }
73 Adds this record to the database. If there is an error, returns the error,
74 otherwise returns false.
79 my($self, %options) = @_;
81 #local $SIG{HUP} = 'IGNORE';
82 #local $SIG{INT} = 'IGNORE';
83 #local $SIG{QUIT} = 'IGNORE';
84 #local $SIG{TERM} = 'IGNORE';
85 #local $SIG{TSTP} = 'IGNORE';
86 #local $SIG{PIPE} = 'IGNORE';
88 #my $oldAutoCommit = $FS::UID::AutoCommit;
89 #local $FS::UID::AutoCommit = 0;
92 my $error = $self->SUPER::insert;
94 #$dbh->rollback if $oldAutoCommit;
95 return "error inserting $self: $error";
99 my $conf = new FS::Conf;
101 $conf->config('payment_receipt-trigger',
102 $self->cust_bill_pay->cust_bill->cust_main->agentnum,
105 if ( $trigger eq 'cust_bill_pay_pkg' ) {
106 my $error = $self->send_receipt(
107 'manual' => $options{'manual'},
109 warn "can't send payment receipt/statement: $error" if $error;
118 Delete this record from the database.
122 # the delete method can be inherited from FS::Record
124 =item replace OLD_RECORD
126 Replaces the OLD_RECORD with this one in the database. If there is an error,
127 returns the error, otherwise returns false.
131 # the replace method can be inherited from FS::Record
135 Checks all fields to make sure this is a valid payment application. If there
136 is an error, returns the error, otherwise returns false. Called by the insert
141 # the check method should currently be supplied - FS::Record contains some
142 # data checking routines
148 $self->ut_numbern('billpaypkgnum')
149 || $self->ut_foreign_key('billpaynum', 'cust_bill_pay', 'billpaynum' )
150 || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum' )
151 || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
152 || $self->ut_foreign_keyn('billpkgtaxlocationnum',
153 'cust_bill_pkg_tax_location',
154 'billpkgtaxlocationnum')
155 || $self->ut_foreign_keyn('billpkgtaxratelocationnum',
156 'cust_bill_pkg_tax_rate_location',
157 'billpkgtaxratelocationnum')
158 || $self->ut_money('amount')
159 || $self->ut_enum('setuprecur', [ 'setup', 'recur' ] )
160 || $self->ut_numbern('sdate')
161 || $self->ut_numbern('edate')
163 return $error if $error;
170 Returns the FS::cust_bill_pay object (payment application to the overall
175 Returns the FS::cust_bill_pkg object (line item to which payment is applied).
179 Sends a payment receipt for the associated payment, against this specific
180 invoice and packages. If there is an error, returns the error, otherwise
187 my $opt = ref($_[0]) ? shift : { @_ };
188 $self->cust_bill_pay->send_receipt(
189 'cust_pkg' => scalar($self->cust_bill_pkg->cust_pkg),
199 B<setuprecur> field is a kludge to compensate for cust_bill_pkg having separate
200 setup and recur fields. It should be removed once that's fixed.
204 L<FS::Record>, schema.html from the base documentation.