Difference between revisions of "Freeside:4:Documentation:Developer/FS/cust main county"

From Freeside
Jump to: navigation, search
(Edit via perl MediaWiki framework (1.13))
 
(No difference)

Latest revision as of 07:20, 18 November 2015

NAME

FS::cust_main_county - Object methods for cust_main_county objects

SYNOPSIS

 use FS::cust_main_county;

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

 $error = $record->insert;

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

 $error = $record->delete;

 $error = $record->check;

 ($county_html, $state_html, $country_html) =
   FS::cust_main_county::regionselector( $county, $state, $country );

DESCRIPTION

An FS::cust_main_county object represents a tax rate, defined by locale. FS::cust_main_county inherits from FS::Record. The following fields are currently supported:

taxnum - primary key (assigned automatically for new tax rates); district - tax district (optional); city; county; state; country; tax - percentage; taxclass; exempt_amount; taxname - if defined, printed on invoices instead of "Tax"; setuptax - if 'Y', this tax does not apply to setup fees; recurtax - if 'Y', this tax does not apply to recurring fees

METHODS

new HASHREF
Creates a new tax rate. To add the tax rate to the database, see "insert".
insert
Adds this tax rate to the database. If there is an error, returns the error, otherwise returns false.
delete
Deletes this tax rate from the database. If there is an error, returns the error, otherwise returns false.
replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.
check
Checks all fields to make sure this is a valid tax rate. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.
label OPTIONS
Returns a label looking like "Anytown, Alameda County, CA, US".
If the taxname field is set, it will look like "CA Sales Tax (Anytown, Alameda County, CA, US)".
If the taxclass is set, then it will be "Anytown, Alameda County, CA, US (International)".
OPTIONS may contain "with_taxclass", "with_city", and "with_district" to show those fields. It may also contain "out", in which case, if this region (district+city+county+state+country) contains no non-zero taxes, the label will read "Out of taxable region(s)".
sql_taxclass_sameregion
Returns an SQL WHERE fragment or the empty string to search for entries with different tax classes.
taxline TAXABLES_ARRAYREF, [ OPTION => VALUE ... ]
Takes an arrayref of FS::cust_bill_pkg objects representing taxable line items, and returns a new FS::cust_bill_pkg object representing the tax on them under this tax rate.
This will have a pseudo-field, "cust_bill_pkg_tax_location", containing an arrayref of FS::cust_bill_pkg_tax_location objects. Each of these will in turn have a "taxable_cust_bill_pkg" pseudo-field linking it to one of the taxable items. All of these links must be resolved as the objects are inserted.
In addition to calculating the tax for the line items, this will calculate any appropriate tax exemptions and attach them to the line items.
Options may include 'custnum' and 'invoice_time' in case the cust_bill_pkg objects belong to an invoice that hasn't been inserted yet.
Options may include 'exemptions', an arrayref of FS::cust_tax_exempt_pkg objects belonging to the same customer, to be counted against the monthly tax exemption limit if there is one.

SUBROUTINES

regionselector [ COUNTY STATE COUNTRY [ PREFIX [ ONCHANGE [ DISABLED ] ] ] ]

BUGS

regionselector? putting web ui components in here? they should probably live somewhere else...

SEE ALSO

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