本文整理汇总了Python中stoqlib.domain.events.CancelPendingPaymentsEvent类的典型用法代码示例。如果您正苦于以下问题:Python CancelPendingPaymentsEvent类的具体用法?Python CancelPendingPaymentsEvent怎么用?Python CancelPendingPaymentsEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CancelPendingPaymentsEvent类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_payments
def setup_payments(self, sale):
""" Add the payments defined in the sale to the coupon. Note that this
function must be called after all the payments has been created.
"""
# XXX: Remove this when bug #2827 is fixed.
if not self._item_ids:
return True
if self.payments_setup:
return True
log.info('Adding payments to the coupon')
while True:
try:
self.emit('add-payments', sale)
self.payments_setup = True
return True
except (DriverError, DeviceError) as details:
log.info("It is not possible to add payments to the coupon: %s"
% str(details))
if not yesno(_(u"An error occurred while trying to print. "
u"Would you like to try again?"),
gtk.RESPONSE_YES,
_("Try again"), _(u"Don't try again")):
CancelPendingPaymentsEvent.emit()
return False
_flush_interface()
开发者ID:igorferreira,项目名称:stoq,代码行数:27,代码来源:fiscalprinter.py
示例2: close
def close(self, sale, store):
# XXX: Remove this when bug #2827 is fixed.
if not self._item_ids:
return True
if self.coupon_closed:
return True
log.info('Closing coupon')
while True:
try:
coupon_id = self.emit('close', sale)
sale.coupon_id = coupon_id
self.coupon_closed = True
return True
except (DeviceError, DriverError) as details:
log.info("It is not possible to close the coupon: %s"
% str(details))
if not yesno(_(u"An error occurred while trying to print. "
u"Would you like to try again?"),
gtk.RESPONSE_YES,
_("Try again"), _(u"Don't try again")):
CancelPendingPaymentsEvent.emit()
return False
_flush_interface()
开发者ID:igorferreira,项目名称:stoq,代码行数:25,代码来源:fiscalprinter.py
示例3: confirm
def confirm(self, sale, store, savepoint=None, subtotal=None):
"""Confirms a |sale| on fiscalprinter and database
If the sale is confirmed, the store will be committed for you.
There's no need for the callsite to call store.confirm().
If the sale is not confirmed, for instance the user cancelled the
sale or there was a problem with the fiscal printer, then the
store will be rolled back.
:param sale: the |sale| to be confirmed
:param trans: a store
:param savepoint: if specified, a database savepoint name that
will be used to rollback to if the sale was not confirmed.
:param subtotal: the total value of all the items in the sale
"""
# Actually, we are confirming the sale here, so the sale
# confirmation process will be available to others applications
# like Till and not only to the POS.
total_paid = sale.group.get_total_confirmed_value()
model = run_dialog(ConfirmSaleWizard, self._parent, store, sale,
subtotal=subtotal,
total_paid=total_paid)
if not model:
CancelPendingPaymentsEvent.emit()
store.rollback(name=savepoint, close=False)
return False
if sale.client and not self.is_customer_identified():
self.identify_customer(sale.client.person)
if not self.totalize(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.setup_payments(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.close(sale, store):
store.rollback(name=savepoint, close=False)
return False
try:
sale.confirm()
except SellError as err:
warning(str(err))
store.rollback(name=savepoint, close=False)
return False
if not self.print_receipts(sale):
warning(_("The sale was cancelled"))
sale.cancel()
print_cheques_for_payment_group(store, sale.group)
# Only finish the transaction after everything passed above.
store.confirm(model)
return True
开发者ID:LeonamSilva,项目名称:stoq,代码行数:60,代码来源:fiscalprinter.py
示例4: setup_payments
def setup_payments(self, sale):
""" Add the payments defined in the sale to the coupon. Note that this
function must be called after all the payments has been created.
"""
# XXX: Remove this when bug #2827 is fixed.
if not self._item_ids:
return True
if self.payments_setup:
return True
log.info('Adding payments to the coupon')
while True:
try:
self.emit('add-payments', sale)
self.payments_setup = True
return True
except (DriverError, DeviceError), details:
log.info("It is not possible to add payments to the coupon: %s"
% str(details))
if not yesno(_(u"Erro na impressão. Deseja tentar novamente?"),
gtk.RESPONSE_YES,
_("Sim"), _(u"Não")):
CancelPendingPaymentsEvent.emit()
return False
_flush_interface()
开发者ID:romaia,项目名称:stoq,代码行数:26,代码来源:fiscalprinter.py
示例5: print_receipts
def print_receipts(self, sale):
#supports_duplicate = self.emit('get-supports-duplicate-receipt')
# Vamos sempre imprimir sempre de uma vez, para simplificar
supports_duplicate = False
log.info('Printing payment receipts')
# Merge card payments by nsu
card_payments = {}
for payment in sale.payments:
if payment.method.method_name != 'card':
continue
operation = payment.method.operation
card_data = operation.get_card_data_by_payment(payment)
card_payments.setdefault(card_data.nsu, [])
card_payments[card_data.nsu].append(payment)
any_failed = False
for nsu, payment_list in card_payments.items():
receipt = CardPaymentReceiptPrepareEvent.emit(nsu, supports_duplicate)
if receipt is None:
continue
value = sum([p.value for p in payment_list])
# This is BS, but if any receipt failed to print, we must print
# the remaining ones in Gerencial Rports
if any_failed:
retval = self.reprint_payment_receipt(receipt)
else:
retval = self.print_payment_receipt(payment_list[0], value, receipt)
while not retval:
if not yesno(_(u"Erro na impressão. Deseja tentar novamente?"),
gtk.RESPONSE_YES,
_("Sim"), _(u"Não")):
CancelPendingPaymentsEvent.emit()
try:
GerencialReportCancelEvent.emit()
except (DriverError, DeviceError), details:
log.info('Error canceling last receipt: %s' %
details)
warning(u'Não foi possível cancelar o último'
' comprovante')
return False
any_failed = True
_flush_interface()
retval = self.reprint_payment_receipt(receipt,
close_previous=True)
开发者ID:romaia,项目名称:stoq,代码行数:48,代码来源:fiscalprinter.py
示例6: totalize
def totalize(self, sale):
# XXX: Remove this when bug #2827 is fixed.
if not self._item_ids:
return True
if self.totalized:
return True
log.info('Totalizing coupon')
while True:
try:
self.emit('totalize', sale)
self.totalized = True
return True
except (DriverError, DeviceError), details:
log.info("It is not possible to totalize the coupon: %s"
% str(details))
if not yesno(_(u"Erro na impressão. Deseja tentar novamente?"),
gtk.RESPONSE_YES,
_("Sim"), _(u"Não")):
CancelPendingPaymentsEvent.emit()
return False
_flush_interface()
开发者ID:romaia,项目名称:stoq,代码行数:23,代码来源:fiscalprinter.py
示例7: totalize
def totalize(self, sale):
# XXX: Remove this when bug #2827 is fixed.
if not self._item_ids:
return True
if self.totalized:
return True
log.info('Totalizing coupon')
while True:
try:
self.emit('totalize', sale)
self.totalized = True
return True
except (DriverError, DeviceError) as details:
log.info("It is not possible to totalize the coupon: %s"
% str(details))
if not yesno(_(u"An error occurred while trying to print. "
u"Would you like to try again?"),
Gtk.ResponseType.YES,
_("Try again"), _(u"Don't try again")):
CancelPendingPaymentsEvent.emit()
return False
_flush_interface()
开发者ID:hackedbellini,项目名称:stoq,代码行数:24,代码来源:fiscalprinter.py
示例8: confirm
def confirm(self, sale, store, savepoint=None, subtotal=None):
"""Confirms a |sale| on fiscalprinter and database
If the sale is confirmed, the store will be committed for you.
There's no need for the callsite to call store.confirm().
If the sale is not confirmed, for instance the user cancelled the
sale or there was a problem with the fiscal printer, then the
store will be rolled back.
:param sale: the |sale| to be confirmed
:param trans: a store
:param savepoint: if specified, a database savepoint name that
will be used to rollback to if the sale was not confirmed.
:param subtotal: the total value of all the items in the sale
"""
# Actually, we are confirming the sale here, so the sale
# confirmation process will be available to others applications
# like Till and not only to the POS.
total_paid = sale.group.get_total_confirmed_value()
model = run_dialog(ConfirmSaleWizard, self._parent, store, sale,
subtotal=subtotal,
total_paid=total_paid)
if not model:
CancelPendingPaymentsEvent.emit()
store.rollback(name=savepoint, close=False)
return False
if sale.client and not self.is_customer_identified():
self.identify_customer(sale.client.person)
if not self.totalize(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.setup_payments(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.close(sale, store):
store.rollback(name=savepoint, close=False)
return False
try:
sale.confirm()
except SellError as err:
warning(str(err))
store.rollback(name=savepoint, close=False)
return False
if not self.print_receipts(sale):
warning(_("The sale was cancelled"))
sale.cancel()
print_cheques_for_payment_group(store, sale.group)
# Only finish the transaction after everything passed above.
store.confirm(model)
# Try to print only after the transaction is commited, to prevent
# losing data if something fails while printing
group = sale.group
booklets = list(group.get_payments_by_method_name(u'store_credit'))
bills = list(group.get_payments_by_method_name(u'bill'))
if (booklets and
yesno(_("Do you want to print the booklets for this sale?"),
gtk.RESPONSE_YES, _("Print booklets"), _("Don't print"))):
try:
print_report(BookletReport, booklets)
except ReportError:
warning(_("Could not print booklets"))
if (bills and BillReport.check_printable(bills) and
yesno(_("Do you want to print the bills for this sale?"),
gtk.RESPONSE_YES, _("Print bills"), _("Don't print"))):
try:
print_report(BillReport, bills)
except ReportError:
# TRANSLATORS: bills here refers to "boletos" in pt_BR
warning(_("Could not print bills"))
return True
开发者ID:igorferreira,项目名称:stoq,代码行数:83,代码来源:fiscalprinter.py
示例9: confirm
def confirm(self, sale, store, savepoint=None, subtotal=None):
"""Confirms a |sale| on fiscalprinter and database
If the sale is confirmed, the store will be committed for you.
There's no need for the callsite to call store.confirm().
If the sale is not confirmed, for instance the user cancelled the
sale or there was a problem with the fiscal printer, then the
store will be rolled back.
:param sale: the |sale| to be confirmed
:param trans: a store
:param savepoint: if specified, a database savepoint name that
will be used to rollback to if the sale was not confirmed.
:param subtotal: the total value of all the items in the sale
"""
# Actually, we are confirming the sale here, so the sale
# confirmation process will be available to others applications
# like Till and not only to the POS.
payments_total = sale.group.get_total_confirmed_value()
sale_total = sale.get_total_sale_amount()
payment = get_formatted_price(payments_total)
amount = get_formatted_price(sale_total)
msg = _(u"Payment value (%s) is greater than sale's total (%s). "
"Do you want to confirm it anyway?") % (payment, amount)
if (sale_total < payments_total and not
yesno(msg, gtk.RESPONSE_NO, _(u"Confirm Sale"), _(u"Don't Confirm"))):
return False
model = run_dialog(ConfirmSaleWizard, self._parent, store, sale,
subtotal=subtotal, total_paid=payments_total,
current_document=self._current_document)
if not model:
CancelPendingPaymentsEvent.emit()
store.rollback(name=savepoint, close=False)
return False
if sale.client and not self.is_customer_identified():
self.identify_customer(sale.client.person)
try:
if not self.totalize(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.setup_payments(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.close(sale, store):
store.rollback(name=savepoint, close=False)
return False
if not self.print_receipts(sale):
store.rollback(name=savepoint, close=False)
return False
# FIXME: This used to be done inside sale.confirm. Maybe it would
# be better to do a proper error handling
till = Till.get_current(store)
assert till
sale.confirm(till=till)
# Only finish the transaction after everything passed above.
store.confirm(model)
except Exception as e:
warning(_("An error happened while trying to confirm the sale. "
"Cancelling the coupon now..."), str(e))
self.cancel()
store.rollback(name=savepoint, close=False)
return False
print_cheques_for_payment_group(store, sale.group)
# Try to print only after the transaction is commited, to prevent
# losing data if something fails while printing
group = sale.group
booklets = list(group.get_payments_by_method_name(u'store_credit'))
bills = list(group.get_payments_by_method_name(u'bill'))
if (booklets and
yesno(_("Do you want to print the booklets for this sale?"),
gtk.RESPONSE_YES, _("Print booklets"), _("Don't print"))):
try:
print_report(BookletReport, booklets)
except ReportError:
warning(_("Could not print booklets"))
if (bills and BillReport.check_printable(bills) and
yesno(_("Do you want to print the bills for this sale?"),
gtk.RESPONSE_YES, _("Print bills"), _("Don't print"))):
try:
print_report(BillReport, bills)
except ReportError:
# TRANSLATORS: bills here refers to "boletos" in pt_BR
warning(_("Could not print bills"))
return True
开发者ID:Guillon88,项目名称:stoq,代码行数:99,代码来源:fiscalprinter.py
示例10: confirm
def confirm(self, sale, store, savepoint=None,
subtotal=None,
total_paid=0):
"""Confirms a |sale| on fiscalprinter and database
If the sale is confirmed, the store will be committed for you.
There's no need for the callsite to call store.confirm().
If the sale is not confirmed, for instance the user cancelled the
sale or there was a problem with the fiscal printer, then the
store will be rolled back.
:param sale: the |sale| to be confirmed
:param trans: a store
:param savepoint: if specified, a database savepoint name that
will be used to rollback to if the sale was not confirmed.
:param subtotal: the total value of all the items in the sale
:param total_paid: what has already been paid on this sale,
used when returning an item
"""
# Actually, we are confirming the sale here, so the sale
# confirmation process will be available to others applications
# like Till and not only to the POS.
model = run_dialog(ConfirmSaleWizard, self._parent, store, sale,
subtotal=subtotal,
total_paid=total_paid)
missing = sale.get_missing_items()
if missing:
run_dialog(ConfirmSaleMissingDialog, self._parent, sale, missing)
store.rollback(name=savepoint, close=False)
return False
if not model:
CancelPendingPaymentsEvent.emit()
store.rollback(name=savepoint, close=False)
return False
if sale.client and not self.is_customer_identified():
self.identify_customer(sale.client.person)
if not self.totalize(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.setup_payments(sale):
store.rollback(name=savepoint, close=False)
return False
if not self.close(sale, store):
store.rollback(name=savepoint, close=False)
return False
sale.confirm()
if not self.print_receipts(sale):
warning('A venda foi cancelada')
sale.cancel()
if sale.only_paid_with_money():
sale.set_paid()
else:
sale.group.pay_money_payments()
print_cheques_for_payment_group(store, sale.group)
# Only finish the transaction after everything passed above.
store.confirm(model)
return True
开发者ID:romaia,项目名称:stoq,代码行数:69,代码来源:fiscalprinter.py
注:本文中的stoqlib.domain.events.CancelPendingPaymentsEvent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论