本文整理汇总了Python中stoqlib.domain.till.Till.get_current方法的典型用法代码示例。如果您正苦于以下问题:Python Till.get_current方法的具体用法?Python Till.get_current怎么用?Python Till.get_current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.till.Till
的用法示例。
在下文中一共展示了Till.get_current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: before_start
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def before_start(self, store):
till = Till.get_current(store)
if till is None:
till = Till(store=store,
station=get_current_station(store))
till.open_till()
assert till == Till.get_current(store)
示例2: testGetCurrentTillClose
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def testGetCurrentTillClose(self):
station = get_current_station(self.store)
self.assertEqual(Till.get_current(self.store), None)
till = Till(store=self.store, station=station)
till.open_till()
self.assertEqual(Till.get_current(self.store), till)
till.close_till()
self.assertEqual(Till.get_current(self.store), None)
示例3: testGetCurrentTillOpen
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def testGetCurrentTillOpen(self):
self.assertEqual(Till.get_current(self.store), None)
station = get_current_station(self.store)
till = Till(store=self.store, station=station)
self.assertEqual(Till.get_current(self.store), None)
till.open_till()
self.assertEqual(Till.get_current(self.store), till)
self.assertEqual(till.opening_date.date(), localtoday().date())
self.assertEqual(till.status, Till.STATUS_OPEN)
self.assertRaises(TillError, till.open_till)
示例4: on_Edit__activate
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def on_Edit__activate(self, action):
try:
Till.get_current(self.store)
except TillError as e:
warning(str(e))
return
store = api.new_store()
views = self.results.get_selected_rows()
sale = store.fetch(views[0].sale)
retval = run_dialog(SalePaymentsEditor, self, store, sale)
if store.confirm(retval):
self.refresh()
store.close()
示例5: _update_till_status
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def _update_till_status(self, closed, blocked):
# Three different situations;
#
# - Till is closed
# - Till is opened
# - Till was not closed the previous fiscal day (blocked)
self.set_sensitive([self.TillOpen], closed)
self.set_sensitive([self.TillClose, self.PaymentReceive],
not closed or blocked)
widgets = [self.TillVerify, self.TillAddCash, self.TillRemoveCash,
self.SearchTillHistory, self.app_vbox]
self.set_sensitive(widgets, not closed and not blocked)
if closed:
text = _(u"Till closed")
self.clear()
self.setup_focus()
elif blocked:
text = _(u"Till blocked from previous day")
else:
till = Till.get_current(self.store)
text = _(u"Till opened on %s") % till.opening_date.strftime('%x')
self.till_status_label.set_text(text)
self._update_toolbar_buttons()
self._update_total()
示例6: _open_till
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def _open_till(self, store):
till = Till(store=store, station=api.get_current_station(store))
till.open_till()
TillOpenEvent.emit(till=till)
self.assertEquals(till, Till.get_current(store))
return till
示例7: open_till
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def open_till(self):
"""Opens the till
"""
try:
current_till = Till.get_current(self.store)
except TillError as e:
warning(str(e))
return False
if current_till is not None:
warning(_("You already have a till operation opened. "
"Close the current Till and open another one."))
return False
store = api.new_store()
try:
model = run_dialog(TillOpeningEditor, self._parent, store)
except TillError as e:
warning(str(e))
model = None
retval = store.confirm(model)
store.close()
if retval:
self._till_status_changed(closed=False, blocked=False)
return retval
示例8: _cancel_last_document
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def _cancel_last_document(self):
try:
self._validate_printer()
except DeviceError as e:
warning(str(e))
return
store = new_store()
last_doc = self._get_last_document(store)
if not self._confirm_last_document_cancel(last_doc):
store.close()
return
if last_doc.last_till_entry:
self._cancel_last_till_entry(last_doc, store)
elif last_doc.last_sale:
# Verify till balance before cancel the last sale.
till = Till.get_current(store)
if last_doc.last_sale.total_amount > till.get_balance():
warning(_("You do not have this value on till."))
store.close()
return
cancelled = self._printer.cancel()
if not cancelled:
info(_("Cancelling sale failed, nothing to cancel"))
store.close()
return
else:
self._cancel_last_sale(last_doc, store)
store.commit()
示例9: create_sale
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def create_sale(self, id_=None, branch=None, client=None):
from stoqlib.domain.sale import Sale
from stoqlib.domain.till import Till
till = Till.get_current(self.store)
if till is None:
till = self.create_till()
till.open_till()
salesperson = self.create_sales_person()
group = self.create_payment_group()
if client:
group.payer = client.person
sale = Sale(
coupon_id=0,
open_date=TransactionTimestamp(),
salesperson=salesperson,
branch=branch or get_current_branch(self.store),
cfop=sysparam(self.store).DEFAULT_SALES_CFOP,
group=group,
client=client,
store=self.store,
)
if id_:
sale.id = id_
sale.identifier = id_
return sale
示例10: _receive
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def _receive(self):
with api.new_store() as store:
till = Till.get_current(store)
assert till
in_payment = self.results.get_selected()
payment = store.fetch(in_payment.payment)
assert self._can_receive(payment)
retval = run_dialog(SalePaymentConfirmSlave, self, store,
payments=[payment], show_till_info=False)
if not retval:
return
try:
TillAddCashEvent.emit(till=till, value=payment.value)
except (TillError, DeviceError, DriverError) as e:
warning(str(e))
return
till_entry = till.add_credit_entry(payment.value,
_(u'Received payment: %s') % payment.description)
TillAddTillEntryEvent.emit(till_entry, store)
if store.committed:
self.search.refresh()
示例11: create_model
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def create_model(self, store):
till = Till.get_current(self.store)
return Settable(employee=None,
payment=None,
# FIXME: should send in consts.now()
open_date=None,
till=till,
balance=till.get_balance(),
value=currency(0))
示例12: testCreateInPayment
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def testCreateInPayment(self):
payment = self.createInPayment()
self.failUnless(isinstance(payment, Payment))
self.assertEqual(payment.value, Decimal(100))
self.assertEqual(payment.till, Till.get_current(self.store))
payment_without_till = self.createInPayment(till=None)
self.failUnless(isinstance(payment, Payment))
self.assertEqual(payment_without_till.value, Decimal(100))
self.assertEqual(payment_without_till.till, None)
示例13: when_done
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def when_done(self, store):
# This is sort of hack, set the opening/closing dates to the date before
# it's run, so we can open/close the till in the tests, which uses
# the examples.
till = Till.get_current(store)
# Do not leave anything in the till.
till.add_debit_entry(till.get_balance(), _(u"Amount removed from Till"))
till.close_till()
yesterday = localtoday() - datetime.timedelta(1)
till.opening_date = yesterday
till.closing_date = yesterday
示例14: _get_till_balance
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def _get_till_balance(self):
"""Returns the balance of till operations"""
try:
till = Till.get_current(self.store)
except TillError:
till = None
if till is None:
return currency(0)
return till.get_balance()
示例15: _cancel_last_sale
# 需要导入模块: from stoqlib.domain.till import Till [as 别名]
# 或者: from stoqlib.domain.till.Till import get_current [as 别名]
def _cancel_last_sale(self, last_doc, store):
if last_doc.last_sale.status == Sale.STATUS_RETURNED:
return
sale = store.fetch(last_doc.last_sale)
value = sale.total_amount
reason = _(u"Cancelling last document on ECF")
sale.cancel(reason, force=True)
till = Till.get_current(store)
# TRANSLATORS: cash out = sangria
till.add_debit_entry(value, _(u"Cash out: last sale cancelled"))
last_doc.last_sale = None
info(_("Document was cancelled"))