def create_invoice(org, status=None, paytype=None, bank=None, details=None): # new invoice i = Invoice() i.organization = org i.plan = org.prefered_plan if status: i.status = status i.bank = bank i.payment_type = PaymentType.objects.get(pk=paytype) i.date_payed = date.today() i.start_date = i.date_payed i.end_date = i.start_date + relativedelta(years=5) i.expiry_date = i.start_date + relativedelta(years=5) i.payment_detail = u"gateway code: %s" % details else: i.status = 2 # free i.save() return i
- seram avisados um mes antes de vencer - nao gera fatura mensal boleto termina em um mês ou menos """ # non exist if Invoice.objects.filter(end_date=end + relativedelta(months=1), organization=x.organization).count() == 0: i = Invoice() # new invoice i.organization = x.organization i.start_date = end i.end_date = end + relativedelta(months=1) i.payment_type = x.organization.payment_type i.ammount = x.organization.prefered_plan.value i.plan = x.organization.prefered_plan i.status = 0 # pendente i.save() to = [] # send mail to bcc = [] bcc.append("*****@*****.**") """ send mail just to user is_active = True """ # administratror of org for e in x.organization.administrators_(): if e.profile.user.is_active and not e.profile.user.email in to: to.append(e.profile.user.email)
- seram avisados um mes antes de vencer - nao gera fatura mensal boleto termina em um mês ou menos """ # non exist if Invoice.objects.filter( end_date=end+relativedelta(months=1), organization=x.organization ).count() == 0 : i = Invoice() # new invoice i.organization = x.organization i.start_date = end i.end_date = end + relativedelta(months=1) i.payment_type = x.organization.payment_type i.ammount = x.organization.prefered_plan.value i.plan = x.organization.prefered_plan i.status = 0 # pendente i.save() to = [] # send mail to ''' send mail just to user is_active = True ''' # administratror of org for e in x.organization.administrators_(): if e.profile.user.is_active and not e.profile.user.email in to: to.append(e.profile.user.email) # secretary of org for e in x.organization.secretary_():
last.end_date = date.today() # can not be None if o.payment_type == None: o.payment_type = PaymentType.objects.get(pk=1) # credit card o.save() # can not be None / Check how many professional are subscribed. if o.prefered_plan == None: o.prefered_plan = Plan.objects.get(pk=2) # 1 professional o.save() """ contratos - seram avisados um mes antes de vencer - nao gera fatura mensal boleto termina em um mês ou menos """ if last.end_date <= ( date.today() + relativedelta(months=1) ): i = Invoice() # new invoice i.organization = o i.start_date = last.end_date i.end_date = i.start_date + relativedelta(months=1) i.payment_type = o.payment_type i.ammount = o.prefered_plan.value i.plan = o.prefered_plan i.status = 0 # pendente i.save()
inv = [] # invoices to print resume # last invoice li = Invoice.objects.filter(organization=o).latest('id') while li.end_date < date.today()+relativedelta(months=1) and li.start_date < date.today(): i = Invoice() # new invoice i.organization = li.organization i.start_date = li.end_date i.end_date = li.end_date + relativedelta(months=1) i.expiry_date = i.start_date + relativedelta(days=7) i.payment_type = li.organization.payment_type i.ammount = li.organization.prefered_plan.value i.plan = li.organization.prefered_plan i.status = 0 # pendente i.save() li = i # check end_date of new invoice inv.append(i) # print resume to email admin if len(inv) > 0 : print '--- Creating a new invoice: %s' % (o) for x in inv: print '- Start %s End %s Expiry %s' % (x.start_date, x.end_date, x.expiry_date) print """
inv = [] # invoices to print resume # last invoice li = Invoice.objects.filter(organization=o).latest('id') while li.end_date < date.today() + relativedelta( months=1) and li.start_date < date.today(): i = Invoice() # new invoice i.organization = li.organization i.start_date = li.end_date i.end_date = li.end_date + relativedelta(months=1) i.expiry_date = i.start_date + relativedelta(days=7) i.payment_type = li.organization.payment_type i.ammount = li.organization.prefered_plan.value i.plan = li.organization.prefered_plan i.status = 0 # pendente i.save() li = i # check end_date of new invoice inv.append(i) # print resume to email admin if len(inv) > 0: print '--- Creating a new invoice: %s' % (o) for x in inv: print '- Start %s End %s Expiry %s' % (x.start_date, x.end_date, x.expiry_date) print """ Before 12 09 2016, will use old format, Use and Pay.