Luke Plant avatar Luke Plant committed 5fb557d

Added booking state for 'full refund' cancellation (in case CCIW cancel a camp)

Comments (0)

Files changed (2)

cciw/bookings/models.py

      (PRICE_DEPOSIT, 'Deposit'),
      ]
 
-BOOKING_INFO_COMPLETE, BOOKING_APPROVED, BOOKING_BOOKED, BOOKING_CANCELLED = range(0, 4)
+BOOKING_INFO_COMPLETE, BOOKING_APPROVED, BOOKING_BOOKED, BOOKING_CANCELLED, BOOKING_CANCELLED_FULL_REFUND = range(0, 5)
 BOOKING_STATES = [
     (BOOKING_INFO_COMPLETE, 'Information complete'),
     (BOOKING_APPROVED, 'Manually approved'),
     (BOOKING_BOOKED, 'Booked'),
     (BOOKING_CANCELLED, 'Cancelled'),
+    (BOOKING_CANCELLED_FULL_REFUND, 'Cancelled - full refund'),
 ]
 
 
         if self.state == BOOKING_CANCELLED:
             return Price.objects.get(year=self.camp.year,
                                      price_type=PRICE_DEPOSIT).price
+        elif self.state == BOOKING_CANCELLED_FULL_REFUND:
+            return Decimal('0.00')
         else:
             amount = Price.objects.get(year=self.camp.year,
                                        price_type=self.price_type).price

cciw/bookings/tests.py

 
 from cciw.bookings.management.commands.expire_bookings import Command as ExpireBookingsCommand
 from cciw.bookings.models import BookingAccount, Price, Booking, Payment, ChequePayment, book_basket_now
-from cciw.bookings.models import PRICE_FULL, PRICE_2ND_CHILD, PRICE_3RD_CHILD, PRICE_CUSTOM, PRICE_SOUTH_WALES_TRANSPORT, PRICE_DEPOSIT, BOOKING_APPROVED, BOOKING_INFO_COMPLETE, BOOKING_BOOKED, BOOKING_CANCELLED
+from cciw.bookings.models import PRICE_FULL, PRICE_2ND_CHILD, PRICE_3RD_CHILD, PRICE_CUSTOM, PRICE_SOUTH_WALES_TRANSPORT, PRICE_DEPOSIT, BOOKING_APPROVED, BOOKING_INFO_COMPLETE, BOOKING_BOOKED, BOOKING_CANCELLED, BOOKING_CANCELLED_FULL_REFUND
 from cciw.cciwmain.common import get_thisyear
 from cciw.cciwmain.models import Camp
 from cciw.cciwmain.tests.mailhelpers import read_email_url
                                          % p_deposit.price)
                             for p in problems))
 
+        # Check 'full refund' cancellation.
+        data['state'] = BOOKING_CANCELLED_FULL_REFUND
+        data['amount_due'] = '20.00'
+        data['price_type'] = PRICE_FULL
+        resp = self.client.post(reverse('cciw.bookings.views.booking_problems_json'),
+                                data)
+
+        json = simplejson.loads(resp.content)
+        problems = json['problems']
+        self.assertTrue(any(p.startswith(u"The 'amount due' is not the expected value of £0.00")
+                            for p in problems))
+
 
 class TestAccountOverview(CreatePlaceMixin, TestCase):
 
 
         acc = self.get_account()
         self.assertEqual(acc.get_balance(), place.amount_due)
+
+
+class TestCancelFullRefund(CreatePlaceMixin, TestCase):
+    """
+    Tests covering what happens when CCIW cancels a camp,
+    using 'full refund'.
+    """
+    fixtures = ['basic.json']
+
+    def test_amount_due(self):
+        self.create_place()
+        acc = self.get_account()
+        place = acc.bookings.all()[0]
+        place.state = BOOKING_CANCELLED_FULL_REFUND
+        self.assertEqual(place.expected_amount_due(), Decimal('0.00'))
+
+    def test_account_amount_due(self):
+        self.create_place()
+        acc = self.get_account()
+        place = acc.bookings.all()[0]
+        place.state = BOOKING_CANCELLED_FULL_REFUND
+        place.auto_set_amount_due()
+        place.save()
+
+        acc = self.get_account()
+        self.assertEqual(acc.get_balance(), place.amount_due)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.