Beispiel #1
0
        def topic(self):
            cep_origem = '00000-000'
            cep_destino = '11111-111'
            client = Client(cep_origem=cep_origem)
            package = Package()
            package.add_item(weight=1, height=2, width=3, length=4)

            expected = (
                '',  # nCdEmpresa
                '',  # sDsSenha
                '40010,41106',  # nCdServico
                cep_origem,  # sCepOrigem
                cep_destino,  # sCepDestino
                1,  # nVlPeso
                CAIXA_PACOTE,  # nCdFormato
                4,  # nVlComprimento
                2,  # nVlAltura
                3,  # nVlLargura
                0,  # nVlDiametro
                False,  # sCdMaoPropria
                0.0,  # nVlValorDeclarado
                False  # sCdAvisoRecebimento
            )

            result = client.build_web_service_call_args(
                package, cep_destino, *(SEDEX, PAC))

            for expected_value, actual_value in zip(expected, result):
                yield (expected_value, actual_value)
        def topic(self):
            cep_origem  = '00000-000'
            cep_destino = '11111-111'
            client = Client(cep_origem=cep_origem)
            package = Package()
            package.add_item(weight=1, height=2, width=3, length=4)

            expected = (
                '',            # nCdEmpresa
                '',            # sDsSenha
                '40010,41106', # nCdServico
                cep_origem,    # sCepOrigem
                cep_destino,   # sCepDestino
                1,             # nVlPeso
                CAIXA_PACOTE,  # nCdFormato
                4,             # nVlComprimento
                2,             # nVlAltura
                3,             # nVlLargura
                0,             # nVlDiametro
                False,         # sCdMaoPropria
                0.0,           # nVlValorDeclarado
                False          # sCdAvisoRecebimento
            )

            result = client.build_web_service_call_args(package, cep_destino,
                    *(SEDEX, PAC))

            for expected_value, actual_value in zip(expected, result):
                yield (expected_value, actual_value)
Beispiel #3
0
    def calculate(self, basket, postcode):
        # If the charge is free then tax must be free (musn't it?) and so we
        # immediately set the tax to zero
        package = Package(formato=CAIXA_PACOTE)
        tax = D(0)
        ret = {}
        try:
            for line in basket.lines.all():
                product = line.product
                weight = product.weight
                height = product.height
                width = product.width
                length = product.length
                if all([weight, height, width, length]):

                    for qty in range(line.quantity):
                        package.add_item(
                            weight=weight,  # Peso
                            height=height,  # Altura
                            width=width,  # Largura
                            length=length  # Comprimento
                        )
            client = Client(cep_origem='31330-130')
            servicos = client.calc_preco_prazo(package, postcode, SEDEX)
            ret.update(service=servicos[0])
            for servico in servicos:
                tax += D(servico.valor)
        except Exception as e:
            print('*******ERRO:', e)
        price = prices.Price(currency=basket.currency,
                             excl_tax=D('0.00'),
                             tax=tax)
        ret.update(price=price)
        return ret
Beispiel #4
0
    def topic(self):
        client = Client(cep_origem='01310-200')
        package = Package()
        package.add_item(weight=0.5, height=6.0, width=16.0, length=16.0)
        result = client.calc_preco_prazo(package, '52020-010', SEDEX, PAC)

        for code, service in zip([SEDEX, PAC], result):
            yield code, service
 def topic(self):
      package = Package()
      args = (
           ('weight', 1),
           ('height', 2),
           ('width', 3),
           ('length', 4)
      )
      return (args, package.add_item(**dict(args)), package)
          def topic(self):
               package = Package()
               args = (
                    ('weight', 1),
                    ('height', 2),
                    ('width', 3),
                    ('length', 4)
               )
               package.reduced_item = Item(**dict(args))

               for attribute, value in args:
                    yield (package, attribute, value)
Beispiel #7
0
def _build_package_from_cart(cart, checking_function):
    package = Package()

    for cart_item in cart.cartitem_set.all():
        product = cart_item.product

        if product.is_shippable and checking_function(product):
            if 'ProductVariation' in product.get_subtypes():
                product = product.productvariation.parent.product

            for i in range(cart_item.quantity):
                package.add_item(weight=float(product.weight),
                                 height=float(product.height),
                                 width=float(product.width),
                                 length=float(product.length))

    return package
def _build_package_from_cart(cart, checking_function):
    package = Package()

    for cart_item in cart.cartitem_set.all():
        product = cart_item.product

        if product.is_shippable and checking_function(product):
            if 'ProductVariation' in product.get_subtypes():
                product = product.productvariation.parent.product

            for i in range(cart_item.quantity):
                package.add_item(
                    weight=float(product.weight),
                    height=float(product.height),
                    width=float(product.width),
                    length=float(product.length)
                )

    return package
Beispiel #9
0
        def topic(self):
            cep_origem = '00000-000'
            cep_destino = '11111-111'
            method_name = 'methodName'
            args = (1, 2, 3)
            client = Client(cep_origem=cep_origem)
            package = Package()
            services = (SEDEX, PAC)
            client.build_web_service_call_args = Mock(return_value=args)
            client.ws_client.service = Mock()
            response = Mock(Servicos=[[create_sudsobject_mock()]])
            getattr(client.ws_client.service, method_name).return_value =\
                    response
            client.call_web_service(method_name, package, cep_destino,
                                    *services)

            return (method_name, package, cep_destino, services, args, client)
 def topic(self):
      return Package(formato=ROLO_PRISMA)
 def topic(self):
      return Package()