Skip to content

Display ea type as pre ea if phase is pre ea #2319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions epictrack-api/src/api/reports/resource_forecast_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ def _filter_data(self, data_items):
return filtered_result
return data_items

def _format_capital_investment(self, work_data):
"""Format the capital investment"""
if work_data.get("capital_investment", None):
work_data["capital_investment"] = (
f"{work_data['capital_investment']:,.0f}"
)
return work_data

def _format_ea_type(self, work_data):
"""Format the capital investment"""
if work_data.get("project_phase", None) == 'Pre-Early Engagement':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phase name is "Pre-EA (EAC Assessment)"

work_data["ea_type"] = 'Pre-EA'
return work_data

def _format_data(self, data):
"""Format the data into required format"""
response = []
Expand All @@ -347,11 +361,9 @@ def _format_data(self, data):
work_data["responsible_epd"] = responsible_epd
work_data["work_lead"] = work_lead
work_data["work_team_members"] = "; ".join(staffs)
if work_data.get("capital_investment", None):
work_data["capital_investment"] = (
f"{work_data['capital_investment']:,.0f}"
)
work_data = self._format_capital_investment(work_data)
work_data = self._handle_months(work_data)
work_data = self._format_ea_type(work_data)
response.append(work_data)
return response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from "material-react-table";
import { json2csv } from "json-2-csv";
import {
RESULT_STATUS,
REPORT_TYPE,
DISPLAY_DATE_FORMAT,
COMMON_ERROR_MESSAGE,
Expand All @@ -27,15 +26,13 @@ import ReportService from "../../../services/reportService";
import { dateUtils } from "../../../utils";
import { ResourceForecastModel } from "./type";
import ClearAllIcon from "@mui/icons-material/ClearAll";
import FileDownloadIcon from "@mui/icons-material/FileDownload";
import ReportHeader from "../shared/report-header/ReportHeader";
import { ETPageContainer, ETParagraph, IButton } from "../../shared";
import MasterTrackTable from "components/shared/MasterTrackTable";
import { showNotification } from "components/shared/notificationProvider";
import { rowsPerPageOptions } from "components/shared/MasterTrackTable/utils";
import Icons from "components/icons";
import { IconProps } from "components/icons/type";

const DownloadIcon: React.FC<IconProps> = Icons["DownloadIcon"];

export default function ResourceForecast() {
Expand Down Expand Up @@ -179,8 +176,8 @@ export default function ResourceForecast() {
[rfData]
);

const workFilter = filterFn("work_title");
const eaTypeFilter = filterFn("ea_type");
const workFilter = filterFn("work_title");
const projectPhaseFilter = filterFn("project_phase");
const eaActFilter = filterFn("ea_act");
const iaacFilter = filterFn("iaac");
Expand Down Expand Up @@ -383,9 +380,9 @@ export default function ResourceForecast() {
setRFData([]);
}
}, [reportDate]);

const downloadPDFReport = React.useCallback(async () => {
try {
fetchReportData();
const binaryReponse = await ReportService.downloadPDF(
REPORT_TYPE.RESOURCE_FORECAST,
{
Expand All @@ -412,7 +409,8 @@ export default function ResourceForecast() {
type: "error",
});
}
}, [reportDate, filters, fetchReportData]);
}, [reportDate, filters]);

return (
<ETPageContainer
direction="row"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PRE_EA_TYPE = "Pre-EA";
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type ResourceForecastModel = {
type: string;
work_id: number;
months: Array<MonthColumn>;
pre_ea: boolean;
};

interface MonthColumn {
Expand Down
Loading