calculate_data.py 641 Bytes

def has_child(DBS, table, kode): #TODO filter parameterized
    qry = DBS.query(table).filter(table.kode.like(kode+'.%')).\
          order_by(table.kode)
    row = qry.first()
    return row

def calculate_data(DBS, table):
    pass
    # qry = DBS.query(table).order_by(table.kode)
    # rows = qry.all()
    # parents = []
    # results = []
    # jml = 0
    # for row in rows:
        # if has_child(DBS, table, row.kode):
            # parents.append(dict(id = row.id, kode=row.kode, jumlah=0))
            # kode = row.kode
            # jml = 0
        # else:
            # if row.jumlah: 
                # jml = jml + row.jumlah