Created
November 4, 2011 13:16
-
-
Save jean/1339288 to your computer and use it in GitHub Desktop.
total_allocations
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
sources = ['FPL','RAL'] | |
financebrains = index.dbsearch({'doctype': u'FinanceData', 'funding_source': sources, 'year': 2010}) | |
total_allocations = 0 | |
allocations_by_source = {} | |
for b in financebrains: | |
for row in doc.getItem('financial_data'): | |
for source in sources: | |
if d['funding_source'].strip() == source: | |
total = allocations_by_source.setdefault(source, 0) | |
if d['slde_f_glan_seq_num'] in ['6210', '6310']: | |
total += eval_float(d['slde_cnvrt_amt']) | |
allocations_by_source[source] = total | |
sources = ['FPL','RAL','FEL'] | |
financebrains = index.dbsearch({'doctype': u'FinanceData', 'funding_source': sources, 'year': 2011, 'month': {'query': 7, 'range': 'max'}}) | |
for b in financebrains: | |
for row in doc.getItem('financial_data'): | |
for source in sources: | |
if d['funding_source'].strip() == source: | |
total = allocations_by_source.setdefault(source, 0) | |
if d['slde_f_glan_seq_num'] == '4350': | |
total += eval_float(d['slde_cnvrt_amt']) | |
allocations_by_source[source] = total | |
findb.portal_skins.plone_scripts.plone_log('pgPPR/bienium_allocations> allocations_by_source: %s'% `allocations_by_source`) #DBG | |
for source, amount in allocations_by_source.items(): | |
total_allocations += amount | |
# In millions: | |
total_allocations = total_allocations/1e6 | |
print 'total_allocations:', total_allocations #DBG | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment