本文整理汇总了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;未经允许,请勿转载。 |
请发表评论