Created
January 29, 2010 14:38
-
-
Save DanielVF/289760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from suds.client import Client | |
URL = 'https://ws.customertest.newdea.com/NonprofitServices_100.asmx?wsdl' | |
LOGIN = '' | |
PASSWORD = '' | |
ORGXID = '' | |
client = Client(URL, timeout=600) | |
def newdea_all_budget_previews(): | |
criteria = client.factory.create('CriteriaOrgXID') | |
criteria.Login = LOGIN | |
criteria.Password = PASSWORD | |
criteria.OrgXID = ORGXID | |
print "Getting all budgets XIDs. This takes FOREVER." | |
return client.service.GetBudgetROListByOrgXID(criteria) | |
def newdea_budget(xid): | |
criteria = client.factory.create('CriteriaOrgXIDObjectXID'); | |
criteria.Login = LOGIN | |
criteria.Password = PASSWORD | |
criteria.OrgXID = ORGXID | |
criteria.ObjectXID = xid | |
print "Getting %s" % xid | |
return client.service.GetBudgetByOrgXIDObjectXID(criteria) | |
def newdea_budget_save(budget): | |
print "Saving budget" | |
criteria = client.factory.create('Criteria'); | |
criteria.Login = LOGIN | |
criteria.Password = PASSWORD | |
return client.service.SaveBudget(criteria,budget) | |
# budgets = newdea_all_budget_previews() | |
# for budget_preview in budgets.List[0]: | |
# budget = newdea_budget(budget_preview.ObjectXID) | |
if True: | |
budget = newdea_budget('884-557') | |
categories_to_clear = [] | |
try: | |
for category in budget.BudgetCategories[0]: | |
if category.Status == 'Inactive': | |
categories_to_clear.append(category.GUID) | |
print " zapping %s" % category.Label | |
# delete category from budget.category | |
for cell in budget.Cells[0]: | |
if cell.CategoryGUID in categories_to_clear: | |
print " zapping cell" | |
cell.PlanAmount = None | |
cell.SimpleActual = None | |
cell.PlanNotes = None | |
cell.ActualNotes = None | |
if categories_to_clear: | |
newdea_budget_save(budget) | |
except Exception as e: | |
print "An error occured: %s" % e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment