From ae3fccbb777634d733e6860e6b6e19e4978c1e9f Mon Sep 17 00:00:00 2001 From: mpostelnicu Date: Wed, 17 Jun 2020 10:32:00 +0300 Subject: [PATCH 1/2] OCMAKU-671 Procurement plan page in public portal is showing drafts --- .../persistence/dao/form/ProcurementPlan.java | 6 ++- .../single/procurementPlan.jsx | 52 +++++++++---------- 2 files changed, 30 insertions(+), 28 deletions(-) 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..6440686ed 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,15 @@ public String toString() { } /** - * Any procurement plan is exportable, even the draft ones + * Procurement Plan is exportable only if there is at least one approved/terminated tender process * * @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 (
navigate()} className="back-link col-md-3"> @@ -69,13 +69,13 @@ class ProcurementPlan extends FeedbackPage {
- +

Procurement Plan

- + { data !== undefined ?
@@ -89,7 +89,7 @@ class ProcurementPlan extends FeedbackPage {
{data.fiscalYear.name}
- + { data.planItems !== undefined ?
@@ -98,7 +98,7 @@ class ProcurementPlan extends FeedbackPage { ({data.planItems.length})
- + { data.planItems.map(planItem =>
@@ -107,8 +107,8 @@ class ProcurementPlan extends FeedbackPage {
{planItem.item.label}
- - + +
Unit Of Issue
@@ -127,7 +127,7 @@ class ProcurementPlan extends FeedbackPage {
{currencyFormatter(planItem.quantity * planItem.estimatedCost)}
- +
Procurement Method
@@ -153,7 +153,7 @@ class ProcurementPlan extends FeedbackPage { className="item-value">{currencyFormatter(planItem.targetGroupValue)}
- +

Timing of activities (quarterly basis)

@@ -175,13 +175,13 @@ class ProcurementPlan extends FeedbackPage {
) } - +
Procurement Plan Documents
- + { - data.formDocs.map(doc =>
+ data.formDocs && data.formDocs.map(doc =>
}> - + {doc.name} @@ -210,7 +210,7 @@ class ProcurementPlan extends FeedbackPage {
: null } - + {this.getFeedbackMessage()}
); } From 7c44d23f0cb25da4c7a4eb1f3f439c692a7b1244 Mon Sep 17 00:00:00 2001 From: mpostelnicu Date: Wed, 17 Jun 2020 10:35:36 +0300 Subject: [PATCH 2/2] OCMAKU-671 updated javadoc --- .../persistence/dao/form/ProcurementPlan.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 6440686ed..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,7 +133,19 @@ public String toString() { } /** - * Procurement Plan is exportable only if there is at least one approved/terminated tender process + * 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 */