Example #1
0
def jqm_options_next_month(l):
    d = now()
    days = []
    for dummy in xrange(0, 31):
        days.append(jqm_option(python2display(l, d)))
        d = add_days(d, 1)
    d = add_months(now(), 3)
    days.append(jqm_option(python2display(l, d)))
    d = add_months(now(), 6)
    days.append(jqm_option(python2display(l, d)))
    d = add_years(now(), 1)
    days.append(jqm_option(python2display(l, d)))
    return "\n".join(days)
Example #2
0
def jqm_options_next_month(l):
    d = now()
    days = []
    for dummy in xrange(0, 31):
        days.append(jqm_option(python2display(l, d)))
        d = add_days(d, 1)
    d = add_months(now(), 3)
    days.append(jqm_option(python2display(l, d)))
    d = add_months(now(), 6)
    days.append(jqm_option(python2display(l, d)))
    d = add_years(now(), 1)
    days.append(jqm_option(python2display(l, d)))
    return "\n".join(days)
Example #3
0
def check_create_next_donation(dbo, username, odid):
    """
    Checks to see if a donation is now received and the next in 
    a sequence needs to be created for donations with a frequency 
    """
    al.debug("Create next donation %d" % int(odid),
             "financial.check_create_next_donation", dbo)
    d = db.query(dbo, "SELECT * FROM ownerdonation WHERE ID = %d" % int(odid))
    if d is None or len(d) == 0:
        al.error("No donation found for %d" % int(odid),
                 "financial.check_create_next_donation", dbo)
        return
    d = d[0]
    # If we have a frequency > 0, the nextcreated flag isn't set
    # and there's a datereceived and due then we need to create the
    # next donation in the sequence
    if d["DATEDUE"] != None and d["DATE"] != None and d["FREQUENCY"] > 0 and d[
            "NEXTCREATED"] == 0:
        nextdue = d["DATEDUE"]
        if d["FREQUENCY"] == 1:
            nextdue = i18n.add_days(nextdue, 7)
        if d["FREQUENCY"] == 2:
            nextdue = i18n.add_months(nextdue, 1)
        if d["FREQUENCY"] == 3:
            nextdue = i18n.add_months(nextdue, 3)
        if d["FREQUENCY"] == 4:
            nextdue = i18n.add_years(nextdue, 1)
        al.debug("Next donation due %s" % str(nextdue),
                 "financial.check_create_next_donation", dbo)
        # Update nextcreated flag for this donation
        db.execute(
            dbo, "UPDATE ownerdonation SET NextCreated = 1 WHERE ID = %d" %
            int(odid))
        # Create the new donation due record
        did = db.get_id(dbo, "ownerdonation")
        sql = db.make_insert_user_sql(
            dbo, "ownerdonation", username,
            (("ID", db.di(did)), ("AnimalID", db.di(d["ANIMALID"])),
             ("OwnerID", db.di(d["OWNERID"])),
             ("MovementID", db.di(d["MOVEMENTID"])),
             ("DonationTypeID", db.di(d["DONATIONTYPEID"])),
             ("DateDue", db.dd(nextdue)), ("Date", db.dd(None)),
             ("Donation", db.di(d["DONATION"])),
             ("IsGiftAid", db.di(d["ISGIFTAID"])),
             ("DonationPaymentID", db.di(d["DONATIONPAYMENTID"])),
             ("Frequency", db.di(d["FREQUENCY"])), ("NextCreated", db.di(0)),
             ("Comments", db.ds(d["COMMENTS"]))))
        db.execute(dbo, sql)
Example #4
0
def check_create_next_donation(dbo, username, odid):
    """
    Checks to see if a donation is now received and the next in 
    a sequence needs to be created for donations with a frequency 
    """
    al.debug("Create next donation %d" % int(odid), "financial.check_create_next_donation", dbo)
    d = db.query(dbo, "SELECT * FROM ownerdonation WHERE ID = %d" % int(odid))
    if d is None or len(d) == 0: 
        al.error("No donation found for %d" % int(odid), "financial.check_create_next_donation", dbo)
        return
    d = d[0]
    # If we have a frequency > 0, the nextcreated flag isn't set
    # and there's a datereceived and due then we need to create the
    # next donation in the sequence
    if d["DATEDUE"] != None and d["DATE"] != None and d["FREQUENCY"] > 0 and d["NEXTCREATED"] == 0:
        nextdue = d["DATEDUE"]
        if d["FREQUENCY"] == 1:
            nextdue = i18n.add_days(nextdue, 7)
        if d["FREQUENCY"] == 2:
            nextdue = i18n.add_months(nextdue, 1)
        if d["FREQUENCY"] == 3:
            nextdue = i18n.add_months(nextdue, 3)
        if d["FREQUENCY"] == 4:
            nextdue = i18n.add_years(nextdue, 1)
        al.debug("Next donation due %s" % str(nextdue), "financial.check_create_next_donation", dbo)
        # Update nextcreated flag for this donation
        db.execute(dbo, "UPDATE ownerdonation SET NextCreated = 1 WHERE ID = %d" % int(odid))
        # Create the new donation due record
        did = db.get_id(dbo, "ownerdonation")
        sql = db.make_insert_user_sql(dbo, "ownerdonation", username, (
            ( "ID", db.di(did)),
            ( "AnimalID", db.di(d["ANIMALID"])),
            ( "OwnerID", db.di(d["OWNERID"])),
            ( "MovementID", db.di(d["MOVEMENTID"])),
            ( "DonationTypeID", db.di(d["DONATIONTYPEID"])),
            ( "DateDue", db.dd(nextdue)),
            ( "Date", db.dd(None)),
            ( "Donation", db.di(d["DONATION"])),
            ( "IsGiftAid", db.di(d["ISGIFTAID"])),
            ( "DonationPaymentID", db.di(d["DONATIONPAYMENTID"])),
            ( "Frequency", db.di(d["FREQUENCY"])),
            ( "NextCreated", db.di(0)),
            ( "Comments", db.ds(d["COMMENTS"]))
        ))
        db.execute(dbo, sql)