use of de.metas.handlingunits.model.I_M_ReceiptSchedule in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_ReceiptSchedule_SelectHUsToReverse method doIt.
@Override
protected String doIt() throws Exception {
final I_M_ReceiptSchedule receiptSchedule = getRecord(I_M_ReceiptSchedule.class);
final List<I_M_HU> hus = ReceiptCorrectHUsProcessor.builder().setM_ReceiptSchedule(receiptSchedule).build().getAvailableHUsToReverse();
if (hus.isEmpty()) {
throw new AdempiereException("@NotFound@ @M_HU_ID@");
}
getResult().setRecordsToOpen(TableRecordReference.ofCollection(hus));
return MSG_OK;
}
use of de.metas.handlingunits.model.I_M_ReceiptSchedule in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_ReverseReceipt method doIt.
@Override
@RunOutOfTrx
protected String doIt() throws Exception {
final List<I_M_ReceiptSchedule> receiptSchedules = getM_ReceiptSchedules();
final List<Integer> huIdsToReverse = retrieveHUsToReverse();
boolean hasChanges = false;
try {
for (final I_M_ReceiptSchedule receiptSchedule : receiptSchedules) {
final ReceiptCorrectHUsProcessor processor = ReceiptCorrectHUsProcessor.builder().setM_ReceiptSchedule(receiptSchedule).tolerateNoHUsFound().build();
if (processor.isNoHUsFound()) {
continue;
}
final List<I_M_InOut> receiptsToReverse = processor.getReceiptsToReverseFromHUIds(huIdsToReverse);
if (receiptsToReverse.isEmpty()) {
continue;
}
processor.reverseReceipts(receiptsToReverse);
hasChanges = true;
}
} finally {
if (hasChanges) {
// Reset the view's affected HUs
getView().removeHUIdsAndInvalidate(huIdsToReverse);
// Notify all active views that given receipt schedules were changed
viewsRepo.notifyRecordsChanged(TableRecordReference.ofSet(receiptSchedules));
}
}
if (!hasChanges) {
throw new AdempiereException("@NotFound@ @M_InOut_ID@");
}
return MSG_OK;
}
use of de.metas.handlingunits.model.I_M_ReceiptSchedule in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_ReceiptSchedule_CreateEmptiesReturns_Base method doIt.
@Override
protected String doIt() throws Exception {
final I_M_ReceiptSchedule receiptSchedule = getProcessInfo().getRecordIfApplies(I_M_ReceiptSchedule.class, ITrx.TRXNAME_ThreadInherited).orElse(null);
final int emptiesInOutId;
if (receiptSchedule == null) {
emptiesInOutId = createDraftEmptiesDocument();
} else {
emptiesInOutId = createDraftEmptiesInOutFromReceiptSchedule(receiptSchedule);
}
// Notify frontend that the empties document shall be opened in single document layout (not grid)
if (emptiesInOutId > 0) {
getResult().setRecordToOpen(TableRecordReference.of(I_M_InOut.Table_Name, emptiesInOutId), getTargetWindowId(), OpenTarget.SingleDocument);
}
return MSG_OK;
}
use of de.metas.handlingunits.model.I_M_ReceiptSchedule in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_ReceiptSchedule_AttachPhoto method doIt.
@Override
protected String doIt() throws Exception {
final I_M_ReceiptSchedule receiptSchedule = getRecord(I_M_ReceiptSchedule.class);
final MImage adImage = MImage.get(getCtx(), p_AD_Image_ID);
if (adImage == null || adImage.getAD_Image_ID() <= 0) {
throw new EntityNotFoundException("@NotFound@ @AD_Image_ID@: " + p_AD_Image_ID);
}
final String name = adImage.getName();
final byte[] data = adImage.getData();
final BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
Services.get(IHUReceiptScheduleBL.class).attachPhoto(receiptSchedule, name, image);
return MSG_OK;
}
Aggregations