yearly fee support
smbaker [Thu, 11 Oct 2012 20:48:33 +0000 (13:48 -0700)]
apps/gacks/gacksinvoice.py

index 9f97727..36800d6 100644 (file)
@@ -538,6 +538,10 @@ class GacksInvoiceManager(GacksDB):
             # If the policy doesn't have a monthly fee, then return
             return
 
+        if policy.membershipFeeMonths <= 0:
+            # This is probably a bug if this happens
+            return
+
         policy_name_id = self.get_object_id(policy.name)
 
         # get a list of monthly fees that have been charged, so we know the most recent one we charged
@@ -548,7 +552,7 @@ class GacksInvoiceManager(GacksDB):
             # We have existing charges. The next charge will be 1 month after
             # the latest charge.
             print "latest", account.name, time.ctime(latest_monthly)
-            date = GacksTime.month_delta(latest_monthly, 1)
+            date = GacksTime.month_delta(latest_monthly, policy.membershipFeeMonths)
         else:
             # We haven't charged any yet, so the next charge will be the
             # service start date.
@@ -569,7 +573,7 @@ class GacksInvoiceManager(GacksDB):
             self.add_charge(account.id, policy_name_id, KIND_MONTHLY_FEE, date, policy.membershipFee, STATE_APPLY)
 
             # bill the next month
-            date = GacksTime.month_delta(date, 1)
+            date = GacksTime.month_delta(date, policy.membershipFeeMonths)
 
     def apply_invoices(self):
         # get a list of (account_id, date) pairs for which there are pending charges.