本文整理汇总了PHP中Address::setRegion方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::setRegion方法的具体用法?PHP Address::setRegion怎么用?PHP Address::setRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::setRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLatLongValidation
function testLatLongValidation()
{
$address = new Address();
$address->setLine1("900 Winslow Way");
$address->setLine2("Ste 130");
$address->setCity("Bainbridge Island");
$address->setRegion("WA");
$address->setPostalCode("98110");
$address->setLongitude("-122.510359");
$address->setLatitude("47.624972");
$validateRequest = new ValidateRequest();
$validateRequest->setAddress($address);
$validateRequest->setTextCase(TextCase::$Upper);
//added for 4.13 changes
$validateRequest->setCoordinates(true);
//Sets Profile name from Configuration File to "Jaas"
//this will force it to Jaas (PostLocate)
$this->client = new AddressServiceSoap("JaasDevelopement");
//validate the Request
$result = $this->client->validate($validateRequest);
//Re-Assigning to the original Profile
$this->client = new AddressServiceSoap("Development");
$this->assertEqual($result->getResultCode(), SeverityLevel::$Success);
$validAddresses = $result->getValidAddresses();
$this->assertEqual(1, count($validAddresses));
$validAddresses = $result->getValidAddresses();
if (count($validAddresses) != 1) {
echo "Unexpected number of addresses returned. Expected one address.";
} else {
$validAddress = $validAddresses[0];
$this->assertEqual(strtoupper($address->getLine1()) . " E " . strtoupper($address->getLine2()), $validAddress->getLine1());
$this->assertEqual("", $validAddress->getLine2());
$this->assertEqual(strtoupper($address->getCity()), $validAddress->getCity());
$this->assertEqual(strtoupper($address->getRegion()), $validAddress->getRegion());
$this->assertEqual($address->getPostalCode() . "-2450", $validAddress->getPostalCode());
$this->assertEqual("H", $validAddress->getAddressType());
$this->assertEqual("C051", $validAddress->getCarrierRoute());
//Ticket 21203: Modified Fips Code value for jaas enabled account.
//$this->assertEqual("5303500000", $validAddress->getFipsCode());
$this->assertEqual("5303503736", $validAddress->getFipsCode());
$this->assertEqual("KITSAP", $validAddress->getCounty());
$this->assertEqual(strtoupper($address->getCity()) . " " . strtoupper($address->getRegion()) . " " . $address->getPostalCode() . "-2450", $validAddress->getLine4());
$this->assertEqual("981102450307", $validAddress->getPostNet());
// Added 4.13 changes for the Lat Long
// Update to check for ZIP+4 precision
// Zip+4 precision coordinates
if (strlen($validAddress->getLatitude()) > 7) {
echo "ZIP+4 precision coordinates received";
$this->assertEqual($address->getLatitude(), $validAddress->getLatitude());
$this->assertEqual($address->getLongitude(), $validAddress->getLongitude());
} else {
echo "ZIP5 precision coordinates received";
$this->assertEqual(substr($validAddress->getLatitude(), 0, 4), substr($address->getLatitude(), 0, 4), "Expected Latitude to start with '47.64'");
$this->assertEqual(substr($validAddress->getLongitude(), 0, 6), substr($address->getLongitude(), 0, 6), "Expected Longitude to start with '-122.53'");
}
}
}
示例2: _convertRequestAddress
/**
* Sets attributes from the Mage address on the AvaTax Request address.
*
* @return $this
*/
protected function _convertRequestAddress()
{
if (!$this->_requestAddress) {
$this->_requestAddress = new Address();
}
$this->_requestAddress->setLine1($this->_mageAddress->getStreet(1));
$this->_requestAddress->setLine2($this->_mageAddress->getStreet(2));
$this->_requestAddress->setCity($this->_mageAddress->getCity());
$this->_requestAddress->setRegion($this->_mageAddress->getRegionCode());
$this->_requestAddress->setCountry($this->_mageAddress->getCountry());
$this->_requestAddress->setPostalCode($this->_mageAddress->getPostcode());
return $this;
}
示例3: _newAddress
/**
* Generic address maker
*
* @param string $line1
* @param string $line2
* @param string $city
* @param string $state
* @param string $zip
* @param string $country
* @return Address
*/
protected function _newAddress($line1, $line2, $city, $state, $zip, $country = 'USA')
{
$address = new Address();
$address->setLine1($line1);
$address->setLine2($line2);
$address->setCity($city);
$address->setRegion($state);
$address->setPostalCode($zip);
$address->setCountry($country);
return $address;
}
示例4: createStandardRequest
function createStandardRequest($calc, $products, $sign = 1)
{
if (!class_exists('TaxServiceSoap')) {
require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
}
if (!class_exists('DocumentType')) {
require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
}
if (!class_exists('DetailLevel')) {
require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('ServiceMode')) {
require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('GetTaxRequest')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php';
}
if (!class_exists('GetTaxResult')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
}
if (!class_exists('Address')) {
require VMAVALARA_CLASS_PATH . DS . 'Address.class.php';
}
if (is_object($calc)) {
$calc = get_object_vars($calc);
}
$request = new GetTaxRequest();
$origin = new Address();
//In Virtuemart we have not differenct warehouses, but we have a shipment address
//So when the vendor has a shipment address, we assume that it is his warehouse
//Later we can combine products with shipment addresses for different warehouse (yehye, future music)
//But for now we just use the BT address
if (!class_exists('VirtueMartModelVendor')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
}
$userId = VirtueMartModelVendor::getUserIdByVendorId($calc['virtuemart_vendor_id']);
$userModel = VmModel::getModel('user');
$virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId);
// this is needed to set the correct user id for the vendor when the user is logged
$userModel->getVendor($calc['virtuemart_vendor_id']);
$vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE);
$vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id];
$origin->setLine1($vendorFields['fields']['address_1']['value']);
$origin->setLine2($vendorFields['fields']['address_2']['value']);
$origin->setCity($vendorFields['fields']['city']['value']);
$origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']);
$origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']);
$origin->setPostalCode($vendorFields['fields']['zip']['value']);
$request->setOriginAddress($origin);
//Address
if (isset($this->addresses[0])) {
$destination = $this->addresses[0];
} else {
return FALSE;
}
if (!class_exists('calculationHelper')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
}
$calculator = calculationHelper::getInstance();
$request->setCurrencyCode($calculator->_currencyDisplay->_vendorCurrency_code_3);
//CurrencyCode
$request->setDestinationAddress($destination);
//Address
$request->setCompanyCode($calc['company_code']);
// Your Company Code From the Dashboard
$request->setDocDate(date('Y-m-d'));
//date, checked
$request->setCustomerCode(self::$vmadd['customer_number']);
//string Required
if (isset(self::$vmadd['tax_usage_type'])) {
$request->setCustomerUsageType(self::$vmadd['tax_usage_type']);
//string Entity Usage
}
if (isset(self::$vmadd['tax_exemption_number'])) {
$request->setExemptionNo(self::$vmadd['tax_exemption_number']);
//string if not using ECMS which keys on customer code
}
if (isset(self::$vmadd['taxOverride'])) {
$request->setTaxOverride(self::$vmadd['taxOverride']);
avadebug('I set tax override ', self::$vmadd['taxOverride']);
}
$setAllDiscounted = false;
if (isset($products['discountAmount'])) {
if (!empty($products['discountAmount'])) {
//$request->setDiscount($sign * $products['discountAmount'] * (-1)); //decimal
$request->setDiscount($sign * $products['discountAmount']);
//decimal
vmdebug('We sent as discount ' . $request->getDiscount());
$setAllDiscounted = true;
}
unset($products['discountAmount']);
}
$request->setDetailLevel('Tax');
//Summary or Document or Line or Tax or Diagnostic
//.........这里部分代码省略.........
示例5: rtrim
// Get The address from the user via keyboard input
echo "Address Line 1: ";
$input = rtrim(fgets($STDIN));
$address->setLine1($input);
echo "Address Line 2: ";
$input = rtrim(fgets($STDIN));
$address->setLine2($input);
echo "Address Line 3: ";
$input = rtrim(fgets($STDIN));
$address->setLine3($input);
echo "City: ";
$input = rtrim(fgets($STDIN));
$address->setCity($input);
echo "State/Province: ";
$input = rtrim(fgets($STDIN));
$address->setRegion($input);
echo "Postal Code: ";
$input = rtrim(fgets($STDIN));
$address->setPostalCode($input);
$textCase = TextCase::$Mixed;
$coordinates = 1;
$request = new ValidateRequest($address, $textCase ? $textCase : TextCase::$Default, $coordinates);
$result = $client->Validate($request);
echo "\n" . 'Validate ResultCode is: ' . $result->getResultCode() . "\n";
if ($result->getResultCode() != SeverityLevel::$Success) {
foreach ($result->getMessages() as $msg) {
echo $msg->getName() . ": " . $msg->getSummary() . "\n";
}
} else {
echo "Normalized Address:\n";
foreach ($result->getvalidAddresses() as $valid) {
示例6: testSetRegion
/**
* Tests Address->setRegion()
*/
public function testSetRegion()
{
$this->Address->setRegion('religion');
$this->assertEquals('religion', $this->Address->region);
}
示例7: getPeople
//.........这里部分代码省略.........
$person->setSmoker($row['Smoker']);
}
/* the following fields require additional queries so are only executed if requested */
if (isset($fields['activities']) || in_array('@all', $fields)) {
$activities = array();
//'A' we haven`t activities yet
/*$res2 = mysqli_query($this->db, "select activity from person_activities where person_id = " . $person_id);
while (list($activity) = @mysqli_fetch_row($res2)) {
$activities[] = $activity;
}*/
$person->setActivities($activities);
}
if (isset($fields['addresses']) || in_array('@all', $fields)) {
$addresses = array();
$sCountry = isset($row['Country']) ? $row['Country'] : '';
$sRegion = isset($row['City']) ? $row['City'] : '';
//'A' region -> city
$sZip = isset($row['zip']) ? $row['zip'] : '';
if (empty($row['unstructured_address'])) {
$row['unstructured_address'] = trim($row['street_address'] . " " . $sRegion . " " . $sCountry);
}
$addres = new Address($row['unstructured_address']);
$addres->setCountry($sCountry);
if (!empty($row['latitude'])) {
$addres->setLatitude($row['latitude']);
}
if (!empty($row['longitude'])) {
$addres->setLongitude($row['longitude']);
}
if (!empty($row['locality'])) {
$addres->setLocality($row['locality']);
}
$addres->setPostalCode($sZip);
$addres->setRegion($sRegion);
if (!empty($row['street_address'])) {
$addres->setStreetAddress($row['street_address']);
}
if (!empty($row['street_address'])) {
$addres->setType($row['street_address']);
}
//FIXME quick and dirty hack to demo PC
$addres->setPrimary(true);
$addresses[] = $addres;
$person->setAddresses($addresses);
}
if (isset($fields['bodyType']) || in_array('@all', $fields)) {
//'A' we haven`t bodyType at all
/*$res2 = mysqli_query($this->db, "select * from person_body_type where person_id = " . $person_id);
if (@mysqli_num_rows($res2)) {
$row = @mysql_fetch_array($res2, MYSQLI_ASSOC);
$bodyType = new BodyType();
$bodyType->setBuild($row['build']);
$bodyType->setEyeColor($row['eye_color']);
$bodyType->setHairColor($row['hair_color']);
$bodyType->setHeight($row['height']);
$bodyType->setWeight($row['weight']);
$person->setBodyType($bodyType);
}*/
}
if (isset($fields['books']) || in_array('@all', $fields)) {
//'A' we haven`t books at all
/*$books = array();
$res2 = mysqli_query($this->db, "select book from person_books where person_id = " . $person_id);
while (list($book) = @mysqli_fetch_row($res2)) {
$books[] = $book;
}
示例8: GetTaxRequest
$request = new GetTaxRequest();
//Add Origin Address
$origin = new Address();
$origin->setLine1("435 Ericksen Ave NE");
$origin->setLine2("Suite 200");
$origin->setCity("Bainbridge Island");
$origin->setRegion("WA");
$origin->setPostalCode("98110-1896");
$request->setOriginAddress($origin);
//Address
//Add Destination address
$destination = new Address();
$destination->setLine1("900 Winslow Way");
$destination->setLine2("Suite 200");
$destination->setCity("Bainbridge Island");
$destination->setRegion("WA");
$destination->setPostalCode("98110");
$request->setDestinationAddress($destination);
//Address
$request->setCompanyCode('DEFAULT');
// Your Company Code From the Dashboard
$request->setDocType(DocumentType::$SalesInvoice);
// Only supported types are SalesInvoice or SalesOrder
$dateTime = new DateTime();
$docCode = "PHPSample" . date_format($dateTime, "dmyGis");
$request->setDocCode($docCode);
// invoice number
$request->setDocDate(date_format($dateTime, "Y-m-d"));
//date
$request->setSalespersonCode("");
// string Optional
示例9: GetTaxRequest
function wc_autoship_taxnow_add_tax_rates($tax_rates, $schedule_id)
{
include_once WP_PLUGIN_DIR . '/taxnow_woo/taxnow-woo.class.php';
include_once WP_PLUGIN_DIR . '/woocommerce-autoship/classes/wc-autoship-schedule.php';
if (class_exists('class_taxNOW_woo') && class_exists('WC_Autoship_Schedule')) {
// Create TaxNOW instance
$taxnow_woo = new class_taxNOW_woo();
// Get autoship schedule
$schedule = new WC_Autoship_Schedule($schedule_id);
// Get autoship customer
$customer = $schedule->get_customer();
// Create service
$service = $taxnow_woo->create_service('TaxServiceSoap', false);
$request = new GetTaxRequest();
$request->setDocDate(date('Y-m-d', current_time('timestamp')));
$request->setDocCode('');
$request->setCustomerCode($customer->get_email());
$request->setCompanyCode(get_option('tnwoo_company_code'));
$request->setDocType(DocumentType::$SalesOrder);
$request->setDetailLevel(DetailLevel::$Tax);
$request->setCurrencyCode(get_option('woocommerce_currency'));
$request->setBusinessIdentificationNo(get_option('tnwoo_business_vat_id'));
// Origin address
$origin = new Address();
$origin->setLine1(get_option('tnwoo_origin_street'));
$origin->setCity(get_option('tnwoo_origin_city'));
$origin->setRegion(get_option('tnwoo_origin_state'));
$origin->setPostalCode(get_option('tnwoo_origin_zip'));
$origin->setCountry(get_option('tnwoo_origin_country'));
$request->setOriginAddress($origin);
// Destination address
$destination = new Address();
$destination->setLine1($customer->get('shipping_address_1'));
$destination->setCity($customer->get('shipping_city'));
$destination->setRegion($customer->get('shipping_state'));
$destination->setPostalCode($customer->get('shipping_postcode'));
$destination->setCountry($customer->get('shipping_country'));
$request->setDestinationAddress($destination);
// Lines items
$items = $schedule->get_items();
$lines = array();
$global_tax_code = get_option('tnwoo_default_tax_code');
foreach ($items as $i => $item) {
// Get WooCommerce product ID
$product_id = $item->get_product_id();
// Create line item
$line = new Line();
$line->setItemCode($product_id);
$line->setDescription($product_id);
$tax_code = get_post_meta($product_id, '_taxnow_taxcode', true);
$line->setTaxCode(!empty($tax_code) ? $tax_code : $global_tax_code);
$line->setQty((int) $item->get_quantity());
$line->setAmount((double) $item->get_autoship_price());
$line->setNo($i + 1);
$line->setDiscounted(0);
$lines[] = $line;
}
$request->setLines($lines);
// Pretax discount
$discount_pretax = 0.0;
// Send request
$taxnow_woo->log_add_entry('calculate_tax', 'request', $request);
try {
$response = $service->getTax($request);
$taxnow_woo->log_add_entry('calculate_tax', 'response', $response);
if ($response->getResultCode() == SeverityLevel::$Success) {
foreach ($response->GetTaxLines() as $l => $TaxLine) {
foreach ($TaxLine->getTaxDetails() as $d => $TaxDetail) {
// Create WooCommerce tax rate
$tax_rate = array('rate' => 100.0 * $TaxDetail->getRate(), 'label' => $TaxDetail->getTaxName(), 'shipping' => 'no', 'compound' => 'no');
$tax_rates["wc_autoship_taxnow_{$l}_{$d}"] = $tax_rate;
}
}
}
} catch (Exception $e) {
$taxnow_woo->log_add_entry('calculate_tax', 'exception', $e->getMessage());
}
}
// Return tax rates
return $tax_rates;
}
示例10: getTax
function getTax($calculationHelper, $calc, $price, $sale = false, $committ = false)
{
if ($calc->activated == 0) {
return false;
}
$shopperData = $this->getShopperData();
if (!$shopperData) {
return false;
}
//if(self::$stop) return self::$stop;
if (!class_exists('TaxServiceSoap')) {
require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
}
if (!class_exists('DocumentType')) {
require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
}
if (!class_exists('DetailLevel')) {
require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('ServiceMode')) {
require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('GetTaxRequest')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php';
}
if (!class_exists('GetTaxResult')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
}
$client = new TaxServiceSoap('Development');
$request = new GetTaxRequest();
$origin = new Address();
//$destination = $this->fillValidateAvalaraAddress($calc);
//In Virtuemart we have not differenct warehouses, but we have a shipment address
//So when the vendor has a shipment address, we assume that it is his warehouse
//Later we can combine products with shipment addresses for different warehouse (yehye, future music)
//But for now we just use the BT address
if (!class_exists('VirtueMartModelVendor')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
}
$userId = VirtueMartModelVendor::getUserIdByVendorId($calc->virtuemart_vendor_id);
$userModel = VmModel::getModel('user');
$virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId);
// this is needed to set the correct user id for the vendor when the user is logged
$userModel->getVendor($calc->virtuemart_vendor_id);
$vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE);
$vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id];
//vmdebug('my vendor fields',$vendorFields);
$origin->setLine1($vendorFields['fields']['address_1']['value']);
$origin->setLine2($vendorFields['fields']['address_2']['value']);
$origin->setCity($vendorFields['fields']['city']['value']);
$origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']);
$origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']);
$origin->setPostalCode($vendorFields['fields']['zip']['value']);
$request->setOriginAddress($origin);
//Address
if (isset($this->addresses[0])) {
$destination = $this->addresses[0];
} else {
return FALSE;
}
$request->setDestinationAddress($destination);
//Address
//vmdebug('The date',$origin,$destination);
$request->setCompanyCode($calc->company_code);
// Your Company Code From the Dashboard
if ($calc->committ and $sale) {
$request->setDocType(DocumentType::$SalesInvoice);
// Only supported types are SalesInvoice or SalesOrder
$request->setCommit(true);
//invoice number, problem is that the invoice number is at this time not known, but the order_number may reachable
$request->setDocCode($committ);
vmdebug('Request as SalesInvoice with invoiceNumber ' . $committ);
} else {
$request->setDocType(DocumentType::$SalesOrder);
$request->setCommit(false);
//invoice number, problem is that the invoice number is at this time not known, neither the order_number
$request->setDocCode('VM2.0.16_order_request');
vmdebug('Request as SalesOrder');
}
$request->setDocDate(date('Y-m-d'));
//date
//$request->setSalespersonCode(""); // string Optional
$request->setCustomerCode($shopperData['customer_id']);
//string Required
if (isset($shopperData['tax_usage_type'])) {
$request->setCustomerUsageType($shopperData['tax_usage_type']);
//string Entity Usage
}
$cartPrices = $calculationHelper->getCartPrices();
//vmdebug('$cartPrices',$cartPrices);
$request->setDiscount($cartPrices['discountAmount']);
//decimal
//$request->setDiscount(0.0);
// $request->setPurchaseOrderNo(""); //string Optional
//.........这里部分代码省略.........
示例11: CalcTax
function CalcTax($taxSvcSoapClient, $companyCode)
{
$request = new GetTaxRequest();
$origin = new Address();
$destination = new Address();
$line1 = new Line();
$origin->setLine1("435 Ericksen Ave NE");
$origin->setLine2("Suite 200");
$origin->setCity("Bainbridge Island");
$origin->setRegion("WA");
$origin->setPostalCode("98110-1896");
$destination->setLine1("900 Winslow Way");
$destination->setLine2("Suite 200");
$destination->setCity("Bainbridge Island");
$destination->setRegion("WA");
$destination->setPostalCode("98110");
$request->setOriginAddress($origin);
//Address
$request->setDestinationAddress($destination);
//Address
$request->setCompanyCode($companyCode);
// Your Company Code From the Dashboard
$request->setDocType(DocumentType::$SalesInvoice);
// Only supported types are SalesInvoice or SalesOrder
$dateTime = new DateTime();
$docCode = "PHPSample" . date_format($dateTime, "dmyGis");
$request->setDocCode($docCode);
// invoice number
$request->setDocDate(date_format($dateTime, "Y-m-d"));
//date
$request->setSalespersonCode("");
// string Optional
$request->setCustomerCode("Cust123");
//string Required
$request->setCustomerUsageType("");
//string Entity Usage
$request->setDiscount(0.0);
//decimal
$request->setPurchaseOrderNo("");
//string Optional
$request->setExemptionNo("");
//string if not using ECMS which keys on customer code
$request->setDetailLevel(DetailLevel::$Document);
$request->setCommit("true");
// commit upon tax calc
$request->setReferenceCode("");
//string Optional
$request->setLocationCode("");
//string Optional - aka outlet id for tax forms
$line1->setNo("1");
//string // line Number of invoice
$line1->setItemCode("SKU123");
//string
$line1->setDescription("Invoice Calculated From PHP SDK");
//string
$line1->setTaxCode("");
//string
$line1->setQty(1.0);
//decimal
$line1->setAmount(1000.0);
//decimal // TotalAmmount
$line1->setDiscounted(false);
//boolean
$line1->setRevAcct("");
//string
$line1->setRef1("");
//string
$line1->setRef2("");
//string
$line1->setExemptionNo("");
//string
$line1->setCustomerUsageType("");
//string
$request->setLines(array($line1));
//array
try {
$getTaxResult = $taxSvcSoapClient->getTax($request);
echo 'GetTax Result: ' . $getTaxResult->getResultCode() . "\n";
if ($getTaxResult->getResultCode() == SeverityLevel::$Success) {
echo "DocCode: " . $request->getDocCode() . "\n";
echo "TotalAmount: " . $getTaxResult->getTotalAmount() . "\n";
echo "TotalTax: " . $getTaxResult->getTotalTax() . "\n";
} else {
foreach ($getTaxResult->getMessages() as $msg) {
echo $msg->getName() . ": " . $msg->getSummary() . "\n";
}
}
} catch (SoapFault $exception) {
$msg = "Exception: ";
if ($exception) {
$msg .= $exception->faultstring;
}
echo $msg . "\n";
echo $taxSvcSoapClient->__getLastRequest() . "\n";
echo $taxSvcSoapClient->__getLastResponse() . "\n";
}
return $request->getDocCode();
}
示例12: CreateTaxRequestForBINo
private function CreateTaxRequestForBINo($bino)
{
$request = new GetTaxRequest();
//Set origin Address
$origin = new Address();
$origin->setLine1("Avalara");
$origin->setLine2("900 winslow way");
$origin->setLine3("Suite 100");
$origin->setCity("Bainbridge Island");
$origin->setRegion("WA");
$origin->setPostalCode("98110-1896");
$origin->setCountry("USA");
$request->setOriginAddress($origin);
//Set destination address
$destination = new Address();
$destination->setLine1("3130 Elliott");
$destination->setCity("Seattle");
$destination->setRegion("WA");
$destination->setPostalCode("98121");
$destination->setCountry("USA");
$request->setDestinationAddress($destination);
//Set line
$line = new Line();
$line->setNo("1");
//string // line Number of invoice
$line->setBusinessIdentificationNo("LL123");
$line->setItemCode("Item123");
//string
$line->setQty(1.0);
//decimal
$line->setAmount(1010.0);
$request->setLines(array($line));
$request->setCompanyCode('DEFAULT');
// Your Company Code From the Dashboard
$request->setDocCode("DocTypeTest");
$request->setBusinessIdentificationNo($bino);
$request->setDocDate(date_format(new DateTime(), "Y-m-d"));
$request->setCustomerCode("TaxSvcTest");
//string Required
$request->setSalespersonCode("");
// string Optional
$request->setDetailLevel(DetailLevel::$Tax);
//Summary or Document or Line or Tax or Diagnostic
return $request;
}
示例13: _newAddress
/**
* Generic address maker
*
* @param string $line1
* @param string $line2
* @param string $city
* @param string $state
* @param string $zip
* @param string $country
* @return Address
*/
protected function _newAddress($line1, $line2, $city, $state, $zip, $country = 'USA')
{
// force string type because hash key generation uses serialize() in Estimate.php
$address = new Address();
$address->setLine1((string) $line1);
$address->setLine2((string) $line2);
$address->setCity((string) $city);
$address->setRegion((string) $state);
$address->setPostalCode((string) $zip);
$address->setCountry((string) $country);
return $address;
}
示例14: convertAddress
/**
* Converts the address fetched from the database to the Address object.
*/
private function convertAddress($row)
{
$formatted = $row['unstructured_address'];
if (empty($formatted)) {
$formatted = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']);
$formatted = empty($formatted) ? $formatted : null;
}
$address = new Address($formatted);
$address->setCountry($row['country']);
$address->setLatitude($row['latitude']);
$address->setLongitude($row['longitude']);
$address->setLocality($row['locality']);
$address->setPostalCode($row['postal_code']);
$address->setRegion($row['region']);
$address->setStreetAddress($row['street_address']);
$address->setType($row['address_type']);
$address->setUnstructuredAddress($row['unstructured_address']);
$address->setExtendedAddress($row['extended_address']);
$address->setPoBox($row['po_box']);
return $address;
}
示例15: getPeople
public function getPeople($ids, $fields, $options, $token)
{
$first = $options->getStartIndex();
$max = $options->getCount();
$this->checkDb();
$ret = array();
$filterQuery = '';
if ($options->getFilterBy() == 'hasApp') {
// remove the filterBy field, it's taken care of in the query already, otherwise filterResults will disqualify all results
$options->setFilterBy(null);
$appId = $token->getAppId();
$filterQuery = " and id in (select member_id from " . TABLE_PREFIX . "social_applications where application_id = {$appId})";
} elseif ($options->getFilterBy() == 'all') {
$options->setFilterBy(null);
}
$query = "SELECT member.*, info.interests, info.associations, info.awards FROM " . TABLE_PREFIX . "members member LEFT JOIN " . TABLE_PREFIX . "social_member_additional_information info ON member.member_id=info.member_id WHERE member.member_id IN (" . implode(',', $ids) . ") {$filterQuery} ORDER BY member.member_id ";
$res = mysql_query($query, $this->db);
if ($res) {
while ($row = mysql_fetch_assoc($res)) {
$member_id = intval($row['member_id']);
$name = new Name($row['first_name'] . ' ' . $row['last_name']);
$name->setGivenName($row['first_name']);
$name->setFamilyName($row['last_name']);
$person = new Person($row['member_id'], $name);
$person->setDisplayName($name->getFormatted());
$person->setAboutMe($row['about_me']);
$person->setAge($row['age']);
$person->setChildren($row['children']);
$person->setBirthday(date('Y-m-d', $row['date_of_birth']));
$person->setEthnicity($row['ethnicity']);
$person->setFashion($row['fashion']);
$person->setHappiestWhen($row['happiest_when']);
$person->setHumor($row['humor']);
$person->setJobInterests($row['job_interests']);
$person->setLivingArrangement($row['living_arrangement']);
$person->setLookingFor($row['looking_for']);
$person->setNickname($row['nickname']);
$person->setPets($row['pets']);
$person->setPoliticalViews($row['political_views']);
$person->setProfileSong($row['profile_song']);
$person->setProfileUrl($this->url_prefix . '/profile/' . $row['member_id']);
$person->setProfileVideo($row['profile_video']);
$person->setRelationshipStatus($row['relationship_status']);
$person->setReligion($row['religion']);
$person->setRomance($row['romance']);
$person->setScaredOf($row['scared_of']);
$person->setSexualOrientation($row['sexual_orientation']);
$person->setStatus($row['status']);
$person->setThumbnailUrl(!empty($row['thumbnail_url']) ? $this->url_prefix . $row['thumbnail_url'] : '');
if (!empty($row['thumbnail_url'])) {
// also report thumbnail_url in standard photos field (this is the only photo supported by ATutor)
$person->setPhotos(array(new Photo($this->url_prefix . 'get_profile_img.php?id=' . $row['member_id'], 'thumbnail', true)));
}
$person->setUtcOffset(sprintf('%+03d:00', $row['time_zone']));
// force "-00:00" utc-offset format
if (!empty($row['drinker'])) {
$person->setDrinker($row['drinker']);
}
if (!empty($row['gender'])) {
$person->setGender(strtolower($row['gender']));
}
if (!empty($row['email'])) {
//TODO: Assumed <static> object TYPE to be "home". Change it if ATutor starts accepting more than one email
$email = new Email(strtolower($row['email']), 'home');
$person->setEmails($email);
}
if (!empty($row['interests'])) {
$strings = explode(',', $row['interests']);
$person->setInterests($strings);
}
//TODO: Not in ATutor yet, skeleton field
if (!empty($row['smoker'])) {
$person->setSmoker($row['smoker']);
}
/* the following fields require additional queries so are only executed if requested */
if (isset($fields['activities']) || isset($fields['@all'])) {
$activities = array();
$sql = "select title from " . TABLE_PREFIX . "social_activities where member_id = " . $member_id;
$res2 = mysql_query($sql, $this->db);
while (list($activity) = mysql_fetch_row($res2)) {
$activities[] = $activity;
}
$person->setActivities($activities);
}
if (isset($fields['addresses']) || isset($fields['@all'])) {
$addresses = array();
$sql = "select address, postal, city, province, country from " . TABLE_PREFIX . "members m where m.member_id = " . $member_id;
$res2 = mysql_query($sql, $this->db);
while ($row = mysql_fetch_assoc($res2)) {
if (empty($row['unstructured_address'])) {
$row['unstructured_address'] = trim($row['street_address'] . " " . $row['province'] . " " . $row['country']);
}
$addres = new Address($row['unstructured_address']);
$addres->setCountry($row['country']);
$addres->setLatitude($row['latitude']);
$addres->setLongitude($row['longitude']);
$addres->setLocality($row['locality']);
$addres->setPostalCode($row['postal_code']);
$addres->setRegion($row['province']);
$addres->setStreetAddress($row['street_address']);
//.........这里部分代码省略.........