Ejemplo n.º 1
0
        public IDRPCASEViewModel()
        {
            this.SETTLE     = new UPDA_IDRP_SETTLE();
            this.PAYMENTREC = new List <UPDA_IDRP_PAYMENTREC>();
            this.PAYMENTOUT = new List <CUS_IDRP_PAYMENTOUT_EX>();
            this.MS         = new MessageStatus();

            this.ITEMS   = new List <PAYITEM>();
            this.SETITEM = null;
        }
Ejemplo n.º 2
0
        public void Calc(bool fStopSETITEM = false)
        {
            this.ITEMS.Clear();

            PAYITEM itemPREV = new PAYITEM();

            itemPREV.REC_DATE        = this.SETTLE.FIRSTPAY_D;
            itemPREV.CALC_Balance    = this.SETTLE.T_ALLBANK;
            itemPREV.CALC_OverduePay = 0;

            int     nMAXCNT            = Math.Max(Math.Max(this.PAYMENTOUT.Count, this.PAYMENTREC.Count), this.SETTLE.TENOR);
            int     nGRACE_CNT         = 0;
            int     i                  = 0;
            decimal Total_CALC_RushOff = 0;

            while (i < nMAXCNT)
            {
                PAYITEM item = new PAYITEM((i < this.PAYMENTREC.Count) ? this.PAYMENTREC[i] : null);
                // 重新排REC_NO  因為會加結清日那筆
                item.REC_NO = itemPREV.REC_NO + 1;
                // 如果不是 CUS_IDRP_PAYMENTREC 資料 計算 繳款日期 下個月
                if (item.REC_DATE is null)
                {
                    if (itemPREV.REC_DATE.HasValue)
                    {
                        item.REC_DATE = itemPREV.REC_DATE.Value.AddMonths(1);
                    }
                }
                // IDRP PAYMENTOUT 資料
                item.SetPayOut((i < this.PAYMENTOUT.Count) ? this.PAYMENTOUT[i] : null);


                //結清日
                if (this.SETTLE.SETTLE_DATE.Value >= itemPREV.REC_DATE.Value && this.SETTLE.SETTLE_DATE.Value <= item.REC_DATE.Value)
                {
                    if (item.REC_DATE.Value.Date == this.SETTLE.SETTLE_DATE.Value.Date)
                    {
                        this.SETITEM = item;
                    }
                    else
                    {
                        TimeSpan ts = this.SETTLE.SETTLE_DATE.Value.Date - itemPREV.REC_DATE.Value.Date;
                        if (ts.TotalDays == 0)
                        {
                            this.SETITEM = itemPREV;
                        }
                        else
                        {
                            //加一筆 結清日
                            PAYITEM itemSET = new PAYITEM();
                            itemSET.REC_NO = item.REC_NO;

                            itemSET.REC_DATE = this.SETTLE.SETTLE_DATE;

                            itemSET.CALC_IntFee     = (this.SETTLE.T_ALLBANK - Total_CALC_RushOff) * (this.SETTLE.APR / 100 * (decimal)(ts.TotalDays - 1) / 365);
                            itemSET.CALC_RushOff    = this.SETTLE.PMT_INST - itemSET.CALC_IntFee;
                            itemSET.CALC_OverduePay = itemSET.REAL_AMT - this.SETTLE.PMT_INST + itemPREV.CALC_OverduePay;

                            Total_CALC_RushOff += item.CALC_RushOff;

                            itemSET.CALC_Balance     = this.SETTLE.T_ALLBANK - (Total_CALC_RushOff + itemSET.CALC_RushOff) - itemSET.CALC_OverduePay;
                            itemSET.CALC_OverdueRate = itemSET.CALC_OverduePay / this.SETTLE.PMT_INST;



                            this.ITEMS.Add(itemSET);
                            this.SETITEM = itemSET;


                            item.REC_NO += 1;
                        }
                    }
                    this.SETITEM.IF_SETTLE = true;
                    this.SETTLE.SETTLE_AMT = this.SETITEM.CALC_Balance;
                    if (fStopSETITEM)
                    {
                        break;
                    }
                }



                if (item.IF_GRACE)
                {
                    item.CALC_IntFee     = 0;
                    item.CALC_RushOff    = 0;
                    item.CALC_OverduePay = item.REAL_AMT + itemPREV.CALC_OverduePay;
                    nGRACE_CNT++;
                    nMAXCNT++;
                }
                else
                {
                    item.CALC_IntFee = (this.SETTLE.T_ALLBANK - Total_CALC_RushOff) * this.SETTLE.APR / 100 / 12;
                    //FA 2020/02/05 ADD IF_LARGEPAY
                    if (item.IF_LARGEPAY)
                    {
                        item.CALC_RushOff    = item.REAL_AMT - item.CALC_IntFee;
                        item.CALC_OverduePay = itemPREV.CALC_OverduePay;
                    }
                    else
                    {
                        item.CALC_RushOff    = this.SETTLE.PMT_INST - item.CALC_IntFee;
                        item.CALC_OverduePay = item.REAL_AMT - this.SETTLE.PMT_INST + itemPREV.CALC_OverduePay;
                    }
                }
                Total_CALC_RushOff += item.CALC_RushOff;


                item.CALC_Balance     = this.SETTLE.T_ALLBANK - Total_CALC_RushOff - item.CALC_OverduePay;
                item.CALC_OverdueRate = item.CALC_OverduePay / this.SETTLE.PMT_INST;



                this.ITEMS.Add(item);
                itemPREV = item;



                i++;
            }
        }