-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Procurement Candidates generate Purchase Order
- Loading branch information
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
.../java/de/metas/ui/web/procurement/process/PMM_Purchase_Candidate_CreatePurchaseOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package de.metas.ui.web.procurement.process; | ||
|
||
import org.springframework.context.annotation.Profile; | ||
|
||
import de.metas.process.IProcessPrecondition; | ||
import de.metas.process.ProcessPreconditionsResolution; | ||
import de.metas.procurement.base.model.I_PMM_PurchaseCandidate; | ||
import de.metas.procurement.base.order.async.PMM_GenerateOrders; | ||
import de.metas.ui.web.WebRestApiApplication; | ||
import de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate; | ||
import de.metas.ui.web.window.datatypes.DocumentIdsSelection; | ||
|
||
/* | ||
* #%L | ||
* de.metas.procurement.base | ||
* %% | ||
* Copyright (C) 2017 metas GmbH | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 2 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-2.0.html>. | ||
* #L% | ||
*/ | ||
|
||
/** | ||
* Mass enqueue {@link I_PMM_PurchaseCandidate} records to be processed and purchase orders to be generated. | ||
* | ||
* @author metas-dev <dev@metasfresh.com> | ||
* | ||
*/ | ||
@Profile(WebRestApiApplication.PROFILE_Webui) | ||
public class PMM_Purchase_Candidate_CreatePurchaseOrder extends ViewBasedProcessTemplate implements IProcessPrecondition | ||
{ | ||
private int recordsEnqueued; | ||
|
||
@Override | ||
protected ProcessPreconditionsResolution checkPreconditionsApplicable() | ||
{ | ||
final DocumentIdsSelection selectedRowIds = getSelectedDocumentIds(); | ||
if (selectedRowIds.isEmpty()) | ||
{ | ||
return ProcessPreconditionsResolution.rejectBecauseNoSelection(); | ||
} | ||
|
||
return ProcessPreconditionsResolution.accept(); | ||
} | ||
|
||
@Override | ||
protected String doIt() throws Exception | ||
{ | ||
recordsEnqueued = PMM_GenerateOrders.prepareEnqueuing() | ||
.filter(getProcessInfo().getQueryFilter()) | ||
.enqueue(); | ||
return MSG_OK; | ||
} | ||
|
||
@Override | ||
protected void postProcess(final boolean success) | ||
{ | ||
if (!success) | ||
{ | ||
return; | ||
} | ||
|
||
// | ||
// Notify frontend that the view shall be refreshed because we changed some candidates | ||
if (recordsEnqueued > 0) | ||
{ | ||
invalidateView(); | ||
} | ||
} | ||
|
||
} |