Account_getTotalSourceDebit.py 687 Bytes
Newer Older
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
## Script (Python) "Account_getTotalSourceDebit"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=self
##title=
##
currency = None

if currency in (None, 'None'):
  currency = context.currency.EUR

total = 0.0
try:
  inventory = context.Resource_zGetInventory(node_uid=context.getUid(), omit_input=1, omit_simulation=1,
                                             resource_uid=(currency.getUid(),),
                                             simulation_state=('draft', 'planned', 'confirmed', 'stopped', 'delivered'))
  total = - inventory[0].inventory or 0.0
except:
  pass

return '%.02f' % total