示例#1
0
        public virtual bool VoidIt()
        {
            log.Info(ToString());
            bool res = true;

            if (DOCSTATUS_Closed.Equals(GetDocStatus()) ||
                DOCSTATUS_Reversed.Equals(GetDocStatus()) ||
                DOCSTATUS_Voided.Equals(GetDocStatus()))
            {
                _processMsg = "Document Closed: " + GetDocStatus();
                return(false);
            }

            //Processed- Documnent canot be voided if payment reference exist
            if (DOCSTATUS_Completed.Equals(GetDocStatus()))
            {
                if (IsVA027_PaymentGenerated())
                {
                    _processMsg = Msg.GetMsg(GetCtx(), "VA027_PaymentAvailable");
                    return(false);
                }
            }


            //	Not Processed
            if (DOCSTATUS_Drafted.Equals(GetDocStatus()) ||
                DOCSTATUS_Invalid.Equals(GetDocStatus()) ||
                DOCSTATUS_InProgress.Equals(GetDocStatus()) ||
                DOCSTATUS_Approved.Equals(GetDocStatus()) ||
                DOCSTATUS_NotApproved.Equals(GetDocStatus()))
            {
                AddDescription(Msg.GetMsg(GetCtx(), "Voided") + " (" + GetVA027_PayAmt() + ")");
                SetVA027_PayAmt(Env.ZERO);
                SetVA027_DiscountAmt(Env.ZERO);
                SetVA027_WriteoffAmt(Env.ZERO);
            }
            //*****************code

            //***********************end here

            else
            {
                res = ReverseCorrectIt();
            }
            if (res == true)
            {
                SetProcessed(true);
                SetDocAction(DOCACTION_None);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        }       //	completeIt

        /// <summary>
        ///	Void Document.
        /// </summary>
        /// <returns>true if success </returns>
        public Boolean VoidIt()
        {
            log.Info(ToString());
            if (DOCSTATUS_Drafted.Equals(GetDocStatus()) ||
                DOCSTATUS_Invalid.Equals(GetDocStatus()))
            {
                SetProcessed(true);
                SetDocAction(DOCACTION_None);
                return(true);
            }
            return(false);
        }       //	voidIt
        }       //	voidIt

        /// <summary>
        /// Close Document.
        /// </summary>
        /// <returns> true if success </returns>
        public Boolean CloseIt()
        {
            log.Info("closeIt - " + ToString());
            MJournal[] journals = GetJournals(true);
            for (int i = 0; i < journals.Length; i++)
            {
                MJournal journal = journals[i];
                if (!journal.IsActive() && !journal.IsProcessed())
                {
                    journal.SetProcessed(true);
                    journal.SetDocStatus(DOCSTATUS_Voided);
                    journal.SetDocAction(DOCACTION_None);
                    journal.Save();
                    continue;
                }
                if (DOCSTATUS_Drafted.Equals(journal.GetDocStatus()) ||
                    DOCSTATUS_InProgress.Equals(journal.GetDocStatus()) ||
                    DOCSTATUS_Invalid.Equals(journal.GetDocStatus()))
                {
                    m_processMsg = "Journal not Completed: " + journal.GetSummary();
                    return(false);
                }

                //	Close if not closed
                if (DOCSTATUS_Closed.Equals(journal.GetDocStatus()) ||
                    DOCSTATUS_Voided.Equals(journal.GetDocStatus()) ||
                    DOCSTATUS_Reversed.Equals(journal.GetDocStatus()))
                {
                    ;
                }
                else
                {
                    if (!journal.CloseIt())
                    {
                        m_processMsg = "Cannot close: " + journal.GetSummary();
                        return(false);
                    }
                    journal.Save();
                }
            }
            return(true);
        }       //	closeIt
