當前位置: 首頁>>代碼示例>>Python>>正文


Python event.Event類代碼示例

本文整理匯總了Python中stoqlib.domain.event.Event的典型用法代碼示例。如果您正苦於以下問題:Python Event類的具體用法?Python Event怎麽用?Python Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Event類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: pay

    def pay(self, paid_date=None, paid_value=None, account=None):
        """Pay the current payment set its status as :obj:`.STATUS_PAID`"""
        if self.status != Payment.STATUS_PENDING:
            raise ValueError(_(u"This payment is already paid."))
        self._check_status(self.STATUS_PENDING, u'pay')

        paid_value = paid_value or (self.value - self.discount +
                                    self.interest)
        self.paid_value = paid_value
        self.paid_date = paid_date or TransactionTimestamp()
        self.status = self.STATUS_PAID

        if (self.is_separate_payment() or
            self.method.operation.create_transaction()):
            AccountTransaction.create_from_payment(self, account)

        sale = self.group and self.group.sale
        if sale:
            transaction = IPaymentTransaction(sale)
            transaction.create_commission(self)

        if self.value == self.paid_value:
            msg = _(u"{method} payment with value {value:.2f} was paid").format(
                    method=self.method.method_name,
                    value=self.value)
        else:
            msg = _(u"{method} payment with value original value "
                    u"{original_value:.2f} was paid with value "
                    u"{value:.2f}").format(
                    method=self.method.method_name,
                    original_value=self.value,
                    value=self.paid_value)
        Event.log(Event.TYPE_PAYMENT, msg.capitalize())
開發者ID:romaia,項目名稱:stoq,代碼行數:33,代碼來源:payment.py

示例2: test_system_event

 def test_system_event(self):
     Event.log(self.store, Event.TYPE_SYSTEM, u"foo")
     events = list(self.store.find(Event))
     events = [event for event in events if event.description == u'foo']
     self.failUnless(events)
     self.assertEquals(events[0].description, u"foo")
     self.assertEquals(events[0].event_type, Event.TYPE_SYSTEM)
開發者ID:EasyDevSolutions,項目名稱:stoq,代碼行數:7,代碼來源:test_event.py

示例3: confirm

    def confirm(self, confirm_date=None):
        """Confirms the purchase order

        :param confirm_data: optional, datetime
        """
        if confirm_date is None:
            confirm_date = TransactionTimestamp()

        if self.status not in [PurchaseOrder.ORDER_PENDING,
                               PurchaseOrder.ORDER_CONSIGNED]:
            fmt = _(u'Invalid order status, it should be '
                    u'ORDER_PENDING or ORDER_CONSIGNED, got %s')
            raise ValueError(fmt % (self.status_str, ))

        # In consigned purchases there is no payments at this point.
        if self.status != PurchaseOrder.ORDER_CONSIGNED:
            for payment in self.payments:
                payment.set_pending()

        if self.supplier:
            self.group.recipient = self.supplier.person

        self.responsible = get_current_user(self.store)
        self.status = PurchaseOrder.ORDER_CONFIRMED
        self.confirm_date = confirm_date

        Event.log(self.store, Event.TYPE_ORDER,
                  _(u"Order %s, total value %2.2f, supplier '%s' "
                    u"is now confirmed") % (self.identifier,
                                            self.purchase_total,
                                            self.supplier.person.name))
開發者ID:Guillon88,項目名稱:stoq,代碼行數:31,代碼來源:purchase.py

示例4: cancel

    def cancel(self, change_entry=None):
        """Cancel the payment, set it's status to :obj:`.STATUS_CANCELLED`
        """
        # TODO Check for till entries here and call cancel_till_entry if
        # it's possible. Bug 2598
        if self.status not in [Payment.STATUS_PREVIEW, Payment.STATUS_PENDING,
                               Payment.STATUS_PAID]:
            raise StoqlibError(_(u"Invalid status for cancel operation, "
                                 u"got %s") % self.get_status_str())

        if self.transaction:
            self.transaction.create_reverse()

        old_status = self.status
        self.status = self.STATUS_CANCELLED
        self.cancel_date = TransactionTimestamp()

        if change_entry is not None:
            change_entry.last_status = old_status
            change_entry.new_status = self.status

        msg = _(u"{method} payment with value {value:.2f} was cancelled").format(
                method=self.method.method_name,
                value=self.value)
        Event.log(Event.TYPE_PAYMENT, msg.capitalize())
開發者ID:romaia,項目名稱:stoq,代碼行數:25,代碼來源:payment.py

示例5: confirm

    def confirm(self, confirm_date=None):
        """Confirms the purchase order

        :param confirm_data: optional, datetime
        """
        if confirm_date is None:
            confirm_date = TransactionTimestamp()

        if self.status not in [PurchaseOrder.ORDER_PENDING,
                               PurchaseOrder.ORDER_CONSIGNED]:
            raise ValueError(
                _(u'Invalid order status, it should be '
                  u'ORDER_PENDING or ORDER_CONSIGNED, got %s') % (
                      self.get_status_str(), ))

        transaction = IPaymentTransaction(self)
        transaction.confirm()

        if self.supplier:
            self.group.recipient = self.supplier.person

        self.responsible = get_current_user(self.store)
        self.status = PurchaseOrder.ORDER_CONFIRMED
        self.confirm_date = confirm_date

        Event.log(self.store, Event.TYPE_ORDER,
                  _(u"Order %s, total value %2.2f, supplier '%s' "
                    u"is now confirmed") % (self.identifier,
                                            self.get_purchase_total(),
                                            self.supplier.person.name))
