예제 #1
0
        /// <summary>
        /// Set Credit Status
        /// </summary>
        public void SetSOCreditStatus()
        {
            MBPartner bp          = new MBPartner(GetCtx(), GetC_BPartner_ID(), Get_TrxName());
            Decimal   creditLimit = GetSO_CreditLimit();

            //	Nothing to do
            if (SOCREDITSTATUS_NoCreditCheck.Equals(GetSOCreditStatus()) ||
                SOCREDITSTATUS_CreditStop.Equals(GetSOCreditStatus()) ||
                Env.ZERO.CompareTo(creditLimit) == 0)
            {
                return;
            }

            //	Above Credit Limit
            // changed this function for fetching open balance because in case of void it calculates again and fetches wrong value of open balance // Lokesh Chauhan
            //if (creditLimit.CompareTo(GetTotalOpenBalance(!_TotalOpenBalanceSet)) < 0)
            if (creditLimit.CompareTo(GetTotalOpenBalance()) <= 0)
            {
                SetSOCreditStatus(SOCREDITSTATUS_CreditHold);
            }
            else
            {
                //	Above Watch Limit
                //Peference check if credit watch per is zero on header then gets the value from bpgroup
                Decimal watchAmt;
                if (bp.Get_ColumnIndex("CreditWatchPercent") > 0)
                {
                    if (bp.GetCreditWatchPercent() == 0)
                    {
                        watchAmt = Decimal.Multiply(creditLimit, bp.GetCreditWatchRatio());
                    }
                    else
                    {
                        watchAmt = Decimal.Multiply(creditLimit, bp.GetCustomerCreditWatch());
                    }
                }
                else
                {
                    watchAmt = Decimal.Multiply(creditLimit, bp.GetCreditWatchRatio());
                }
                if (watchAmt.CompareTo(GetTotalOpenBalance()) < 0)
                {
                    SetSOCreditStatus(SOCREDITSTATUS_CreditWatch);
                }
                else    //	is OK
                {
                    SetSOCreditStatus(SOCREDITSTATUS_CreditOK);
                }
            }
            log.Fine("SOCreditStatus=" + GetSOCreditStatus());
        }