use of de.metas.ui.web.pporder.PPOrderLinesView in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_IssueTUs method doIt.
@Override
protected String doIt() throws Exception {
final HUEditorRow row = getSingleSelectedRow();
final I_M_HU sourceLUorTU = row.getM_HU();
final HUsToNewTUsRequest request = HUsToNewTUsRequest.forSourceHuAndQty(sourceLUorTU, qtyTUs);
final List<I_M_HU> extractedTUs = HUTransformService.newInstance().husToNewTUs(request);
if (extractedTUs.isEmpty()) {
throw new AdempiereException("@NoSelection@");
}
final PPOrderLinesView ppOrderView = getPPOrderView().get();
final int ppOrderId = ppOrderView.getPP_Order_ID();
Services.get(IHUPPOrderBL.class).createIssueProducer().setTargetOrderBOMLinesByPPOrderId(ppOrderId).createDraftIssues(extractedTUs);
getView().invalidateAll();
ppOrderView.invalidateAll();
return MSG_OK;
}
use of de.metas.ui.web.pporder.PPOrderLinesView in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_Launcher method checkPreconditionsApplicable.
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
if (!getSelectedRowIds().isSingleDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final PPOrderLinesView ppOrderLineView = getView();
if (!(ppOrderLineView.isStatusPlanning() || ppOrderLineView.isStatusReview())) {
final String internalReason = StringUtils.formatMessage("The PP_Order of the the current ppOrderLineView is not in planning or in review; ppOrderLineView={}", ppOrderLineView);
return ProcessPreconditionsResolution.rejectWithInternalReason(internalReason);
}
final PPOrderLineRow singleSelectedRow = getSingleSelectedRow();
if (!singleSelectedRow.isIssue()) {
final String internalReason = StringUtils.formatMessage("The selected ppOrderLineRow is not an issue row; selectedRow={}", singleSelectedRow);
return ProcessPreconditionsResolution.rejectWithInternalReason(internalReason);
}
if (singleSelectedRow.isProcessed()) {
final String internalReason = StringUtils.formatMessage("The selected ppOrderLineRow is already flagged as processed; selectedRow={}", singleSelectedRow);
return ProcessPreconditionsResolution.rejectWithInternalReason(internalReason);
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.pporder.PPOrderLinesView in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_Receipt method postProcess.
@Override
protected void postProcess(boolean success) {
// Invalidate the view because for sure we have changes
final PPOrderLinesView ppOrderLinesView = getView();
ppOrderLinesView.invalidateAll();
viewsRepo.notifyRecordChanged(I_PP_Order.Table_Name, ppOrderLinesView.getPP_Order_ID());
}
use of de.metas.ui.web.pporder.PPOrderLinesView in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_M_Source_HU_IssueTuQty method doIt.
@Override
protected String doIt() throws Exception {
final PPOrderLineRow row = getSingleSelectedRow();
final List<I_M_Source_HU> sourceHus = retrieveActiveSourceHus(row);
if (sourceHus.isEmpty()) {
throw new AdempiereException("@NoSelection@");
}
final Map<Integer, I_M_Source_HU> huId2SourceHu = new HashMap<>();
final ImmutableList<I_M_HU> husThatAreFlaggedAsSource = sourceHus.stream().peek(sourceHu -> huId2SourceHu.put(sourceHu.getM_HU_ID(), sourceHu)).map(I_M_Source_HU::getM_HU).collect(ImmutableList.toImmutableList());
final HUsToNewTUsRequest request = HUsToNewTUsRequest.builder().sourceHUs(husThatAreFlaggedAsSource).qtyTU(qtyTU.intValue()).build();
EmptyHUListener emptyHUListener = EmptyHUListener.doBeforeDestroyed(hu -> {
if (huId2SourceHu.containsKey(hu.getM_HU_ID())) {
SourceHUsService.get().snapshotSourceHU(huId2SourceHu.get(hu.getM_HU_ID()));
}
}, "Create snapshot of source-HU before it is destroyed");
final List<I_M_HU> extractedTUs = HUTransformService.builder().emptyHUListener(emptyHUListener).build().husToNewTUs(request);
final PPOrderLinesView ppOrderView = getView();
final int ppOrderId = ppOrderView.getPP_Order_ID();
Services.get(IHUPPOrderBL.class).createIssueProducer().setTargetOrderBOMLinesByPPOrderId(ppOrderId).createDraftIssues(extractedTUs);
getView().invalidateAll();
ppOrderView.invalidateAll();
return MSG_OK;
}
use of de.metas.ui.web.pporder.PPOrderLinesView in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_ChangePlanningStatus_Template method postProcess.
@Override
protected void postProcess(final boolean success) {
final PPOrderLinesView ppOrderLinesView = getView();
ppOrderLinesView.invalidateAll();
final int ppOrderId = ppOrderLinesView.getPP_Order_ID();
viewsRepo.notifyRecordChanged(I_PP_Order.Table_Name, ppOrderId);
}
Aggregations