Commit 94225ecc by aa.gusti

webr

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