Skip to content

Commit

Permalink
OLCand: getFlatrateConditionsId, getHUPIProductItemId
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Feb 28, 2018
1 parent 56156c6 commit 8e4605e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import java.util.List;

import org.adempiere.model.InterfaceWrapperHelper;

import com.google.common.collect.ImmutableList;

import de.metas.contracts.flatrate.interfaces.I_C_OLCand;
import de.metas.ordercandidate.api.OLCand;
import de.metas.ordercandidate.spi.IOLCandGroupingProvider;

Expand All @@ -31,9 +28,8 @@ public class FlatrateGroupingProvider implements IOLCandGroupingProvider
@Override
public List<Object> provideLineGroupingValues(final OLCand cand)
{
final I_C_OLCand flatratesCand = InterfaceWrapperHelper.create(cand.unbox(), I_C_OLCand.class);

return ImmutableList.<Object> of(flatratesCand.getC_Flatrate_Conditions_ID());
final int flatrateConditionsId = cand.getFlatrateConditionsId();
return ImmutableList.<Object> of(flatrateConditionsId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
*
* 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
* 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
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/


import org.adempiere.model.InterfaceWrapperHelper;
import org.adempiere.util.Check;
import org.compiere.model.I_C_OrderLine;

import de.metas.contracts.flatrate.interfaces.I_C_OLCand;
import de.metas.ordercandidate.api.OLCand;
import de.metas.ordercandidate.spi.IOLCandListener;

Expand All @@ -49,20 +47,19 @@ public class FlatrateOLCandListener implements IOLCandListener
@Override
public void onOrderLineCreated(final OLCand olCand, final I_C_OrderLine orderLine)
{
de.metas.contracts.subscription.model.I_C_OrderLine flatrateOrderLine =
InterfaceWrapperHelper.create(orderLine, de.metas.contracts.subscription.model.I_C_OrderLine.class);
de.metas.contracts.subscription.model.I_C_OrderLine flatrateOrderLine = InterfaceWrapperHelper.create(orderLine, de.metas.contracts.subscription.model.I_C_OrderLine.class);

final I_C_OLCand flatrateOlCand = InterfaceWrapperHelper.create(olCand.unbox(), I_C_OLCand.class);
if (flatrateOrderLine.getC_Flatrate_Conditions_ID() <= 0)
final int flatrateConditionsId = olCand.getFlatrateConditionsId();
if (flatrateConditionsId <= 0)
{
flatrateOrderLine.setC_Flatrate_Conditions_ID(flatrateOlCand.getC_Flatrate_Conditions_ID());
flatrateOrderLine.setC_Flatrate_Conditions_ID(flatrateConditionsId);
}
else
{
Check.assume(flatrateOrderLine.getC_Flatrate_Conditions_ID() == flatrateOlCand.getC_Flatrate_Conditions_ID(),
olCand + " with C_Flatrate_Conditions_ID=" + flatrateOlCand.getC_Flatrate_Conditions_ID() +
" can't be aggregated into " +
orderLine + " with C_Flatrate_Conditions_ID=" + flatrateOrderLine.getC_Flatrate_Conditions_ID());
final int orderLineFlatrateConditionsId = flatrateOrderLine.getC_Flatrate_Conditions_ID();
Check.assume(orderLineFlatrateConditionsId == flatrateConditionsId,
"{} with C_Flatrate_Conditions_ID={} can't be aggregated into {} with C_Flatrate_Conditions_ID={}",
olCand, flatrateConditionsId, orderLine, orderLineFlatrateConditionsId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public class OLCandHUPackingAware implements IHUPackingAware

public OLCandHUPackingAware(final de.metas.ordercandidate.model.I_C_OLCand olCand)
{
super();

Check.assumeNotNull(olCand, "olcand not null");
this.olCand = InterfaceWrapperHelper.create(olCand, I_C_OLCand.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
*
* 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
* 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
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/


import org.adempiere.model.InterfaceWrapperHelper;
import org.compiere.model.I_C_OrderLine;

import de.metas.adempiere.gui.search.impl.OLCandHUPackingAware;
import de.metas.handlingunits.model.I_C_OrderLine;
import de.metas.ordercandidate.api.OLCand;
import de.metas.ordercandidate.model.I_C_OLCand;
import de.metas.ordercandidate.spi.IOLCandListener;
Expand All @@ -40,14 +38,12 @@
public class OLCandPIIPListener implements IOLCandListener
{
/**
* Sets the new order line's <code>M_HU_PI_Item_Product_ID</code> from the olCand's effective <code>M_HU_PI_Item_Product_ID</code>, so that the sytem won't have to guess.
* Sets the new order line's <code>M_HU_PI_Item_Product_ID</code> from the olCand's effective <code>M_HU_PI_Item_Product_ID</code>, so that the system won't have to guess.
*/
@Override
public void onOrderLineCreated(final OLCand olCand, final I_C_OrderLine newOrderLine)
public void onOrderLineCreated(final OLCand olCand, final org.compiere.model.I_C_OrderLine newOrderLine)
{
final de.metas.handlingunits.model.I_C_OrderLine newOrderLineExt = InterfaceWrapperHelper.create(newOrderLine, de.metas.handlingunits.model.I_C_OrderLine.class);
final OLCandHUPackingAware olCandHUPackingAware = new OLCandHUPackingAware(olCand.unbox());

newOrderLineExt.setM_HU_PI_Item_Product_ID(olCandHUPackingAware.getM_HU_PI_Item_Product_ID());
final I_C_OrderLine newOrderLineExt = InterfaceWrapperHelper.create(newOrderLine, I_C_OrderLine.class);
newOrderLineExt.setM_HU_PI_Item_Product_ID(olCand.getHUPIProductItemId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,18 @@ public boolean isExplicitProductPriceAttribute()
{
return candidate.isExplicitProductPriceAttribute();
}

public int getFlatrateConditionsId()
{
return candidate.getC_Flatrate_Conditions_ID();
}

public int getHUPIProductItemId()
{
if (candidate.getM_HU_PI_Item_Product_Override_ID() > 0)
{
return candidate.getM_HU_PI_Item_Product_Override_ID();
}
return candidate.getM_HU_PI_Item_Product_ID();
}
}

0 comments on commit 8e4605e

Please sign in to comment.