(self, note=None, web_user=None,
                           adjustment_method=None,
                           service_type=None, pro_bono_status=None,
                           funding_source=None, new_version=None)
return renewed_subscription
This creates a new subscription with a date_start that is
        equivalent to the current subscription's date_end.
        - The date_end is left None.
        - The plan_version is the cheapest self-subscribable plan with the
          same set of privileges that the current plan has.
This creates a new subscription with a date_start that is
        equivalent to the current subscription's date_end.
        - The date_end is left None.
        - The plan_version is the cheapest self-subscribable plan with the
          same set of privileges that the current plan has.
This creates a new subscription with a date_start that is equivalent to the current subscription s date_end . - The date_end is left None . - The plan_version is the cheapest self - subscribable plan with the same set of privileges that the current plan has .
def renew_subscription(self, note=None, web_user=None,
                           adjustment_method=None,
                           service_type=None, pro_bono_status=None,
                           funding_source=None, new_version=None):
        """
        This creates a new subscription with a date_start that is
        equivalent to the current subscription's date_end.
        - The date_end is left None.
        - The plan_version is the cheapest self-subscribable plan with the
          same set of privileges that the current plan has.
        """
        adjustment_method = adjustment_method or SubscriptionAdjustmentMethod.INTERNAL

        if self.date_end is None:
            raise SubscriptionRenewalError(
                "Cannot renew a subscription with no date_end set."
            )

        if new_version is None:
            current_privileges = get_privileges(self.plan_version)
            new_version = DefaultProductPlan.get_lowest_edition(
                current_privileges, return_plan=True,
            )

        if new_version is None:
            # this should NEVER happen, but on the off-chance that it does...
            raise SubscriptionRenewalError(
                "There was an issue renewing your subscription. Someone "
                "from Dimagi will get back to you shortly."
            )
        renewed_subscription = Subscription(
            account=self.account,
            plan_version=new_version,
            subscriber=self.subscriber,
            salesforce_contract_id=self.salesforce_contract_id,
            date_start=self.date_end,
            date_end=None,
        )
        if service_type is not None:
            renewed_subscription.service_type = service_type
        if pro_bono_status is not None:
            renewed_subscription.pro_bono_status = pro_bono_status
        if funding_source is not None:
            renewed_subscription.funding_source = funding_source
        if datetime.date.today() == self.date_end:
            renewed_subscription.is_active = True
        renewed_subscription.save()

        # record renewal from old subscription
        SubscriptionAdjustment.record_adjustment(
            self, method=adjustment_method, note=note, web_user=web_user,
            reason=SubscriptionAdjustmentReason.RENEW,
        )

        return renewed_subscription
def renew_subscription ( self , note = None , web_user = None , adjustment_method = None , service_type = None , pro_bono_status = None , funding_source = None , new_version = None ) : adjustment_method = adjustment_method or SubscriptionAdjustmentMethod . INTERNAL if self . date_end is None : raise SubscriptionRenewalError ( "Cannot renew a subscription with no date_end set." ) if new_version is None : current_privileges = get_privileges ( self . plan_version ) new_version = DefaultProductPlan . get_lowest_edition ( current_privileges , return_plan = True , ) if new_version is None : # this should NEVER happen, but on the off-chance that it does... raise SubscriptionRenewalError ( "There was an issue renewing your subscription. Someone " "from Dimagi will get back to you shortly." ) renewed_subscription = Subscription ( account = self . account , plan_version = new_version , subscriber = self . subscriber , salesforce_contract_id = self . salesforce_contract_id , date_start = self . date_end , date_end = None , ) if service_type is not None : renewed_subscription . service_type = service_type if pro_bono_status is not None : renewed_subscription . pro_bono_status = pro_bono_status if funding_source is not None : renewed_subscription . funding_source = funding_source if datetime . date . today ( ) == self . date_end : renewed_subscription . is_active = True renewed_subscription . save ( ) # record renewal from old subscription SubscriptionAdjustment . record_adjustment ( self , method = adjustment_method , note = note , web_user = web_user , reason = SubscriptionAdjustmentReason . RENEW , ) return renewed_subscription