Ejemplo n.º 1
0
 def create_receipt_by_term_type(self, product, order_item, term_type):
     today = timezone.now()
     receipt = Receipt()
     receipt.profile = self.invoice.profile
     receipt.order_item = order_item
     receipt.transaction = self.payment.transaction
     receipt.status = PurchaseStatus.COMPLETE
     receipt.start_date = today
     if term_type == TermType.PERPETUAL or term_type == TermType.ONE_TIME_USE:
         receipt.auto_renew = False
     elif term_type == TermType.SUBSCRIPTION:
         total_months = int(
             order_item.offer.term_details['period_length']) * int(
                 order_item.offer.term_details['payment_occurrences'])
     else:
         total_months = term_type - 100
         # Get if it is monthy, bi-monthly, quartarly of annually
     if term_type < TermType.PERPETUAL:
         trial_offset = self.get_payment_schedule_start_date(
             order_item
         )  # If there are any trial days or months you need to offset it on the end date.
         receipt.end_date = self.get_future_date_months(
             trial_offset, total_months)
         receipt.auto_renew = True
     return receipt
Ejemplo n.º 2
0
    def create_receipt_by_term_type(self, product, order_item, term_type):
        today = timezone.now()
        receipt = Receipt()
        receipt.profile = self.invoice.profile
        receipt.order_item = order_item
        receipt.transaction = self.payment.transaction
        receipt.status = PurchaseStatus.COMPLETE
        receipt.start_date = today
        if term_type == TermType.PERPETUAL or term_type == TermType.ONE_TIME_USE:
            receipt.auto_renew = False
        elif term_type == TermType.SUBSCRIPTION:
            total_months = int(order_item.offer.term_details['period_length']) * int(order_item.offer.term_details['payment_occurrences'])
            receipt.end_date = self.get_future_date_months(today, total_months)
            receipt.auto_renew = True
        else:
            total_months = term_type - 100
            receipt.end_date = self.get_future_date_months(today, total_months)
            receipt.auto_renew = True

        return receipt
Ejemplo n.º 3
0
 def create_receipt_by_term_type(self, product, order_item, term_type):
     receipt = Receipt()
     receipt.profile = self.invoice.profile
     receipt.order_item = order_item
     receipt.transaction = self.payment.transaction
     receipt.status = PurchaseStatus.COMPLETE
     receipt.start_date = timezone.now()
     if term_type == TermType.SUBSCRIPTION:
         total_months = int(
             order_item.offer.term_details['period_length']) * int(
                 order_item.offer.term_details['payment_occurrences'])
         receipt.end_date = timezone.now() + timedelta(days=(total_months *
                                                             31))
         receipt.auto_renew = True
     elif term_type == TermType.MONTHLY_SUBSCRIPTION:
         total_months = 1
         receipt.end_date = timezone.now() + timedelta(days=(total_months *
                                                             31))
         receipt.auto_renew = True
     elif term_type == TermType.QUARTERLY_SUBSCRIPTION:
         total_months = 3
         receipt.end_date = timezone.now() + timedelta(days=(total_months *
                                                             31))
         receipt.auto_renew = True
     elif term_type == TermType.SEMIANNUAL_SUBSCRIPTION:
         total_months = 6
         receipt.end_date = timezone.now() + timedelta(days=(total_months *
                                                             31))
         receipt.auto_renew = True
     elif term_type == TermType.ANNUAL_SUBSCRIPTION:
         total_months = 12
         receipt.end_date = timezone.now() + timedelta(days=(total_months *
                                                             31))
         receipt.auto_renew = True
     elif term_type == TermType.PERPETUAL:
         receipt.auto_renew = False
     elif term_type == TermType.ONE_TIME_USE:
         receipt.auto_renew = False
     return receipt