当前位置: 首页>>代码示例>>Python>>正文


Python shipping_package.ShipmentConfirm类代码示例

本文整理汇总了Python中ups.shipping_package.ShipmentConfirm的典型用法代码示例。如果您正苦于以下问题:Python ShipmentConfirm类的具体用法?Python ShipmentConfirm怎么用?Python ShipmentConfirm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ShipmentConfirm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_packages

    def get_packages(packing_slips, package_type_code):
        packages = []

        for docname in packing_slips:
            doc = frappe.get_doc("Packing Slip",docname)
            # item = frappe.get_doc("Item", doc.package_used)
            item = frappe.db.get_value("Custom UOM Conversion Details", {
                        "parent": doc.package_used,
                        "uom": "Nos"
                    }, ["length", "width", "height"], as_dict=True)
            package_ref = "%s/%s"%(doc.delivery_note, doc.name)

            package_weight = ShipmentConfirm.package_weight_type(
                Weight= str(doc.gross_weight_pkg), Code="LBS", Description="Weight In Pounds")

            dimensions = ShipmentConfirm.dimensions_type(
                Code="IN",
                Description="Deimensions In Inches",
                Length= str(item.get("length")) or "0",
                Width= str(item.get("width")) or "0",
                Height= str(item.get("height")) or "0",
            )

            package_type = ShipmentConfirm.packaging_type(Code=package_type_code)

            package = ShipmentConfirm.package_type(
                package_type,
                package_weight,
                dimensions,
                # E.ReferenceNumber(E.Value(package_ref)),
            )

            packages.append(package)

        return packages
开发者ID:aruizramon,项目名称:alec_frappe_subscription,代码行数:35,代码来源:ups_helper.py

示例2: get_ship_to

    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',
        )
开发者ID:openlabs,项目名称:PyUPS,代码行数:29,代码来源:helper.py

示例3: get_ship_from

    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',
        )
开发者ID:openlabs,项目名称:PyUPS,代码行数:29,代码来源:helper.py

示例4: test_0020_gb_gb

    def test_0020_gb_gb(self):
        "GB to GB UPS Standard with 2 packages"
        ship_confirm_request = ShipmentConfirm.shipment_confirm_request_type(
            Helper.get_shipper(self.shipper_number, "GB"),
            Helper.get_ship_to("GB"),
            Helper.get_ship_from("GB"),

            # Package 1
            Helper.get_package(
                "GB", weight='15.0', package_type_code='02'
            ),  # Customer Supplied Package

            # Package 2
            Helper.get_package(
                "GB", weight='15.0', package_type_code='02'
            ),  # Customer Supplied Package

            Helper.get_payment_info(AccountNumber=self.shipper_number),
            ShipmentConfirm.service_type(Code='11'),    # UPS Standard
            Description=__doc__[:50]
        )
        response = self.shipment_confirm_api.request(ship_confirm_request)
        digest = self.shipment_confirm_api.extract_digest(response)

        # now accept the package
        accept_request = ShipmentAccept.shipment_accept_request_type(digest)
        self.shipment_accept_api.request(accept_request)
开发者ID:sharoonthomas,项目名称:PyUPS,代码行数:27,代码来源:test_shipping_package_gb_xx.py

示例5: _get_ups_packages

    def _get_ups_packages(self):
        """
        Return UPS Packages XML
        """
        UPSConfiguration = Pool().get('ups.configuration')

        ups_config = UPSConfiguration(1)
        package_type = ShipmentConfirm.packaging_type(
            Code=self.ups_package_type
        )  # FIXME: Support multiple packaging type

        weight = self.package_weight.quantize(
            Decimal('.01'), rounding=ROUND_UP
        )
        package_weight = ShipmentConfirm.package_weight_type(
            Weight=str(weight),
            Code=ups_config.weight_uom_code,
        )
        package_service_options = ShipmentConfirm.package_service_options_type(
            ShipmentConfirm.insured_value_type(MonetaryValue='0')
        )
        package_container = ShipmentConfirm.package_type(
            package_type,
            package_weight,
            package_service_options
        )
        return [package_container]
开发者ID:mbehrle,项目名称:trytond-shipping-ups,代码行数:27,代码来源:stock.py

