protected override string DoIt()
        {
            ds = new DataSet();

            ds = DB.ExecuteDataset("SELECT C_Recurring_ID From C_Recurring Where IsActive='Y' AND AD_Client_ID=" + GetAD_Client_ID()
                                   + " AND TRUNC(DateNextRun)=" + GlobalVariable.TO_DATE(DateTime.Now, true));
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                for (Int32 i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Recurring = new MRecurring(GetCtx(), Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_Recurring_ID"]), Get_Trx());
                    dateDoc   = Recurring.GetDateNextRun();
                    if (dateDoc != null && Recurring.CalculateRuns())
                    {
                        //  throw new Exception("No Runs Left");
                        MRecurringRun run = new MRecurringRun(GetCtx(), Recurring);
                        String        msg = "@Created@ ";
                        // if (Recurring.GetDateNextRun() == DateTime.Now.Date || Recurring.GetDateNextRun() == null)
                        //{
                        //	Copy
                        if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Order))
                        {
                            MOrder from  = new MOrder(GetCtx(), Recurring.GetC_Order_ID(), Get_TrxName());
                            MOrder order = MOrder.CopyFrom(from, dateDoc,
                                                           from.GetC_DocType_ID(), false, false, Get_TrxName());
                            run.SetC_Order_ID(order.GetC_Order_ID());
                            msg += order.GetDocumentNo();
                        }
                        else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Invoice))
                        {
                            MInvoice from    = new MInvoice(GetCtx(), Recurring.GetC_Invoice_ID(), Get_TrxName());
                            MInvoice invoice = MInvoice.CopyFrom(from, dateDoc,
                                                                 from.GetC_DocType_ID(), false, Get_TrxName(), false);
                            run.SetC_Invoice_ID(invoice.GetC_Invoice_ID());
                            msg += invoice.GetDocumentNo();
                        }
                        else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Project))
                        {
                            MProject project = MProject.CopyFrom(GetCtx(), Recurring.GetC_Project_ID(), dateDoc, Get_TrxName());
                            run.SetC_Project_ID(project.GetC_Project_ID());
                            msg += project.GetValue();
                        }
                        else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournalBatch))
                        {
                            MJournalBatch journal = MJournalBatch.CopyFrom(GetCtx(), Recurring.GetGL_JournalBatch_ID(), dateDoc, Get_TrxName());
                            run.SetGL_JournalBatch_ID(journal.GetGL_JournalBatch_ID());
                            msg += journal.GetDocumentNo();
                        }
                        else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournal))
                        {
                            MJournal Journal = MJournal.CopyFrom(GetCtx(), Recurring.GetGL_Journal_ID(), dateDoc, Get_TrxName());
                            run.SetGL_Journal_ID(Journal.GetGL_Journal_ID());
                            msg += Journal.GetDocumentNo();
                        }
                        else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Payment))
                        {
                            MPayment from    = new MPayment(GetCtx(), Recurring.GetC_Payment_ID(), Get_TrxName());
                            MPayment payment = MPayment.CopyFrom(from, dateDoc,
                                                                 from.GetC_DocType_ID(), Get_TrxName());
                            run.SetC_Payment_ID(payment.GetC_Payment_ID());
                            msg += payment.GetDocumentNo();
                        }
                        //else
                        //  return "Invalid @RecurringType@ = " + Recurring.GetRecurringType();
                        if (run.Save(Get_TrxName()))
                        {
                            Recurring.SetDateLastRun(run.GetUpdated());
                            Recurring.SetRunsRemaining(Recurring.GetRunsRemaining() - 1);
                            SetDateNextRun();
                            Recurring.Save(Get_TrxName());
                        }
                        // }
                    }
                }
            }
            DisposeVariables();
            return("");
            //  throw new NotImplementedException();
        }