示例#4
0
        public virtual bool VoidIt()
        {
            log.Info(ToString());

            if (DOCSTATUS_Closed.Equals(GetDocStatus()) ||
                DOCSTATUS_Reversed.Equals(GetDocStatus()) ||
                DOCSTATUS_Voided.Equals(GetDocStatus()))
            {
                _processMsg = "Document Closed: " + GetDocStatus();
                return(false);
            }

            //	Not Processed
            if (DOCSTATUS_Drafted.Equals(GetDocStatus()) ||
                DOCSTATUS_Invalid.Equals(GetDocStatus()) ||
                DOCSTATUS_InProgress.Equals(GetDocStatus()) ||
                DOCSTATUS_Approved.Equals(GetDocStatus()) ||
                DOCSTATUS_NotApproved.Equals(GetDocStatus()))
            {
                //	Set lines to 0
                MCostAllocationLine[] lines = GetLines(false);
                for (int i = 0; i < lines.Length; i++)
                {
                    MCostAllocationLine line = lines[i];
                    Decimal             old  = line.GetAmount();
                    if (old != 0)
                    {
                        line.SetAmount(Env.ZERO);
                        line.Save(Get_TrxName());
                    }
                }
            }
            else
            {
                return(ReverseCorrectIt());
            }

            SetIsProcessed(true);
            SetDocAction(DOCACTION_None);
            return(true);
        }
