|
|
|
@ -2,7 +2,7 @@ import os
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
from typing import Optional, TypedDict, Any
|
|
|
|
from typing import Optional, TypedDict, Any
|
|
|
|
|
|
|
|
|
|
|
|
from sqlalchemy import Select, Delete, Float, func, cast, String, text
|
|
|
|
from sqlalchemy import Select, Delete, Float, func, cast, String, text, case
|
|
|
|
from sqlalchemy.orm import selectinload
|
|
|
|
from sqlalchemy.orm import selectinload
|
|
|
|
from sqlalchemy.exc import SQLAlchemyError
|
|
|
|
from sqlalchemy.exc import SQLAlchemyError
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
@ -385,12 +385,12 @@ async def get_top_10_economic_life(*, db_session: DbSession, common) -> list[Equ
|
|
|
|
|
|
|
|
|
|
|
|
query = (
|
|
|
|
query = (
|
|
|
|
query.add_columns(
|
|
|
|
query.add_columns(
|
|
|
|
func.case(
|
|
|
|
case(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(current_year - Equipment.minimum_eac_year) >= 0,
|
|
|
|
(current_year - Equipment.minimum_eac_year) >= 0,
|
|
|
|
(current_year - Equipment.minimum_eac_year),
|
|
|
|
(current_year - Equipment.minimum_eac_year),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
else_=None,
|
|
|
|
else_=0,
|
|
|
|
).label("economic_life")
|
|
|
|
).label("economic_life")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.filter(Equipment.minimum_eac_year != None)
|
|
|
|
.filter(Equipment.minimum_eac_year != None)
|
|
|
|
@ -416,7 +416,7 @@ async def get_top_10_replacement_priorities(*, db_session: DbSession, common) ->
|
|
|
|
# Only select rows where (current_year - Equipment.minimum_eac_year) >= 0
|
|
|
|
# Only select rows where (current_year - Equipment.minimum_eac_year) >= 0
|
|
|
|
query = (
|
|
|
|
query = (
|
|
|
|
query.add_columns(
|
|
|
|
query.add_columns(
|
|
|
|
func.case(
|
|
|
|
case(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(current_year - Equipment.minimum_eac_year) >= 0,
|
|
|
|
(current_year - Equipment.minimum_eac_year) >= 0,
|
|
|
|
(current_year - Equipment.minimum_eac_year),
|
|
|
|
(current_year - Equipment.minimum_eac_year),
|
|
|
|
|