% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>
FS::cust_bill_pkg - Object methods for cust_bill_pkg records
use FS::cust_bill_pkg;
$record = new FS::cust_bill_pkg \%hash;
$record = new FS::cust_bill_pkg { 'column' => 'value' };
$error = $record->insert;
$error = $record->check;
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:
primary key
invoice (see FS::cust_bill)
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)
optional package definition (see FS::part_pkg) override
setup fee
recurring fee
starting date of recurring fee
ending date of recurring fee
Line item description (overrides normal package description)
If not set, defaults to 1
If not set, defaults to setup
If not set, defaults to recur
If set to Y, indicates data should not appear as separate line item on invoice
sdate and edate are specified as UNIX timestamps; see "time" in perlfunc. Also see Time::Local and Date::Parse for conversion functions.
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).
Adds this line item to the database. If there is an error, returns the error, otherwise returns false.
Voids this line item: deletes the line item and adds a record of the voided line item to the FS::cust_bill_pkg_void table (and related tables).
Not recommended.
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.
Converts the contents of the 'details' pseudo-field to FS::cust_bill_pkg_detail objects, if they aren't already.
Sets up tax exemptions. TAXOBJECT is the FS::cust_main_county or FS::tax_rate record for the tax.
This will deal with the following cases:
It does NOT deal with monthly tax exemptions, which need more context than this humble little method cares to deal with.
OPTIONS should include "custnum" => the customer number if this tax line hasn't been inserted (which it probably hasn't).
Returns a list of exemption objects, which will also be attached to the line item as the 'cust_tax_exempt_pkg' pseudo-field. Inserting the line item will insert these records as well.
Returns the invoice (see FS::cust_bill) for this invoice line item.
Returns the customer (FS::cust_main object) for this line item.
Returns the previous cust_bill_pkg for this package, if any.
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).
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).
Returns the number of billing units (for tax purposes) represented by this, line item.
If this item has any discounts, returns a hashref in the format used by "_items_cust_bill_pkg" in FS::Template_Mixin to describe the discount(s) on an invoice. This will contain the keys 'description', 'amount', 'ext_description' (an arrayref of text lines describing the discounts), and '_is_discount' (a flag).
The value for 'amount' will be negative, and will be scaled for the package quantity.
A helper method for insert, populates the pseudo-field display with appropriate FS::cust_bill_pkg_display objects.
Options are passed as a list of name/value pairs. Options are:
part_pkg: FS::part_pkg object from this line item's package.
real_pkgpart: if this line item comes from a bundled package, the pkgpart of the owning package. Otherwise the same as the part_pkg's pkgpart above.
Returns a hash: keys are "setup", "recur" or usage classnum, values are FS::cust_bill_pkg objects, each with no more than a single class (setup or recur) of charge.
Returns the amount of the charge associated with usage class CLASSNUM if CLASSNUM is defined. Otherwise returns the total charge associated with usage.
Returns a list of usage classnums associated with this invoice line's details.
Returns the list of associated cust_bill_pkg_tax_location and/or cust_bill_pkg_tax_rate_location objects
Whether to show a zero recurring amount. This is true if the package or its definition has the recur_show_zero flag, and the recurring fee is actually zero for this period.
Whether to show a zero setup charge. This requires the package or its definition to have the setup_show_zero flag, but it also returns false if the package's setup date is before this line item's start date.
Returns the sum of credits applied to this item. Arguments are the same as owed_sql/paid_sql/credited_sql.
Returns the FS::cust_location number that this line item is in for tax purposes. For package sales, it's the package tax location; for fees, it's the customer's default service location.
Returns an SQL expression for the total usage charges in details on an item.
Returns an SQL expression for the amount owed. BEFORE and AFTER specify a date window. OPTIONS may include 'no_usage' (excludes usage charges) and 'setuprecur' (set to "setup" or "recur" to limit to one or the other).
Returns an SQL expression for the sum of payments applied to this item.
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.
The upgrade procedure is pretty sketchy.
FS::Record, FS::cust_bill, FS::cust_pkg, FS::cust_main, schema.html from the base documentation.