Difference between revisions of "Freeside:1.7:Documentation:Developer/FS/cust credit"

From Freeside
Jump to: navigation, search
(import from POD)
 
(import from POD)
 
(One intermediate revision by the same user not shown)
Line 20: Line 20:
 
An FS::cust_credit object represents a credit; the equivalent of a negative '''cust_bill''' record (see [[Freeside:1.7:Documentation:Developer/FS/cust bill|FS::cust_bill]]). FS::cust_credit inherits from FS::Record. The following fields are currently supported:
 
An FS::cust_credit object represents a credit; the equivalent of a negative '''cust_bill''' record (see [[Freeside:1.7:Documentation:Developer/FS/cust bill|FS::cust_bill]]). FS::cust_credit inherits from FS::Record. The following fields are currently supported:
  
; crednum - primary key (assigned automatically for new credits); custnum - customer (see [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]]); amount - amount of the credit; _date - specified as a UNIX timestamp; see [[Freeside:1.7:Documentation:Developer/perlfunc#time|"time" in perlfunc|perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.7:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.7:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions.; otaker - order taker (assigned automatically, see [[Freeside:1.7:Documentation:Developer/FS/UID|FS::UID]]); reason - text; closed - books closed flag, empty or `Y'
+
; crednum
 +
:Primary key (assigned automatically for new credits)
 +
; custnum
 +
:Customer (see [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]])
 +
; amount
 +
:Amount of the credit
 +
; _date
 +
:Specified as a UNIX timestamp; see [[perlfunc#time|"time" in perlfunc]]. Also see [[Freeside:1.7:Documentation:Developer/Time/Local|Time::Local]] and [[Freeside:1.7:Documentation:Developer/Date/Parse|Date::Parse]] for conversion functions.
 +
; otaker
 +
:Order taker (assigned automatically, see [[Freeside:1.7:Documentation:Developer/FS/UID|FS::UID]])
 +
; reason
 +
:Text ( deprecated )
 +
; reasonnum
 +
:Reason (see [[Freeside:1.7:Documentation:Developer/FS/reason|FS::reason]])
 +
; closed
 +
:Books closed flag, empty or `Y'
 +
 
 
==METHODS==
 
==METHODS==
 
; new HASHREF
 
; new HASHREF
Line 32: Line 48:
 
; check
 
; check
 
:Checks all fields to make sure this is a valid credit. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
 
:Checks all fields to make sure this is a valid credit. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
; cust_refund
 
:Depreciated. See the cust_credit_refund method.
 
 
:#Returns all refunds (see [[Freeside:1.7:Documentation:Developer/FS/cust refund|FS::cust_refund]]) for this credit.
 
 
; cust_credit_refund
 
; cust_credit_refund
 
:Returns all refund applications (see [[Freeside:1.7:Documentation:Developer/FS/cust credit refund|FS::cust_credit_refund]]) for this credit.
 
:Returns all refund applications (see [[Freeside:1.7:Documentation:Developer/FS/cust credit refund|FS::cust_credit_refund]]) for this credit.
 
; cust_credit_bill
 
; cust_credit_bill
 
:Returns all application to invoices (see [[Freeside:1.7:Documentation:Developer/FS/cust credit bill|FS::cust_credit_bill]]) for this credit.
 
:Returns all application to invoices (see [[Freeside:1.7:Documentation:Developer/FS/cust credit bill|FS::cust_credit_bill]]) for this credit.
 +
; unapplied
 +
:Returns the amount of this credit that is still unapplied/outstanding; amount minus all refund applications (see [[Freeside:1.7:Documentation:Developer/FS/cust credit refund|FS::cust_credit_refund]]) and applications to invoices (see [[Freeside:1.7:Documentation:Developer/FS/cust credit bill|FS::cust_credit_bill]]).
 
; credited
 
; credited
:Returns the amount of this credit that is still outstanding; which is amount minus all refund applications (see [[Freeside:1.7:Documentation:Developer/FS/cust credit refund|FS::cust_credit_refund]]) and applications to invoices (see [[Freeside:1.7:Documentation:Developer/FS/cust credit bill|FS::cust_credit_bill]]).
+
:Deprecated name for the unapplied method.
 
; cust_main
 
; cust_main
 
:Returns the customer (see [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]]) for this credit.
 
:Returns the customer (see [[Freeside:1.7:Documentation:Developer/FS/cust main|FS::cust_main]]) for this credit.
 +
; reason
 +
:Returns the text of the associated reason (see [[Freeside:1.7:Documentation:Developer/FS/reason|FS::reason]]) for this credit.
 +
 +
==CLASS METHODS==
 +
; unapplied_sql
 +
:Returns an SQL fragment to retreive the unapplied amount.
 +
; credited_sql
 +
:Deprecated name for the unapplied_sql method.
  
 
==BUGS==
 
==BUGS==
 
The delete method. The replace method.
 
The delete method. The replace method.
 +
 +
'''credited''' and '''credited_sql''' are now called '''unapplied''' and '''unapplied_sql'''. The old method names should start to give warnings.
  
 
==SEE ALSO==
 
==SEE ALSO==
 
[[Freeside:1.7:Documentation:Developer/FS/Record|FS::Record]], [[Freeside:1.7:Documentation:Developer/FS/cust credit refund|FS::cust_credit_refund]], [[Freeside:1.7:Documentation:Developer/FS/cust refund|FS::cust_refund]], [[Freeside:1.7:Documentation:Developer/FS/cust credit bill|FS::cust_credit_bill]] [[Freeside:1.7:Documentation:Developer/FS/cust bill|FS::cust_bill]], schema.html from the base documentation.
 
[[Freeside:1.7:Documentation:Developer/FS/Record|FS::Record]], [[Freeside:1.7:Documentation:Developer/FS/cust credit refund|FS::cust_credit_refund]], [[Freeside:1.7:Documentation:Developer/FS/cust refund|FS::cust_refund]], [[Freeside:1.7:Documentation:Developer/FS/cust credit bill|FS::cust_credit_bill]] [[Freeside:1.7:Documentation:Developer/FS/cust bill|FS::cust_bill]], schema.html from the base documentation.

Latest revision as of 19:04, 18 February 2008

NAME

FS::cust_credit - Object methods for cust_credit records

SYNOPSIS

 use FS::cust_credit;

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

 $error = $record->insert;

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

 $error = $record->delete;

 $error = $record->check;

DESCRIPTION

An FS::cust_credit object represents a credit; the equivalent of a negative cust_bill record (see FS::cust_bill). FS::cust_credit inherits from FS::Record. The following fields are currently supported:

crednum
Primary key (assigned automatically for new credits)
custnum
Customer (see FS::cust_main)
amount
Amount of the credit
_date
Specified as a UNIX timestamp; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.
otaker
Order taker (assigned automatically, see FS::UID)
reason
Text ( deprecated )
reasonnum
Reason (see FS::reason)
closed
Books closed flag, empty or `Y'

METHODS

new HASHREF
Creates a new credit. To add the credit to the database, see "insert".
insert
Adds this credit to the database ("Posts" the credit). If there is an error, returns the error, otherwise returns false.
delete
Unless the closed flag is set, deletes this credit and all associated applications (see FS::cust_credit_bill). In most cases, you want to use the void method instead to leave a record of the deleted credit.
replace OLD_RECORD
You can, but probably shouldn't modify credits...
check
Checks all fields to make sure this is a valid credit. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
cust_credit_refund
Returns all refund applications (see FS::cust_credit_refund) for this credit.
cust_credit_bill
Returns all application to invoices (see FS::cust_credit_bill) for this credit.
unapplied
Returns the amount of this credit that is still unapplied/outstanding; amount minus all refund applications (see FS::cust_credit_refund) and applications to invoices (see FS::cust_credit_bill).
credited
Deprecated name for the unapplied method.
cust_main
Returns the customer (see FS::cust_main) for this credit.
reason
Returns the text of the associated reason (see FS::reason) for this credit.

CLASS METHODS

unapplied_sql
Returns an SQL fragment to retreive the unapplied amount.
credited_sql
Deprecated name for the unapplied_sql method.

BUGS

The delete method. The replace method.

credited and credited_sql are now called unapplied and unapplied_sql. The old method names should start to give warnings.

SEE ALSO

FS::Record, FS::cust_credit_refund, FS::cust_refund, FS::cust_credit_bill FS::cust_bill, schema.html from the base documentation.