Skip to content

Commit

Permalink
HUPPOrderIssueProducer: improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed May 18, 2017
1 parent a175bab commit e31bcba
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public class HUPPOrderIssueProducer implements IHUPPOrderIssueProducer
private final transient IHandlingUnitsBL handlingUnitsBL = Services.get(IHandlingUnitsBL.class);
private final transient IHUPPOrderQtyDAO huPPOrderQtyDAO = Services.get(IHUPPOrderQtyDAO.class);

private static final String MSG_IssuingAggregatedTUsNotAllowed = "de.metas.handlingunits.pporder.api.impl.HUPPOrderIssueProducer.IssuingAggregatedTUsNotAllowed";
private static final String MSG_IssuingVHUsNotAllowed = "de.metas.handlingunits.pporder.api.impl.HUPPOrderIssueProducer.IssuingVHUsNotAllowed";
private static final String MSG_IssuingHUWithMultipleProductsNotAllowed = "de.metas.handlingunits.pporder.api.impl.HUPPOrderIssueProducer.IssuingHUsWithMultipleProductsNotAllowed";

public static final LockOwner lockOwner = LockOwner.forOwnerName("PP_Order_PreparedToIssue");

private Date movementDate;
Expand Down Expand Up @@ -150,17 +154,22 @@ private I_PP_Order_Qty createIssue_InTrx(final IHUContext huContext, final I_M_H
// If not a top level HU, take it out first
if (!handlingUnitsBL.isTopLevel(hu))
{
if(handlingUnitsBL.isAggregateHU(hu))
{
throw HUException.ofAD_Message(MSG_IssuingAggregatedTUsNotAllowed);
}
if (handlingUnitsBL.isVirtual(hu))
{
throw new HUException("Issuing VHUs is not allowed");
throw HUException.ofAD_Message(MSG_IssuingVHUsNotAllowed);
}
else
{
huTrxBL.setParentHU(huContext //
, null // parentHUItem
, hu //
, true // destroyOldParentIfEmptyStorage
);
}

huTrxBL.setParentHU(huContext //
, null // parentHUItem
, hu //
, true // destroyOldParentIfEmptyStorage
);
// throw new HUException("Only top level HUs are allowed to be issued");
}

//
Expand All @@ -180,7 +189,9 @@ private I_PP_Order_Qty createIssue_InTrx(final IHUContext huContext, final I_M_H

if (productStorages.size() != 1)
{
throw new HUException("HU with multiple products is not allowed: hu=" + hu + ", productStorages=" + productStorages);
throw HUException.ofAD_Message(MSG_IssuingHUWithMultipleProductsNotAllowed)
.setParameter("HU", hu)
.setParameter("ProductStorages", productStorages);
}
productStorage = productStorages.get(0);
}
Expand Down Expand Up @@ -313,7 +324,7 @@ public void reverseDraftIssue(final I_PP_Order_Qty candidate)
{
throw new HUException("Cannot reverse candidate because it's already processed: " + candidate);
}

final I_M_HU huToIssue = candidate.getM_HU();
huLockBL.unlock(huToIssue, HUPPOrderIssueProducer.lockOwner);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- 2017-05-18T11:04:12.120
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Message_Trl WHERE AD_Message_ID=544322
;

-- 2017-05-18T11:04:12.135
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Message WHERE AD_Message_ID=544322
;

-- 2017-05-18T11:04:26.280
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,544324,0,TO_TIMESTAMP('2017-05-18 11:04:26','YYYY-MM-DD HH24:MI:SS'),100,'de.metas.handlingunits','Y','Issuing aggregated TUs is not allowed. Please use the quick action which partially issues TUs.','E',TO_TIMESTAMP('2017-05-18 11:04:26','YYYY-MM-DD HH24:MI:SS'),100,'de.metas.handlingunits.pporder.api.impl.HUPPOrderIssueProducer.IssuingAggregatedTUsNotAllowed')
;

-- 2017-05-18T11:04:26.285
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=544324 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;

-- 2017-05-18T11:07:09.606
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,544325,0,TO_TIMESTAMP('2017-05-18 11:07:09','YYYY-MM-DD HH24:MI:SS'),100,'de.metas.handlingunits','Y','Issuing HUs with multiple Products is not allowed.','E',TO_TIMESTAMP('2017-05-18 11:07:09','YYYY-MM-DD HH24:MI:SS'),100,'de.metas.handlingunits.pporder.api.impl.HUPPOrderIssueProducer.IssuingHUsWithMultipleProductsNotAllowed')
;

-- 2017-05-18T11:07:09.609
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=544325 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;

-- 2017-05-18T11:08:02.645
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,544326,0,TO_TIMESTAMP('2017-05-18 11:08:02','YYYY-MM-DD HH24:MI:SS'),100,'de.metas.handlingunits','Y','Issuing VHUs is not allowed.','E',TO_TIMESTAMP('2017-05-18 11:08:02','YYYY-MM-DD HH24:MI:SS'),100,'de.metas.handlingunits.pporder.api.impl.HUPPOrderIssueProducer.IssuingVHUsNotAllowed')
;

-- 2017-05-18T11:08:02.649
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=544326 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;

0 comments on commit e31bcba

Please sign in to comment.