1package Google::Checkout::General::TaxTableAreas;
2
3=head1 NAME
4
5Google::Checkout::General::TaxTableAreas
6
7=head1 SYNOPSIS
8
9  use Google::Checkout::XML::Constants;
10  use Google::Checkout::General::TaxRule;
11  use Google::Checkout::General::TaxTable;
12  use Google::Checkout::General::TaxTableAreas;
13  use Google::Checkout::General::MerchantCheckoutFlow;
14
15  #--
16  #-- Shipping tax set to 1 means shippings
17  #-- are taxable and the rate is 2.5%. This
18  #-- tax rule should apply to all 50 states
19  #--
20  my $tax_rule = Google::Checkout::General::TaxRule->new(
21                 shipping_tax => 1,
22                 rate => 0.025,
23                 area => Google::Checkout::General::TaxTableAreas->new(
24                         country => [Google::Checkout::XML::Constants::FULL_50_STATES]));
25
26  #--
27  #-- default tax table
28  #--
29  my $tax_table1 = Google::Checkout::General::TaxTable->new(
30                   default => 1,
31                   rules => [$tax_rule]);
32
33  #--
34  #-- same tax table but with a name
35  #--
36  my $tax_table2 = Google::Checkout::General::TaxTable->new(
37                   default    => 0,
38                   name       => "tax",
39                   standalone => 1,
40                   rules      => [$tax_rule]);
41
42  my $checkout_flow = Google::Checkout::General::MerchantCheckoutFlow->new(
43                      shipping_method       => [$flat_rate_shipping],
44                      edit_cart_url         => "http://edit/cart/url",
45                      continue_shopping_url => "http://continue/shopping/url",
46                      buyer_phone           => "1-111-111-1111",
47                      tax_table             => [$tax_table1,$tax_table2],
48                      merchant_calculation  => $merchant_calculation);
49
50=head1 DESCRIPTION
51
52A sub-class of C<Google::Checkout::General::ShippingRestrictions>.
53This module is responsible for creating tax table areas which can
54then be added to C<Google::Checkout::General::TaxRule>.
55
56=over 4
57
58=item new STATE => ..., ZIP => ..., COUNTRY => ...
59
60Constructor. Takes array reference of state, zip code
61and country area where this tax table area will cover.
62
63=item get_state
64
65Returns an array reference of states.
66
67=item add_state STATE
68
69Adds another state.
70
71=item get_zip
72
73Returns an array reference of zip codes.
74
75=item add_zip ZIP
76
77Adds another zip code. Zip code might
78contains wildcard operator to specify a
79range of zip codes.
80
81=item get_country
82
83Returns the country area.
84
85=item add_country COUNTRY_AREA
86
87Adds another country area. Currently, only
88C<Google::Checkout::XML::Constants::FULL_50_STATES> is supported.
89
90=item get_country
91
92Returns the country area.
93
94=item add_postal POSTAL_AREA
95
96Adds another postal area.
97
98=item get_postal
99
100Returns the postal area.
101
102=item add_world BOOLEAN
103
104Adds world area.
105
106=item get_world
107
108Returns
109
110=back
111
112=cut
113
114=head1 COPYRIGHT
115
116Copyright 2006 Google. All rights reserved.
117
118=head1 SEE ALSO
119
120Google::Checkout::General::TaxRule
121Google::Checkout::General::ShippingRestrictions
122
123=cut
124
125use strict;
126use warnings;
127
128use Google::Checkout::General::ShippingRestrictions;
129our @ISA = qw/Google::Checkout::General::ShippingRestrictions/;
130
131sub new
132{
133  my ($class, %args) = @_;
134
135  my %translated;
136
137  #--
138  #-- States
139  #--
140  $translated{allowed_state}        = $args{state}   if $args{state};
141  $translated{allowed_zip}          = $args{zip}     if $args{zip};
142  $translated{allowed_country_area} = $args{country} if $args{country};
143  $translated{allowed_postal_area}  = $args{postal}  if $args{postal};
144  $translated{allowed_world_area}   = $args{world}   if $args{world};
145
146  my $self = $class->SUPER::new(%translated);
147
148  return bless $self => $class;
149}
150
151sub get_state
152{
153  my ($self) = @_;
154
155  return $self->get_allowed_state;
156}
157
158sub get_zip
159{
160  my ($self) = @_;
161
162  return $self->get_allowed_zip;
163}
164
165sub get_country
166{
167  my ($self) = @_;
168
169  return $self->get_allowed_country_area;
170}
171
172sub get_postal
173{
174  my ($self) = @_;
175
176  return $self->get_allowed_postal_area;
177}
178
179sub get_world
180{
181  my ($self) = @_;
182
183  return $self->get_allowed_world_area;
184}
185
186sub add_state
187{
188  my ($self, $data) = @_;
189
190  return $self->add_allowed_state($data);
191}
192
193sub add_zip
194{
195  my ($self, $data) = @_;
196
197  return $self->add_allowed_zip($data);
198}
199
200sub add_country
201{
202  my ($self, $data) = @_;
203
204  return $self->add_allowed_country_area($data);
205}
206
207sub add_postal
208{
209  my ($self, $data) = @_;
210
211  return $self->add_allowed_postal_area($data);
212}
213
214sub add_world
215{
216  my ($self, $data) = @_;
217
218  return $self->add_allowed_world_area($data);
219}
220
2211;
222