fix: bep year and bep total lcc

main
MrWaradana 12 months ago
parent 76d1f50a19
commit 0e4be2d20f

@ -3,9 +3,4 @@ import uvicorn
from src.config import PORT, HOST from src.config import PORT, HOST
if __name__ == "__main__": if __name__ == "__main__":
uvicorn.run( uvicorn.run("src.main:app", host=HOST, port=PORT, reload=True)
"src.main:app",
host=HOST,
port=PORT,
# reload=True
)

@ -58,11 +58,12 @@ async def get_charts(
chart_data = results.scalars().all() chart_data = results.scalars().all()
bep_year = None bep_year = None
previous_year = 0
previous_total_cost = 0 previous_total_cost = 0
previous_revenue = 0 previous_revenue = 0
bep_total_lcc = 0 bep_total_lcc = 0
for item in chart_data: for idx, item in enumerate(chart_data):
total_cost = ( total_cost = (
item.chart_capex_annualized item.chart_capex_annualized
+ item.chart_oem_annualized + item.chart_oem_annualized
@ -74,12 +75,17 @@ async def get_charts(
if (previous_total_cost > previous_revenue and total_cost < revenue) or ( if (previous_total_cost > previous_revenue and total_cost < revenue) or (
previous_total_cost < previous_revenue and total_cost > revenue previous_total_cost < previous_revenue and total_cost > revenue
): ):
bep_total_lcc = total_cost if total_cost < revenue:
bep_year = item.tahun bep_total_lcc = previous_total_cost
bep_year = previous_year
else:
bep_total_lcc = total_cost
bep_year = item.tahun
break break
previous_total_cost = total_cost previous_total_cost = total_cost
previous_revenue = revenue previous_revenue = revenue
previous_year = item.tahun
return chart_data, bep_year, bep_total_lcc return chart_data, bep_year, bep_total_lcc

Loading…
Cancel
Save