Ejemplo n.º 1
0
    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',
        )
Ejemplo n.º 2
0
    def get_ship_from(country="GB"):
        """Returns a shipfrom from a known country"""
        if country == "GB":
            ship_from_address = ShipmentConfirm.address_type(
                AddressLine1="2,Hope Rd",
                AddressLine2="Anson Road",
                City="Manchester",
                CountryCode="GB",
                PostalCode="M145EU"
            )
        elif country == "US":
            ship_from_address = ShipmentConfirm.address_type(
                AddressLine1="245 NE 24th Street",
                AddressLine2="Suite 108",
                City="Miami",
                StateProvinceCode="FL",
                CountryCode="US",
                PostalCode="33137"
            )
        else:
            raise Exception("This country is not supported")

        return ShipmentConfirm.ship_from_type(
            ship_from_address,
            CompanyName="Openlabs",
            AttentionName="Someone other than Sharoon",
            TaxIdentificationNumber="33065",
            PhoneNumber='0987654321',
        )
Ejemplo n.º 3
0
    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',
        )
Ejemplo n.º 4
0
    def get_ship_from(country="GB"):
        """Returns a shipfrom from a known country"""
        if country == "GB":
            ship_from_address = ShipmentConfirm.address_type(
                AddressLine1="2,Hope Rd",
                AddressLine2="Anson Road",
                City="Manchester",
                CountryCode="GB",
                PostalCode="M145EU")
        elif country == "US":
            ship_from_address = ShipmentConfirm.address_type(
                AddressLine1="245 NE 24th Street",
                AddressLine2="Suite 108",
                City="Miami",
                StateProvinceCode="FL",
                CountryCode="US",
                PostalCode="33137")
        else:
            raise Exception("This country is not supported")

        return ShipmentConfirm.ship_from_type(
            ship_from_address,
            CompanyName="Openlabs",
            AttentionName="Someone other than Sharoon",
            TaxIdentificationNumber="33065",
            PhoneNumber='0987654321',
        )
    def get_address(doc, is_ship_from=False):
        addr = ""
        if is_ship_from:
            address_line1 = doc.address_line_1 or ""
            address_line2 = doc.address_line_2 or ""
            city = doc.city or ""
            state = doc.state or ""
            country_code = doc.country or ""
            pincode = doc.pin_code or ""
            addr = "warehouse"
        else:
            address_line1 = doc.address_line1 or ""
            address_line2 = doc.address_line2 or ""
            city = doc.city or ""
            state = doc.state or ""
            country_code = frappe.db.get_value("Country", doc.country,
                                               "code") or ""
            pincode = str(doc.pincode) or ""
            addr = "shipping"

        if address_line1 and city and state and country_code and pincode:
            return ShipmentConfirm.address_type(
                AddressLine1=address_line1,
                AddressLine2=address_line2,
                City=city,
                StateProvinceCode=state,
                CountryCode=country_code,
                PostalCode=pincode,
            )
        else:
            frappe.throw(
                "Invalid address details, Please check the %s address" %
                (addr))
Ejemplo n.º 6
0
    def _get_ups_address_xml(self):
        """
        Return Address XML
        """
        if not all([self.street, self.city, self.country]):
            self.raise_user_error("Street, City and Country are required.")

        if self.country.code in ["US", "CA"] and not self.subdivision:
            self.raise_user_error("State is required for %s" % self.country.code)

        if self.country.code in ["US", "CA", "PR"] and not self.zip:
            # If Shipper country is US or Puerto Rico, 5 or 9 digits is
            # required. The character - may be used to separate the first five
            # digits and the last four digits. If the Shipper country is CA,
            # then the postal code is required and must be 6 alphanumeric
            # characters whose format is A#A#A# where A is an uppercase letter
            # and # is a digit. For all other countries the postal code is
            # optional and must be no more than 9 alphanumeric characters long.
            self.raise_user_error("ZIP is required for %s" % self.country.code)

        vals = {
            "AddressLine1": self.street[:35],  # Limit to 35 Char
            "City": self.city[:30],  # Limit 30 Char
            "CountryCode": self.country.code,
        }

        if self.streetbis:
            vals["AddressLine2"] = self.streetbis[:35]  # Limit to 35 char
        if self.subdivision:
            # TODO: Handle Ireland Case
            vals["StateProvinceCode"] = self.subdivision.code[3:]
        if self.zip:
            vals["PostalCode"] = self.zip

        return ShipmentConfirm.address_type(**vals)
    def get_address(doc, is_ship_from= False):
        addr = ""
        if is_ship_from:
            address_line1 = doc.address_line_1 or ""
            address_line2 = doc.address_line_2 or ""
            city = doc.city or ""
            state = doc.state or ""
            country_code = doc.country or ""
            pincode = doc.pin_code or ""
            addr = "warehouse"
        else:
            address_line1 = doc.address_line1 or ""
            address_line2 = doc.address_line2 or ""
            city = doc.city or ""
            state = doc.state or ""
            country_code = frappe.db.get_value("Country",doc.country,"code") or ""
            pincode = str(doc.pincode) or ""
            addr = "shipping"

        if address_line1 and city and state and country_code and pincode:
            return ShipmentConfirm.address_type(
                AddressLine1= address_line1,
                AddressLine2= address_line2,
                City= city,
                StateProvinceCode= state,
                CountryCode= country_code,
                PostalCode= pincode,
            )
        else:
            frappe.throw("Invalid address details, Please check the %s address"%(addr))
Ejemplo n.º 8
0
    def _get_ups_address_xml(self):
        """
        Return Address XML
        """
        if not all([self.street, self.city, self.country]):
            self.raise_user_error("Street, City and Country are required.")

        if self.country.code in ['US', 'CA'] and not self.subdivision:
            self.raise_user_error(
                "State is required for %s" % self.country.code
            )

        if self.country.code in ['US', 'CA', 'PR'] and not self.zip:
            # If Shipper country is US or Puerto Rico, 5 or 9 digits is
            # required. The character - may be used to separate the first five
            # digits and the last four digits. If the Shipper country is CA,
            # then the postal code is required and must be 6 alphanumeric
            # characters whose format is A#A#A# where A is an uppercase letter
            # and # is a digit. For all other countries the postal code is
            # optional and must be no more than 9 alphanumeric characters long.
            self.raise_user_error("ZIP is required for %s" % self.country.code)

        vals = {
            'AddressLine1': self.street[:35],  # Limit to 35 Char
            'City': self.city[:30],  # Limit 30 Char
            'CountryCode': self.country.code,
        }

        if self.streetbis:
            vals['AddressLine2'] = self.streetbis[:35]  # Limit to 35 char
        if self.subdivision:
            # TODO: Handle Ireland Case
            vals['StateProvinceCode'] = self.subdivision.code[3:]
        if self.zip:
            vals['PostalCode'] = self.zip

        return ShipmentConfirm.address_type(**vals)