Commit 79bd0e90 by aa.gusti

a

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