commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / tools / extensions / org.civicrm.payment.googlecheckout / packages / Google / library / googletaxrule.php
1 <?php
2
3 /**
4 * Copyright (C) 2006 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 /* This class is used to create Tax rules to be added to the tax tables
19 * in the shopping cart
20 * Ther are two types of tax rules
21 * 1. default (should be added to a default tax table)
22 * 2. alternate (should be added to an alternate tax table)
23 *
24 * Invoke a separate instance of this class for each tax rule to be
25 * added to the cart
26 * Required fields are the rule type and the tax rate
27 * Country area can be specified as part of constructor arguments or
28 * using individual Set methods. Possible values here are
29 * 1. CONTINENTAL_48
30 * 2. FULL_50_STATES
31 * 3. ALL
32 * State and zip patterns must be exclusively updated using their
33 * individual Set methods
34 */
35 class GoogleTaxRule {
36
37 var $shipping_taxed;
38 var $tax_rule_type;
39 var $tax_rate;
40
41 var $state_areas_arr;
42 var $zip_patterns_arr;
43 var $country_area;
44
45 /**
46 * @param $type
47 * @param $tax_rate
48 * @param string $country_area
49 * @param string $shipping_taxed
50 */
51 function GoogleTaxRule($type, $tax_rate, $country_area = "",
52 $shipping_taxed = "false"
53 ) {
54 $this->rax_rule_type = strtolower($type);
55 $this->shipping_taxed = $shipping_taxed;
56 $this->tax_rate = $tax_rate;
57
58 if ($country_area != "") {
59
60 $this->SetCountryArea($country_area);
61 }
62
63 $this->state_areas_arr = array();
64 $this->zip_patterns_arr = array();
65 }
66
67 /**
68 * @param $areas
69 */
70 function SetStateAreas($areas) {
71 if (is_array($areas)) {
72 $this->state_areas_arr = $areas;
73 }
74 else $this->state_areas_arr = array($areas);
75 }
76
77 /**
78 * @param $zips
79 */
80 function SetZipPatterns($zips) {
81 if (is_array($zips)) {
82 $this->zip_patterns_arr = $zips;
83 }
84 else $this->zip_patterns_arr = array($zips);
85 }
86
87 /**
88 * @param $country_area
89 */
90 function SetCountryArea($country_area) {
91 if ($country_area == "CONTINENTAL_48" || $country_area == "FULL_50_STATES"
92 || $country_area = "ALL"
93 ) $this->country_area = $country_area;
94 else $this->country_area = "";
95 }
96 }
97