NAME
Interchange6::Schema::Result::Tax
TABLE: taxes
DESCRIPTION
The taxes table contains taxes such as sales tax and VAT. Each tax has a unique tax_name but can contain multiple rows for each tax_name to allow for changes in tax rates over time. When there is more than one row for a single tax_name then the valid_from and valid_to periods may not overlap.
ACCESSORS
taxes_id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
sequence: 'taxes_id_seq'
tax_name
data_type: 'varchar'
is_nullable: 0
size: 64
description
data_type: 'varchar'
is_nullable: 0
size: 64
percent
data_type: 'numeric'
is_nullable: 0
size: [7,4]
decimal_places
data_type: 'integer'
is_nullable: 0
default_value: 2
Number of decimal_places of precision required. Defaults to 2.
rounding
data_type: char"
is_nullable: 1
size: 1
default_value: undef
Default rounding is half round up to the number of decimal_places. To use floor or ceiling set rounding to 'f' or 'c' as appropriate. The rounding value is automatically converted to lower case and any invalid value passed in will cause an exception to be thrown.
valid_from
data_type: 'date'
set_on_create: 1
is_nullable: 0
valid_to
data_type: 'date'
is_nullable: 1
country_iso_code
data_type: 'char'
is_foreign_key: 1
is_nullable: 1
size: 2
states_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
created
data_type: 'datetime'
set_on_create: 1
is_nullable: 0
last_modified
data_type: 'datetime'
set_on_create: 1
set_on_update: 1
is_nullable: 0
METHODS
calculate
Calculate tax
Arguments should be a hash ref of the following arguments:
price
Price of product either inclusive or exclusive of tax - required.
tax_included
Boolean indicating whether price is inclusive of tax or not. Defaults to 0 which means exclusive of tax.
Will throw an exception if the price us not numeric.
Usage example:
my $tax = $taxrecord->caclulate({ price => 13.47, tax_included => 1 });
# with percentage 18 our tax is 2.05
PRIMARY KEY
RELATIONS
state
Type: belongs_to
Related object: Interchange6::Schema::Result::State
country
Type: belongs_to
Related object: Interchange6::Schema::Result::Country
INHERITED METHODS
new
We overload the new method to set default values on certain rows at create time.
sqlt_deploy_hook
Called during table creation to add indexes on the following columns:
tax_name
valid_from
valid_to
INHERITED METHODS
validate
Validity checks that cannot be enforced using primary key, unique or other database methods using Interchange6::Schema::Component::Validation. The validity checks enforce the following rules:
Check country_iso_code is valid
If both valid_from and valid_to are defined then valid_to must be a later date than valid_from.
A single tax_name may appear more than once in the table to allow for changes in tax rates but valid_from/valid_to date ranges must not overlap.