Difference between revisions of "Freeside:1.9:Documentation:Developer/FS/cust pay"

From Freeside
Jump to: navigation, search
(import from POD)
m (Edit via perl MediaWiki framework (1.13))
 
(2 intermediate revisions by the same user not shown)
Line 20: Line 20:
 
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:
 
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 [[Freeside:1.9:Documentation:Developer/FS/cust main|FS::cust_main]]); paid - Amount of this payment; _date - specified as a UNIX timestamp; see [[Freeside:1.9:Documentation:Developer/perlfunc#time|"time" in perlfunc|perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.9:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.9:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions.; payby - Payment Type (See [[Freeside:1.9:Documentation:Developer/FS/payinfo Mixin|FS::payinfo_Mixin]] for valid payby values); payinfo - Payment Information (See [[Freeside:1.9:Documentation:Developer/FS/payinfo Mixin|FS::payinfo_Mixin]] for data format); paymask - Masked payinfo (See [[Freeside:1.9:Documentation:Developer/FS/payinfo Mixin|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'
+
; paynum - primary key (assigned automatically for new payments); custnum - customer (see [[Freeside:1.9:Documentation:Developer/FS/cust main|FS::cust_main]]); _date - specified as a UNIX timestamp; see [[perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.9:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.9:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions.; paid - Amount of this payment; otaker - order taker (assigned automatically, see [[Freeside:1.9:Documentation:Developer/FS/UID|FS::UID]]); payby - Payment Type (See [[Freeside:1.9:Documentation:Developer/FS/payinfo Mixin|FS::payinfo_Mixin]] for valid payby values); payinfo - Payment Information (See [[Freeside:1.9:Documentation:Developer/FS/payinfo Mixin|FS::payinfo_Mixin]] for data format); paymask - Masked payinfo (See [[Freeside:1.9:Documentation:Developer/FS/payinfo Mixin|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==
 
==METHODS==
 
; new HASHREF
 
; new HASHREF
Line 57: Line 57:
 
; unrefunded
 
; unrefunded
 
:Returns the amount of this payment that has not been refuned; which is paid minus all refund applications (see [[Freeside:1.9:Documentation:Developer/FS/cust pay refund|FS::cust_pay_refund]]).
 
:Returns the amount of this payment that has not been refuned; which is paid minus all refund applications (see [[Freeside:1.9:Documentation:Developer/FS/cust pay refund|FS::cust_pay_refund]]).
; cust_main
+
; amount
:Returns the parent customer object (see [[Freeside:1.9:Documentation:Developer/FS/cust main|FS::cust_main]]).
+
:Returns the "paid" field.
  
 
==CLASS METHODS==
 
==CLASS METHODS==
 
; unapplied_sql
 
; unapplied_sql
 
:Returns an SQL fragment to retreive the unapplied amount.
 
:Returns an SQL fragment to retreive the unapplied amount.
 +
 +
==SUBROUTINES==
 +
; batch_import HASHREF
 +
:Inserts new payments.
  
 
==BUGS==
 
==BUGS==
Line 68: Line 72:
  
 
==SEE ALSO==
 
==SEE ALSO==
[[Freeside:1.9:Documentation:Developer/FS/cust bill pay|FS::cust_bill_pay]], [[Freeside:1.9:Documentation:Developer/FS/cust bill|FS::cust_bill]], [[Freeside:1.9:Documentation:Developer/FS/Record|FS::Record]], schema.html from the base documentation.
+
[[Freeside:1.9:Documentation:Developer/FS/cust pay pending|FS::cust_pay_pending]], [[Freeside:1.9:Documentation:Developer/FS/cust bill pay|FS::cust_bill_pay]], [[Freeside:1.9:Documentation:Developer/FS/cust bill|FS::cust_bill]], [[Freeside:1.9:Documentation:Developer/FS/Record|FS::Record]], schema.html from the base documentation.

Latest revision as of 18:14, 6 February 2009

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.