/// <summary>
        /// Create Confirmation
        /// </summary>
        /// <returns>document no</returns>
        protected override String DoIt()
        {
            //log.info("M_InOut_ID=" + _M_InOut_ID + ", Type=" + _ConfirmType);
            MInOut shipment = new MInOut(GetCtx(), _M_InOut_ID, null);

            if (shipment.Get_ID() == 0)
            {
                throw new ArgumentException("Not found M_InOut_ID=" + _M_InOut_ID);
            }
            //
            MInOutConfirm[] confirmations = shipment.GetConfirmations(false);
            MInOutConfirm   confirm       = null;
            int             count         = 0;

            if (confirmations != null && confirmations.Length > 0)
            {
                for (Int32 i = 0; i < confirmations.Length; i++)
                {
                    confirm = null;
                    count  += 1;
                    confirm = confirmations[i];
                    if (confirm.GetDocStatus() == "VO")
                    {
                        if (count == confirmations.Length)
                        {
                            confirm = MInOutConfirm.Create(shipment, _ConfirmType, false);
                            break;
                        }
                    }
                    if (confirm.GetDocStatus() == "DR")
                    {
                        confirm = MInOutConfirm.Create(shipment, _ConfirmType, true);
                        break;
                    }
                }
            }
            else
            {
                confirm = MInOutConfirm.Create(shipment, _ConfirmType, true);
            }
            //throw new Exception("Cannot create Confirmation for " + shipment.GetDocumentNo());

            if (confirm == null)
            {
                throw new Exception("Cannot create Confirmation for " + shipment.GetDocumentNo());
            }
            if (shipment.GetDocStatus() == "DR") //To set docstatus for MR in InProgress state when shipment/MR is in Drafted state
            {
                shipment.SetDocStatus("IP");
                shipment.FreezeDoc();
            }
            //
            return("Open Shipment Confirmation Number generated: " + confirm.GetDocumentNo());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create Confirmation
        /// </summary>
        /// <returns>document no</returns>
        protected override String DoIt()
        {
            //log.info("M_InOut_ID=" + _M_InOut_ID + ", Type=" + _ConfirmType);
            MInOut shipment = new MInOut(GetCtx(), _M_InOut_ID, null);

            if (shipment.Get_ID() == 0)
            {
                throw new ArgumentException("Not found M_InOut_ID=" + _M_InOut_ID);
            }
            //
            MInOutConfirm confirm = MInOutConfirm.Create(shipment, _ConfirmType, true);

            if (confirm == null)
            {
                throw new Exception("Cannot create Confirmation for " + shipment.GetDocumentNo());
            }
            //
            return("Open Shipment Confirmation Number generated: " + confirm.GetDocumentNo());
        }