示例6: get_packages

    def get_packages(packing_slips, package_type_code):
        packages = []

        for docname in packing_slips:
            doc = frappe.get_doc("Packing Slip",docname)
            item = frappe.get_doc("Item", doc.package_used)
            package_ref = "%s/%s"%(doc.delivery_note, doc.name)

            package_weight = ShipmentConfirm.package_weight_type(
                Weight= str(doc.gross_weight_pkg), Code="LBS", Description="Weight In Pounds")

            dimensions = ShipmentConfirm.dimensions_type(
                Code="IN",
                Description="Deimensions In Inches",
                Length= str(item.length) or "0",
                Width= str(item.width) or "0",
                Height= str(item.height) or "0",
            )

            package_type = ShipmentConfirm.packaging_type(Code=package_type_code)

            package = ShipmentConfirm.package_type(
                package_type,
                package_weight,
                dimensions,
                # E.ReferenceNumber(E.Value(package_ref)),
            )

            packages.append(package)

        return packages
开发者ID:patilsangram,项目名称:Aleck-Frappe-subscription,代码行数:31,代码来源:ups_helper.py

示例7: test_0010_blow_up

 def test_0010_blow_up(self):
     """Send a stupid request which should blow up because its valid in the
     client but not in UPS server. Example: dont send packages"""
     with self.assertRaises(PyUPSException):
         ship_confirm_request = ShipmentConfirm.shipment_confirm_request_type(
             Helper.get_shipper(self.shipper_number, "GB"),
             Helper.get_ship_to("GB"),
             Helper.get_ship_from("GB"),
             Helper.get_payment_info(AccountNumber=self.shipper_number),
             ShipmentConfirm.service_type(Code="11"),  # UPS Standard
             Description=__doc__[:50],
         )
         self.shipment_confirm_api.request(ship_confirm_request)
开发者ID:openlabs,项目名称:PyUPS,代码行数:13,代码来源:test_shipping_package_gb_xx.py

示例8: get_address

    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))
开发者ID:aruizramon,项目名称:alec_frappe_subscription,代码行数:30,代码来源:ups_helper.py

示例9: _get_ups_address_xml

    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)
开发者ID:fulfilio,项目名称:trytond-shipping-ups,代码行数:35,代码来源:party.py

示例10: get_payment_info

    def get_payment_info(type="prepaid", **kwargs):
        """Returns the payment info filled

        :param type: The payment type.

        .. note::
            if payment type is prepaid AccountNumber must be provided.
        """
        if type == 'prepaid':
            assert 'AccountNumber' in kwargs
            return ShipmentConfirm.payment_information_type(
                ShipmentConfirm.payment_information_prepaid_type(
                    AccountNumber=kwargs['AccountNumber'])
            )
        else:
            raise Exception("Type %s is not supported" % type)
开发者ID:aruizramon,项目名称:alec_frappe_subscription,代码行数:16,代码来源:ups_helper.py

示例11: _get_shipment_confirm_xml

    def _get_shipment_confirm_xml(self):
        """
        Return XML of shipment for shipment_confirm
        """
        Company = Pool().get('company.company')
        UPSConfiguration = Pool().get('ups.configuration')

        ups_config = UPSConfiguration(1)
        if not self.ups_service_type:
            self.raise_user_error('ups_service_type_missing')

        payment_info_prepaid = \
            ShipmentConfirm.payment_information_prepaid_type(
                AccountNumber=ups_config.shipper_no
            )
        payment_info = ShipmentConfirm.payment_information_type(
            payment_info_prepaid)
        packages = self._get_ups_packages()
        shipment_service = ShipmentConfirm.shipment_service_option_type(
            SaturdayDelivery='1' if self.ups_saturday_delivery
            else 'None'
        )
        description = ','.join([
            move.product.name for move in self.outgoing_moves
        ])

        shipment_args = [
            self.warehouse.address.to_ups_shipper(),
            self.delivery_address.to_ups_to_address(),
            self.warehouse.address.to_ups_from_address(),
            ShipmentConfirm.service_type(Code=self.ups_service_type.code),
            payment_info, shipment_service,
        ]
        if ups_config.negotiated_rates:
            shipment_args.append(
                ShipmentConfirm.rate_information_type(negotiated=True)
            )
        if self.warehouse.address.country.code == 'US' and \
                self.delivery_address.country.code in ['PR', 'CA']:
            # Special case for US to PR or CA InvoiceLineTotal should be sent
            monetary_value = str(sum(map(
                lambda move: move.get_monetary_value_for_ups(),
                self.outgoing_moves
            )))

            company_id = Transaction().context.get('company')
            if not company_id:
                self.raise_user_error("Company is not in context")

            company = Company(company_id)
            shipment_args.append(ShipmentConfirm.invoice_line_total_type(
                MonetaryValue=monetary_value,
                CurrencyCode=company.currency.code
            ))

        shipment_args.extend(packages)
        shipment_confirm = ShipmentConfirm.shipment_confirm_request_type(
            *shipment_args, Description=description[:35]
        )
        return shipment_confirm
