Commit 79bd0e90 by aa.gusti

a

1 parent fa99ab0d
......@@ -27,6 +27,7 @@ def calculate():
old_level = 0
levels = {}
murnis = {}
perubahans = {}
key = ""
for row in rows:
if row.level_id > old_level:
......@@ -40,18 +41,29 @@ def calculate():
murnis[key] = row.murni
else:
murnis[key] += row.murni
if not key in perubahans:
perubahans[key] = row.perubahan
else:
perubahans[key] += row.perubahan
#JIKA level < sebelumnya update current row
if row.level_id < old_level:
row.murni = murnis[key]
row.perubahan = perubahans[key]
EisDBSession.add(row)
EisDBSession.flush()
murnis[key] = 0 #key sebelumnya diset jadi 0
perubahans[key] = 0 #key sebelumnya diset jadi 0
key = 'a'+str(row.level_id)
if not key in murnis:
murnis[key] = row.murni
else:
murnis[key] += row.murni
if not key in perubahans:
perubahans[key] = row.perubahan
else:
perubahans[key] += row.perubahan
old_level = row.level_id
......@@ -66,16 +78,16 @@ def validate_parent(departemen_kd, departemen_nm, rekening):
continue
induk = EisDBSession.query(EisAnggaran).\
filter_by(tahun=str(row.tahun),
kode=row.kode,
departemen_kd = departemen_kd,
kode=row.kode.strip(),
departemen_kd = departemen_kd.strip(),
).first()
if not induk:
induk = EisAnggaran()
induk.tahun = str(tahun)
induk.kode = row.kode
induk.departemen_kd = departemen_kd
induk.kode = row.kode.strip()
induk.departemen_kd = departemen_kd.strip()
induk.level_id = row.kode.count('.')
induk.nama = row.nama
induk.nama = row.nama.strip()
EisDBSession.add(induk)
EisDBSession.flush()
......@@ -90,11 +102,11 @@ def import_anggaran():
if not anggaran:
anggaran = EisAnggaran()
anggaran.tahun = str(row.tahun)
anggaran.kode = row.kd_rekening
anggaran.departemen_kd = row.kd_opd
anggaran.kode = row.kd_rekening.strip()
anggaran.departemen_kd = row.kd_opd.strip()
anggaran.level_id = row.kd_rekening.count('.')
anggaran.nama = row.nm_rekening
anggaran.departemen_nm = row.nm_opd
anggaran.nama = row.nm_rekening.strip()
anggaran.departemen_nm = row.nm_opd.strip()
anggaran.murni = row.ang_murni
anggaran.perubahan = row.ang_perubahan
EisDBSession.add(anggaran)
......
......@@ -124,7 +124,7 @@ def import_by(all=False):
for row in query.filter(Realisasi.kd_rekening.like('6.%')).all():
eis = EisDBSession.query(EisByPayment).\
filter_by(tahun = str(row.tahun),
rekening_kd = row.kd_rekening.strip(),
kode = row.kd_rekening.strip(),
departemen_kd = row.kd_opd.strip(),
tanggal = tanggal,
).first()
......@@ -137,14 +137,14 @@ def import_by(all=False):
eis.level_id = row.kd_rekening.count('.')
eis.nama = row.nm_rekening.strip()
eis.departemen_nm = row.nm_opd.strip()
eis.jumlah = row.realisai
eis.jumlah = row.realisasi
EisDBSession.add(eis)
EisDBSession.flush()
validate_parent(EisByPayment, eis.departemen_kd, eis.departemen_nm, eis.kode)
EisDBSession.commit()
EisDBSession.commit()
import_ap(True)
#import_ap(True)
import_by(True)
calculate(EisApPayment,True)
calculate(EisByPayment,True)
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!