Commit 418537bc authored by Krophil's avatar Krophil

tests for accounting added

parent df7b0a5f
......@@ -6,6 +6,7 @@ from django.conf import settings
from core.models import User
from counter.models import Counter
from accounting.models import GeneralJournal, Operation, AccountingType
class RefoundAccountTest(TestCase):
......@@ -17,7 +18,7 @@ class RefoundAccountTest(TestCase):
self.skia.customer.save()
def test_permission_denied(self):
self.client.login(useername='guy', password='plop')
self.client.login(username='guy', password='plop')
response_post = self.client.post(reverse("accounting:refound_account"),
{"user": self.skia.id})
response_get = self.client.get(reverse("accounting:refound_account"))
......@@ -45,3 +46,75 @@ class RefoundAccountTest(TestCase):
self.assertTrue('<form action="" method="post">' in str(response_get.content))
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()
def test_permission_granted(self):
self.client.login(username='comptable', password='plop')
response_get = self.client.get(reverse("accounting:journal_details", args=[self.journal.id]))
self.assertTrue(response_get.status_code == 200)
self.assertTrue('<td>M\\xc3\\xa9thode de paiement</td>' in str(response_get.content))
def test_permission_not_granted(self):
self.client.login(username='skia', password='plop')
response_get = self.client.get(reverse("accounting:journal_details", args=[self.journal.id]))
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.skia = User.objects.filter(username='skia').first()
def test_new_operation(self):
self.client.login(username='comptable', password='plop')
at = AccountingType.objects.filter(code = '604').first()
at.save()
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())
def test_new_operation_not_authorized(self):
self.client.login(username='skia', password='plop')
at = AccountingType.objects.filter(code = '604').first()
at.save()
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.assertTrue(response.status_code == 403)
\ No newline at end of file
......@@ -295,22 +295,22 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
ca.save()
gj = GeneralJournal(name="A16", start_date=date.today(), club_account=ca)
gj.save()
credit = AccountingType(code='74', label="Someone gave us money", movement_type='CREDIT')
credit = AccountingType(code='74', label="Subventions d'exploitation", movement_type='CREDIT')
credit.save()
debit = AccountingType(code='607', label="Had to pay a beer", movement_type='DEBIT')
debit = AccountingType(code='606', label="Achats non stockés de matières et fournitures(*1)", movement_type='DEBIT')
debit.save()
t = AccountingType(code='602', label="Gros test de malade", movement_type='DEBIT')
t.save()
Operation(journal=gj, date=date.today(), amount=32.3, remark="...", mode="CASH", done=True, accounting_type=t, target_type="USER", target_id=skia.id).save()
t = AccountingType(code='60', label="...", movement_type='DEBIT')
t.save()
Operation(journal=gj, date=date.today(), amount=32.3, remark="...", mode="CASH", done=True, accounting_type=t, target_type="USER", target_id=skia.id).save()
Operation(journal=gj, date=date.today(), amount=46.42, remark="An answer to life...", mode="CASH", done=True, accounting_type=t, target_type="USER", target_id=skia.id).save()
debit2 = AccountingType(code='604', label="Achats d'études et prestations de services(*2)", movement_type='DEBIT')
debit2.save()
Operation(journal=gj, date=date.today(), amount=300, remark="Paiement Guy", mode="CASH", done=True, accounting_type=debit2, target_type="USER", target_id=skia.id).save()
buying = AccountingType(code='60', label="Achats (sauf 603)", movement_type='DEBIT')
buying.save()
Operation(journal=gj, date=date.today(), amount=32.3, remark="Essence", mode="CASH", done=True, accounting_type=buying, target_type="USER", target_id=skia.id).save()
Operation(journal=gj, date=date.today(), amount=46.42, remark="marqueurs + rouleaux", mode="CASH", done=True, accounting_type=debit, target_type="USER", target_id=skia.id).save()
Operation(journal=gj, date=date.today(), amount=666.42,
remark="An answer to life...", mode="CASH", done=True, accounting_type=credit, target_type="USER",
remark="Subvention territoire de FarfarAway", mode="CASH", done=True, accounting_type=credit, target_type="USER",
target_id=skia.id).save()
Operation(journal=gj, date=date.today(), amount=42,
remark="An answer to life...", mode="CASH", done=False, accounting_type=debit, target_type="CLUB",
remark="La Gargotte du Korrigan", mode="CASH", done=False, accounting_type=debit, target_type="CLUB",
target_id=bar_club.id).save()
woenzco = Company(name="Woenzel & co")
woenzco.save()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment