Refactor get_daily_data method to handle filters as a list and improve query rea…

…dability; update templates to display additional financial data.
1 parent 7f60d19d
......@@ -17,13 +17,13 @@ eis-reklame,Reklame,/eis/reklame,1,0,1,eis-pajak,pcpd,Views,view_reklame,eis,pcp
eis-atd,Air Tanah,/eis/atd,1,0,1,eis-pajak,pcpd,Views,view_atd,eis,pcpd.pt
eis-opsen,Opsen,/eis/opsen,1,0,1,eis-pajak,pcpd,Views,view_opsen,eis,pcpd.pt
eis-webr,Retribusi,/eis/webr,1,0,1,,pcpd,Views,view_webr,eis,pcpd_retribusi.pt
eis,EIS,/eis,0,0,0
eis,EIS,/eis,1,0,0
eis-carousel,Carousel,/eis/carousel,1,0,0
eis-carousel-act,Carousel Action,/eis/carousel/{act}/act,1,0
eis-carousel-add,Carousel Add,/eis/carousel/add,1,0
eis-carousel-edit,Carousel Edit,/eis/carousel/{id}/edit,1,0
eis-carousel-delete,Carousel Delete,/eis/carousel/{id}/delete,1,0
eis-dashboard,EIS,/eis/dashboard,0,0,0
eis-dashboard,EIS,/eis/dashboard,1,0,0
eis-dashboard-act,EIS Act,/eis/dashboard/{act}/act,1,0
eis-dashboard-calc-all,EIS Calc ALL,/eis/dashboad/calc/all,1,0
eis-home,EIS Home,/eis/home,0,0,0
......
......@@ -156,6 +156,8 @@ class Views(BaseView):
def get_daily_data(self, table, field, today, filters, typ=None):
#todo ada kemungkinan menyebabkan error ke transaksi yang lain
if type(filters) is not list:
filters = [filters]
if PCDBSession.registry().in_transaction():
PCDBSession.rollback()
columns = [field.label("step")]
......@@ -163,7 +165,7 @@ class Views(BaseView):
.group_by(field)\
.order_by(field)
qry = qry.filter(filters)
qry = qry.filter(*filters)
if typ != None:
if typ == "pajak":
qry = qry.filter(table.jenis_pajak.notin_(PAD_TYP['pbb']))
......@@ -216,15 +218,14 @@ class Views(BaseView):
return target
def get_pbb_data(self):
if log.root.level == logging.DEBUG:
today = datetime.strptime('2025-06-05', "%Y-%m-%d")
else:
today = datetime.now().date()
today = datetime.now().date()
#Piutang
#Harian
field = func.to_char(PembayaranSppt.tgl_pembayaran_sppt, 'yyyy-mm-dd')
filter_exp = PembayaranSppt.tgl_pembayaran_sppt.between(
today-timedelta(days=6), today)
amt, trx, daily, dailyTrx, dailyAcc, dailyAccTrx = \
self.get_daily_data(PembayaranSppt, field,
today.strftime("%Y-%m-%d"), filter_exp)
......@@ -236,6 +237,14 @@ class Views(BaseView):
ytd, ytdTrx, yearly, yearlyTrx, yearlyAcc, yearlyAccTrx = \
self.get_daily_data(PembayaranSppt, field,
str(today.year), filter_exp)
#Piutang
filter_exp = [PembayaranSppt.tgl_pembayaran_sppt.between(
datetime.strptime(f"{today.year}-01-01", "%Y-%m-%d"), today),
PembayaranSppt.thn_pajak_sppt < today.year]
piutang, piutangTrx, yearly, yearlyTrx, yearlyAcc, yearlyAccTrx = \
self.get_daily_data(PembayaranSppt, field,
str(today.year), filter_exp)
#Bulanan
field = func.to_char(PembayaranSppt.tgl_pembayaran_sppt, 'MM')
month, monthTrx, monthly, monthlyTrx, monthlyAcc, monthlyAccTrx = \
......@@ -262,6 +271,8 @@ class Views(BaseView):
"dailyAcc": dailyAcc,
"dailyAccTrx": dailyAccTrx,
"ytd": ytd,
"piutang": piutang,
"piutangTrx": piutangTrx,
"trxYtd": ytdTrx,
"pie": [("I", 100, '#16a75c'), ("II", 200, '#ffb900'),
("III", 300, '#133132'), ("IV", 200, '#123456'),
......
......@@ -40,6 +40,12 @@
<h2 class="primary">
<b>Rp. <h2 class="odometer sub-odometer bold primary" id="ytd">0</h2></b>
<p>
Pokok Rp. <span class=" bold" id="pokok">0</span>
</p>
<p>
Piutang Rp. <span class=" bold" id="piutang">0</span>
</p>
<p>
Target Rp. <span class=" bold" id="ytdTarget">123</span>
<p>
Persentase <span class="odometer sub-odometer bold primary" id="ytdPersen">
......@@ -486,6 +492,9 @@
trx.innerHTML = parseInt(newData.trx).toLocaleString("id-ID");
odytd.update(newData.ytd);
trxYtd.innerHTML = parseInt(newData.trxYtd).toLocaleString("id-ID");
pokok.innerHTML = parseInt(newData.pokok).toLocaleString("id-ID");
piutang.innerHTML = parseInt(newData.piutang).toLocaleString("id-ID");
ytdTarget.innerHTML = parseInt(newData.ytdTarget).toLocaleString("id-ID");
ytdPersen.innerHTML = parseFloat(newData.ytdPersen).toFixed(2) + "%";
time.innerHTML = formatter.format(date);//newData.time;
......@@ -530,8 +539,8 @@
"columnDefs": [
{ className: 'text-center', width: "50px", targets: [0] },
{ className: 'text-left', targets: [1] },
{ className: 'text-right', width: "100px", target:0, targets: [2, 3, 4], render: $.fn.dataTable.render.number('.', ',', 0, '') },
{ className: 'text-right', width: "100px", target:0, targets: [5], render: $.fn.dataTable.render.number('.', ',', 2, '') }
{ className: 'text-right', width: "100px", target: 0, targets: [2, 3, 4], render: $.fn.dataTable.render.number('.', ',', 0, '') },
{ className: 'text-right', width: "100px", target: 0, targets: [5], render: $.fn.dataTable.render.number('.', ',', 2, '') }
]
}
);
......@@ -569,4 +578,4 @@
</script>
</html>
</html>
\ No newline at end of file
......@@ -424,8 +424,8 @@
"columnDefs": [
{ className: 'text-center', width: "50px", targets: [0] },
{ className: 'text-left', targets: [1] },
{ className: 'text-right', width: "100px", targets: [2, 3, 4], render: $.fn.dataTable.render.number('.', ',', 0, '')},
{ className: 'text-right', width: "100px", targets: [5], render: $.fn.dataTable.render.number('.', ',', 2, '')},
{ className: 'text-right', width: "100px", targets: [2, 3, 4], render: $.fn.dataTable.render.number('.', ',', 0, '') },
{ className: 'text-right', width: "100px", targets: [5], render: $.fn.dataTable.render.number('.', ',', 2, '') },
]
}
);
......@@ -511,4 +511,4 @@
}
</script>
</html>
</html>
\ 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!