示例#5
0
        /// <summary>
        /// Void Document.
        /// </summary>
        /// <returns>false</returns>
        public bool VoidIt()
        {
            log.Info(ToString());
            if (DOCSTATUS_Closed.Equals(GetDocStatus()) ||
                DOCSTATUS_Reversed.Equals(GetDocStatus()) ||
                DOCSTATUS_Voided.Equals(GetDocStatus()))
            {
                m_processMsg = "Document Closed: " + GetDocStatus();
                SetDocAction(DOCACTION_None);
                return(false);
            }

            //	Not Processed
            if (DOCSTATUS_Drafted.Equals(GetDocStatus()) ||
                DOCSTATUS_Invalid.Equals(GetDocStatus()) ||
                DOCSTATUS_InProgress.Equals(GetDocStatus()) ||
                DOCSTATUS_Approved.Equals(GetDocStatus()) ||
                DOCSTATUS_NotApproved.Equals(GetDocStatus()))
            {
                ;
            }
            //	Std Period open?
            else
            {
                if (!MPeriod.IsOpen(GetCtx(), GetStatementDate(), MDocBaseType.DOCBASETYPE_BANKSTATEMENT, GetAD_Org_ID()))
                {
                    m_processMsg = "@PeriodClosed@";
                    return(false);
                }

                // is Non Business Day?
                // JID_1205: At the trx, need to check any non business day in that org. if not fund then check * org.
                if (MNonBusinessDay.IsNonBusinessDay(GetCtx(), GetStatementDate(), GetAD_Org_ID()))
                {
                    m_processMsg = Common.Common.NONBUSINESSDAY;
                    return(false);
                }


                if (MFactAcct.Delete(Table_ID, GetC_BankStatement_ID(), Get_TrxName()) < 0)
                {
                    return(false);       //	could not delete
                }
            }

            //	Set lines to 0
            Decimal transactionAmt = 0; //To update transaction amount in unMatched Balance in case of void

            MBankStatementLine[] lines = GetLines(true);
            for (int i = 0; i < lines.Length; i++)
            {
                MBankStatementLine line = lines[i];
                transactionAmt += line.GetTrxAmt();
                if (line.GetStmtAmt().CompareTo(Env.ZERO) != 0)
                {
                    String description = Msg.Translate(GetCtx(), "Voided") + " ("
                                         + Msg.Translate(GetCtx(), "StmtAmt") + "=" + line.GetStmtAmt();
                    if (line.GetTrxAmt().CompareTo(Env.ZERO) != 0)
                    {
                        description += ", " + Msg.Translate(GetCtx(), "TrxAmt") + "=" + line.GetTrxAmt();
                    }
                    if (line.GetChargeAmt().CompareTo(Env.ZERO) != 0)
                    {
                        description += ", " + Msg.Translate(GetCtx(), "ChargeAmt") + "=" + line.GetChargeAmt();
                    }
                    if (line.GetInterestAmt().CompareTo(Env.ZERO) != 0)
                    {
                        description += ", " + Msg.Translate(GetCtx(), "InterestAmt") + "=" + line.GetInterestAmt();
                    }
                    description += ")";
                    line.AddDescription(description);
                    line.SetStmtAmt(Env.ZERO);
                    line.SetTrxAmt(Env.ZERO);
                    line.SetChargeAmt(Env.ZERO);
                    line.SetInterestAmt(Env.ZERO);
                    line.Save(Get_TrxName());
                    if (line.GetC_Payment_ID() != 0)
                    {
                        MPayment payment = new MPayment(GetCtx(), line.GetC_Payment_ID(), Get_TrxName());
                        payment.SetIsReconciled(false);
                        payment.Save(Get_TrxName());
                    }
                }
            }
            AddDescription(Msg.Translate(GetCtx(), "Voided"));
            Decimal voidedDifference = GetStatementDifference();

            SetStatementDifference(Env.ZERO);

            //VA009----------------------------------Anuj----------------------
            //int _CountVA009 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA009_'  AND IsActive = 'Y'"));
            if (Env.IsModuleInstalled("VA009_"))
            {
                MBankStatementLine[] STlines = GetLines(false);
                string status = "R"; // Received
                for (int i = 0; i < STlines.Length; i++)
                {
                    MBankStatementLine line = STlines[i];
                    if (line.GetC_Payment_ID() != 0)
                    {
                        MPayment payment        = new MPayment(GetCtx(), line.GetC_Payment_ID(), Get_TrxName());
                        string   _paymentMethod = Util.GetValueOfString(DB.ExecuteScalar("Select va009_paymentbaseType from va009_paymentmethod where va009_paymentmethod_id=" + payment.GetVA009_PaymentMethod_ID() + " And IsActive = 'Y' AND AD_Client_ID = " + GetAD_Client_ID()));
                        if (_paymentMethod == "S") // Check
                        {
                            status = "B";          // Bounced
                        }
                        else
                        {
                            status = "C"; // Rejected
                        }
                        payment.SetVA009_ExecutionStatus(status);
                        payment.Save(Get_TrxName());

                        //MInvoicePaySchedule inp = new MInvoicePaySchedule(GetCtx(), payment.GetC_InvoicePaySchedule_ID(), Get_TrxName());
                        //inp.SetVA009_ExecutionStatus(status);
                        //inp.Save(Get_TrxName());

                        // update execution status as set on Payment on Invoice Schedule -  for those payment which are completed or closed
                        if (payment.GetDocStatus() == DOCSTATUS_Closed || payment.GetDocStatus() == DOCSTATUS_Completed)
                        {
                            int no = Util.GetValueOfInt(DB.ExecuteQuery(@"UPDATE C_InvoicePaySchedule
                                                                          SET VA009_ExecutionStatus = '" + payment.GetVA009_ExecutionStatus() + @"'  
                                                                          WHERE C_Payment_ID = " + line.GetC_Payment_ID(), null, Get_Trx()));
                        }
                    }
                }
            }
            //END----------------------------------Anuj----------------------

            //	Update Bank Account
            MBankAccount ba = MBankAccount.Get(GetCtx(), GetC_BankAccount_ID());

            ba.SetCurrentBalance(Decimal.Subtract(ba.GetCurrentBalance(), voidedDifference));
            ba.SetUnMatchedBalance(Decimal.Add(ba.GetUnMatchedBalance(), transactionAmt));   //Arpit
            ba.Save(Get_TrxName());
            SetProcessed(true);
            SetDocAction(DOCACTION_None);
            return(true);
        }
示例#6
0
        /// <summary>
        /// Void Document.
        /// </summary>
        /// <returns>false</returns>
        public bool VoidIt()
        {
            log.Info(ToString());
            if (DOCSTATUS_Closed.Equals(GetDocStatus()) ||
                DOCSTATUS_Reversed.Equals(GetDocStatus()) ||
                DOCSTATUS_Voided.Equals(GetDocStatus()))
            {
                m_processMsg = "Document Closed: " + GetDocStatus();
                SetDocAction(DOCACTION_None);
                return(false);
            }

            //	Not Processed
            if (DOCSTATUS_Drafted.Equals(GetDocStatus()) ||
                DOCSTATUS_Invalid.Equals(GetDocStatus()) ||
                DOCSTATUS_InProgress.Equals(GetDocStatus()) ||
                DOCSTATUS_Approved.Equals(GetDocStatus()) ||
                DOCSTATUS_NotApproved.Equals(GetDocStatus()))
            {
                ;
            }
            //	Std Period open?
            else
            {
                if (!MPeriod.IsOpen(GetCtx(), GetStatementDate(), MDocBaseType.DOCBASETYPE_BANKSTATEMENT))
                {
                    m_processMsg = "@PeriodClosed@";
                    return(false);
                }

                // is Non Business Day?
                if (MNonBusinessDay.IsNonBusinessDay(GetCtx(), GetStatementDate()))
                {
                    m_processMsg = Common.Common.NONBUSINESSDAY;
                    return(false);
                }


                if (MFactAcct.Delete(Table_ID, GetC_BankStatement_ID(), Get_TrxName()) < 0)
                {
                    return(false);       //	could not delete
                }
            }

            //	Set lines to 0
            MBankStatementLine[] lines = GetLines(true);
            for (int i = 0; i < lines.Length; i++)
            {
                MBankStatementLine line = lines[i];
                if (line.GetStmtAmt().CompareTo(Env.ZERO) != 0)
                {
                    String description = Msg.Translate(GetCtx(), "Voided") + " ("
                                         + Msg.Translate(GetCtx(), "StmtAmt") + "=" + line.GetStmtAmt();
                    if (line.GetTrxAmt().CompareTo(Env.ZERO) != 0)
                    {
                        description += ", " + Msg.Translate(GetCtx(), "TrxAmt") + "=" + line.GetTrxAmt();
                    }
                    if (line.GetChargeAmt().CompareTo(Env.ZERO) != 0)
                    {
                        description += ", " + Msg.Translate(GetCtx(), "ChargeAmt") + "=" + line.GetChargeAmt();
                    }
                    if (line.GetInterestAmt().CompareTo(Env.ZERO) != 0)
                    {
                        description += ", " + Msg.Translate(GetCtx(), "InterestAmt") + "=" + line.GetInterestAmt();
                    }
                    description += ")";
                    line.AddDescription(description);
                    line.SetStmtAmt(Env.ZERO);
                    line.SetTrxAmt(Env.ZERO);
                    line.SetChargeAmt(Env.ZERO);
                    line.SetInterestAmt(Env.ZERO);
                    line.Save(Get_TrxName());
                    if (line.GetC_Payment_ID() != 0)
                    {
                        MPayment payment = new MPayment(GetCtx(), line.GetC_Payment_ID(), Get_TrxName());
                        payment.SetIsReconciled(false);
                        payment.Save(Get_TrxName());
                    }
                }
            }
            AddDescription(Msg.Translate(GetCtx(), "Voided"));
            Decimal voidedDifference = GetStatementDifference();

            SetStatementDifference(Env.ZERO);

            //	Update Bank Account
            MBankAccount ba = MBankAccount.Get(GetCtx(), GetC_BankAccount_ID());

            ba.SetCurrentBalance(Decimal.Subtract(ba.GetCurrentBalance(), voidedDifference));
            ba.Save(Get_TrxName());
            SetProcessed(true);
            SetDocAction(DOCACTION_None);
            return(true);
        }