开发者ID:mbehrle,项目名称:trytond-shipping-ups,代码行数:60,代码来源:stock.py

示例12: get_ups_package_container

    def get_ups_package_container(self):
        """
        Return UPS package container for a single package
        """
        shipment = self.shipment
        carrier = shipment.carrier

        package_type = ShipmentConfirm.packaging_type(
            Code=shipment.ups_package_type
        )  # FIXME: Support multiple packaging type

        package_weight = ShipmentConfirm.package_weight_type(
            Weight="%.2f" % self.weight, Code=carrier.ups_weight_uom_code
        )
        package_service_options = ShipmentConfirm.package_service_options_type(
            ShipmentConfirm.insured_value_type(MonetaryValue="0")
        )
        package_container = ShipmentConfirm.package_type(package_type, package_weight, package_service_options)
        return package_container
开发者ID:riteshshrv,项目名称:trytond-shipping-ups,代码行数:19,代码来源:stock.py

示例13: test_0030_gb_gb_saturday

    def test_0030_gb_gb_saturday(self):
        "GB to GB UPS Standard with 2 packages and Saturday delivery"
        ship_confirm_request = ShipmentConfirm.shipment_confirm_request_type(
            Helper.get_shipper(self.shipper_number, "GB"),
            Helper.get_ship_to("GB"),
            Helper.get_ship_from("GB"),
            # Package 1
            Helper.get_package("GB", weight="15.0", package_type_code="02"),  # Customer Supplied Package
            # Package 2
            Helper.get_package("GB", weight="15.0", package_type_code="02"),  # Customer Supplied Package
            ShipmentConfirm.shipment_service_option_type(SaturdayDelivery="1"),
            Helper.get_payment_info(AccountNumber=self.shipper_number),
            ShipmentConfirm.service_type(Code="11"),  # UPS Standard
            Description=__doc__[:50],
        )
        response = self.shipment_confirm_api.request(ship_confirm_request)
        digest = self.shipment_confirm_api.extract_digest(response)

        # now accept the package
        accept_request = ShipmentAccept.shipment_accept_request_type(digest)
        self.shipment_accept_api.request(accept_request)
开发者ID:openlabs,项目名称:PyUPS,代码行数:21,代码来源:test_shipping_package_gb_xx.py

示例14: get_ups_shipment_confirm_request

def get_ups_shipment_confirm_request(delivery_note, params):
    dn = delivery_note
    packing_slips = [row.packing_slip for row in dn.packing_slip_details]
    if not packing_slips:
        frappe.throw("Can not find the linked Packing Slip ...")

    ship_from_address_name = params.get("default_warehouse")
    shipper_number = params.get("shipper_number")
    package_type = ups_packages.get(params.get("package_type"))
    rates = {}
    if dn.ups_rates:
        rates = json.loads(dn.ups_rates)
    service_code = rates.get("service_used") or "03"
    ship_to_params = {
        "customer":dn.customer,
        "contact_display":dn.contact_display,
        "contact_mobile":dn.contact_mobile
    }

    packages = Helper.get_packages(packing_slips, package_type)

    request = ShipmentConfirm.shipment_confirm_request_type(
        Helper.get_shipper(params),
        Helper.get_ship_to_address(ship_to_params, dn.shipping_address_name,),
        Helper.get_ship_from_address(params, ship_from_address_name),
        Helper.get_payment_info(AccountNumber=shipper_number),
        ShipmentConfirm.service_type(Code=service_code),
        # Labal specification container
        LabelSpecification = E.LabelSpecification(
            E.LabelPrintMethod(E.Code("ZPL"),),
            E.LabelStockSize(E.Height("4"),E.Width("6"),),
            E.LabelImageFormat(E.Code("ZPL"),),
        ),
        Description="Description"
    )
    request.find("Shipment").extend(packages)

    return request
开发者ID:mbauskar,项目名称:alec_frappe_subscription,代码行数:38,代码来源:ups_shipping_package.py

示例15: get_ship_from_address

    def get_ship_from_address(params, address_name):
        doc = frappe.get_doc("Warehouse",address_name)
        if not doc:
            frappe.throw("Can not fetch Shipper Address")
        else:
            ship_from_address = UPSHelper.get_address(doc,True)

            return ShipmentConfirm.ship_from_type(
                ship_from_address,
                CompanyName= params.get("attention_name") or "",
                AttentionName= params.get("user_name") or "",
                # TaxIdentificationNumber="",
                PhoneNumber= doc.phone_no or "",
            )
开发者ID:aruizramon,项目名称:alec_frappe_subscription,代码行数:14,代码来源:ups_helper.py


注:本文中的ups.shipping_package.ShipmentConfirm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。