def test_create_payment(self): acc = self.create_account() branch = self.create_branch() method = PaymentMethod(method_name=u'Test', destination_account=acc) group = self.create_payment_group() self.create_payment(payment_type=Payment.TYPE_IN, date=None, value=100, method=method, branch=branch, group=group) with self.assertRaisesRegexp( PaymentMethodError, ('You can not create more inpayments for this payment ' 'group since the maximum allowed for this payment ' 'method is 1')): method.create_payment(payment_type=Payment.TYPE_IN, payment_group=group, branch=branch, value=100, due_date=None, description=None, base_value=None, payment_number=None) self.create_payment(payment_type=Payment.TYPE_IN, date=None, value=100, method=method, branch=branch, group=group) with self.assertRaises(DatabaseInconsistency): method.create_payment(payment_type=Payment.TYPE_IN, payment_group=group, branch=branch, value=100, due_date=None, description=None, base_value=None, payment_number=None)
def apply_patch(store): has_methods = store.find(PaymentMethod).count() > 0 if has_methods: multiple = store.find(PaymentMethod, method_name=u'multiple').one() if multiple is None: PaymentMethod(method_name=u'multiple', description=_(u'Multiple'), store=store)
def test_get_by_account(self): account = self.create_account() methods = PaymentMethod.get_by_account(self.store, account) self.assertTrue(methods.is_empty()) PaymentMethod(store=self.store, method_name=u'test', destination_account=account) methods = PaymentMethod.get_by_account(self.store, account) self.assertFalse(methods.is_empty())
def test_inactivate(self): acc = self.create_account() method = PaymentMethod(method_name=u'Test', destination_account=acc) self.assertIsNone(method.inactivate()) method.is_active = False with self.assertRaises(AssertionError) as error: method.inactivate() self.assertEqual(str(error.exception), 'This provider is already inactive')
def apply_patch(store): has_methods = store.find(PaymentMethod).count() > 0 if has_methods: method = store.find(PaymentMethod, method_name=u'store_credit').one() if method is None: PaymentMethod(method_name=u'store_credit', description=_(u'Store Credit'), max_installments=1, store=store)
def test_create_payments_without_installments(self): acc = self.create_account() branch = self.create_branch() method = PaymentMethod(method_name=u'Test', destination_account=acc) group = self.create_payment_group() with self.assertRaises(ValueError) as error: method.create_payments(payment_type=Payment.TYPE_IN, group=group, branch=branch, value=Decimal(100), due_dates=[]) self.assertEquals(str(error.exception), _('Need at least one ' 'installment'))
def register_payment_methods(store): """Registers the payment methods and creates persistent domain classes associated with them. """ from stoqlib.domain.payment.method import PaymentMethod from stoqlib.domain.payment.operation import get_payment_operation_manager log.info("Registering payment operations") pom = get_payment_operation_manager() log.info("Creating domain objects for payment methods") account = sysparam(store).IMBALANCE_ACCOUNT for operation_name in pom.get_operation_names(): operation = pom.get(operation_name) pm = store.find(PaymentMethod, method_name=operation_name).one() if pm is None: pm = PaymentMethod(store=store, method_name=operation_name, destination_account=account, max_installments=operation.max_installments)
def test_get_status_string(self): acc = self.create_account() method = PaymentMethod(method_name=u'Test', destination_account=acc) self.assertEqual(method.get_status_string(), u'Active') method.inactivate() self.assertEqual(method.get_status_string(), u'Inactive')