開發者ID:leandrorchaves,項目名稱:stoq,代碼行數:30,代碼來源:purchase.py

示例6: on_create

 def on_create(self):
     # Should be done after_create()
     return
     Event.log(self.store,
               Event.TYPE_SYSTEM,
               _(u"Created computer '%s' for branch '%s'") % (
               self.name, self.branch.person.name))
開發者ID:leandrorchaves,項目名稱:stoq,代碼行數:7,代碼來源:station.py

示例7: close

    def close(self):
        """Closes the purchase order
        """
        if self.status != PurchaseOrder.ORDER_CONFIRMED:
            raise ValueError(_(u'Invalid status, it should be confirmed '
                               u'got %s instead') % self.status_str)
        self.status = self.ORDER_CLOSED

        Event.log(self.store, Event.TYPE_ORDER,
                  _(u"Order %s, total value %2.2f, supplier '%s' "
                    u"is now closed") % (self.identifier,
                                         self.purchase_total,
                                         self.supplier.person.name))
開發者ID:Guillon88,項目名稱:stoq,代碼行數:13,代碼來源:purchase.py

示例8: on_confirm

    def on_confirm(self):
        price = self.model.get_sale_base_subtotal()
        discount = self._get_discount_percentage()
        new_price = price - (price * discount / 100)

        # If user that authorized the discount is not the current user
        if discount > 0 and self._user is not api.get_current_user(self.store):
            Event.log_sale_discount(store=self.store,
                                    sale_number=self.model.identifier,
                                    user_name=self._user.username,
                                    discount_value=discount,
                                    original_price=price,
                                    new_price=new_price)

        self.model.set_items_discount(self._get_discount_percentage())
開發者ID:igorferreira,項目名稱:stoq,代碼行數:15,代碼來源:discounteditor.py

示例9: pay

    def pay(self, paid_date=None, paid_value=None,
            source_account=None, destination_account=None,
            account_transaction_number=None):
        """Pay the current payment set its status as :obj:`.STATUS_PAID`

        If this payment belongs to a sale, and all other payments from the sale
        are paid then the sale will be set as paid.
        """
        if self.status != Payment.STATUS_PENDING:
            raise ValueError(_(u"This payment is already paid."))
        self._check_status(self.STATUS_PENDING, u'pay')

        paid_value = paid_value or (self.value - self.discount +
                                    self.interest)
        self.paid_value = paid_value
        self.paid_date = paid_date or TransactionTimestamp()
        self.status = self.STATUS_PAID

        if (self.is_separate_payment() or
                self.method.operation.create_transaction()):
            AccountTransaction.create_from_payment(
                self,
                code=account_transaction_number,
                source_account=source_account,
                destination_account=destination_account)

        sale = self.group and self.group.sale
        if sale:
            sale.create_commission(self)

            # When paying payments of a sale, check if the other payments are
            # paid. If they are, this means you can change the sale status to
            # paid as well.
            if sale.can_set_paid():
                sale.set_paid()

        if self.value == self.paid_value:
            msg = _(u"{method} payment with value {value:.2f} was paid").format(
                method=self.method.method_name,
                value=self.value)
        else:
            msg = _(u"{method} payment with value original value "
                    u"{original_value:.2f} was paid with value "
                    u"{value:.2f}").format(method=self.method.method_name,
                                           original_value=self.value,
                                           value=self.paid_value)
        Event.log(self.store, Event.TYPE_PAYMENT, msg.capitalize())
開發者ID:hackedbellini,項目名稱:stoq,代碼行數:47,代碼來源:payment.py

示例10: add_sellable

    def add_sellable(self, sellable):
        price = sellable.get_price_for_category(self.model.client_category)
        new_price = self.cost.read()

        # Percentage of discount
        discount = 100 - new_price * 100 / price

        if discount > 0 and self.manager:
            Event.log_sale_item_discount(
                store=self.store,
                sale_number=self.model.identifier,
                user_name=self.manager.username,
                discount_value=discount,
                product=sellable.description,
                original_price=price,
                new_price=new_price)

        SellableItemStep.add_sellable(self, sellable)
開發者ID:Joaldino,項目名稱:stoq,代碼行數:18,代碼來源:salequotewizard.py

示例11: _maybe_log_discount

    def _maybe_log_discount(self):
        # If not authorized to apply a discount
        if self.manager is None:
            return

        price = self.model.sellable.get_price_for_category(self.model.sale.client_category)
        new_price = self.price.read()

        if new_price >= price:
            return

        discount = 100 - new_price * 100 / price

        Event.log_sale_item_discount(
            store=self.store, sale_number=self.model.sale.identifier,
            user_name=self.manager.username,
            discount_value=discount,
            product=self.model.sellable.description,
            original_price=price,
            new_price=new_price)
開發者ID:pkaislan,項目名稱:stoq,代碼行數:20,代碼來源:saleeditor.py


注:本文中的stoqlib.domain.event.Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。