def add_donation(donationdate, ownerid, amount, comment): """ Adds a donation """ global nextdonationid ddate = getdate(donationdate) if ddate == None: return if amount.strip() == "": return d = asm.OwnerDonation(nextdonationid) nextdonationid += 1 d.OwnerID = ownerid d.MovementID = 0 d.AnimalID = 0 d.DonationTypeID = 1 d.Date = ddate d.Donation = int(tocurrency(amount) * 100) d.Comments = comment donations.append(d)
a.ActiveMovementID = m.ID a.ActiveMovementDate = m.MovementDate a.ActiveMovementType = 1 a.LastChangedDate = dateout movements.append(m) # If there's $100 in the Spay/Neu Dep column, that means a deposit was # taken for spaying/neutering. # If the word "returned" is present, make it $0 (eg: $100 returned to adopter) # If the word "NOT" is present, do nothing (eg: $100 dep NOT taken) # If $100 is not present, do nothing if d["Spay/Neu Dep"].startswith("$100") and d["Spay/Neu Dep"].find( "NOT") == -1: amt = 10000 if d["Spay/Neu Dep"].find("returned") != -1: amt = 0 od = asm.OwnerDonation() od.DonationTypeID = 7 od.DonationPaymentID = 1 od.Date = m.MovementDate od.OwnerID = o.ID od.AnimalID = a.ID od.Donation = amt od.Comments = d["Spay/Neu Dep"] ownerdonations.append(od) if dateout is not None and d["Adoption Status"] == "Returned to owner": m = asm.Movement() m.AnimalID = a.ID m.OwnerID = uo.ID m.MovementType = 5 m.MovementDate = dateout
if nextownerid == 7200: nextownerid = 7400 # Avoid manually created animals o.OwnerForeNames = row[ADOPT_FIRST_NAME] o.OwnerSurname = row[ADOPT_LAST_NAME] o.OwnerName = o.OwnerTitle + " " + o.OwnerForeNames + " " + o.OwnerSurname o.OwnerAddress = row[ADOPT_ADDRESS] o.OwnerTown = row[ADOPT_CITY] o.OwnerCounty = row[ADOPT_STATE] o.OwnerPostcode = row[ADOPT_ZIP_CODE] o.EmailAddress = row[ADOPT_EMAIL] o.HomeTelephone = row[ADOPT_HOME_PHONE] o.Comments = "Drivers Lic: " + row[ADOPT_CA_DRIVERS_LICENSE] ownermap[personkey] = o # If there is an donation fee amount on the row, create one if getcurrency(row[ADOPT_DONATION]) > 0 and o is not None: od = asm.OwnerDonation(nextownerdonationid) ownerdonations.append(od) nextownerdonationid += 1 if nextownerdonationid == 7801: nextownerdonationid = 7900 # Avoid later added recs od.OwnerID = o.ID od.AnimalID = a.ID od.MovementID = 0 od.Comments = row[ADOPT_PAYMENT_TYPE] + " " + row[ADOPT_PAYMENT__] + " " + row[ADOPT_EXP_DATE] od.Date = getdate(row[ADOPT_DATE_OF_ADOPTION]) od.Donation = getcurrency(row[ADOPT_DONATION]) od.DonationTypeID = 1 # Donation od.DonationPaymentID = getpaymentmethod(row[ADOPT_PAYMENT_TYPE]) # If there is an adoption fee amount on the row, create one. # NB: od deliberately holds adoption fee going into the next # section so that adoptions can embellish movement id on it
if row[AMOUNT] == "Amount": continue # Enough data for row? if len(row) < 2: break if row[0].strip() == "" and row[1].strip() == "" and row[2].strip( ) == "": continue # Have we already got a record for this owner and their donation? if not finddonation(row[FIRST_NAME], row[LAST_NAME], row[DATE], row[AMOUNT]): # Nope, let's grab the owner record so we can make one oid = findowner(row[FIRST_NAME], row[LAST_NAME]) if oid == None: continue # Create the donation if row[AMOUNT] != "" and row[AMOUNT] != "0": d = asm.OwnerDonation(nextdid) nextdid += 1 d.OwnerID = oid d.MovementID = 0 d.AnimalID = 0 d.DonationTypeID = 1 d.Date = getdate(row[DATE]) d.Donation = int(float(row[AMOUNT]) * 100) d.Comments = row[SPECIAL_FEATURE].strip() print d print "DELETE FROM configuration WHERE ItemName LIKE 'DBView%';" print "COMMIT;"
if strip(row, CL_DATE) != "": m = asm.Movement(nextmovementid) movements.append(m) nextmovementid += 1 m.AnimalID = a.ID m.OwnerID = o.ID m.MovementType = 5 m.MovementDate = getdate(row[CL_DATE]) m.Comments = strip(row, CLAIM_NO) + " " + strip(row, NOTES) a.ActiveMovementDate = m.MovementDate a.ActiveMovementID = m.ID a.ActiveMovementType = m.MovementType a.Archived = 1 if strip(row, CLAIM_FEE) != "" and strip(row, CLAIM_FEE) != "0": d = asm.OwnerDonation(nextdonationid) nextdonationid += 1 d.OwnerID = o.ID d.MovementID = m.ID d.AnimalID = a.ID d.DonationTypeID = 6 d.Date = getdate(row[CL_DATE]) d.Donation = tocurrency(strip(row, CLAIM_FEE)) d.Comments = "" donations.append(d) CARD_NO = 0 SEARCH = 1 TODAY = 2 TITLE = 3 AD_NAME = 4