Freeside:1.9:Documentation:Developer/FS/cust pay

From Freeside
Jump to: navigation, search

NAME

FS::cust_pay - Object methods for cust_pay objects

SYNOPSIS

 use FS::cust_pay;

 $record = new FS::cust_pay \%hash;
 $record = new FS::cust_pay { 'column' => 'value' };

 $error = $record->insert;

 $error = $new_record->replace($old_record);

 $error = $record->delete;

 $error = $record->check;

DESCRIPTION

An FS::cust_pay object represents a payment; the transfer of money from a customer. FS::cust_pay inherits from FS::Record. The following fields are currently supported:

paynum - primary key (assigned automatically for new payments); custnum - customer (see FS::cust_main); _date - specified as a UNIX timestamp; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.; paid - Amount of this payment; otaker - order taker (assigned automatically, see FS::UID); payby - Payment Type (See FS::payinfo_Mixin for valid payby values); payinfo - Payment Information (See FS::payinfo_Mixin for data format); paymask - Masked payinfo (See FS::payinfo_Mixin for how this works); paybatch - text field for tracking card processing or other batch grouping; payunique - Optional unique identifer to prevent duplicate transactions.; closed - books closed flag, empty or `Y'

METHODS

new HASHREF
Creates a new payment. To add the payment to the databse, see "insert".
insert
Adds this payment to the database.
For backwards-compatibility and convenience, if the additional field invnum is defined, an FS::cust_bill_pay record for the full amount of the payment will be created. In this case, custnum is optional. An hash of optional arguments may be passed. Currently "manual" is supported. If true, a payment receipt is sent instead of a statement when 'payment_receipt_email' configuration option is set.
void [ REASON ]
Voids this payment: deletes the payment and all associated applications and adds a record of the voided payment to the FS::cust_pay_void table.
delete
Unless the closed flag is set, deletes this payment and all associated applications (see FS::cust_bill_pay and FS::cust_pay_refund). In most cases, you want to use the void method instead to leave a record of the deleted payment.
replace OLD_RECORD
You can, but probably shouldn't modify payments...
check
Checks all fields to make sure this is a valid payment. If there is an error, returns the error, otherwise returns false. Called by the insert method.
batch_insert CUST_PAY_OBJECT, ...
Class method which inserts multiple payments. Takes a list of FS::cust_pay objects. Returns a list, each element representing the status of inserting the corresponding payment - empty. If there is an error inserting any payment, the entire transaction is rolled back, i.e. all payments are inserted or none are.
For example:

 my @errors = FS::cust_pay->batch_insert(@cust_pay);
 my $num_errors = scalar(grep $_, @errors);
 if ( $num_errors == 0 ) {
   #success; all payments were inserted
 } else {
   #failure; no payments were inserted.
 }

cust_bill_pay
Returns all applications to invoices (see FS::cust_bill_pay) for this payment.
cust_pay_refund
Returns all applications of refunds (see FS::cust_pay_refund) to this payment.
unapplied
Returns the amount of this payment that is still unapplied; which is paid minus all payment applications (see FS::cust_bill_pay) and refund applications (see FS::cust_pay_refund).
unrefunded
Returns the amount of this payment that has not been refuned; which is paid minus all refund applications (see FS::cust_pay_refund).
amount
Returns the "paid" field.

CLASS METHODS

unapplied_sql
Returns an SQL fragment to retreive the unapplied amount.

SUBROUTINES

batch_import HASHREF
Inserts new payments.

BUGS

Delete and replace methods.

SEE ALSO

FS::cust_pay_pending, FS::cust_bill_pay, FS::cust_bill, FS::Record, schema.html from the base documentation.