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

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_bill_pkg object represents an invoice line item. FS::cust_bill_pkg inherits from FS::Record. The following fields are currently supported:
 
An FS::cust_bill_pkg object represents an invoice line item. FS::cust_bill_pkg inherits from FS::Record. The following fields are currently supported:
  
; billpkgnum - primary key; invnum - invoice (see [[Freeside:1.9:Documentation:Developer/FS/cust bill|FS::cust_bill]]); pkgnum - package (see [[Freeside:1.9:Documentation:Developer/FS/cust pkg|FS::cust_pkg]]) or 0 for the special virtual sales tax package, or -1 for the virtual line item (itemdesc is used for the line); setup - setup fee; recur - recurring fee; sdate - starting date of recurring fee; edate - ending date of recurring fee; itemdesc - Line item description (currentlty used only when pkgnum is 0 or -1)
+
; billpkgnum - primary key; invnum - invoice (see [[Freeside:1.9:Documentation:Developer/FS/cust bill|FS::cust_bill]]); pkgnum - package (see [[Freeside:1.9:Documentation:Developer/FS/cust pkg|FS::cust_pkg]]) or 0 for the special virtual sales tax package, or -1 for the virtual line item (itemdesc is used for the line); pkgpart_override - optional package definition (see [[Freeside:1.9:Documentation:Developer/FS/part pkg|FS::part_pkg]]) override =item setup - setup fee; recur - recurring fee; sdate - starting date of recurring fee; edate - ending date of recurring fee; itemdesc - Line item description (overrides normal package description); quantity - If not set, defaults to 1; unitsetup - If not set, defaults to setup; unitrecur - If not set, defaults to recur
sdate and edate are specified as UNIX timestamps; 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.
+
sdate and edate are specified as UNIX timestamps; 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.
  
 
==METHODS==
 
==METHODS==
 
; new HASHREF
 
