def get_ship_to(country="GB"): """Returns a shipto to a known country""" if country == "GB": ship_to_address = ShipmentConfirm.address_type( AddressLine1="205, Copper Gate House", AddressLine2="16 Brune Street", City="London", # StateProvinceCode="E1 7NJ", CountryCode="GB", PostalCode="E1 7NJ" ) elif country == "US": ship_to_address = ShipmentConfirm.address_type( AddressLine1="1 Infinite Loop", City="Cupertino", StateProvinceCode="CA", CountryCode="US", PostalCode="95014" ) else: raise Exception("This country is not supported") return ShipmentConfirm.ship_to_type( ship_to_address, CompanyName="Apple", AttentionName="Someone other than Steve", TaxIdentificationNumber="123456", PhoneNumber='4089961010', )
def get_ship_to(country="GB"): """Returns a shipto to a known country""" if country == "GB": ship_to_address = ShipmentConfirm.address_type( AddressLine1="205, Copper Gate House", AddressLine2="16 Brune Street", City="London", # StateProvinceCode="E1 7NJ", CountryCode="GB", PostalCode="E1 7NJ") elif country == "US": ship_to_address = ShipmentConfirm.address_type( AddressLine1="1 Infinite Loop", City="Cupertino", StateProvinceCode="CA", CountryCode="US", PostalCode="95014") else: raise Exception("This country is not supported") return ShipmentConfirm.ship_to_type( ship_to_address, CompanyName="Apple", AttentionName="Someone other than Steve", TaxIdentificationNumber="123456", PhoneNumber='4089961010', )
def get_ship_to_address(params, address_name): doc = frappe.get_doc("Address", address_name) if not doc: frappe.throw("Can not fetch Customer Address") else: ship_to_address = UPSHelper.get_address(doc, False) return ShipmentConfirm.ship_to_type( ship_to_address, CompanyName=params.get("customer") or "", AttentionName=params.get("contact_display") or doc.customer_name or "", # TaxIdentificationNumber="", # PhoneNumber= params.get("contact_mobile"), PhoneNumber=doc.phone or "")
def get_ship_to_address(params, address_name): doc = frappe.get_doc("Address", address_name) if not doc: frappe.throw("Can not fetch Customer Address") else: ship_to_address = UPSHelper.get_address(doc, False) return ShipmentConfirm.ship_to_type( ship_to_address, CompanyName= params.get("customer") or "", AttentionName= params.get("contact_display") or doc.customer_name or "", # TaxIdentificationNumber="", # PhoneNumber= params.get("contact_mobile"), PhoneNumber= doc.phone or "" )
def to_ups_to_address(self): """ Converts party address to UPS `To Address`. :return: Returns instance of ToAddress """ party = self.party tax_identification_number = "" if party.identifiers: tax_identification_number = party.identifiers[0].code elif hasattr(party, "tax_exemption_number") and party.tax_exemption_number: tax_identification_number = party.tax_exemption_number vals = { "CompanyName": self.name or party.name, "TaxIdentificationNumber": tax_identification_number, "AttentionName": self.name or party.name, } if getattr(self, "phone"): phone = getattr(self, "phone") else: phone = party.phone if phone: vals["PhoneNumber"] = digits_only_re.sub("", phone) fax = party.fax if fax: vals["FaxNumber"] = fax # EMailAddress email = party.email if email: vals["EMailAddress"] = email # TODO: LocationID is optional return ShipmentConfirm.ship_to_type(self._get_ups_address_xml(), **vals)
def to_ups_to_address(self): ''' Converts party address to UPS `To Address`. :return: Returns instance of ToAddress ''' party = self.party tax_identification_number = '' if party.vat_number: tax_identification_number = party.vat_number elif hasattr(party, 'tax_exemption_number') and \ party.tax_exemption_number: tax_identification_number = party.tax_exemption_number vals = { 'CompanyName': self.name or party.name, 'TaxIdentificationNumber': tax_identification_number, 'AttentionName': self.name or party.name, } if party.phone: vals['PhoneNumber'] = digits_only_re.sub('', party.phone) fax = party.fax if fax: vals['FaxNumber'] = fax # EMailAddress email = party.email if email: vals['EMailAddress'] = email # TODO: LocationID is optional return ShipmentConfirm.ship_to_type(self._get_ups_address_xml(), **vals)