Exemplo n.º 1
0
    def test_get_description(self):
        sale = self.create_sale()
        purchase = self.create_purchase_order()
        renegotiation = self.create_payment_renegotiation()
        group = self.create_payment_group()
        decrease = self.create_stock_decrease(group=group)
        group = self.create_payment_group()
        receiving_invoice = self.create_receiving_invoice(group=group)

        sale.identifier = 77777
        purchase.identifier = 88888
        renegotiation.identifier = 99999
        decrease.identifier = 12345
        receiving_invoice.identifier = 12223

        self.assertEqual(sale.group.get_description(), u'sale 77777')
        self.assertEqual(purchase.group.get_description(), u'order 88888')
        self.assertEqual(renegotiation.group.get_description(),
                         u'renegotiation 99999')
        self.assertEqual(decrease.group.get_description(),
                         u'stock decrease 12345')
        self.assertEqual(receiving_invoice.group.get_description(),
                         u'receiving 12223')

        callback = lambda g, s: Settable(payment_description='foobar')
        PaymentGroupGetOrderEvent.connect(callback)
        try:
            self.assertEqual(self.create_payment_group().get_description(),
                             'foobar')
        finally:
            PaymentGroupGetOrderEvent.disconnect(callback)
Exemplo n.º 2
0
    def test_get_description(self):
        sale = self.create_sale()
        purchase = self.create_purchase_order()
        renegotiation = self.create_payment_renegotiation()
        group = self.create_payment_group()
        decrease = self.create_stock_decrease(group=group)

        sale.identifier = 77777
        purchase.identifier = 88888
        renegotiation.identifier = 99999
        decrease.identifier = 12345

        self.assertEquals(sale.group.get_description(), u'sale 77777')
        self.assertEquals(purchase.group.get_description(), u'order 88888')
        self.assertEquals(renegotiation.group.get_description(),
                          u'renegotiation 99999')
        self.assertEquals(decrease.group.get_description(),
                          u'stock decrease 12345')

        callback = lambda g, s: Settable(payment_description='foobar')
        PaymentGroupGetOrderEvent.connect(callback)
        try:
            self.assertEquals(
                self.create_payment_group().get_description(), 'foobar')
        finally:
            PaymentGroupGetOrderEvent.disconnect(callback)
Exemplo n.º 3
0
Arquivo: group.py Projeto: lulzzz/stoq
    def get_order_object(self):
        """Get the order object related to this payment group"""
        for obj in [self.sale, self.purchase, self._renegotiation,
                    self.stock_decrease]:
            if obj is not None:
                return obj

        return PaymentGroupGetOrderEvent.emit(self, self.store)
Exemplo n.º 4
0
    def get_order_object(self):
        """Get the order object related to this payment group"""
        for obj in [self.sale, self.purchase, self._renegotiation,
                    self.stock_decrease, self.receiving_invoice]:
            if obj is not None:
                return obj

        return PaymentGroupGetOrderEvent.emit(self, self.store)
Exemplo n.º 5
0
    def test_get_order_object(self):
        sale = self.create_sale()
        purchase = self.create_purchase_order()
        renegotiation = self.create_payment_renegotiation()
        decrease = self.create_stock_decrease(group=self.create_payment_group())

        for obj in [sale, purchase, renegotiation, decrease]:
            self.assertEqual(obj.group.get_order_object(), obj)

        group = self.create_payment_group()
        self.assertIsNone(group.get_order_object())

        obj = object()
        callback = lambda g, s: obj
        PaymentGroupGetOrderEvent.connect(callback)
        try:
            self.assertIs(group.get_order_object(), obj)
        finally:
            PaymentGroupGetOrderEvent.disconnect(callback)
Exemplo n.º 6
0
    def test_get_order_object(self):
        sale = self.create_sale()
        purchase = self.create_purchase_order()
        renegotiation = self.create_payment_renegotiation()
        decrease = self.create_stock_decrease(group=self.create_payment_group())

        for obj in [sale, purchase, renegotiation, decrease]:
            self.assertEqual(obj.group.get_order_object(), obj)

        group = self.create_payment_group()
        self.assertIsNone(group.get_order_object())

        obj = object()
        callback = lambda g, s: obj
        PaymentGroupGetOrderEvent.connect(callback)
        try:
            self.assertIs(group.get_order_object(), obj)
        finally:
            PaymentGroupGetOrderEvent.disconnect(callback)