Commit 94225ecc by aa.gusti

webr

1 parent 7badc8bb
......@@ -12,6 +12,7 @@ from models_webr import (ARInvoice as Invoice, ARSspd as Realisasi,
from models_eis import (ArPayment as EisArPayment,
ByPayment as EisByPayment,
Rekening as EisRekening,
Opd as EisOpd,
EisBase, EisDBSession)
from conf import webr_url as url
......@@ -82,20 +83,20 @@ def validate_parent(tabel, departemen_kd, departemen_nm, rekening, tanggal):
induk.kode = row.kode.strip()
induk.departemen_kd = departemen_kd.strip()
induk.tanggal = tanggal
induk.departemen_nm = departemen_nm.strip()
induk.departemen_nm = departemen_nm
induk.level_id = row.kode.count('.')
induk.nama = row.nama.strip()
EisDBSession.add(induk)
EisDBSession.flush()
def import_ar(all=False):
query = DBSession.query(Invoice.unit_kode, Invoice.unit_nama,
query = DBSession.query(func.substring(Invoice.unit_kode,1,8).label('unit_kode'),
Invoice.rek_kode, Invoice.rek_nama,
func.to_char(Realisasi.tgl_bayar,'YYYY-MM-DD').label('tgl_bayar'),
func.sum(Realisasi.bunga).label('bunga'),
func.sum(Realisasi.bayar).label('bayar'),).\
join(Realisasi, (Realisasi.arinvoice_id == Invoice.id)).\
group_by(Invoice.unit_kode, Invoice.unit_nama,
group_by(func.substring(Invoice.unit_kode,1,8),
Invoice.rek_kode, Invoice.rek_nama,
func.to_char(Realisasi.tgl_bayar,'YYYY-MM-DD'))
if not all:
......@@ -108,6 +109,13 @@ def import_ar(all=False):
departemen_kd = row.unit_kode.strip(),
tanggal = row.tgl_bayar,
).first()
print(row.unit_kode)
unit_nm = EisDBSession.query(EisOpd).\
filter_by(tahun = str(tahun),
kode = row.unit_kode.strip(),
).first()
if unit_nm:
unit_nm = unit_nm.nama.strip()
if not eis:
eis = EisArPayment()
eis.tahun = str(tahun)
......@@ -115,8 +123,8 @@ def import_ar(all=False):
eis.departemen_kd = row.unit_kode.strip()
eis.tanggal = row.tgl_bayar
eis.level_id = row.rek_kode.count('.')
eis.nama = row.rek_nama.strip()
eis.departemen_nm = row.unit_nama.strip()
eis.nama = row.rek_nama
eis.departemen_nm = unit_nm
eis.jumlah = row.bayar - row.bunga
EisDBSession.add(eis)
if row.bunga:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!