; new HASHREF
:Creates a new line item. To add the line item to the database, see [[Freeside:1.9:Documentation:Developer/#insert|"insert"|#insert|"insert"]]. Line items are normally created by calling the bill method of a customer object (see [[Freeside:1.9:Documentation:Developer/FS/cust main|FS::cust_main]]).
+
:Creates a new line item. To add the line item to the database, see [[#insert|"insert"]]. Line items are normally created by calling the bill method of a customer object (see [[Freeside:1.9:Documentation:Developer/FS/cust main|FS::cust_main]]).
 
; insert
 
; insert
 
:Adds this line item to the database. If there is an error, returns the error, otherwise returns false.
 
:Adds this line item to the database. If there is an error, returns the error, otherwise returns false.
Line 36: Line 36:
 
; cust_pkg
 
; cust_pkg
 
:Returns the package (see [[Freeside:1.9:Documentation:Developer/FS/cust pkg|FS::cust_pkg]]) for this invoice line item.
 
:Returns the package (see [[Freeside:1.9:Documentation:Developer/FS/cust pkg|FS::cust_pkg]]) for this invoice line item.
 +
; part_pkg
 +
:Returns the package definition for this invoice line item.
 
; cust_bill
 
; cust_bill
 
:Returns the invoice (see [[Freeside:1.9:Documentation:Developer/FS/cust bill|FS::cust_bill]]) for this invoice line item.
 
:Returns the invoice (see [[Freeside:1.9:Documentation:Developer/FS/cust bill|FS::cust_bill]]) for this invoice line item.
; details
+
; details [ OPTION => VALUE ... ]
 
:Returns an array of detail information for the invoice line item.
 
:Returns an array of detail information for the invoice line item.
 +
 +
:Currently available options are: ''format'' ''escape_function''
 +
 +
:If ''format'' is set to html or latex then the array members are improved for tabular appearance in those environments if possible.
 +
 +
:If ''escape_function'' is set then the array members are processed by this function before being returned.
 
; desc
 
; desc
 
:Returns a description for this line item. For typical line items, this is the ''pkg'' field of the corresponding '''FS::part_pkg''' object (see [[Freeside:1.9:Documentation:Developer/FS/part pkg|FS::part_pkg]]). For one-shot line items and named taxes, it is the ''itemdesc'' field of this line item, and for generic taxes, simply returns "Tax".
 
:Returns a description for this line item. For typical line items, this is the ''pkg'' field of the corresponding '''FS::part_pkg''' object (see [[Freeside:1.9:Documentation:Developer/FS/part pkg|FS::part_pkg]]). For one-shot line items and named taxes, it is the ''itemdesc'' field of this line item, and for generic taxes, simply returns "Tax".
Line 46: Line 54:
 
; owed_recur
 
; owed_recur
 
:Returns the amount owed (still outstanding) on this line item's recurring fee, which is the amount of the line item minus all payment applications (see [[Freeside:1.9:Documentation:Developer/FS/cust bill pay pkg|FS::cust_bill_pay_pkg]] and credit applications (see [[Freeside:1.9:Documentation:Developer/FS/cust credit bill pkg|FS::cust_credit_bill_pkg]]).
 
:Returns the amount owed (still outstanding) on this line item's recurring fee, which is the amount of the line item minus all payment applications (see [[Freeside:1.9:Documentation:Developer/FS/cust bill pay pkg|FS::cust_bill_pay_pkg]] and credit applications (see [[Freeside:1.9:Documentation:Developer/FS/cust credit bill pkg|FS::cust_credit_bill_pkg]]).
 +
; units
 +
:Returns the number of billing units (for tax purposes) represented by this, line item.
 +
; quantity; unitsetup; unitrecur; disintegrate
 +
:Returns a list of cust_bill_pkg objects each with no more than a single class (including setup or recur) of charge.
 +
; usage CLASSNUM
 +
:Returns the amount of the charge associated with usage class CLASSNUM if CLASSNUM is defined. Otherwise returns the total charge associated with usage.
 +
; usage_classes
 +
:Returns a list of usage classnums associated with this invoice line's details.
 +
; cust_bill_pkg_display [ type => TYPE ]
 +
:Returns an array of display information for the invoice line item optionally limited to 'TYPE'.
  
 
==BUGS==
 
==BUGS==

Latest revision as of 18:14, 6 February 2009

NAME

FS::cust_bill_pkg - Object methods for cust_bill_pkg records

SYNOPSIS

 use FS::cust_bill_pkg;

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

 $error = $record->insert;

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

 $error = $record->delete;

 $error = $record->check;

DESCRIPTION

An FS::cust_bill_pkg object represents an invoice line item. FS::cust_bill_pkg inherits from FS::Record. The following fields are currently supported:

billpkgnum - primary key; invnum - invoice (see FS::cust_bill); pkgnum - package (see FS::cust_pkg) or 0 for the special virtual sales tax package, or -1 for the virtual line item (itemdesc is used for the line); pkgpart_override - optional package definition (see FS::part_pkg) override =item setup - setup fee; recur - recurring fee; sdate - starting date of recurring fee; edate - ending date of recurring fee; itemdesc - Line item description (overrides normal package description); quantity - If not set, defaults to 1; unitsetup - If not set, defaults to setup; unitrecur - If not set, defaults to recur

sdate and edate are specified as UNIX timestamps; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.

METHODS

new HASHREF
Creates a new line item. To add the line item to the database, see "insert". Line items are normally created by calling the bill method of a customer object (see FS::cust_main).
insert
Adds this line item to the database. If there is an error, returns the error, otherwise returns false.
delete
Currently unimplemented. I don't remove line items because there would then be no record the items ever existed (which is bad, no?)
replace OLD_RECORD
Currently unimplemented. This would be even more of an accounting nightmare than deleteing the items. Just don't do it.
check
Checks all fields to make sure this is a valid line item. If there is an error, returns the error, otherwise returns false. Called by the insert method.
cust_pkg
Returns the package (see FS::cust_pkg) for this invoice line item.
part_pkg
Returns the package definition for this invoice line item.
cust_bill
Returns the invoice (see FS::cust_bill) for this invoice line item.
details [ OPTION => VALUE ... ]
Returns an array of detail information for the invoice line item.
Currently available options are: format escape_function
If format is set to html or latex then the array members are improved for tabular appearance in those environments if possible.
If escape_function is set then the array members are processed by this function before being returned.
desc
Returns a description for this line item. For typical line items, this is the pkg field of the corresponding FS::part_pkg object (see FS::part_pkg). For one-shot line items and named taxes, it is the itemdesc field of this line item, and for generic taxes, simply returns "Tax".
owed_setup
Returns the amount owed (still outstanding) on this line item's setup fee, which is the amount of the line item minus all payment applications (see FS::cust_bill_pay_pkg and credit applications (see FS::cust_credit_bill_pkg).
owed_recur
Returns the amount owed (still outstanding) on this line item's recurring fee, which is the amount of the line item minus all payment applications (see FS::cust_bill_pay_pkg and credit applications (see FS::cust_credit_bill_pkg).
units
Returns the number of billing units (for tax purposes) represented by this, line item.
quantity; unitsetup; unitrecur; disintegrate
Returns a list of cust_bill_pkg objects each with no more than a single class (including setup or recur) of charge.
usage CLASSNUM
Returns the amount of the charge associated with usage class CLASSNUM if CLASSNUM is defined. Otherwise returns the total charge associated with usage.
usage_classes
Returns a list of usage classnums associated with this invoice line's details.
cust_bill_pkg_display [ type => TYPE ]
Returns an array of display information for the invoice line item optionally limited to 'TYPE'.

BUGS

setup and recur shouldn't be separate fields. There should be one "amount" field and a flag to tell you if it is a setup/one-time fee or a recurring fee.

A line item with both should really be two separate records (preserving sdate and edate for setup fees for recurring packages - that information may be valuable later). Invoice generation (cust_main::bill), invoice printing (cust_bill), tax reports (report_tax.cgi) and line item reports (cust_bill_pkg.cgi) would need to be updated.

owed_setup and owed_recur could then be repaced by just owed, and cust_bill::open_cust_bill_pkg and cust_bill_ApplicationCommon::apply_to_lineitems could be simplified.

SEE ALSO

FS::Record, FS::cust_bill, FS::cust_pkg, FS::cust_main, schema.html from the base documentation.