Search in sources :

Example 6 with I_M_ReceiptSchedule

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;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) I_M_ReceiptSchedule(de.metas.handlingunits.model.I_M_ReceiptSchedule)

Example 7 with I_M_ReceiptSchedule

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;
}
Also used : ReceiptCorrectHUsProcessor(de.metas.handlingunits.inout.ReceiptCorrectHUsProcessor) I_M_InOut(org.compiere.model.I_M_InOut) AdempiereException(org.adempiere.exceptions.AdempiereException) I_M_ReceiptSchedule(de.metas.handlingunits.model.I_M_ReceiptSchedule) RunOutOfTrx(de.metas.process.RunOutOfTrx)

Example 8 with I_M_ReceiptSchedule

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;
}
Also used : I_M_ReceiptSchedule(de.metas.handlingunits.model.I_M_ReceiptSchedule)

Example 9 with I_M_ReceiptSchedule

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;
}
Also used : MImage(org.compiere.model.MImage) IHUReceiptScheduleBL(de.metas.handlingunits.receiptschedule.IHUReceiptScheduleBL) ByteArrayInputStream(java.io.ByteArrayInputStream) I_M_ReceiptSchedule(de.metas.handlingunits.model.I_M_ReceiptSchedule) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) BufferedImage(java.awt.image.BufferedImage)

Aggregations

I_M_ReceiptSchedule (de.metas.handlingunits.model.I_M_ReceiptSchedule)9 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)3 I_M_HU (de.metas.handlingunits.model.I_M_HU)2 RunOutOfTrx (de.metas.process.RunOutOfTrx)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 TerminalException (de.metas.adempiere.form.terminal.TerminalException)1 ILUTUConfigurationFactory (de.metas.handlingunits.allocation.ILUTUConfigurationFactory)1 ILUTUProducerAllocationDestination (de.metas.handlingunits.allocation.ILUTUProducerAllocationDestination)1 ReceiptCorrectHUsProcessor (de.metas.handlingunits.inout.ReceiptCorrectHUsProcessor)1 IHUReceiptScheduleBL (de.metas.handlingunits.receiptschedule.IHUReceiptScheduleBL)1 ReceiptScheduleHUGenerator (de.metas.handlingunits.receiptschedule.impl.ReceiptScheduleHUGenerator)1 IReceiptScheduleBL (de.metas.inoutcandidate.api.IReceiptScheduleBL)1 Quantity (de.metas.quantity.Quantity)1 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)1 BufferedImage (java.awt.image.BufferedImage)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 I_M_InOut (org.compiere.model.I_M_InOut)1 MImage (org.compiere.model.MImage)1