Interchange6::Schema::Result::Zone
In the context of zones the term 'state' refers to state, province or other principal subdivision of a country as defined in ISO 3116-2. Countries to be added to a zone must already exist in Interchange6::Schema::Result::Country and states in Interchange6::Schema::Result::State.
Zones can contain any of the following:
No countries and no states
An empty zone must be created before countries/states are added but otherwise is probably not useful.
Multiple countries
For example to create a trading group like the European Union.
A single country
A single country with a single state
For example Quebec in Canada which has GST + QST
A single country with multiple states
For example a group containing all Canadian provinces that charge only GST.
The following combinations are NOT allowed:
Multiple countries with one or more states
One or more states with no country
Countries and states should be added to and removed from the zone using these methods which are described further below:
add_countries
remove_countries
add_states
remove_states
NOTE: avoid using other methods from DBIx::Class::Relationship::Base since you may inadvertently end up with an invalid zone.
Primary Key.
For example for storing the UPS/USPS zone code or a simple name for the zone.
Unique constraint.
Date and time when this record was created returned as DateTime object. Value is auto-set on insert.
Date and time when this record was last modified returned as DateTime object. Value is auto-set on insert and update.
Type: has_many
Related object: Interchange6::Schema::Result::ZoneCountry
Type: many_to_many
Accessor to related country results ordered by name.
Related object: Interchange6::Schema::Result::ZoneState
Accessor to related state results ordered by name.
has_many relationship with Interchange6::Schema::Result::ShipmentDestination
has_many
many_to_many relationship to shipment_method. Currently it ignores the active field in shipment_destinations.
many_to_many
active
Overloaded method. We allow a form of multi-create here so you can do something like:
$schema->resultset('Zone')->create({ zone => 'some states of the USA', countries => [ 'US' ], states => [ 'CA', 'PA' ], });
If there is only a single country or state the value can be a scalar instead of a hashref.
Argument is one of:
Returns the zone object on success.
Argument can be Interchange6::Schema::Result::Country, country name or iso code. Returns 1 if zone includes that country else 0;
Takes no args. Returns the number of countries in the zone.
Argument is either a Interchange6::Schema::Result::Country object or an arrayref of the same.
Throws an exception on failure.
Argument can be Interchange6::Schema::Result::State, state name or iso code. Returns 1 if zone includes that state else 0;
Takes no args. Returns the number of states in the zone.
Argument is either a Interchange6::Schema::Result::State object or an arrayref of the same.
Returns the Zone object or undef on failure. Errors are available via errors method inherited from Interchange6::Schema::Role::Errors.
To install Interchange6::Schema, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Interchange6::Schema
CPAN shell
perl -MCPAN -e shell install Interchange6::Schema
For more information on module installation, please visit the detailed CPAN module installation guide.