Commit 2e660d0d by Ari Agung Prasetiyo

update query pbb

1 parent 1f8e56ae
# from types import NoneType
import os
from pyramid.view import (
view_config,
)
......@@ -6,11 +7,11 @@ from ..views import BaseView
from ..models import *
from ..models.eis import Eis, Chart, ChartItem, Slide
from datatables import ColumnDT, DataTables
from sqlalchemy import func, and_, String
from sqlalchemy import func, and_, String, text
from sqlalchemy.sql.expression import cast
from ..models.payment import PaymentPBB, PaymentPAD, PaymentBPHTB, PaymentWEBR, TargetsBangbadil, UploadRealisasiOpsen
from opensipkd.pbb.monitoring.models import PembayaranSppt, Kecamatan, Kelurahan, Sppt
from opensipkd.pjdl.models import Sspd, Pajak, Usaha
from opensipkd.pjdl.models import Sspd, Pajak, Usaha, PdlDBSession
from datetime import timedelta
from ..models.payment import PCDBSession
......@@ -29,6 +30,20 @@ PAD_TYP = {
"pbb": ["0"],
}
PAD2_TYP = {
"hotel": "41011903",
"resto": "41011901",
"hiburan": "41011905",
"ppju": "41011902",
"minerba": "410114",
"parkir": "41011904",
"walet": "410113",
"atd": "410112",
"reklame": "410109",
"pbb": "0",
}
jenis_pajak = {
"opsen_pkb": {
"kode": "4.1.01.20.01.0001",
......@@ -138,12 +153,12 @@ class Views(BaseView):
elif typ == 'opsen_bbnkb':
qry = table.qry_sum_bbnkb(columns) \
.group_by(field)\
.order_by(field)
.order_by(field)
else:
qry = table.qry_sum(columns) \
.group_by(field)\
.order_by(field)
qry = qry.filter(*filters)
opsen = ["opsen_pkb", "opsen_bbnkb"]
if typ != None and typ not in opsen:
......@@ -165,6 +180,8 @@ class Views(BaseView):
bayar = mapped.get("bayar", 0)
denda = mapped.get("denda", 0)
pokok = float(bayar)
if typ == 'pbb':
pokok = bayar-denda
tx = mapped.get("trx",0)
daily.append((step, pokok))
dailyTrx.append((step, tx))
......@@ -793,8 +810,9 @@ class Views(BaseView):
elif jenis == "bphtb":
realisasi = self.get_bphtb_data()["ytd"]
else:
realisasi = self.get_pad_data(jenis)["ytd"]
#realisasi = self.get_pad_data(jenis)
#realisasi = realisasi[f"{jenis}"]["realisasi"]
return {jenis: {"kode": jenis_pajak[jenis]["kode"].ljust(8, '0'),
"nama": jenis_pajak[jenis]["nama"],
......@@ -863,6 +881,32 @@ class Views(BaseView):
resp["time"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return resp
def realisasi_pad(self, jenis):
target = self.get_targets(jenis)
today = datetime.now().date()
file_dir = os.path.split(__file__)[0]
filename = os.path.join(file_dir, 'realisasi_pad.sql')
rekeningkd = PAD2_TYP[jenis]
with open(filename, 'r') as f:
qry = f.read().format(bulan = today.month, tahun=today.year, kondisi=f"and levelid in (3,4) and issummary = 1 and rekeningkd='{rekeningkd}'")
engine = PdlDBSession.get_bind()
with engine.connect() as conn:
result = conn.execute(text(qry.replace('\n', ' ')))
d = []
# r = result[0]
for r in result:
d.append(dict(zip(result.keys(), r)))
d = d[0]
realisasi = d["realisasi_lalu"] + d["realisasi"]
return {jenis: {"kode": d["kode"],
"nama": d["nama"],
"target": target,
"realisasi": realisasi,
"sisa": target - realisasi,
"persen": round(realisasi/target * 100, 2) if target > 0 else 0}
}
def view_pajak(self):
return {"module": 'pajak',
"title": "Realisasi Pajak Daerah"}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!