コード例 #1
0
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
コード例 #2
0
# Create next invoice if last was paid and organization is not suspension
for x in Invoice.objects.filter(end_date=end, status__gt=0, organization__suspension=False):
    """
        contratos
            - 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
コード例 #3
0
# Create next invoice if last was paid and organization is not suspension
for x in Invoice.objects.filter(end_date=end, status__gt=0, organization__suspension=False):
    """
        contratos
            - 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:
コード例 #4
0
ファイル: createInoviceByOrg.py プロジェクト: Niets/gestorpsi
from gestorpsi.organization.models import Organization 
from gestorpsi.gcm.models.payment import PaymentType
from gestorpsi.gcm.models.invoice import Invoice
from gestorpsi.gcm.models.plan import Plan

# main code
for o in Organization.objects.filter(suspension=False, organization=None):

    # when client do register a automatic invoice will be created.
    # Org have no less than one invoice by default roles system invoice.
    try:
        last = Invoice.objects.filter(organization=o).latest('end_date')
    except:
        last = Invoice()
        last.start_date = date.today() - relativedelta(months=1)
        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
コード例 #5
0
from gestorpsi.organization.models import Organization 
from gestorpsi.gcm.models.payment import PaymentType
from gestorpsi.gcm.models.invoice import Invoice
from gestorpsi.gcm.models.plan import Plan

# main code
for o in Organization.objects.filter(suspension=False, organization=None):

    # when client do register a automatic invoice will be created.
    # Org have no less than one invoice by default roles system invoice.
    try:
        last = Invoice.objects.filter(organization=o).latest('end_date')
    except:
        last = Invoice()
        last.start_date = date.today() - relativedelta(months=1)
        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
コード例 #6
0
ファイル: createDelayInovice.py プロジェクト: Niets/gestorpsi
from gestorpsi.settings import URL_HOME, URL_APP, SIGNATURE
from gestorpsi.organization.models import Organization 
from gestorpsi.gcm.models.invoice import Invoice

# main code
for o in Organization.objects.filter(suspension=False, organization=None):

    # last invoice
    li = Invoice.objects.filter(organization=o).latest('id')

    while li.end_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.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

        to = [] # send mail to
        # administratror
        for e in li.organization.administrators_():
            if not e.profile.user.email in to:
                to.append(e.profile.user.email) 
        # secretary
コード例 #7
0
# main code
for o in Organization.objects.filter(suspension=False,
                                     organization=None,
                                     date_created__gte=new_format):

    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: