Permalink
Browse files

Created tests and fixed templates

  • Loading branch information...
1 parent 03ba322 commit d3fc83cac80955368d21947530654446a9e0bd0b @annttu annttu committed Dec 23, 2013
View
12 membership/models.py
@@ -665,8 +665,8 @@ def render_as_text(self):
"""
membership = self.billingcycle.membership
vat = Decimal(self.billingcycle.get_vat_percentage()) / Decimal(100)
-
if not self.is_reminder():
+ non_vat_amount = (self.billingcycle.sum / (Decimal(1) + vat))
return render_to_string('membership/bill.txt', {
'membership_type' : MEMBER_TYPES_DICT[membership.type],
'membership_type_raw' : membership.type,
@@ -686,8 +686,8 @@ def render_as_text(self):
'today': datetime.now(),
'reference_number': group_right(self.billingcycle.reference_number),
'sum': self.billingcycle.sum,
- 'vat_amount': vat * self.billingcycle.sum,
- 'non_vat_amount': (Decimal(1) - vat) * self.billingcycle.sum,
+ 'vat_amount': vat * non_vat_amount,
+ 'non_vat_amount': non_vat_amount,
'vat_percentage': self.billingcycle.get_vat_percentage(),
'barcode': barcode_4(iban = settings.IBAN_ACCOUNT_NUMBER,
refnum = self.billingcycle.reference_number,
@@ -697,7 +697,7 @@ def render_as_text(self):
else:
amount_paid = self.billingcycle.amount_paid()
sum = self.billingcycle.sum - amount_paid
-
+ non_vat_sum = sum / (Decimal(1) + vat)
return render_to_string('membership/reminder.txt', {
'membership_type' : MEMBER_TYPES_DICT[membership.type],
'membership_type_raw' : membership.type,
@@ -721,8 +721,8 @@ def render_as_text(self):
'original_sum': self.billingcycle.sum,
'amount_paid': amount_paid,
'sum': sum,
- 'vat_amount': vat * sum,
- 'non_vat_amount': (1 - vat) * sum,
+ 'vat_amount': vat * non_vat_sum,
+ 'non_vat_amount': non_vat_sum,
'vat_percentage': self.billingcycle.get_vat_percentage(),
'barcode': barcode_4(iban = settings.IBAN_ACCOUNT_NUMBER,
refnum = self.billingcycle.reference_number,
View
9 membership/templates/membership/bill.txt
@@ -19,10 +19,10 @@ PL 11
Laskun erittely
----------------------------------------------------------------------
-Jäsenmaksu {{ membership_type|ljust:"15" }} {{ billingcycle.start|date:"SHORT_DATE_FORMAT" }} - {{ billingcycle.end|date:"SHORT_DATE_FORMAT" }} {{ non_vat_amount|rjust:"5"}} e
-Arvonlisävero {{ vat_percentage|ljust:"3" }} {{ vat_amount|rjust:"5" }} e
+Jäsenmaksu {{ membership_type|ljust:"15" }} {{ billingcycle.start|date:"SHORT_DATE_FORMAT" }} - {{ billingcycle.end|date:"SHORT_DATE_FORMAT" }} {{ non_vat_amount|rjust:"5"|floatformat:2 }} euroa
+Arvonlisävero {{ vat_percentage|ljust:"3"|floatformat:0 }} % {{ vat_amount|rjust:"5"|floatformat:2 }} euroa
----------------------------------------------------------------------
-Loppusumma yhteensä {{ sum|rjust:"5"}} e
+Loppusumma yhteensä {{ sum|rjust:"5"|floatformat:2 }} e
Maksaminen
----------------------------------------------------------------------
@@ -36,9 +36,6 @@ Virtuaaliviivakoodi: {{ barcode }}
Viitenumeroa on ehdottomasti käytettävä maksaessa jotta maksu
kohdistuisi oikein!
-Voit myös maksaa enemmän, jolloin ylimenevä osuus tulkitaan
-lahjoitukseksi.
-
Laskuttaja
----------------------------------------------------------------------
Kapsi Internet-käyttäjät ry
View
10 membership/templates/membership/reminder.txt
@@ -43,11 +43,11 @@ Kotipaikka: {{ municipality|ljust:"30" }}
Muistutettavat jäsenmaksut:
--------------------------------------------------------------------
-Jäsenmaksu {{ membership_type|ljust:"15" }} {{ billingcycle.start|date:"SHORT_DATE_FORMAT" }} - {{ billingcycle.end|date:"SHORT_DATE_FORMAT" }} {{ non_vat_amount|rjust:"5"}} e
-Arvonlisävero {{ vat_percentage|ljust:"3" }} {{ vat_amount|rjust:"5" }} e{% if amount_paid %}
-Aiemmat suoritukset {{ amount_paid|rjust:"5"}} e{% endif %}
+Jäsenmaksu {{ membership_type|ljust:"15" }} {{ billingcycle.start|date:"SHORT_DATE_FORMAT" }} - {{ billingcycle.end|date:"SHORT_DATE_FORMAT" }} {{ non_vat_amount|rjust:"5"|floatformat:2}} euroa
+Arvonlisävero {{ vat_percentage|ljust:"3"|floatformat:0 }} % {{ vat_amount|rjust:"5"|floatformat:2 }} euroa{% if amount_paid %}
+Aiemmat suoritukset {{ amount_paid|rjust:"5"}} euroa{% endif %}
--------------------------------------------------------------------
- {{ sum|rjust:"5"}} e
+ {{ sum|rjust:"5"}} euroa
@@ -93,5 +93,5 @@ TAPAHTUMAT
(Tapahtumalistaa ei vielä saatavilla)
---
+--
Kapsin laskutus <laskutus@tuki.kapsi.fi>
View
86 membership/tests.py
@@ -255,20 +255,32 @@ def test_fees(self):
H_FEE=0
soon = datetime.now() + timedelta(hours=1)
# Old fees
- Fee.objects.create(type='P', start=week_ago, sum=P_FEE/2)
- Fee.objects.create(type='O', start=week_ago, sum=O_FEE/2)
- Fee.objects.create(type='S', start=week_ago, sum=S_FEE/2)
- Fee.objects.create(type='H', start=week_ago, sum=H_FEE/2)
+ Fee.objects.create(type='P', start=week_ago, sum=P_FEE/2,
+ vat_percentage=24)
+ Fee.objects.create(type='O', start=week_ago, sum=O_FEE/2,
+ vat_percentage=24)
+ Fee.objects.create(type='S', start=week_ago, sum=S_FEE/2,
+ vat_percentage=24)
+ Fee.objects.create(type='H', start=week_ago, sum=H_FEE/2,
+ vat_percentage=24)
# Real fees
- p_fee = Fee.objects.create(type='P', start=now, sum=P_FEE)
- o_fee = Fee.objects.create(type='O', start=now, sum=O_FEE)
- s_fee = Fee.objects.create(type='S', start=now, sum=S_FEE)
- h_fee = Fee.objects.create(type='H', start=now, sum=H_FEE)
+ p_fee = Fee.objects.create(type='P', start=now, sum=P_FEE,
+ vat_percentage=24)
+ o_fee = Fee.objects.create(type='O', start=now, sum=O_FEE,
+ vat_percentage=24)
+ s_fee = Fee.objects.create(type='S', start=now, sum=S_FEE,
+ vat_percentage=24)
+ h_fee = Fee.objects.create(type='H', start=now, sum=H_FEE,
+ vat_percentage=24)
# Future fees that must not interfere
- Fee.objects.create(type='P', start=soon, sum=P_FEE*2)
- Fee.objects.create(type='O', start=soon, sum=O_FEE*2)
- Fee.objects.create(type='S', start=soon, sum=S_FEE*2)
- Fee.objects.create(type='H', start=soon, sum=H_FEE*2)
+ Fee.objects.create(type='P', start=soon, sum=P_FEE*2,
+ vat_percentage=24)
+ Fee.objects.create(type='O', start=soon, sum=O_FEE*2,
+ vat_percentage=24)
+ Fee.objects.create(type='S', start=soon, sum=S_FEE*2,
+ vat_percentage=24)
+ Fee.objects.create(type='H', start=soon, sum=H_FEE*2,
+ vat_percentage=24)
makebills()
c_p = BillingCycle.objects.get(membership__type='P')
c_o = BillingCycle.objects.get(membership__type='O')
@@ -861,11 +873,11 @@ def test_dash_delimiter_begins_with_plus(self):
class OrganizationRegistratioTest(TestCase):
def setUp(self):
self.field = OrganizationRegistrationNumber()
-
+
def test_valid(self):
self.assertEqual(u"1.11", self.field.clean(u"1.11"))
self.assertEqual(u"123.123", self.field.clean(u"123.123"))
-
+
def test_invalid(self):
self.assertRaises(ValidationError, self.field.clean, "str.str")
self.assertRaises(ValidationError, self.field.clean, "11111")
@@ -1296,22 +1308,38 @@ class CorrectVatAmountInBillTest(TestCase):
"""
fixtures = ['membership_fees.json', 'test_user.json']
- # def setUp(self):
- # self.user = User.objects.get(id=1)
+ def setUp(self):
+ #settings.BILLING_CC_EMAIL = None
+ self.user = User.objects.get(id=1)
- # self.m = create_dummy_member('N')
- # self.m.save()
- # self.m.preapprove(self.user)
- # self.m.approve(self.user)
+ self.m = create_dummy_member('N')
+ self.m.save()
+ self.m.preapprove(self.user)
+ self.m.approve(self.user)
+
+ cycle_start = datetime(year=2012, month=10, day=10)
+ self.cycle = BillingCycle(membership=self.m, start=cycle_start)
+ self.cycle.save()
+ cycle_start_2014 = datetime(year=2014, month=1, day=10)
+ self.cycle_2014 = BillingCycle(membership=self.m,
+ start=cycle_start_2014)
+ self.cycle_2014.save()
+ self.bill_2013 = Bill(billingcycle=self.cycle, type='P',
+ due_date=cycle_start)
+ self.bill_2014 = Bill(billingcycle=self.cycle_2014, type='P',
+ due_date=cycle_start_2014)
+ #mail.outbox = []
- # cycle_start = datetime.now() - timedelta(days=60)
- # cycle = BillingCycle(membership=self.m, start=cycle_start)
- # cycle.save()
- # self.bill = Bill(billingcycle=cycle, type='P',
- # due_date=datetime.now() - timedelta(days=20))
+ def tearDown(self):
+
+ #self.bill_2014.delete()
+ #self.bill_2013.delete()
+ self.cycle.delete()
+ self.cycle_2014.delete()
+ self.m.delete()
- # def test_should_contain_vat_percentage(self):
- # self.assertIn("24%", self.bill.render_as_text(test_year=2014))
+ def test_should_contain_vat_percentage(self):
+ self.assertIn("vero 24", self.bill_2014.render_as_text())
- # def test_should_not_contain_vat_percentage(self):
- # self.assertNotIn("24%", self.bill.render_as_text(test_year=2013))
+ def test_should_not_contain_vat_percentage(self):
+ self.assertNotIn("vero 24", self.bill_2013.render_as_text())
View
46 sikteeri/membership_fees.json
@@ -1,80 +1,80 @@
[
{
- "pk": 1,
+ "pk": 1,
"model": "membership.fee",
"fields": {
"type": "P",
- "start": "2003-01-01 00:00:00",
+ "start": "2003-01-01 00:00:00",
"sum": "30.00",
"vat_percentage": "0"
}
},
{
- "pk": 2,
+ "pk": 2,
"model": "membership.fee",
"fields": {
"type": "O",
- "start": "2003-01-01 00:00:00",
+ "start": "2003-01-01 00:00:00",
"sum": "100.00",
"vat_percentage": "0"
}
},
{
- "pk": 3,
+ "pk": 3,
"model": "membership.fee",
"fields": {
"type": "S",
- "start": "2003-01-01 00:00:00",
+ "start": "2003-01-01 00:00:00",
"sum": "100.00",
"vat_percentage": "0"
}
},
{
- "pk": 4,
+ "pk": 4,
"model": "membership.fee",
"fields": {
"type": "H",
- "start": "2003-01-01 00:00:00",
+ "start": "2003-01-01 00:00:00",
"sum": "0.00",
"vat_percentage": "0"
}
},
{
- "pk": 5,
+ "pk": 5,
"model": "membership.fee",
"fields": {
"type": "P",
- "start": "2011-01-01 00:00:00",
+ "start": "2011-01-01 00:00:00",
"sum": "35.00",
"vat_percentage": "0"
}
},
{
- "pk": 6,
+ "pk": 6,
"model": "membership.fee",
"fields": {
"type": "O",
- "start": "2011-01-01 00:00:00",
+ "start": "2011-01-01 00:00:00",
"sum": "60.00",
"vat_percentage": "0"
}
},
{
- "pk": 7,
+ "pk": 7,
"model": "membership.fee",
"fields": {
"type": "S",
- "start": "2011-01-01 00:00:00",
+ "start": "2011-01-01 00:00:00",
"sum": "250.00",
"vat_percentage": "0"
}
},
{
- "pk": 8,
+ "pk": 8,
"model": "membership.fee",
"fields": {
"type": "H",
- "start": "2011-01-01 00:00:00",
+ "start": "2011-01-01 00:00:00",
"sum": "0.00",
"vat_percentage": "0"
}
@@ -84,37 +84,37 @@
"model": "membership.fee",
"fields": {
"type": "P",
- "start": "2011-01-01 00:00:00",
+ "start": "2014-01-01 00:00:00",
"sum": "40.00",
"vat_percentage": "24"
}
},
{
- "pk": 10,
+ "pk": 10,
"model": "membership.fee",
"fields": {
"type": "O",
- "start": "2014-01-01 00:00:00",
+ "start": "2014-01-01 00:00:00",
"sum": "60.00",
"vat_percentage": "24"
}
},
{
- "pk": 11,
+ "pk": 11,
"model": "membership.fee",
"fields": {
"type": "S",
- "start": "2014-01-01 00:00:00",
+ "start": "2014-01-01 00:00:00",
"sum": "250.00",
"vat_percentage": "24"
}
},
{
- "pk": 12,
+ "pk": 12,
"model": "membership.fee",
"fields": {
"type": "H",
- "start": "2014-01-01 00:00:00",
+ "start": "2014-01-01 00:00:00",
"sum": "0.00",
"vat_percentage": "24"
}

0 comments on commit d3fc83c

Please sign in to comment.