av.AnimalID = a.ID av.VaccinationID = int(row["vacc"].strip()) print av # tblreceiptentry.csv for row in asm.csv_to_list(PATH + "tblreceiptentry.csv"): od = asm.OwnerDonation() od.DonationTypeID = 1 pm = getsbpaymentmethod(row["paymentmethod"]) od.DonationPaymentID = 1 if pm.find("Check") != -1: od.DonationPaymentID = 2 if pm.find("Credit Card") != -1: od.DonationPaymentID = 3 if pm.find("Debit Card") != -1: od.DonationPaymentID = 4 od.Date = getdate(row["receiptdate"]) od.OwnerID = findowner(row["recnum"]).ID od.Donation = asm.get_currency(row["Amount"]) comments = "Check No: " + row["chequeno"] comments += "\nMethod: " + pm comments += "\n" + row["NotesToPrint"] od.Comments = comments print od # Now that everything else is done, output stored records print "DELETE FROM primarykey;" print "DELETE FROM configuration WHERE ItemName Like 'VariableAnimalDataUpdated';" for a in animals: print a for o in owners: print o for m in movements: print m
animalmedicals.append( asm.animal_regimen_single(a.ID, startdate, treatmentname, dosage, comments)) # tblreceiptentry.csv for row in asm.csv_to_list(PATH + "tblreceiptentry.csv"): od = asm.OwnerDonation() od.DonationTypeID = 1 pm = getsbpaymentmethod(row["dep_paymentMethod"]) od.DonationPaymentID = 1 if pm.find("Check") != -1: od.DonationPaymentID = 2 if pm.find("Credit Card") != -1: od.DonationPaymentID = 3 if pm.find("Debit Card") != -1: od.DonationPaymentID = 4 od.Date = getdate(row["receiptdate"]) od.OwnerID = findowner(row["recnum"]).ID od.Donation = asm.get_currency(row["dep_amount"]) comments = "Check No: " + row["dep_chequeNo"] comments += "\nMethod: " + pm comments += "\n" + row["NotesToPrint"] od.Comments = comments ownerdonations.append(od) """ # Used to populate an additional field called Tag with any SB tag number set for row in asm.csv_to_list(PATH + "tbltaghistory.csv"): a = findanimal(row["animalId"]) if a is not None: asm.additional_field("Tag", 2, a.ID, row["tagNumber"]) """ # Now that everything else is done, output stored records print "DELETE FROM primarykey;"
m.ReturnDate = asm.getdate_mmddyy(d["ReturnDate"]) if d["ReasonForReturn"] != "": m.Comments += " " + d["ReasonForReturn"] a.Archived = 1 a.ActiveMovementID = m.ID a.ActiveMovementType = 1 a.LastChangedDate = m.MovementDate movements.append(m) if d["AdoptionFeePd"] == "1": od = asm.OwnerDonation() ownerdonations.append(od) od.OwnerID = o.ID od.AnimalID = a.ID od.MovementID = m.ID od.Date = m.MovementDate od.Donation = asm.get_currency(d["AdoptionFeeAmount"]) od.DonationTypeID = 2 # Adoption Fee # Get the current image for this animal from PetFinder if it is on shelter if a.Archived == 0 and PETFINDER_ID != "" and pf != "": asm.petfinder_image(pf, a.ID, a.AnimalName) for d in creceipts: if not owners.has_key(d["PerID"]): continue o = owners[d["PerID"]] od = asm.OwnerDonation() ownerdonations.append(od) od.OwnerID = o.ID od.AnimalID = 0 od.MovementID = 0 od.Date = asm.getdate_mmddyy(d["Date"])
""" Parses one of their dispatch dates """ if s.strip() == "": return None return asm.getdate_mmddyyyy(s[:s.find(" ")]) # People and licenses first for d in asm.csv_to_list("%s/licenses.csv" % PATH, strip=True): if d["Animal People"].strip() == "": continue # Can't do anything without person o = get_owner(d["Animal People"].strip()) ol = asm.OwnerLicence() ownerlicence.append(ol) ol.OwnerID = o.ID ol.LicenceTypeID = 1 ol.LicenceNumber = d["ID Number"] ol.LicenceFee = asm.get_currency(d["License Fee"]) ol.IssueDate = getdate(d["Issue Date"]) ol.ExpiryDate = getdate(d["End Date"]) ol.CreatedBy = "conversion/%s" % d["Issued By"] if ol.ExpiryDate is None: ol.ExpiryDate = asm.add_days(ol.IssueDate, 3650) ol.Comments = "Item: %s\nAnimal: %s\nReceipt: %s" % ( d["Fee Item"], d["Animal Name"], d["Receipt #"]) # People and microchips next for d in asm.csv_to_list("%s/microchips.csv" % PATH, strip=True): if d["Associated people"].strip() == "": continue # Can't do anything without person if d["Microchip"].strip() == "": continue # Pointless without an actual microchip o = get_owner(d["Associated people"].strip()) # Bare minimum non-shelter animal record for the microchip
m = asm.Movement(nextmovementid) nextmovementid += 1 m.AnimalID = a.ID m.OwnerID = o.ID m.MovementType = 1 m.MovementDate = evtdate a.Archived = 1 a.ActiveMovementDate = evtdate a.ActiveMovementID = m.ID a.ActiveMovementType = 1 movements.append(m) for row in asm.csv_to_list(PATH + "appeals.csv", strip=True): # Skip junk data if asm.get_currency(row["Amount"]) == 0: continue o = findowner(masterid = row["SponsorID"]) if o is None: continue od = asm.OwnerDonation(nextownerdonationid) ownerdonations.append(od) nextownerdonationid += 1 od.OwnerID = o.ID od.AnimalID = 0 od.MovementID = 0 od.Date = asm.getdate_mmddyy(row["AppealDate"]) od.Donation = asm.get_currency(row["Amount"]) od.DonationTypeID = asm.donationtype_id_for_name(row["AppealType"], True) od.DonationPaymentID = getpaymentmethod(row["Paymethod"]) od.Comments = row["Anotes"]
m.MovementType = 1 m.MovementDate = asm.todatetime(d["DATE_DISPO"]) if d["RECLAIMED"] == "X": m.MovementType = 5 m.LastChangedDate = m.MovementDate a.Archived = 1 a.ActiveMovementType = m.MovementType a.ActiveMovementDate = m.MovementDate for p in DBF("%s/PAYMENTS.DBF" % PATH): od = asm.OwnerDonation() ownerdonations.append(od) if p["PMNT_ID"] in ppo: o = ppo[p["PMNT_ID"]] od.OwnerID = o.ID od.Donation = asm.get_currency(p["AMOUNT"]) od.Date = p["PMNT_DATE"] od.DonationTypeID = 4 # Surrender if p["PMNT_CODE"] == "ADP": od.DonationTypeID = 2 for l in DBF("%s/LICENSE.DBF" % PATH): ol = asm.OwnerLicence() ownerlicences.append(ol) if l["OWNER_ID"] in ppo: o = ppo[l["OWNER_ID"]] ol.OwnerID = o.ID ol.LicenceTypeID = 1 ol.LicenceNumber = l["LIC_NUM"] if "FEE" in l: ol.LicenceFee = asm.get_currency(l["FEE"]) ol.IssueDate = l["LIC_DATE"]
m.OwnerID = get_asm_ownerid(d["ID"]) activeowner = m.OwnerID m.MovementType = 1 m.MovementDate = getdate(d["DateAdopted"]) a.Archived = 1 a.ActiveMovementID = m.ID a.ActiveMovementType = 1 a.LastChangedDate = m.MovementDate movements.append(m) if d["AdoptionFee"] != "": od = asm.OwnerDonation() od.DonationTypeID = 2 # adoption fee od.DonationPaymentID = 1 od.Date = m.MovementDate od.OwnerID = m.OwnerID od.Donation = asm.get_currency(d["AdoptionFee"]) ownerdonations.append(od) if d["SpayNeuterAmt"] != "": od = asm.OwnerDonation() od.DonationTypeID = 1 # donation od.DonationPaymentID = 1 od.Date = a.DateBroughtIn od.OwnerID = m.OwnerID od.Donation = asm.get_currency(d["SpayNeuterAmt"]) od.Comments = "Spay/Neuter fee" ownerdonations.append(od) if d["MicrochipFee"] != "": od = asm.OwnerDonation() od.DonationTypeID = 1 # donation od.DonationPaymentID = 1 od.Date = a.DateBroughtIn
if oname in ppo: o = ppo[oname] a = None if d["Animal ID"] in ppa: a = ppa[d["Animal ID"]] if o and a: m = asm.Movement() m.AnimalID = a.ID m.OwnerID = o.ID m.MovementType = 1 m.MovementDate = getdate(d["Date"]) a.Archived = 1 a.ActiveMovementID = m.ID a.ActiveMovementDate = m.MovementDate a.ActiveMovementType = 1 a.LastChangedDate = m.MovementDate movements.append(m) fee = asm.get_currency(d["Fee Paid"]) if fee > 0: od = asm.OwnerDonation() od.DonationTypeID = 1 od.DonationPaymentID = 1 od.Date = m.MovementDate od.OwnerID = o.ID od.Donation = fee ownerdonations.append(od) # Allow shelter animals to have their chips registered for a in animals: if a.Archived == 0: a.IsNotForRegistration = 0 # Now that everything else is done, output stored records
o.OwnerTown = row["City"] o.OwnerCounty = row["State"] o.OwnerPostcode = row["Zip"] o.HomeTelephone = row["Phone"] o.CreatedDate = asm.getdate_ddmmyyyy(row["DateAdd"]) o.Comments = row["Notes"] # items.csv for row in asm.csv_to_list(PATH + "items.csv"): if ppt.has_key(row["Item"]): continue dt = asm.DonationType() donationtypes.append(dt) ppt[row["Item"]] = dt dt.Name = "%s - %s" % (row["Item"], row["Desc"]) dt.Description = row["Desc"] dt.DefaultCost = asm.get_currency(row["Amount"]) # invoices.csv for row in asm.csv_to_list(PATH + "invoices.csv"): if not ppt.has_key(row["Item"]): continue if not ppo.has_key(row["custid"]): continue od = asm.OwnerDonation() ownerdonations.append(od) dt = ppt[row["Item"]] o = ppo[row["custid"]] od.OwnerID = o.ID od.DonationTypeID = dt.ID od.Date = asm.getdate_ddmmyyyy(row["Date"]) od.Donation = asm.get_currency(row["Amount"]) od.Quantity = asm.cint(row["Qty"]) try:
m.OwnerID = o.ID m.MovementType = 1 m.MovementDate = exitdate a.Archived = 1 a.ActiveMovementDate = exitdate a.ActiveMovementID = m.ID a.ActiveMovementType = 1 movements.append(m) if amount != "0": od = asm.OwnerDonation() ownerdonations.append(od) od.OwnerID = o.ID od.AnimalID = a.ID od.MovementID = m.ID od.Date = exitdate od.Donation = asm.get_currency(amount) od.DonationTypeID = 2 od.DonationPaymentID = 1 elif cd["dispositionType"] == "R": customerid = findin(credemption, "dispRecID", cd["recID"], "customerID") amount = findin(cadoptions, "dispRecID", cd["recID"], "amountCollected") o = owners[customerid] m = asm.Movement() m.AnimalID = a.ID m.OwnerID = o.ID m.MovementType = 5 m.MovementDate = exitdate a.Archived = 1 a.ActiveMovementDate = exitdate
m.MovementType = 1 m.Comments = row["Comments"] a.Archived = 1 a.ActiveMovementDate = m.MovementDate a.ActiveMovementType = 1 a.ActiveMovementID = m.ID if row["Fee"] != "": od = asm.OwnerDonation() ownerdonations.append(od) od.DonationTypeID = 2 od.DonationPaymentID = 1 od.Date = m.MovementDate od.OwnerID = o.ID od.AnimalID = a.ID od.MovementID = m.ID od.Donation = asm.get_currency(row["Fee"]) # releases.csv for row in asm.csv_to_list(PATH + "releases.csv", remove_non_ascii=True): a = None if ppa.has_key(row["Animal Id"]): a = ppa[row["Animal Id"]] if a is None: continue m = asm.Movement() movements.append(m) m.OwnerID = 0 m.AnimalID = a.ID m.MovementDate = asm.getdate_iso(row["Date Released"]) m.MovementType = 7 # Released to wild a.ActiveMovementType = 7 if row["Type"] == "Transfer": m.OwnerID = to.ID
# the licence ol = asm.OwnerLicence() ownerlicences.append(ol) lt = row["Licence Type"] ol.OwnerID = o.ID ol.AnimalID = a.ID ol.LicenceTypeID = asm.licencetype_from_db(lt) licnum = "%s%s-%s" % (lt[0:3].upper(), lt[len(lt) - 2:], row["Licence Number"]) if numused.has_key(licnum): licnum = licnum + "-2" if numused.has_key(licnum) and licnum.endswith("-2"): licnum = licnum[0:len(licnum) - 2] + "-3" ol.LicenceNumber = licnum numused[licnum] = "X" ol.LicenceFee = asm.get_currency(row["Fee"]) ol.IssueDate = asm.getdate_ddmmyyyy(row["Issued"]) ol.ExpiryDate = asm.getdate_ddmmyyyy(row["Expired"]) if ol.IssueDate is None: ol.IssueDate = asm.today() if ol.ExpiryDate is None: ol.ExpiryDate = asm.today() ol.Comments = row["Comments"] # Now that everything else is done, output stored records for a in animals: print a for o in owners: print o for ol in ownerlicences: print ol asm.stderr_summary(animals=animals, ownerlicences=ownerlicences, owners=owners)