Exemplo n.º 1
0
 def test_invalid_form_not_enough_funds_in_the_account_2(self):
     data = {'user_send_id': '1', 'summ': Decimal('0.01'), 'inn': 1234}
     form = TransactionForm(data=data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
         {'user_send_id': ['На счете списания не достаточно средств.']}
     )
Exemplo n.º 2
0
 def test_invalid_form_(self):
     data = {'user_send_id': '6', 'summ': Decimal('20.00'), 'inn': 2222}
     form = TransactionForm(data=data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
         {'inn': ['Это ИНН отправителя. Других пользователей с этим ИНН в базе нет.']}
     )
Exemplo n.º 3
0
 def test_invalid_form_lack_of_users_with_this_inn(self):
     data = {'user_send_id': '1', 'summ': Decimal('10.00'), 'inn': 123}
     form = TransactionForm(data=data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
         {'inn': ['Пользователей с указанным ИНН нет в базе данных.']}
     )
Exemplo n.º 4
0
 def test_invalid_form_inn_field_can_not_null_inn_field_can_not_null(self):
     data = {'user_send_id': '1', 'summ': Decimal('0.00'), 'inn': 0}
     form = TransactionForm(data=data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
         {'inn': ['ИНН не может быть равным нулю.'],
         'summ': ['Сумма перевода не должна быть равной нулю.']}
     )
Exemplo n.º 5
0
 def test_invalid_form_not_enough_funds_in_the_account_lack_of_inn_field(self):
     data = {'user_send_id': '1', 'summ': Decimal('121.00')}
     form = TransactionForm(data=data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
         {'user_send_id': ['На счете списания не достаточно средств.'],
         'inn': ['Обязательное поле.']}
     )
Exemplo n.º 6
0
def new_transtaction(request):
    TEST = False
    # Retrieve post by id
    if request.method == 'POST':
        # Form was submitted
        form = TransactionForm(request.POST)
        if form.is_valid():
            if TEST:
                pass
            else:
                form_clean = form_processing(form, request.user)
                to_cl_out = scv_cl_out(form_clean)
                to_ag_out = scv_ag_out(form_clean)
                trans = cs_trans_form(form_clean, to_cl_out, to_ag_out)
            return HttpResponseRedirect(reverse_lazy('transtaction-list'))
            #Create a new transaction with default status to delivered
    else:
        data = {'from_agent_number': request.user.username}
        form = TransactionForm(initial=data)
    return render(request, 'main/new_transtaction.html', {'form': form})
Exemplo n.º 7
0
    def post(self, request, pk=None, account=None):

        redirect = reverse('transactions', kwargs={'account': account})

        try:
            form = TransactionForm(
                request.POST, instance=TransactionEntry.objects.get(pk=pk))
        except ObjectDoesNotExist:
            form = TransactionForm(request.POST)
        context = {
            'accounts': self.get_accounts(),
            'account_subtypes': self.get_account_groups(),
            'form': form,
            'active': self.get_active_account(account)
        }

        if form.is_valid():
            form.save()
            self.update_balance()
            return HttpResponseRedirect(redirect)
        else:
            return render(request, 'main/create_edit.html', context)
Exemplo n.º 8
0
 def test_invalid_form_field_inn_required_field_summ_required(self):
     data = {'user_send_id': '1',}
     form = TransactionForm(data=data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors,
         {'summ': ['Обязательное поле.'], 'inn': ['Обязательное поле.']})
Exemplo n.º 9
0
 def test_valid_form(self):
     data = {'user_send_id': '1', 'summ': Decimal('10.00'), 'inn': 1234}
     form = TransactionForm(data=data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.errors, {})