Freeside:1.9:Documentation:Developer/FS/part pkg
From Freeside
Contents
NAME
FS::part_pkg - Object methods for part_pkg objects
SYNOPSIS
use FS::part_pkg; $record = new FS::part_pkg \%hash $record = new FS::part_pkg { 'column' => 'value' }; $custom_record = $template_record->clone; $error = $record->insert; $error = $new_record->replace($old_record); $error = $record->delete; $error = $record->check; @pkg_svc = $record->pkg_svc; $svcnum = $record->svcpart; $svcnum = $record->svcpart( 'svc_acct' );
DESCRIPTION
An FS::part_pkg object represents a package definition. FS::part_pkg inherits from FS::Record. The following fields are currently supported:
- pkgpart - primary key (assigned automatically for new package definitions); pkg - Text name of this package definition (customer-viewable); comment - Text name of this package definition (non-customer-viewable); classnum - Optional package class (see FS::pkg_class); promo_code - Promotional code; setup - Setup fee expression (deprecated); freq - Frequency of recurring fee; recur - Recurring fee expression (deprecated); setuptax - Setup fee tax exempt flag, empty or `Y'; recurtax - Recurring fee tax exempt flag, empty or `Y'; taxclass - Tax class; plan - Price plan; plandata - Price plan data (deprecated - see FS::part_pkg_option instead); disabled - Disabled flag, empty or `Y'; pay_weight - Weight (relative to credit_weight and other package definitions) that controls payment application to specific line items.; credit_weight - Weight (relative to other package definitions) that controls credit application to specific line items.; agentnum - Optional agentnum (see FS::agent)
METHODS
- new HASHREF
- Creates a new package definition. To add the package definition to the database, see "insert"|#insert|"insert".
- clone
- An alternate constructor. Creates a new package definition by duplicating an existing definition. A new pkgpart is assigned and `(CUSTOM) ' is prepended to the comment field. To add the package definition to the database, see "insert"|#insert|"insert".
- insert [ , OPTION => VALUE ... ]
- Adds this package definition to the database. If there is an error, returns the error, otherwise returns false.
- Currently available options are: pkg_svc, primary_svc, cust_pkg, custnum_ref and options.
- If pkg_svc is set to a hashref with svcparts as keys and quantities as values, appropriate FS::pkg_svc records will be inserted.
- If primary_svc is set to the svcpart of the primary service, the appropriate FS::pkg_svc record will be updated.
- If cust_pkg is set to a pkgnum of a FS::cust_pkg record (or the FS::cust_pkg record itself), the object will be updated to point to this package definition.
- In conjunction with cust_pkg, if custnum_ref is set to a scalar reference, the scalar will be updated with the custnum value from the cust_pkg record.
- If options is set to a hashref of options, appropriate FS::part_pkg_option records will be inserted.
- delete
- Currently unimplemented.
- replace OLD_RECORD [ , OPTION => VALUE ... ]
- Replaces OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
- Currently available options are: pkg_svc and primary_svc
- If pkg_svc is set to a hashref with svcparts as keys and quantities as values, the appropriate FS::pkg_svc records will be replace.
- If primary_svc is set to the svcpart of the primary service, the appropriate FS::pkg_svc record will be updated.
- check
- Checks all fields to make sure this is a valid package definition. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
- pkg_class
- Returns the package class, as an FS::pkg_class object, or the empty string if there is no package class.
- classname
- Returns the package class name, or the empty string if there is no package class.
- agent
- Returns the associated agent for this event, if any, as an FS::agent object.
- pkg_svc
- Returns all FS::pkg_svc objects (see FS::pkg_svc) for this package definition (with non-zero quantity).
- svcpart [ SVCDB ]
- Returns the svcpart of the primary service definition (see FS::part_svc) associated with this package definition (see FS::pkg_svc). Returns false if there not a primary service definition or exactly one service definition with quantity 1, or if SVCDB is specified and does not match the svcdb of the service definition,
- payby
- Returns a list of the acceptable payment types for this package. Eventually this should come out of a database table and be editable, but currently has the following logic instead:
- If the package is free, the single item BILL is returned, otherwise, the single item CARD is returned.
- (CHEK? LEC? Probably shouldn't accept those by default, prone to abuse)
- is_free
- Returns true if this package is free.
- freq_pretty
- Returns an english representation of the freq field, such as "monthly", "weekly", "semi-annually", etc.
- plandata
- For backwards compatibility, returns the plandata field as well as all options from FS::part_pkg_option.
- part_pkg_option
- Returns all options as FS::part_pkg_option objects (see FS::part_pkg_option).
- options
- Returns a list of option names and values suitable for assigning to a hash.
- option OPTIONNAME
- Returns the option value for the given name, or the empty string.
- _rebless
- Reblesses the object into the FS::part_pkg::PLAN class (if available), where PLAN is the object's plan field. There should be better docs on how to create new price plans, but until then, see "NEW PLAN CLASSES"|#NEW PLAN CLASSES|"NEW PLAN CLASSES".
SUBROUTINES
- plan_info; format OPTION DATA
- Returns data formatted according to the function 'format' described in the plan info. Returns DATA if no such function exists.
- parse OPTION DATA
- Returns data parsed according to the function 'parse' described in the plan info. Returns DATA if no such function exists.
NEW PLAN CLASSES
A module should be added in FS/FS/part_pkg/ Eventually, an example may be found in eg/plan_template.pm. Until then, it is suggested that you use the other modules in FS/FS/part_pkg/ as a guide.
BUGS
The delete method is unimplemented.
setup and recur semantics are not yet defined (and are implemented in FS::cust_bill. hmm.). now they're deprecated and need to go.
plandata should go
SEE ALSO
FS::Record, FS::cust_pkg, FS::type_pkgs, FS::pkg_svc, Safe. schema.html from the base documentation.