[POS-commit] r6335 - in stoqlib/trunk: . stoqlib/domain/payment
stoqlib/domain/test
Johan Dahlin
jdahlin at async.com.br
Thu Apr 5 17:28:03 BRT 2007
Author: jdahlin
Date: Thu Apr 5 17:28:03 2007
New Revision: 6335
Modified:
stoqlib/trunk/CONTRIBUTORS
stoqlib/trunk/stoqlib/domain/payment/methods.py
stoqlib/trunk/stoqlib/domain/test/test_payment_method.py
Log:
#3261: Na aplicação Purchase, ao executarmos uma compra podemos escolher até 100 parcelas, based on patch by Renato Francisco Ferreira
Modified: stoqlib/trunk/CONTRIBUTORS
==============================================================================
--- stoqlib/trunk/CONTRIBUTORS (original)
+++ stoqlib/trunk/CONTRIBUTORS Thu Apr 5 17:28:03 2007
@@ -21,6 +21,7 @@
Lucas Rosada
Marco Antonio Porcho Souza
Matthew Thomas
+Renato Francisco Ferreira
Ronaldo Maia
Ruda Porto Filgueiras
Silvio Rangel
Modified: stoqlib/trunk/stoqlib/domain/payment/methods.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/payment/methods.py (original)
+++ stoqlib/trunk/stoqlib/domain/payment/methods.py Thu Apr 5 17:28:03 2007
@@ -209,11 +209,14 @@
% interest)
def _calculate_payment_value(self, total_value, installments_number,
- interest=None):
+ iface, interest=None):
if not installments_number:
raise ValueError('The payment_qty argument must be greater '
'than zero')
- self._check_installments_number(installments_number)
+
+ if iface is IInPayment:
+ self._check_installments_number(installments_number)
+
self._check_interest_value(interest)
if not interest:
@@ -235,15 +238,16 @@
else:
destination = self.destination
max = self.get_max_installments_number()
- if created_number == max:
- raise PaymentMethodError('You can not create more inpayments '
- 'for this payment group since the '
- 'maximum allowed for this payment '
- 'method is %d' % max)
- elif created_number > max:
- raise DatabaseInconsistency('You have more inpayments in '
- 'database than the maximum '
- 'allowed for this payment method')
+ if iface is IInPayment:
+ if created_number == max:
+ raise PaymentMethodError('You can not create more inpayments '
+ 'for this payment group since the '
+ 'maximum allowed for this payment '
+ 'method is %d' % max)
+ elif created_number > max:
+ raise DatabaseInconsistency('You have more inpayments in '
+ 'database than the maximum '
+ 'allowed for this payment method')
if not description:
description = self.describe_payment(payment_group)
@@ -273,7 +277,7 @@
interest = Decimal(0)
normalized_value = self._calculate_payment_value(
- value, installments, interest)
+ value, installments, iface, interest)
normalized_value = quantize(normalized_value)
if interest:
Modified: stoqlib/trunk/stoqlib/domain/test/test_payment_method.py
==============================================================================
--- stoqlib/trunk/stoqlib/domain/test/test_payment_method.py (original)
+++ stoqlib/trunk/stoqlib/domain/test/test_payment_method.py Thu Apr 5 17:28:03 2007
@@ -56,7 +56,7 @@
method = self.method_type.selectOne(connection=self.trans)
return method.create_outpayment(group, Decimal(100))
- def createInPayments(self):
+ def createInPayments(self, no=3):
sale = self.create_sale()
group = sale.addFacet(IPaymentGroup,
connection=self.trans)
@@ -64,18 +64,18 @@
d = datetime.datetime.today()
method = self.method_type.selectOne(connection=self.trans)
payments = method.create_inpayments(group, Decimal(100),
- [d, d, d])
+ [d] * no)
return [p.get_adapted() for p in payments]
- def createOutPayments(self):
+ def createOutPayments(self, no=3):
purchase = self.create_purchase_order()
group = IPaymentGroup(purchase)
d = datetime.datetime.today()
method = self.method_type.selectOne(connection=self.trans)
payments = method.create_outpayments(group, Decimal(100),
- [d, d, d])
+ [d] * no)
return [p.get_adapted() for p in payments]
@@ -137,6 +137,15 @@
self.method_type.selectOne(connection=self.trans))
+ def testMaxInPaymnets(self):
+ method = self.method_type.selectOne(connection=self.trans)
+ max = method.get_max_installments_number()
+ self.assertRaises(ValueError, self.createInPayments, max + 1)
+
+ def testMaxOutPaymnets(self):
+ method = self.method_type.selectOne(connection=self.trans)
+ max = method.get_max_installments_number()
+ self.createOutPayments(max + 1)
class TestAPaymentMethod(DomainTest, _TestPaymentMethod):
method_type = CheckPM
@@ -167,7 +176,6 @@
self._createUnclosedTill()
self.assertRaises(TillError, self.createInPayments)
-
class TestMoneyPM(DomainTest, _TestPaymentMethodsBase):
method_type = MoneyPM
enum = PaymentMethodType.MONEY
More information about the POS-commit
mailing list