|
|
|
@ -330,6 +330,22 @@ def main():
|
|
|
|
cost_a_pm = 0
|
|
|
|
cost_a_pm = 0
|
|
|
|
cost_a_pinjaman = 0
|
|
|
|
cost_a_pinjaman = 0
|
|
|
|
cost_a_depreciation = 0
|
|
|
|
cost_a_depreciation = 0
|
|
|
|
|
|
|
|
net_capacity_factor_v = 0
|
|
|
|
|
|
|
|
eaf_v = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Prefetch CF/EAF master data once to avoid repeated queries per row
|
|
|
|
|
|
|
|
cur.execute(
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
SELECT year as tahun, cf, eaf
|
|
|
|
|
|
|
|
FROM lcc_ms_year_data
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
year_rows = cur.fetchall()
|
|
|
|
|
|
|
|
year_data_map = {
|
|
|
|
|
|
|
|
int(t): (validate_number(cf), validate_number(eaf))
|
|
|
|
|
|
|
|
for (t, cf, eaf) in year_rows
|
|
|
|
|
|
|
|
if t is not None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for row in rows:
|
|
|
|
for row in rows:
|
|
|
|
# row adalah tuple sesuai urutan select_sql
|
|
|
|
# row adalah tuple sesuai urutan select_sql
|
|
|
|
@ -337,6 +353,18 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
seq = data["seq"] # primary key / unique key untuk WHERE
|
|
|
|
seq = data["seq"] # primary key / unique key untuk WHERE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ambil net_capacity_factor dan eaf dari year-data cache berdasarkan tahun
|
|
|
|
|
|
|
|
cf_eaf = (
|
|
|
|
|
|
|
|
year_data_map.get(int(data["tahun"]))
|
|
|
|
|
|
|
|
if data.get("tahun") is not None
|
|
|
|
|
|
|
|
else None
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if cf_eaf:
|
|
|
|
|
|
|
|
net_capacity_factor_v, eaf_v = cf_eaf
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
net_capacity_factor_v = 0
|
|
|
|
|
|
|
|
eaf_v = 0
|
|
|
|
|
|
|
|
|
|
|
|
if data["is_actual"] == 1:
|
|
|
|
if data["is_actual"] == 1:
|
|
|
|
net_capacity_factor = validate_number(data["net_capacity_factor"])
|
|
|
|
net_capacity_factor = validate_number(data["net_capacity_factor"])
|
|
|
|
eaf = validate_number(data["eaf"])
|
|
|
|
eaf = validate_number(data["eaf"])
|
|
|
|
@ -368,6 +396,9 @@ def main():
|
|
|
|
cost_bd_pm_nonmi = cost_bd_pm_nonmi # last value
|
|
|
|
cost_bd_pm_nonmi = cost_bd_pm_nonmi # last value
|
|
|
|
cost_bd_bd = cost_bd_bd # last value
|
|
|
|
cost_bd_bd = cost_bd_bd # last value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net_capacity_factor = net_capacity_factor_v
|
|
|
|
|
|
|
|
eaf = eaf_v
|
|
|
|
|
|
|
|
|
|
|
|
# ++++++ REVENUE +++++++
|
|
|
|
# ++++++ REVENUE +++++++
|
|
|
|
revenue_total = revenue_a + revenue_b + revenue_c + revenue_d
|
|
|
|
revenue_total = revenue_a + revenue_b + revenue_c + revenue_d
|
|
|
|
if seq > 0:
|
|
|
|
if seq > 0:
|
|
|
|
|