Ejemplo n.º 1
0
def delete_bill(bill_id):

  br = gdata.bills(id=bill_id).fetch(1000)
  if len(br) > 0:
    b = br[0]
    ir = gdata.billItems(bill_id=b.id).fetch(1000)
    
    for item in ir:
      sr = gdata.billItemSubBalances(bill_item_id=item.id).fetch(1000)
      for s in sr:
        logging.info("DELETING subbalance with id " + s.id)
        db.delete(s)
      logging.info("DELETING item with id " + item.id)
      db.delete(item)
    logging.info("DELETING bill with id " + b.id)
    db.delete(b)
Ejemplo n.º 2
0
def list_bills(req, response):

  j = yield get_tenant(req, response)
  tenant = j >> unpack
  tenant # just to thawrt PEP warning
  j = yield get_account(req, response)
  adef = j >> unpack

  r = gdata.bills(account_id=adef.id).fetch(1000)
  
  resp = { 'account_no' : adef.account_no, 'bills' : [] }

  for bill in r:
    bi = { "bill" : gdata.to_dict(bill), "billitems" : [] }
    ir = gdata.billItems(bill_id=bill.id).fetch(1000)
    for item in ir:
      bi['billitems'].append(gdata.to_dict(item))
    resp['bills'].append(bi)

  response.set_status('200 OK')
  logging.info(resp)
  yield Just(resp)