Esempio n. 2
0
        protected override string DoIt()
        {
            try
            {
                _log.Info("Start Imported Data completion for GulfOil : " + System.DateTime.Now);

                #region complete Order Record
                sql.Clear();
                sql.Append("SELECT * FROM C_Order WHERE IsActive = 'Y'   AND DocStatus NOT IN ('CO' , 'CL') ORDER BY dateacct");
                dsRecord = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                dataRow = dsRecord.Tables[0].Select("IsActive = 'Y' ", "dateacct");
                if (dataRow != null && dataRow.Length > 0)
                {
                    ViennaAdvantage.Model.MOrder order = null;

                    message.Clear();
                    notCompletedRecord.Clear();
                    message.Append("Records Of C_Order ");

                    for (int i = 0; i < dataRow.Length; i++)
                    {
                        try
                        {
                            order = new ViennaAdvantage.Model.MOrder(GetCtx(), Util.GetValueOfInt(dataRow[i]["C_Order_ID"]), Get_Trx());
                            order.CompleteIt();
                            if (order.GetDocAction() == "CL")
                            {
                                order.SetDocStatus("CO");
                                order.SetDocAction("CL");
                                if (!order.Save(Get_Trx()))
                                {
                                    notCompletedRecord.Append(order.GetDocumentNo() + " ,");
                                    Get_Trx().Rollback();
                                    ValueNamePair pp = VLogger.RetrieveError();
                                    _log.Info("Error found for saving C_Order Record ID = " + order.GetDocumentNo() +
                                              " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                }
                                else
                                {
                                    Get_Trx().Commit();
                                }
                            }
                            else
                            {
                                notCompletedRecord.Append(order.GetDocumentNo() + " ,");
                                Get_Trx().Rollback();
                                _log.Info("Order not completed for this Record ID = " + order.GetDocumentNo());
                            }
                        }
                        catch { }
                    }

                    if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                    {
                        errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                    }
                }
                #endregion

                #region complete Invoice Record
                sql.Clear();
                sql.Append("SELECT * FROM C_Invoice WHERE IsActive = 'Y'   AND DocStatus NOT IN ('CO' , 'CL') ORDER BY dateacct");
                dsRecord = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                dataRow = dsRecord.Tables[0].Select("IsActive = 'Y' ", "dateacct");
                if (dataRow != null && dataRow.Length > 0)
                {
                    ViennaAdvantage.Model.MInvoice invoice = null;

                    message.Clear();
                    notCompletedRecord.Clear();
                    message.Append("Records Of C_Invoice ");

                    for (int i = 0; i < dataRow.Length; i++)
                    {
                        try
                        {
                            invoice = new ViennaAdvantage.Model.MInvoice(GetCtx(), Util.GetValueOfInt(dataRow[i]["C_Invoice_ID"]), Get_Trx());
                            invoice.CompleteIt();
                            if (invoice.GetDocAction() == "CL")
                            {
                                invoice.SetDocStatus("CO");
                                invoice.SetDocAction("CL");
                                if (!invoice.Save(Get_Trx()))
                                {
                                    notCompletedRecord.Append(invoice.GetDocumentNo() + " ,");
                                    Get_Trx().Rollback();
                                    ValueNamePair pp = VLogger.RetrieveError();
                                    _log.Info("Error found for saving C_Invoice Record ID = " + invoice.GetDocumentNo() +
                                              " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                }
                                else
                                {
                                    Get_Trx().Commit();
                                }
                            }
                            else
                            {
                                notCompletedRecord.Append(invoice.GetDocumentNo() + " ,");
                                Get_Trx().Rollback();
                                _log.Info("Invoice not completed for this Record ID = " + invoice.GetDocumentNo() + " Message- " + invoice.GetProcessMsg());
                            }
                        }
                        catch { }
                    }

                    if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                    {
                        errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                    }
                }
                #endregion

                sql.Clear();
                sql.Append("SELECT * FROM M_InOut WHERE IsActive = 'Y'  AND DocStatus NOT IN ('CO' , 'CL' , 'RE' , 'VO') ORDER BY movementdate");
                dsInOut = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                sql.Clear();
                sql.Append("SELECT * FROM M_Inventory WHERE IsActive = 'Y' AND DocStatus NOT IN ('CO' , 'CL' , 'RE' , 'VO') ORDER BY movementdate");
                dsInventory = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                sql.Clear();
                sql.Append("SELECT * FROM M_Movement WHERE IsActive = 'Y' AND  DocStatus NOT IN ('CO' , 'CL' , 'RE' , 'VO') ORDER BY movementdate");
                dsMovement = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                sql.Clear();
                sql.Append("SELECT * FROM C_Payment WHERE IsActive = 'Y' AND  DocStatus NOT IN ('CO' , 'CL' , 'RE' , 'VO') ORDER BY dateacct");
                dsPayment = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                sql.Clear();
                sql.Append("SELECT * FROM C_Cash WHERE IsActive = 'Y' AND  DocStatus NOT IN ('CO' , 'CL' , 'RE' , 'VO') ORDER BY dateacct");
                dsCashJournal = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                sql.Clear();
                sql.Append("SELECT * FROM GL_Journal  WHERE IsActive = 'Y' AND  DocStatus NOT IN ('CO' , 'CL' , 'RE' , 'VO') ORDER BY dateacct");
                dsGLJournal = DB.ExecuteDataset(sql.ToString(), null, Get_Trx());

                // min date record from the transaction window
                minDateRecord = SerachMinDate();

                int diff = (DateTime.Now - minDateRecord.Value).Days;

                for (int days = 0; days <= diff; days++)
                {
                    if (days != 0)
                    {
                        minDateRecord = minDateRecord.Value.AddDays(1);
                    }

                    try
                    {
                        #region Physical Inventory
                        dataRow = dsInventory.Tables[0].Select("isinternaluse = 'N' AND  movementdate = '" + minDateRecord + "'", "M_Inventory_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            MInventory inventory = null;

                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of Physical Inventory ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    inventory = new MInventory(GetCtx(), Util.GetValueOfInt(dataRow[i]["M_Inventory_ID"]), Get_Trx());
                                    inventory.CompleteIt();
                                    if (inventory.GetDocAction() == "CL")
                                    {
                                        inventory.SetDocStatus("CO");
                                        inventory.SetDocAction("CL");
                                        if (!inventory.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(inventory.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving Physical Inventory Record ID = " + inventory.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(inventory.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Physical Inventory not completed for this Record ID = " + inventory.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }

                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region Internal use inventory
                        dataRow = dsInventory.Tables[0].Select("isinternaluse = 'Y' AND  movementdate = '" + minDateRecord + "'", "M_Inventory_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            MInventory inventory = null;

                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of Internal use inventory ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    inventory = new MInventory(GetCtx(), Util.GetValueOfInt(dataRow[i]["M_Inventory_ID"]), Get_Trx());
                                    inventory.CompleteIt();
                                    if (inventory.GetDocAction() == "CL")
                                    {
                                        inventory.SetDocStatus("CO");
                                        inventory.SetDocAction("CL");
                                        if (!inventory.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(inventory.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving Physical Inventory Record ID = " + inventory.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(inventory.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Physical Inventory not completed for this Record ID = " + inventory.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region complete material receipt
                        dataRow = dsInOut.Tables[0].Select("IsSoTrx = 'N' AND IsReturnTrx = 'N'  AND DocStatus NOT IN ('CO' , 'CL') AND  DateAcct = '" + minDateRecord + "'", "M_InOut_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of material receipt ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    inout = new ViennaAdvantage.Model.MInOut(GetCtx(), Util.GetValueOfInt(dataRow[i]["M_InOut_ID"]), Get_Trx());
                                    inout.CompleteIt();
                                    if (inout.GetDocAction() == "CL")
                                    {
                                        inout.SetDocStatus("CO");
                                        inout.SetDocAction("CL");
                                        if (!inout.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Order Record ID = " + inout.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Material Receipt not completed for this Record ID = " + inout.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region complete Movement Record
                        dataRow = dsMovement.Tables[0].Select("movementdate = '" + minDateRecord + "'", "M_Movement_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            ViennaAdvantage.Model.MMovement movement = null;

                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of M_Movement ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    movement = new ViennaAdvantage.Model.MMovement(GetCtx(), Util.GetValueOfInt(dataRow[i]["M_Movement_ID"]), Get_Trx());
                                    movement.CompleteIt();
                                    if (movement.GetDocAction() == "CL")
                                    {
                                        movement.SetDocStatus("CO");
                                        movement.SetDocAction("CL");
                                        if (!movement.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(movement.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Invoice Record ID = " + movement.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(movement.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Movement not completed for this Record ID = " + movement.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region complete shipment
                        dataRow = dsInOut.Tables[0].Select("IsSoTrx = 'Y' AND IsReturnTrx = 'N' AND  DateAcct = '" + minDateRecord + "'", "M_Inout_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of shipment ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    inout = new ViennaAdvantage.Model.MInOut(GetCtx(), Util.GetValueOfInt(dataRow[i]["M_InOut_ID"]), Get_Trx());
                                    inout.CompleteIt();
                                    if (inout.GetDocAction() == "CL")
                                    {
                                        inout.SetDocStatus("CO");
                                        inout.SetDocAction("CL");
                                        if (!inout.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Order Record ID = " + inout.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Shipment not completed for this Record ID = " + inout.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region complete Customer Return
                        dataRow = dsInOut.Tables[0].Select("IsSoTrx = 'Y' AND IsReturnTrx = 'Y'  AND  DateAcct = '" + minDateRecord + "'", "M_Inout_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of Customer Return ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    inout = new ViennaAdvantage.Model.MInOut(GetCtx(), Util.GetValueOfInt(dataRow[i]["M_InOut_ID"]), Get_Trx());
                                    inout.CompleteIt();
                                    if (inout.GetDocAction() == "CL")
                                    {
                                        inout.SetDocStatus("CO");
                                        inout.SetDocAction("CL");
                                        if (!inout.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Order Record ID = " + inout.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Customer return not completed for this Record ID = " + inout.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region complete Return to Vendor
                        dataRow = dsInOut.Tables[0].Select("IsSoTrx = 'N' AND IsReturnTrx = 'Y'  AND  DateAcct = '" + minDateRecord + "'", "M_InOut_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of Return to Vendor ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    inout = new ViennaAdvantage.Model.MInOut(GetCtx(), Util.GetValueOfInt(dataRow[i]["M_InOut_ID"]), Get_Trx());
                                    inout.CompleteIt();
                                    if (inout.GetDocAction() == "CL")
                                    {
                                        inout.SetDocStatus("CO");
                                        inout.SetDocAction("CL");
                                        if (!inout.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Order Record ID = " + inout.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(inout.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Return to Vendor not completed for this Record ID = " + inout.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region Complete Payment
                        dataRow = dsPayment.Tables[0].Select("DateAcct = '" + minDateRecord + "'", "C_Payment_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of Payment ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    payment = new MPayment(GetCtx(), Util.GetValueOfInt(dataRow[i]["C_Payment_ID"]), Get_Trx());
                                    payment.CompleteIt();
                                    if (payment.GetDocAction() == "CL")
                                    {
                                        payment.SetDocStatus("CO");
                                        payment.SetDocAction("CL");
                                        if (!payment.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(payment.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Payment Record ID = " + payment.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(payment.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Payment not completed for this Record ID = " + payment.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region Complete Cash Journal
                        dataRow = dsCashJournal.Tables[0].Select("DateAcct = '" + minDateRecord + "'", "C_Cash_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of Cash Journal ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    cash = new MCash(GetCtx(), Util.GetValueOfInt(dataRow[i]["C_Cash_ID"]), Get_Trx());
                                    cash.CompleteIt();
                                    if (cash.GetDocAction() == "CL")
                                    {
                                        cash.SetDocStatus("CO");
                                        cash.SetDocAction("CL");
                                        if (!cash.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(cash.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Cash Record ID = " + cash.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(cash.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Cash Journal not completed for this Record ID = " + cash.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion

                        #region Complete GL Journal
                        dataRow = dsGLJournal.Tables[0].Select("DateAcct = '" + minDateRecord + "'", "GL_Journal_ID");
                        if (dataRow != null && dataRow.Length > 0)
                        {
                            message.Clear();
                            notCompletedRecord.Clear();
                            message.Append("Records Of GL Journal ");

                            for (int i = 0; i < dataRow.Length; i++)
                            {
                                try
                                {
                                    journal = new MJournal(GetCtx(), Util.GetValueOfInt(dataRow[i]["GL_Journal_ID"]), Get_Trx());
                                    journal.CompleteIt();
                                    if (journal.GetDocAction() == "CL")
                                    {
                                        journal.SetDocStatus("CO");
                                        journal.SetDocAction("CL");
                                        if (!journal.Save(Get_Trx()))
                                        {
                                            notCompletedRecord.Append(journal.GetDocumentNo() + " ,");
                                            Get_Trx().Rollback();
                                            ValueNamePair pp = VLogger.RetrieveError();
                                            _log.Info("Error found for saving C_Cash Record ID = " + journal.GetDocumentNo() +
                                                      " Error Name is " + pp.GetName() + " And Error Type is " + pp.GetType());
                                        }
                                        else
                                        {
                                            Get_Trx().Commit();
                                        }
                                    }
                                    else
                                    {
                                        notCompletedRecord.Append(journal.GetDocumentNo() + " ,");
                                        Get_Trx().Rollback();
                                        _log.Info("Cash Journal not completed for this Record ID = " + journal.GetDocumentNo());
                                    }
                                }
                                catch { }
                            }
                            if (!string.IsNullOrEmpty(notCompletedRecord.ToString()))
                            {
                                errorMessage.Append(message.ToString() + " : " + notCompletedRecord.ToString());
                            }
                        }
                        #endregion
                    }
                    catch { }
                }
                _log.Info(" End Imported Data completion for GulfOil : " + System.DateTime.Now);
            }
            catch (Exception ex)
            {
                _log.Info("Error Occured during completion of record by using  ImportedDataCompletion Process - " + ex.ToString());
                return(Msg.GetMsg(GetCtx(), "NotCompleted"));
            }
            if (!string.IsNullOrEmpty(errorMessage.ToString()))
            {
                return("Not Completed Record : " + errorMessage.ToString());
            }
            else
            {
                return(Msg.GetMsg(GetCtx(), "SucessfullyCompleted"));
            }
        }
        /// <summary>
        /// Process
        /// </summary>
        /// <returns></returns>
        protected override string DoIt()
        {
            try
            {
                MRevenueRecognitionPlan revenueRecognitionPlan = null;
                MInvoiceLine            invoiceLine            = null;
                MInvoice            invoice             = null;
                MRevenueRecognition mRevenueRecognition = new MRevenueRecognition(GetCtx(), _RevenueRecognition_ID, Get_Trx());

                // Count of  previous date's RevenueRecognition_Run whose journal is not created
                string sql = "SELECT COUNT(C_RevenueRecognition_Run_ID) FROM C_RevenueRecognition_Run run " +
                             "INNER JOIN C_RevenueRecognition_Plan pl ON pl.C_RevenueRecognition_Plan_ID = run.C_RevenueRecognition_Plan_ID WHERE ";
                if (C_InvoiceLine_ID > 0)
                {
                    sql += "pl.C_invoiceLine_ID = " + C_InvoiceLine_ID + " AND ";
                }

                sql += "pl.C_RevenueRecognition_ID = " + _RevenueRecognition_ID + " AND NVL(GL_Journal_ID, 0)<=0 AND run.RECOGNITIONDATE < " + GlobalVariable.TO_DATE(DateTime.Now, true);

                if (Util.GetValueOfInt(DB.ExecuteScalar(sql)) == 0)
                {
                    MRevenueRecognitionPlan[] revenueRecognitionPlans = MRevenueRecognitionPlan.GetRecognitionPlans(mRevenueRecognition, C_InvoiceLine_ID, _orgId);
                    journal_ID = new int[revenueRecognitionPlans.Length];

                    if (ReversalType == "P")
                    {
                        for (int i = 0; i < revenueRecognitionPlans.Length; i++)
                        {
                            revenueRecognitionPlan = revenueRecognitionPlans[i];
                            invoiceLine            = new MInvoiceLine(GetCtx(), revenueRecognitionPlan.GetC_InvoiceLine_ID(), Get_Trx());
                            invoice = new MInvoice(GetCtx(), invoiceLine.GetC_Invoice_ID(), Get_Trx());

                            //get Sum of Amount Whose journal is not yet created
                            sql = "SELECT SUM(run.Recognizedamt) AS TotalRecognizedAmt FROM C_RevenueRecognition_Run run WHERE " +
                                  "C_RevenueRecognition_Plan_ID = " + revenueRecognitionPlan.GetC_RevenueRecognition_Plan_ID() + " AND NVL(GL_Journal_ID,0) <= 0";

                            totalAmt = Util.GetValueOfInt(DB.ExecuteScalar(sql));
                            if (totalAmt != 0)
                            {
                                //if totalAmount is not 0 then only create Journal

                                if (revenueRecognitionPlan.GetC_AcctSchema_ID() != _AcctSchema_ID || revenueRecognitionPlan.GetC_Currency_ID() != _Currency_ID)
                                {
                                    if (journal != null)
                                    {
                                        if (DocNo == null)
                                        {
                                            DocNo = journal.GetDocumentNo();
                                        }
                                        else
                                        {
                                            DocNo += "," + journal.GetDocumentNo();
                                        }
                                        journal_ID[i - 1] = journal.GetGL_Journal_ID();
                                    }
                                    journal = new MJournal(GetCtx(), 0, Get_Trx());

                                    journal.SetC_DocType_ID(_DocType);
                                    journal = CreateJournalHDR(revenueRecognitionPlan);
                                    if (journal.Save(Get_TrxName()))
                                    {
                                        _AcctSchema_ID = journal.GetC_AcctSchema_ID();
                                        _Currency_ID   = journal.GetC_Currency_ID();
                                        lineno         = Util.GetValueOfInt(DB.ExecuteScalar("SELECT NVL(MAX(Line), 0)+10  AS DefaultValue FROM GL_JournalLine WHERE GL_Journal_ID=" + journal.GetGL_Journal_ID(), null, invoice.Get_Trx()));
                                    }
                                    else
                                    {
                                        pp = VLogger.RetrieveError();
                                        if (pp != null)
                                        {
                                            errorMsg = pp.GetName();
                                            if (errorMsg == "")
                                            {
                                                errorMsg = pp.GetValue();
                                            }
                                        }
                                        if (errorMsg == "")
                                        {
                                            errorMsg = Msg.GetMsg(GetCtx(), "GLJournalNotCreated");
                                        }
                                        Get_TrxName().Rollback();
                                        return(errorMsg);
                                    }
                                }
                                revenueRecognitionPlan.SetRecognizedAmt(totalAmt + revenueRecognitionPlan.GetRecognizedAmt());
                                if (!revenueRecognitionPlan.Save())
                                {
                                    pp = VLogger.RetrieveError();
                                    if (pp != null)
                                    {
                                        errorMsg = pp.GetName();
                                        if (errorMsg == "")
                                        {
                                            errorMsg = pp.GetValue();
                                        }
                                    }
                                    if (errorMsg == "")
                                    {
                                        errorMsg = Msg.GetMsg(GetCtx(), "GLJournalNotCreated");
                                    }
                                    Get_TrxName().Rollback();
                                    return(errorMsg);
                                }

                                for (int k = 0; k < 2; k++)
                                {
                                    journalLine = new MJournalLine(journal);

                                    journalLine = GenerateJounalLine(journal, invoice, invoiceLine, revenueRecognitionPlan, totalAmt, mRevenueRecognition.GetRecognitionType(), k);
                                    if (journalLine.Save(Get_TrxName()))
                                    {
                                        lineno += 10;
                                    }
                                    else
                                    {
                                        pp = VLogger.RetrieveError();
                                        if (pp != null)
                                        {
                                            errorMsg = pp.GetName();
                                            if (errorMsg == "")
                                            {
                                                errorMsg = pp.GetValue();
                                            }
                                        }
                                        if (errorMsg == "")
                                        {
                                            errorMsg = Msg.GetMsg(GetCtx(), "GLJournalNotCreated");
                                        }
                                        Get_TrxName().Rollback();
                                        return(errorMsg);
                                    }
                                }
                                sql = "UPDATE C_RevenueRecognition_Run  set Gl_Journal_ID= " + journal.GetGL_Journal_ID() +
                                      " WHERE C_RevenueRecognition_Plan_ID= " + revenueRecognitionPlan.GetC_RevenueRecognition_Plan_ID() + "AND NVL(Gl_Journal_ID,0)=0";
                                int count = DB.ExecuteQuery(sql, null, Get_Trx());
                                log.Log(Level.INFO, (Msg.GetMsg(GetCtx(), "RevenueRecognitionRunUpdated") + count));
                            }
                        }
                        if (journal != null)
                        {
                            if (DocNo == null)
                            {
                                DocNo = journal.GetDocumentNo();
                            }
                            else
                            {
                                DocNo += "," + journal.GetDocumentNo();
                            }
                            journal_ID[journal_ID.Length - 1] = journal.GetGL_Journal_ID();
                        }
                    }
                    #region Existing Reversal Type
                    //else if (ReversalType == "E")
                    //{
                    //    for (int i = 0; i < revenueRecognitionPlans.Length; i++)
                    //    {
                    //        MRevenueRecognitionPlan revenueRecognitionPlan = revenueRecognitionPlans[i];
                    //        MInvoiceLine invoiceLine = new MInvoiceLine(GetCtx(), revenueRecognitionPlan.GetC_InvoiceLine_ID(), Get_Trx());
                    //        MInvoice invoice = new MInvoice(GetCtx(), invoiceLine.GetC_Invoice_ID(), Get_Trx());
                    //        sql = "Select Distinct round(SUM(recognizedamt),5) as RecognizedAmt from C_RevenueRecognition_Run Where C_RevenueRecognition_Plan_ID = " + revenueRecognitionPlan.GetC_RevenueRecognition_Plan_ID() + " And NVL(GL_Journal_ID,0) > 0 ";
                    //        DataSet ds = new DataSet();
                    //        ds = DB.ExecuteDataset(sql);
                    //        if (ds != null && ds.Tables[0].Rows.Count > 0)
                    //        {
                    //            decimal Amt = Util.GetValueOfDecimal(ds.Tables[0].Rows[i]["RecognizedAmt"]);
                    //            string sql1 = "Select GL_Journal_ID from C_RevenueRecognition_Run Where C_RevenueRecognition_Plan_ID = " + revenueRecognitionPlan.GetC_RevenueRecognition_Plan_ID() + " And NVL(GL_Journal_ID,0) > 0 AND RowNum=1";
                    //            int GL_Journal_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql1));
                    //            MJournal journal = new MJournal(GetCtx(), GL_Journal_ID, Get_TrxName());
                    //            log.Info(ToString());
                    //            //	Journal
                    //            MJournal reverse = new MJournal(journal);
                    //            reverse.SetDateDoc(DateTime.Now);
                    //            reverse.SetC_Period_ID(journal.GetC_Period_ID());
                    //            int Period_ID = MPeriod.GetC_Period_ID(GetCtx(), DateTime.Now);
                    //            reverse.SetDateAcct(DateTime.Now);
                    //            if (reverse.Save())
                    //            {
                    //                MJournalLine[] journalLines = journal.GetLines(false);
                    //                if (journalLines.Length > 0)
                    //                {
                    //                    for (int j = 0; j < journalLines.Length; j++)
                    //                    {
                    //                        MJournalLine journalLine = journalLines[j];
                    //                        MJournalLine newjournalLine = new MJournalLine(GetCtx(), 0, Get_TrxName());
                    //                        PO.CopyValues(journalLine, newjournalLine, GetAD_Client_ID(), GetAD_Org_ID());
                    //                        newjournalLine.SetGL_Journal_ID(reverse.GetGL_Journal_ID());

                    //                        newjournalLine.SetDateAcct(DateTime.Now);
                    //                        //	Amounts
                    //                        if (newjournalLine.GetAmtAcctCr() > 0)
                    //                        {
                    //                            newjournalLine.SetAmtAcctDr(0);
                    //                            newjournalLine.SetAmtSourceDr(0);
                    //                            newjournalLine.SetAmtSourceCr(Decimal.Negate(Amt));
                    //                            newjournalLine.SetAmtAcctCr(Decimal.Negate(Amt));
                    //                        }
                    //                        else
                    //                        {
                    //                            newjournalLine.SetAmtAcctDr(Decimal.Negate(Amt));
                    //                            newjournalLine.SetAmtSourceDr(Decimal.Negate(Amt));
                    //                            newjournalLine.SetAmtSourceCr(0);
                    //                            newjournalLine.SetAmtAcctCr(0);
                    //                        }

                    //                        newjournalLine.SetIsGenerated(true);
                    //                        newjournalLine.SetProcessed(false);
                    //                        newjournalLine.Save();
                    //                        if (j == 1)
                    //                        {
                    //                            break;
                    //                        }
                    //                    }
                    //                }
                    //            }
                    //            if (reverse != null && reverse.GetDocStatus() != "CO")
                    //            {
                    //                reverse.CompleteIt();
                    //                reverse.SetProcessed(true);
                    //                reverse.SetDocStatus("CO");
                    //                reverse.SetDocAction("CL");
                    //                reverse.Save(Get_TrxName());
                    //                if (DocNo == null)
                    //                {
                    //                    DocNo = reverse.GetDocumentNo();
                    //                }
                    //                int count = Util.GetValueOfInt(DB.ExecuteQuery("Update C_RevenueRecognition_Run Set GL_Journal_ID=null WHere C_RevenueRecognition_Plan_ID=" + revenueRecognitionPlan.GetC_RevenueRecognition_Plan_ID()));
                    //                int count1 = Util.GetValueOfInt(DB.ExecuteQuery("Update C_RevenueRecognition_Plan Set RecognizedAmt=RecognizedAmt - " + Amt + " WHere C_RevenueRecognition_Plan_ID=" + revenueRecognitionPlan.GetC_RevenueRecognition_Plan_ID()));
                    //            }
                    //        }
                    //    }
                    //}
                    #endregion

                    Get_TrxName().Commit();
                    if (journal_ID != null)
                    {
                        for (int i = 0; i < journal_ID.Length; i++)
                        {
                            if (journal_ID[i] > 0)
                            {
                                string result = RevenueRun.CompleteOrReverse(GetCtx(), journal_ID[i], 169, "CO");
                                if (!String.IsNullOrEmpty(result))
                                {
                                    journalIDS += ", " + journal_ID[i] + " " + result;
                                }
                            }
                        }
                    }

                    if (DocNo == null)
                    {
                        return(Msg.GetMsg(GetCtx(), "FoundNoRevenueRecognitionPlan"));
                    }
                }
                else
                {
                    return(Msg.GetMsg(GetCtx(), "NotRecoganized"));
                }
            }
            catch (Exception ex)
            {
                log.Log(Level.SEVERE, Msg.GetMsg(GetCtx(), "GLJournalnotallocateddueto") + ex.Message);
                Get_TrxName().Rollback();
                return(ex.Message);
            }

            if (!String.IsNullOrEmpty(journalIDS))
            {
                return(Msg.GetMsg(GetCtx(), "GLJournalCreated") + DocNo + ", " + Msg.GetMsg(GetCtx(), "GLJournalNotCompleted") + journalIDS);
            }
            else
            {
                return(Msg.GetMsg(GetCtx(), "GLJournalCreated") + DocNo);
            }
        }
        /// <summary>
        /// Create GL Journal
        /// </summary>
        /// <param name="mRevenueRecognition">Revenue Recognition</param>
        /// <returns>Message</returns>
        public string CreateJournals(MRevenueRecognition mRevenueRecognition)
        {
            try
            {
                MRevenueRecognitionRun[] mRevenueRecognitionRuns = null;

                MRevenueRecognitionPlan revenueRecognitionPlan = null;
                MInvoiceLine            invoiceLine            = null;
                MInvoice invoice = null;


                mRevenueRecognitionRuns = MRevenueRecognitionRun.GetRecognitionRuns(mRevenueRecognition, _RecognitionDate, _orgId, false);
                journal_ID = new int[mRevenueRecognitionRuns.Length];
                if (mRevenueRecognitionRuns.Length > 0)
                {
                    for (int j = 0; j < mRevenueRecognitionRuns.Length; j++)
                    {
                        MRevenueRecognitionRun revenueRecognitionRun = mRevenueRecognitionRuns[j];
                        revenueRecognitionPlan = new MRevenueRecognitionPlan(GetCtx(), revenueRecognitionRun.GetC_RevenueRecognition_Plan_ID(), Get_TrxName());
                        invoiceLine            = new MInvoiceLine(GetCtx(), revenueRecognitionPlan.GetC_InvoiceLine_ID(), Get_TrxName());
                        invoice = new MInvoice(GetCtx(), invoiceLine.GetC_Invoice_ID(), Get_TrxName());

                        if (revenueRecognitionPlan.GetC_AcctSchema_ID() != _AcctSchema_ID || revenueRecognitionPlan.GetC_Currency_ID() != _Currency_ID || revenueRecognitionRun.GetRecognitionDate() != _RecognizeDate)
                        {
                            if (journal != null)
                            {
                                if (DocNo == null)
                                {
                                    DocNo = journal.GetDocumentNo();
                                }
                                else
                                {
                                    DocNo += ", " + journal.GetDocumentNo();
                                }
                                journal_ID[j - 1] = journal.GetGL_Journal_ID();
                            }
                            journal = new MJournal(GetCtx(), 0, Get_TrxName());

                            journal.SetC_DocType_ID(_DocType);
                            journal = CreateJournalHDR(revenueRecognitionPlan, revenueRecognitionRun, mRevenueRecognition.GetRecognitionFrequency());


                            if (journal.Save())
                            {
                                _AcctSchema_ID = journal.GetC_AcctSchema_ID();
                                _Currency_ID   = journal.GetC_Currency_ID();
                                _RecognizeDate = revenueRecognitionRun.GetRecognitionDate();
                                lineno         = Util.GetValueOfInt(DB.ExecuteScalar("SELECT NVL(MAX(Line), 0)+10  AS DefaultValue FROM GL_JournalLine WHERE GL_Journal_ID=" + journal.GetGL_Journal_ID(), null, invoice.Get_Trx()));
                            }
                            else
                            {
                                pp = VLogger.RetrieveError();
                                if (pp != null)
                                {
                                    errorMsg = pp.GetName();
                                    if (errorMsg == "")
                                    {
                                        errorMsg = pp.GetValue();
                                    }
                                }
                                if (errorMsg == "")
                                {
                                    errorMsg = Msg.GetMsg(GetCtx(), "GLJournalNotCreated");
                                }
                                Get_TrxName().Rollback();
                                return(errorMsg);
                            }
                        }
                        for (int k = 0; k < 2; k++)
                        {
                            journalLine = new MJournalLine(journal);
                            journalLine = GenerateJounalLine(journal, invoice, invoiceLine, revenueRecognitionPlan, revenueRecognitionRun, mRevenueRecognition.GetRecognitionType(), k);
                            if (journalLine.Save())
                            {
                                revenueRecognitionRun.SetGL_Journal_ID(journal.GetGL_Journal_ID());
                                revenueRecognitionRun.Save();
                                lineno += 10;
                            }
                            else
                            {
                                pp = VLogger.RetrieveError();
                                if (pp != null)
                                {
                                    errorMsg = pp.GetName();
                                    if (errorMsg == "")
                                    {
                                        errorMsg = pp.GetValue();
                                    }
                                }
                                if (errorMsg == "")
                                {
                                    errorMsg = Msg.GetMsg(GetCtx(), "GLJournalNotCreated");
                                }
                                Get_TrxName().Rollback();
                                return(errorMsg);
                            }
                        }
                        revenueRecognitionPlan.SetRecognizedAmt(revenueRecognitionRun.GetRecognizedAmt() + revenueRecognitionPlan.GetRecognizedAmt());
                        if (!revenueRecognitionPlan.Save())
                        {
                            pp = VLogger.RetrieveError();
                            if (pp != null)
                            {
                                errorMsg = pp.GetName();
                                if (errorMsg == "")
                                {
                                    errorMsg = pp.GetValue();
                                }
                            }
                            if (errorMsg == "")
                            {
                                errorMsg = Msg.GetMsg(GetCtx(), "GLJournalNotCreated");
                            }
                            Get_TrxName().Rollback();
                            return(errorMsg);
                        }
                    }
                    if (journal != null)
                    {
                        if (DocNo == null)
                        {
                            DocNo = journal.GetDocumentNo();
                        }
                        else
                        {
                            DocNo += ", " + journal.GetDocumentNo();
                        }

                        journal_ID[journal_ID.Length - 1] = journal.GetGL_Journal_ID();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log(Level.SEVERE, Msg.GetMsg(GetCtx(), "GLJournalnotallocateddueto") + ex.Message);
                Get_TrxName().Rollback();
                return(ex.Message);
            }
            if (DocNo == null)
            {
                return(Msg.GetMsg(GetCtx(), "FoundNoRevenueRecognitionPlan"));
            }

            Get_TrxName().Commit();
            if (journal_ID != null)
            {
                for (int i = 0; i < journal_ID.Length; i++)
                {
                    if (journal_ID[i] > 0)
                    {
                        string result = CompleteOrReverse(GetCtx(), journal_ID[i], 169, "CO");
                        if (!String.IsNullOrEmpty(result))
                        {
                            journalIDS += ", " + journal_ID[i] + " " + result;
                        }
                    }
                }
            }
            if (!String.IsNullOrEmpty(journalIDS))
            {
                return(Msg.GetMsg(GetCtx(), "GLJournalCreated") + DocNo + " " + Msg.GetMsg(GetCtx(), "GLJournalNotCompleted") + journalIDS);
            }
            else
            {
                return(Msg.GetMsg(GetCtx(), "GLJournalCreated") + DocNo);
            }
        }