The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Interchange6::Schema::Result::Zone

TABLE: zones

DESCRIPTION

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.

ACCESSORS

zones_id

  data_type: 'integer'
  is_auto_increment: 1
  is_nullable: 0
  sequence: 'zones_id_seq'

zone

For example for storing the UPS/USPS zone code or perhaps a simple name for the zone.

  data_type: 'varchar'
  default_value: (empty string)
  is_nullable: 1
  size: 255

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

PRIMARY KEY

UNIQUE CONSTRAINTS

zones_zone

On ( zone )

RELATIONS

zone_countries

Type: has_many

Related object: Interchange6::Schema::Result::ZoneCountry

countries

Type: many_to_many

Accessor to related country results ordered by name.

zone_states

Type: has_many

Related object: Interchange6::Schema::Result::ZoneState

states

Type: many_to_many

Accessor to related state results ordered by name.

shipment_destinations

has_many relationship with Interchange6::Schema::Result::ShipmentDestination

shipment_methods

many_to_many relationship to shipment_method. Currently it ignores the active field in shipment_destinations.

METHODS

new

Should not be called directly. Used to set default values for certain rows.

add_countries

Argument is either a Interchange6::Schema::Result::Country object or an arrayref of the same.

Throws an exception on failure.

has_country

Argument can be Interchange6::Schema::Result::Country, country name or iso code. Returns 1 if zone includes that country else 0;

country_count

Takes no args. Returns the number of countries in the zone.

remove_countries

Argument is either a Interchange6::Schema::Result::Country object or an arrayref of the same.

Throws an exception on failure.

add_states

Argument is either a Interchange6::Schema::Result::State object or an arrayref of the same.

Throws an exception on failure.

has_state

Argument can be Interchange6::Schema::Result::State, state name or iso code. Returns 1 if zone includes that state else 0;

state_count

Takes no args. Returns the number of states in the zone.

remove_states

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.