use of org.adempiere.exceptions.FillMandatoryException in project metasfresh-webui-api by metasfresh.
the class MailRestController method sendEmail.
private WebuiEmail sendEmail(final WebuiEmail webuiEmail) {
final String emailId = webuiEmail.getEmailId();
//
// Create the email object
final I_AD_Client adClient = Services.get(IClientDAO.class).retriveClient(Env.getCtx(), userSession.getAD_Client_ID());
final String mailCustomType = null;
final I_AD_User from = Services.get(IUserDAO.class).retrieveUser(webuiEmail.getFrom().getIdAsInt());
final List<String> toList = extractEMailAddreses(webuiEmail.getTo()).collect(ImmutableList.toImmutableList());
if (toList.isEmpty()) {
throw new FillMandatoryException("To");
}
final String to = toList.get(0);
final String subject = webuiEmail.getSubject();
final String message = webuiEmail.getMessage();
final boolean html = false;
final EMail email = Services.get(IMailBL.class).createEMail(adClient, mailCustomType, from, to, subject, message, html);
toList.stream().skip(1).forEach(email::addTo);
webuiEmail.getAttachments().stream().map(webuiAttachment -> {
final byte[] content = mailAttachmentsRepo.getAttachmentAsByteArray(emailId, webuiAttachment);
return EMailAttachment.of(webuiAttachment.getDisplayName(), content);
}).forEach(email::addAttachment);
//
// Actually send the email
final EMailSentStatus sentStatus = email.send();
if (!sentStatus.isSentOK()) {
throw new AdempiereException("Failed sending the email: " + sentStatus.getSentMsg());
}
//
// Delete temporary attachments
mailAttachmentsRepo.deleteAttachments(emailId, webuiEmail.getAttachments());
// Mark the webui email as sent
return webuiEmail.toBuilder().sent(true).build();
}
use of org.adempiere.exceptions.FillMandatoryException in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformCommand method execute.
public final WebuiHUTransformCommandResult execute() {
final HUEditorRow row = getSelectedRow();
final ActionType action = getActionType();
final WebuiHUTransformParameters parameters = getParameters();
switch(action) {
case CU_To_NewCU:
{
return action_SplitCU_To_NewCU(row, parameters.getQtyCU());
}
case CU_To_ExistingTU:
{
return action_SplitCU_To_ExistingTU(row, parameters.getTuHU(), parameters.getQtyCU());
}
case CU_To_NewTUs:
{
if (parameters.getHuPIItemProduct() == null) {
throw new FillMandatoryException(WEBUI_M_HU_Transform.PARAM_M_HU_PI_Item_Product_ID);
}
return action_SplitCU_To_NewTUs(row, parameters.getHuPIItemProduct(), parameters.getQtyCU(), parameters.isHuPlanningReceiptOwnerPM_TU());
}
case TU_Set_Ownership:
{
return action_updatePlanningReceiptOwnerPM(row, parameters.isHuPlanningReceiptOwnerPM_TU());
}
case TU_To_NewTUs:
{
return action_SplitTU_To_NewTUs(row, parameters.getQtyTU());
}
case TU_To_NewLUs:
{
if (parameters.getHuPIItem() == null) {
throw new FillMandatoryException(WEBUI_M_HU_Transform.PARAM_M_HU_PI_Item_ID);
}
return action_SplitTU_To_NewLU(row, parameters.getHuPIItem(), parameters.getQtyTU(), parameters.isHuPlanningReceiptOwnerPM_LU());
}
case LU_Set_Ownership:
{
return action_updatePlanningReceiptOwnerPM(row, parameters.isHuPlanningReceiptOwnerPM_LU());
}
case TU_To_ExistingLU:
{
return action_SplitTU_To_ExistingLU(row, parameters.getLuHU(), parameters.getQtyTU());
}
//
default:
{
throw new AdempiereException("@Unknown@ @Action@ " + action);
}
}
}
use of org.adempiere.exceptions.FillMandatoryException in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_ReturnTUsToVendor method doIt.
@Override
protected String doIt() throws Exception {
if (p_QtyTU <= 0) {
throw new FillMandatoryException("QtyTU");
}
topLevelHU = getRecord(I_M_HU.class);
//
// Get the original receipt line
final List<I_M_InOutLine> receiptLines = huAssignmentDAO.retrieveModelsForHU(topLevelHU, I_M_InOutLine.class).stream().filter(// material receipt
inoutLine -> !inoutLine.getM_InOut().isSOTrx()).collect(ImmutableList.toImmutableList());
final I_M_InOutLine receiptLine = ListUtils.singleElement(receiptLines);
//
// Split out the TUs we need to return
final HUsToNewTUsRequest request = HUsToNewTUsRequest.forSourceHuAndQty(topLevelHU, p_QtyTU);
tusToReturn = HUTransformService.newInstance().husToNewTUs(request);
if (tusToReturn.size() != p_QtyTU) {
throw new AdempiereException(WEBUI_HU_Constants.MSG_NotEnoughTUsFound, new Object[] { p_QtyTU, tusToReturn.size() });
}
//
// Assign the split TUs to the receipt line
// FIXME: this is a workaround until https://github.com/metasfresh/metasfresh/issues/2392 is implemented
tusToReturn.forEach(tu -> huAssignmentBL.createHUAssignmentBuilder().initializeAssignment(getCtx(), ITrx.TRXNAME_ThreadInherited).setM_LU_HU(null).setM_TU_HU(tu).setTopLevelHU(tu).setModel(receiptLine).build());
//
// Actually create the vendor return
final Timestamp movementDate = Env.getDate(getCtx());
huInOutBL.createVendorReturnInOutForHUs(tusToReturn, movementDate);
//
return MSG_OK;
}
use of org.adempiere.exceptions.FillMandatoryException in project metasfresh-webui-api by metasfresh.
the class PackingInfoProcessParams method createAndSaveNewLUTUConfig.
public I_M_HU_LUTU_Configuration createAndSaveNewLUTUConfig() {
final I_M_HU_LUTU_Configuration defaultLUTUConfig = getDefaultLUTUConfig();
// Validate parameters
// not mandatory
final int lu_PI_Item_ID = getLuPiItemId();
final int M_HU_PI_Item_Product_ID = getTU_HU_PI_Item_Product_ID();
final BigDecimal qtyCU = getQtyCU();
final boolean isVirtualHU = M_HU_PI_Item_Product_ID == IHUPIItemProductDAO.VIRTUAL_HU_PI_Item_Product_ID;
final BigDecimal qtyTU = isVirtualHU ? BigDecimal.ONE : this.qtyTU;
if (M_HU_PI_Item_Product_ID <= 0) {
throw new FillMandatoryException(PARAM_M_HU_PI_Item_Product_ID);
}
if (qtyCU == null || qtyCU.signum() <= 0) {
throw new FillMandatoryException(PARAM_QtyCU);
}
if (qtyTU == null || qtyTU.signum() <= 0) {
throw new FillMandatoryException(PARAM_QtyTU);
}
final I_M_HU_LUTU_Configuration lutuConfigNew = InterfaceWrapperHelper.copy().setFrom(defaultLUTUConfig).copyToNew(I_M_HU_LUTU_Configuration.class);
// CU
lutuConfigNew.setQtyCU(qtyCU);
lutuConfigNew.setIsInfiniteQtyCU(false);
// TU
configureLUTUConfigTU(lutuConfigNew, M_HU_PI_Item_Product_ID, qtyTU);
// LU
configureLUTUConfigLU(lutuConfigNew, lu_PI_Item_ID);
lutuConfigurationFactory.save(lutuConfigNew);
return lutuConfigNew;
}
use of org.adempiere.exceptions.FillMandatoryException in project metasfresh-webui-api by metasfresh.
the class WEBUI_PickingSlotsClearingView_TakeOutHUAndAddToNewHU method doIt.
@Override
protected String doIt() throws Exception {
if (qtyCU == null || qtyCU.signum() <= 0) {
throw new FillMandatoryException(PARAM_QtyCU);
}
final I_M_HU fromHU = getSingleSelectedPickingSlotTopLevelHU();
final IAllocationSource source = HUListAllocationSourceDestination.of(fromHU).setDestroyEmptyHUs(true);
final IHUProducerAllocationDestination destination = createHUProducer(fromHU);
HULoader.of(source, destination).setAllowPartialUnloads(false).setAllowPartialLoads(false).load(prepareUnloadRequest(fromHU, qtyCU).setForceQtyAllocation(true).create());
// If the source HU was destroyed, then "remove" it from picking slots
if (handlingUnitsBL.isDestroyedRefreshFirst(fromHU)) {
pickingCandidateService.inactivateForHUId(fromHU.getM_HU_ID());
}
return MSG_OK;
}
Aggregations