Commit 1faaf87e by aagusti

pap

1 parent 19a1181d
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#bbnkb2_pok #bbnkb2_pok
#jumlah #jumlah
import sys
from models_eis import (ArPayment as EisArPayment, from models_eis import (ArPayment as EisArPayment,
Rekening as EisRekening, Rekening as EisRekening,
EisBase, EisDBSession) EisBase, EisDBSession)
...@@ -49,11 +50,6 @@ tahun = now.strftime('%Y') ...@@ -49,11 +50,6 @@ tahun = now.strftime('%Y')
dep_kode = '3.03.02.' dep_kode = '3.03.02.'
dep_nama = 'BADAN PENDAPATAN DAERAH' dep_nama = 'BADAN PENDAPATAN DAERAH'
rek_kode = '4.1.1.06.01.'
rek_nama = 'PAJAK AIR PERMUKAAN'
denda_kode = '4.1.4.07.03.'
denda_nama = 'DENDA PAJAK AIR PERMUKAAN'
def calculate(tabel, all=None, kode=None): def calculate(tabel, all=None, kode=None):
query = EisDBSession.query(tabel).filter_by(tahun = str(tahun)).\ query = EisDBSession.query(tabel).filter_by(tahun = str(tahun)).\
...@@ -126,7 +122,7 @@ def validate_parent(tabel, departemen_kd, departemen_nm, rekening, tanggal): ...@@ -126,7 +122,7 @@ def validate_parent(tabel, departemen_kd, departemen_nm, rekening, tanggal):
EisDBSession.add(induk) EisDBSession.add(induk)
EisDBSession.flush() EisDBSession.flush()
def insert_data(row, kode, nama): def insert_data(row, kode, nama, denda_kode, denda_nama):
# TODO # TODO
eis = EisDBSession.query(EisArPayment).\ eis = EisDBSession.query(EisArPayment).\
filter_by(tahun = str(tahun), filter_by(tahun = str(tahun),
...@@ -148,7 +144,7 @@ def insert_data(row, kode, nama): ...@@ -148,7 +144,7 @@ def insert_data(row, kode, nama):
EisDBSession.flush() EisDBSession.flush()
validate_parent(EisArPayment, eis.departemen_kd, eis.departemen_nm, eis.kode, eis.tanggal) validate_parent(EisArPayment, eis.departemen_kd, eis.departemen_nm, eis.kode, eis.tanggal)
if row['denda']: if row['denda']:
print(row) print('denda', row, denda_kode, denda_nama)
insert_denda(row, denda_kode, denda_nama) insert_denda(row, denda_kode, denda_nama)
def insert_denda(row, kode, nama): def insert_denda(row, kode, nama):
...@@ -164,7 +160,7 @@ def insert_denda(row, kode, nama): ...@@ -164,7 +160,7 @@ def insert_denda(row, kode, nama):
eis.kode = kode eis.kode = kode
eis.departemen_kd = dep_kode eis.departemen_kd = dep_kode
eis.tanggal = row['tanggal'] eis.tanggal = row['tanggal']
eis.level_id = rek_kode.count('.') eis.level_id = kode.count('.')
eis.nama = nama eis.nama = nama
eis.departemen_nm = dep_nama eis.departemen_nm = dep_nama
eis.jumlah = row['denda'] eis.jumlah = row['denda']
...@@ -174,6 +170,12 @@ def insert_denda(row, kode, nama): ...@@ -174,6 +170,12 @@ def insert_denda(row, kode, nama):
def import_pap(all=False): def import_pap(all=False):
rek_kode = '4.1.1.06.01.'
rek_nama = 'PAJAK AIR PERMUKAAN'
denda_kode = '4.1.4.07.03.'
denda_nama = 'DENDA PAJAK AIR PERMUKAAN'
sql = "SELECT tg_pros_bayar as tanggal, pap as pokok, den_pajak as denda FROM v_rtimepap "\ sql = "SELECT tg_pros_bayar as tanggal, pap as pokok, den_pajak as denda FROM v_rtimepap "\
"WHERE year(tg_pros_bayar) = '{tahun}' {where} "\ "WHERE year(tg_pros_bayar) = '{tahun}' {where} "\
"ORDER BY tg_pros_bayar" "ORDER BY tg_pros_bayar"
...@@ -186,12 +188,8 @@ def import_pap(all=False): ...@@ -186,12 +188,8 @@ def import_pap(all=False):
format(tanggal = tanggal.strftime('%d-%m-%Y')),) format(tanggal = tanggal.strftime('%d-%m-%Y')),)
print(sql) print(sql)
rows = engine.fetchall(sql) rows = engine.fetchall(sql)
rek_kode = '4.1.1.06.01.'
rek_nama = 'PAJAK AIR PERMUKAAN'
denda_kode = '4.1.4.07.03.'
denda_nama = 'DENDA PAJAK AIR PERMUKAAN'
for row in rows: for row in rows:
insert_data(row, rek_kode, rek_nama) insert_data(row, rek_kode, rek_nama, denda_kode, denda_nama)
EisDBSession.commit() EisDBSession.commit()
...@@ -202,32 +200,27 @@ def import_pkb(all=False): ...@@ -202,32 +200,27 @@ def import_pkb(all=False):
denda_kode = '4.1.4.07.01.' denda_kode = '4.1.4.07.01.'
denda_nama = 'PENDAPATAN DENDA KENDARAAN BERMOTOR' denda_nama = 'PENDAPATAN DENDA KENDARAAN BERMOTOR'
if all: if all:
sql = "SELECT tg_pros_bayar as tanggal, (bbn1_pok+bbn2_pok) as bbn_pok, "\ sql = "SELECT tg_pros_bayar as tanggal, pkb_pok as pokok, pkb_den as denda "\
"(bbn1_den+bbn2_den) as bbn_den, pkb_pok as pokok, pkb_den as denda "\
"FROM v_sts "\ "FROM v_sts "\
"WHERE year(tg_pros_bayar) = '{tahun}' {where} "\ "WHERE year(tg_pros_bayar) = '{tahun}' {where} "\
"ORDER BY tg_pros_bayar" "ORDER BY tg_pros_bayar "
sql = sql.format(tahun = tahun, sql = sql.format(tahun = tahun,
where = '') where = '')
print(sql) print(sql)
rows = engine.fetchall(sql) rows = engine.fetchall(sql)
for row in rows: for row in rows:
insert_data(row, rek_kode, rek_nama) insert_data(row, rek_kode, rek_nama, denda_kode, denda_nama)
sql = "SELECT tg_pros_bayar as tanggal, (bbn1_pok+bbn2_pok) as bbn_pok, "\ sql = "SELECT tg_pros_bayar as tanggal, pkb_pok as pokok, pkb_den as denda "\
"(bbn1_den+bbn2_den) as bbn_den, pkb_pok as pokok, pkb_den as denda "\
"FROM v_rtime "\ "FROM v_rtime "\
"WHERE year(tg_pros_bayar) = '{tahun}' {where} "\ "WHERE year(tg_pros_bayar) = '{tahun}' {where} "\
"ORDER BY tg_pros_bayar" "ORDER BY tg_pros_bayar"
sql = sql.format(tahun = tahun, sql = sql.format(tahun = tahun,
where = '') where = '')
sql = sql.format(tahun = tahun,
where = " AND tg_pros_bayar = '{tanggal}'".\
format(tanggal = tanggal.strftime('%d-%m-%Y')),)
print(sql) print(sql)
rows = engine.fetchall(sql) rows = engine.fetchall(sql)
for row in rows: for row in rows:
insert_data(row, rek_kode, rek_nama) insert_data(row, rek_kode, rek_nama, denda_kode, denda_nama)
EisDBSession.commit() EisDBSession.commit()
print ('IMPORT BBN') print ('IMPORT BBN')
...@@ -237,7 +230,7 @@ def import_pkb(all=False): ...@@ -237,7 +230,7 @@ def import_pkb(all=False):
denda_nama = 'PENDAPATAN DENDA BBN-KB' denda_nama = 'PENDAPATAN DENDA BBN-KB'
if all: if all:
sql = "SELECT tg_pros_bayar as tanggal, (bbn1_pok+bbn2_pok) as pokok, "\ sql = "SELECT tg_pros_bayar as tanggal, (bbn1_pok+bbn2_pok) as pokok, "\
"(bbn1_den+bbn2_den) as denda, pkb_pok as pkb_pok, pkb_den as pkb_den "\ "(bbn1_den+bbn2_den) as denda "\
"FROM v_sts "\ "FROM v_sts "\
"WHERE year(tg_pros_bayar) = '{tahun}' {where} "\ "WHERE year(tg_pros_bayar) = '{tahun}' {where} "\
"ORDER BY tg_pros_bayar" "ORDER BY tg_pros_bayar"
...@@ -246,10 +239,10 @@ def import_pkb(all=False): ...@@ -246,10 +239,10 @@ def import_pkb(all=False):
print(sql) print(sql)
rows = engine.fetchall(sql) rows = engine.fetchall(sql)
for row in rows: for row in rows:
insert_data(row, rek_kode, rek_nama) insert_data(row, rek_kode, rek_nama, denda_kode, denda_nama)
sql = "SELECT tg_pros_bayar as tanggal, (bbn1_pok+bbn2_pok) as pokok, "\ sql = "SELECT tg_pros_bayar as tanggal, (bbn1_pok+bbn2_pok) as pokok, "\
"(bbn1_den+bbn2_den) as denda, pkb_pok as pkb_pok, pkb_den as pkb_den "\ "(bbn1_den+bbn2_den) as denda "\
"FROM v_rtime "\ "FROM v_rtime "\
"WHERE year(tg_pros_bayar) = '{tahun}' {where} "\ "WHERE year(tg_pros_bayar) = '{tahun}' {where} "\
"ORDER BY tg_pros_bayar" "ORDER BY tg_pros_bayar"
...@@ -261,10 +254,15 @@ def import_pkb(all=False): ...@@ -261,10 +254,15 @@ def import_pkb(all=False):
print(sql) print(sql)
rows = engine.fetchall(sql) rows = engine.fetchall(sql)
for row in rows: for row in rows:
insert_data(row, rek_kode, rek_nama) insert_data(row, rek_kode, rek_nama, denda_kode, denda_nama)
EisDBSession.commit() EisDBSession.commit()
print('IMPORT PAP') def main(argv):
import_pap(True) all = argv and argv[1:] and argv[1]=='all' or False
import_pkb(True) import_pap(all)
calculate(EisArPayment,True) import_pkb(all)
calculate(EisArPayment,all)
argv = sys.argv
print 'argv', argv
main(sys.argv)
export INFORMIXSERVER="kpusat19_svr" export INFORMIXSERVER="kpusat19_svr"
/usr/bin/python import-pap.py export DBDATE=DMY4-
/usr/bin/python import-pap.py "$@"
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!