diff --git a/persistence/src/main/java/org/devgateway/toolkit/persistence/dao/form/ProcurementPlan.java b/persistence/src/main/java/org/devgateway/toolkit/persistence/dao/form/ProcurementPlan.java index 5ab9c2319..dcc5b2292 100644 --- a/persistence/src/main/java/org/devgateway/toolkit/persistence/dao/form/ProcurementPlan.java +++ b/persistence/src/main/java/org/devgateway/toolkit/persistence/dao/form/ProcurementPlan.java @@ -133,13 +133,27 @@ public String toString() { } /** - * Any procurement plan is exportable, even the draft ones + * please read first OCMAKU-477 to understand why we need to export draft procurement plans. + *
+ * the rule to determine if a procurement plan will be published is now the following (by "exportable" + * we mean terminated or approved): + *
+ * if the procurement plan is exportable - it gets published + * if the procurement plan is draft AND it contains at least one exportable project which contains at least + * one tender process which is exportable + *
+ * This has implications on the public portal pages, since draft submission of procurement plans is + *
+ * procurement plans can be exported without file uploads + * procurement plans can be exported without approval dates * * @return */ @Override + @Transactional public boolean isExportable() { - return true; + return super.isExportable() || getProjects().stream().filter(Statusable::isExportable). + flatMap(p -> p.getTenderProcesses().stream()).anyMatch(Statusable::isExportable); } @Override diff --git a/ui/oce/makueni/procurementPlan/single/procurementPlan.jsx b/ui/oce/makueni/procurementPlan/single/procurementPlan.jsx index e26be3c43..c4e938a4c 100644 --- a/ui/oce/makueni/procurementPlan/single/procurementPlan.jsx +++ b/ui/oce/makueni/procurementPlan/single/procurementPlan.jsx @@ -6,30 +6,30 @@ import FeedbackPage from '../../FeedbackPage'; class ProcurementPlan extends FeedbackPage { constructor(props) { super(props); - + this.state = {}; - + this.ppID = ppState.input({ name: 'ppID', }); - + this.ppInfoUrl = ppState.mapping({ name: 'ppInfoUrl', deps: [this.ppID], mapper: id => `${API_ROOT}/makueni/procurementPlan/id/${id}`, }); - + this.ppInfo = ppState.remote({ name: 'ppInfo', url: this.ppInfoUrl, }); } - + componentDidMount() { const { id } = this.props; - + this.ppID.assign('PP', id); - + this.ppInfo.addListener('PP', () => { this.ppInfo.getState() .then(data => { @@ -37,27 +37,27 @@ class ProcurementPlan extends FeedbackPage { }); }); } - + componentWillUnmount() { this.ppInfo.removeListener('PP'); } - + getFeedbackSubject() { const { data } = this.state; - + let metadata; if (data !== undefined) { metadata = " - " + data.department.label + " - " + data.fiscalYear.name; } return escape("Procurement Plan" + metadata); } - + render() { const { navigate } = this.props; const { data } = this.state; - + const { currencyFormatter, formatDate } = this.props.styling.tables; - + return (