[POS-commit] r1840 - stoqdrivers/trunk/stoqdrivers/devices/printers
Henrique Romano
henrique at async.com.br
Fri Dec 9 16:54:45 BRST 2005
Author: henrique
Date: Fri Dec 9 16:54:45 2005
New Revision: 1840
Modified:
stoqdrivers/trunk/stoqdrivers/devices/printers/fiscal.py
Log:
Including a little check to avoid close_coupon raise a error when the
payments doesn't match the coupon total value.
Modified: stoqdrivers/trunk/stoqdrivers/devices/printers/fiscal.py
==============================================================================
--- stoqdrivers/trunk/stoqdrivers/devices/printers/fiscal.py (original)
+++ stoqdrivers/trunk/stoqdrivers/devices/printers/fiscal.py Fri Dec 9 16:54:45 2005
@@ -70,6 +70,7 @@
def __init__(self, brand=None, model=None, device=None, config_file=None):
BasePrinter.__init__(self, brand, model, device, config_file)
self.has_been_totalized = False
+ self.totalized_value = self.payments_total_value = 0.0
self._capabilities = self._driver.get_capabilities()
def get_capabilities(self):
@@ -100,6 +101,7 @@
self.info('coupon_totalize')
result = self._driver.coupon_totalize(discount, charge, taxcode)
self.has_been_totalized = True
+ self.totalized_value = result
return result
@capcheck(payment_method, float, str)
@@ -110,6 +112,7 @@
"before add payments.")
result = self._driver.coupon_add_payment(payment_method, payment_value,
payment_description)
+ self.payments_total_value += result
return result
def cancel(self):
@@ -124,9 +127,15 @@
@capcheck(str)
def close(self, promotional_message=''):
self.info('coupon_close')
- if self.has_been_totalized:
- return self._driver.coupon_close(promotional_message)
- raise CloseCouponError("You must totalize the coupon before close it")
+ if not self.has_been_totalized:
+ raise CloseCouponError("You must totalized the coupon before "
+ "closing it")
+ elif self.totalized_value > self.payments_total_value:
+ raise CloseCouponError("Isn't possible close the coupon since "
+ "the payments added doesn't corresponds"
+ "to coupon totalied value")
+ else:
+ self._driver.coupon_close(promotional_message)
def summarize(self):
self.info('summarize')
More information about the POS-commit
mailing list