Skip to content

Commit

Permalink
#5392 discount breaks copy process ( moved)
Browse files Browse the repository at this point in the history
  • Loading branch information
metas-rc committed Jul 26, 2019
1 parent 1bcecf6 commit bd2fabf
Showing 1 changed file with 69 additions and 0 deletions.
@@ -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;
}
}

0 comments on commit bd2fabf

Please sign in to comment.