mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-12 04:49:25 +00:00
Format accounting
This commit is contained in:
@ -22,15 +22,12 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.test import Client, TestCase
|
||||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import Group
|
||||
from django.core.management import call_command
|
||||
from django.conf import settings
|
||||
from datetime import date, datetime
|
||||
from datetime import date
|
||||
|
||||
from core.models import User
|
||||
from counter.models import Counter
|
||||
from accounting.models import GeneralJournal, Operation, Label, AccountingType, SimplifiedAccountingType
|
||||
|
||||
|
||||
@ -72,10 +69,11 @@ class RefoundAccountTest(TestCase):
|
||||
self.assertFalse(response_post.status_code == 403)
|
||||
self.assertTrue(self.skia.customer.amount == 0)
|
||||
|
||||
|
||||
class JournalTest(TestCase):
|
||||
def setUp(self):
|
||||
call_command("populate")
|
||||
self.journal = GeneralJournal.objects.filter(id = 1).first()
|
||||
self.journal = GeneralJournal.objects.filter(id=1).first()
|
||||
|
||||
def test_permission_granted(self):
|
||||
self.client.login(username='comptable', password='plop')
|
||||
@ -91,115 +89,116 @@ class JournalTest(TestCase):
|
||||
self.assertTrue(response_get.status_code == 403)
|
||||
self.assertFalse('<td>M\xc3\xa9thode de paiement</td>' in str(response_get.content))
|
||||
|
||||
|
||||
class OperationTest(TestCase):
|
||||
def setUp(self):
|
||||
call_command("populate")
|
||||
self.journal = GeneralJournal.objects.filter(id = 1).first()
|
||||
self.journal = GeneralJournal.objects.filter(id=1).first()
|
||||
self.skia = User.objects.filter(username='skia').first()
|
||||
at = AccountingType(code='443', label="Ce code n'existe pas", movement_type='CREDIT')
|
||||
at.save()
|
||||
l = Label(club_account= self.journal.club_account, name='bob')
|
||||
l = Label(club_account=self.journal.club_account, name='bob')
|
||||
l.save()
|
||||
self.client.login(username='comptable', password='plop')
|
||||
self.op1 = Operation(journal=self.journal, date=date.today(), amount=1,
|
||||
remark="Test bilan", mode='CASH', done=True, label=l,
|
||||
accounting_type=at, target_type='USER', target_id=self.skia.id)
|
||||
self.op1 = Operation(journal=self.journal, date=date.today(), amount=1,
|
||||
remark="Test bilan", mode='CASH', done=True, label=l,
|
||||
accounting_type=at, target_type='USER', target_id=self.skia.id)
|
||||
self.op1.save()
|
||||
self.op2 = Operation(journal=self.journal, date=date.today(), amount=2,
|
||||
remark="Test bilan", mode='CASH', done=True, label=l,
|
||||
accounting_type=at, target_type='USER', target_id=self.skia.id)
|
||||
self.op2 = Operation(journal=self.journal, date=date.today(), amount=2,
|
||||
remark="Test bilan", mode='CASH', done=True, label=l,
|
||||
accounting_type=at, target_type='USER', target_id=self.skia.id)
|
||||
self.op2.save()
|
||||
|
||||
def test_new_operation(self):
|
||||
self.client.login(username='comptable', password='plop')
|
||||
at = AccountingType.objects.filter(code = '604').first()
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 30,
|
||||
'remark' : "Un gros test",
|
||||
'journal' : self.journal.id,
|
||||
'target_type' : 'OTHER',
|
||||
'target_id' : '',
|
||||
'target_label' : "Le fantome de la nuit",
|
||||
'date' : '04/12/2020',
|
||||
'mode' : 'CASH',
|
||||
'cheque_number' : '',
|
||||
'invoice' : '',
|
||||
'simpleaccounting_type' : '',
|
||||
'accounting_type': at.id,
|
||||
'label' : '',
|
||||
'done' : False,
|
||||
})
|
||||
self.client.login(username='comptable', password='plop')
|
||||
at = AccountingType.objects.filter(code='604').first()
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 30,
|
||||
'remark': "Un gros test",
|
||||
'journal': self.journal.id,
|
||||
'target_type': 'OTHER',
|
||||
'target_id': '',
|
||||
'target_label': "Le fantome de la nuit",
|
||||
'date': '04/12/2020',
|
||||
'mode': 'CASH',
|
||||
'cheque_number': '',
|
||||
'invoice': '',
|
||||
'simpleaccounting_type': '',
|
||||
'accounting_type': at.id,
|
||||
'label': '',
|
||||
'done': False,
|
||||
})
|
||||
self.assertFalse(response.status_code == 403)
|
||||
self.assertTrue(self.journal.operations.filter(target_label = "Le fantome de la nuit").exists())
|
||||
self.assertTrue(self.journal.operations.filter(target_label="Le fantome de la nuit").exists())
|
||||
response_get = self.client.get(reverse("accounting:journal_details", args=[self.journal.id]))
|
||||
self.assertTrue('<td>Le fantome de la nuit</td>' in str(response_get.content))
|
||||
|
||||
def test_bad_new_operation(self):
|
||||
self.client.login(username='comptable', password='plop')
|
||||
at = AccountingType.objects.filter(code = '604').first()
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 30,
|
||||
'remark' : "Un gros test",
|
||||
'journal' : self.journal.id,
|
||||
'target_type' : 'OTHER',
|
||||
'target_id' : '',
|
||||
'target_label' : "Le fantome de la nuit",
|
||||
'date' : '04/12/2020',
|
||||
'mode' : 'CASH',
|
||||
'cheque_number' : '',
|
||||
'invoice' : '',
|
||||
'simpleaccounting_type' : '',
|
||||
'accounting_type': '',
|
||||
'label' : '',
|
||||
'done' : False,
|
||||
})
|
||||
AccountingType.objects.filter(code='604').first()
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 30,
|
||||
'remark': "Un gros test",
|
||||
'journal': self.journal.id,
|
||||
'target_type': 'OTHER',
|
||||
'target_id': '',
|
||||
'target_label': "Le fantome de la nuit",
|
||||
'date': '04/12/2020',
|
||||
'mode': 'CASH',
|
||||
'cheque_number': '',
|
||||
'invoice': '',
|
||||
'simpleaccounting_type': '',
|
||||
'accounting_type': '',
|
||||
'label': '',
|
||||
'done': False,
|
||||
})
|
||||
self.assertTrue('Vous devez fournir soit un type comptable simplifi\\xc3\\xa9 ou un type comptable standard' in str(response.content))
|
||||
|
||||
def test_new_operation_not_authorized(self):
|
||||
self.client.login(username='skia', password='plop')
|
||||
at = AccountingType.objects.filter(code = '604').first()
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 30,
|
||||
'remark' : "Un gros test",
|
||||
'journal' : self.journal.id,
|
||||
'target_type' : 'OTHER',
|
||||
'target_id' : '',
|
||||
'target_label' : "Le fantome du jour",
|
||||
'date' : '04/12/2020',
|
||||
'mode' : 'CASH',
|
||||
'cheque_number' : '',
|
||||
'invoice' : '',
|
||||
'simpleaccounting_type' : '',
|
||||
'accounting_type': at.id,
|
||||
'label' : '',
|
||||
'done' : False,
|
||||
})
|
||||
at = AccountingType.objects.filter(code='604').first()
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 30,
|
||||
'remark': "Un gros test",
|
||||
'journal': self.journal.id,
|
||||
'target_type': 'OTHER',
|
||||
'target_id': '',
|
||||
'target_label': "Le fantome du jour",
|
||||
'date': '04/12/2020',
|
||||
'mode': 'CASH',
|
||||
'cheque_number': '',
|
||||
'invoice': '',
|
||||
'simpleaccounting_type': '',
|
||||
'accounting_type': at.id,
|
||||
'label': '',
|
||||
'done': False,
|
||||
})
|
||||
self.assertTrue(response.status_code == 403)
|
||||
self.assertFalse(self.journal.operations.filter(target_label = "Le fantome du jour").exists())
|
||||
self.assertFalse(self.journal.operations.filter(target_label="Le fantome du jour").exists())
|
||||
|
||||
def test__operation_simple_accounting(self):
|
||||
self.client.login(username='comptable', password='plop')
|
||||
sat = SimplifiedAccountingType.objects.all().first()
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 23,
|
||||
'remark' : "Un gros test",
|
||||
'journal' : self.journal.id,
|
||||
'target_type' : 'OTHER',
|
||||
'target_id' : '',
|
||||
'target_label' : "Le fantome de l'aurore",
|
||||
'date' : '04/12/2020',
|
||||
'mode' : 'CASH',
|
||||
'cheque_number' : '',
|
||||
'invoice' : '',
|
||||
'simpleaccounting_type' : sat.id,
|
||||
'accounting_type': '',
|
||||
'label' : '',
|
||||
'done' : False,
|
||||
})
|
||||
response = self.client.post(reverse('accounting:op_new',
|
||||
args=[self.journal.id]),
|
||||
{'amount': 23,
|
||||
'remark': "Un gros test",
|
||||
'journal': self.journal.id,
|
||||
'target_type': 'OTHER',
|
||||
'target_id': '',
|
||||
'target_label': "Le fantome de l'aurore",
|
||||
'date': '04/12/2020',
|
||||
'mode': 'CASH',
|
||||
'cheque_number': '',
|
||||
'invoice': '',
|
||||
'simpleaccounting_type': sat.id,
|
||||
'accounting_type': '',
|
||||
'label': '',
|
||||
'done': False,
|
||||
})
|
||||
self.assertFalse(response.status_code == 403)
|
||||
self.assertTrue(self.journal.operations.filter(amount=23).exists())
|
||||
response_get = self.client.get(reverse("accounting:journal_details", args=[self.journal.id]))
|
||||
@ -216,8 +215,7 @@ class OperationTest(TestCase):
|
||||
response_get = self.client.get(reverse("accounting:journal_person_statement", args=[self.journal.id]))
|
||||
self.assertTrue("S' Kia</a></td>\\n \\n <td>3.00</td>" in str(response_get.content))
|
||||
|
||||
|
||||
def test_accounting_statement(self):
|
||||
self.client.login(username='comptable', password='plop')
|
||||
response_get = self.client.get(reverse("accounting:journal_accounting_statement", args=[self.journal.id]))
|
||||
self.assertTrue("<td>443 - Cr\\xc3\\xa9dit - Ce code n'existe pas</td>\\n <td>3.00</td>" in str(response_get.content))
|
||||
self.assertTrue("<td>443 - Cr\\xc3\\xa9dit - Ce code n'existe pas</td>\\n <td>3.00</td>" in str(response_get.content))
|
||||
|
Reference in New Issue
Block a user