Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5392 discount breaks copy process ( moved)
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/main/java/de/metas/ui/web/pricing/process/M_DiscountSchemaBreak_CopyToOtherSchema.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,69 @@ | ||
package de.metas.ui.web.pricing.process; | ||
|
||
import org.adempiere.ad.dao.IQueryFilter; | ||
import org.adempiere.exceptions.AdempiereException; | ||
import org.compiere.model.I_M_DiscountSchema; | ||
import org.compiere.model.I_M_DiscountSchemaBreak; | ||
|
||
import de.metas.pricing.conditions.PricingConditionsId; | ||
import de.metas.pricing.conditions.service.IPricingConditionsRepository; | ||
import de.metas.process.IProcessPrecondition; | ||
import de.metas.process.Param; | ||
import de.metas.process.ProcessPreconditionsResolution; | ||
import de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate; | ||
import de.metas.util.Services; | ||
|
||
/* | ||
* #%L | ||
* de.metas.business | ||
* %% | ||
* Copyright (C) 2019 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% | ||
*/ | ||
|
||
public class M_DiscountSchemaBreak_CopyToOtherSchema extends ViewBasedProcessTemplate implements IProcessPrecondition | ||
{ | ||
private final IPricingConditionsRepository pricingConditionsRepo = Services.get(IPricingConditionsRepository.class); | ||
|
||
@Param(parameterName = I_M_DiscountSchema.COLUMNNAME_M_DiscountSchema_ID) | ||
private int p_PricingConditionsId; | ||
|
||
@Override | ||
protected ProcessPreconditionsResolution checkPreconditionsApplicable() | ||
{ | ||
if (getSelectedRowIds().isEmpty()) | ||
{ | ||
return ProcessPreconditionsResolution.rejectBecauseNoSelection(); | ||
} | ||
|
||
return ProcessPreconditionsResolution.accept(); | ||
} | ||
|
||
@Override | ||
protected String doIt() | ||
{ | ||
final IQueryFilter<I_M_DiscountSchemaBreak> queryFilter = getProcessInfo().getQueryFilterOrElse(null); | ||
if (queryFilter == null) | ||
{ | ||
throw new AdempiereException("@NoSelection@"); | ||
} | ||
|
||
pricingConditionsRepo.copyDiscountSchemaBreaks(PricingConditionsId.ofDiscountSchemaId(p_PricingConditionsId), queryFilter); | ||
|
||
return MSG_OK; | ||
} | ||
} |