Freeside:3:Documentation:Developer/FS/cust refund

From Freeside
Jump to: navigation, search

NAME

FS::cust_refund - Object method for cust_refund objects

SYNOPSIS

 use FS::cust_refund;

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

 $error = $record->insert;

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

 $error = $record->delete;

 $error = $record->check;

DESCRIPTION

An FS::cust_refund represents a refund: the transfer of money to a customer; equivalent to a negative payment (see FS::cust_pay). FS::cust_refund inherits from FS::Record. The following fields are currently supported:

refundnum
primary key (assigned automatically for new refunds)
custnum
customer (see FS::cust_main)
refund
Amount of the refund
reason
Reason for the refund
_date
specified as a UNIX timestamp; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.
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
usernum
order taker (see FS::access_user
closed
books closed flag, empty or `Y'
gatewaynum, processor, auth, order_number
Same as for FS::cust_pay, but specifically the result of realtime authorization of the refund.

METHODS

new HASHREF
Creates a new refund. To add the refund to the database, see "insert".
insert
Adds this refund to the database.
For backwards-compatibility and convenience, if the additional field crednum is defined, an FS::cust_credit_refund record for the full amount of the refund will be created. Or (this time for convenience and consistancy), if the additional field paynum is defined, an FS::cust_pay_refund record for the full amount of the refund will be created. In both cases, custnum is optional.
delete
Unless the closed flag is set, deletes this refund and all associated applications (see FS::cust_credit_refund and FS::cust_pay_refund).
replace OLD_RECORD
You can, but probably shouldn't modify refunds...
Replaces the OLD_RECORD with this one in the database, or, if OLD_RECORD is not supplied, replaces this record. If there is an error, returns the error, otherwise returns false.
check
Checks all fields to make sure this is a valid refund. If there is an error, returns the error, otherwise returns false. Called by the insert method.
cust_credit_refund
Returns all applications to credits (see FS::cust_credit_refund) for this refund.
cust_pay_refund
Returns all applications to payments (see FS::cust_pay_refund) for this refund.
unapplied
Returns the amount of this refund that is still unapplied; which is amount minus all credit applications (see FS::cust_credit_refund) and payment applications (see FS::cust_pay_refund).

CLASS METHODS

unapplied_sql
Returns an SQL fragment to retreive the unapplied amount.

BUGS

Delete and replace methods.

SEE ALSO

FS::Record, FS::cust_credit, schema.html from the base documentation.