using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 计算贴现利息
    /// 根据输入的要素计算贴现利息
    /// </summary>
    public class CountedInterest : TFOutput
    {
        #region Output
        /// <summary>
        /// 利息 0410
        /// (null)
        /// </summary>
        public string LX { get; internal set; }


        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 票面金额 0400
            /// (null) 
            /// </summary>
            public string PMJE { get; set; }

            /// <summary>
            /// 交易日期 0440
            /// (null) 
            /// </summary>
            public string JYRQ { get; set; }

            /// <summary>
            /// 汇票到期日 0450
            /// (null) 
            /// </summary>
            public string HPDQR { get; set; }

            /// <summary>
            /// 在途天数 0460
            /// (null) 
            /// </summary>
            public string ZTTS { get; set; }

            /// <summary>
            /// 利率标志 0720
            /// 84域输入的利率的类型 D日利率M月利率Y年利率 
            /// </summary>
            public string LLBZ { get; set; }

            /// <summary>
            /// 利率 0840
            /// (null) 
            /// </summary>
            public string LL { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new CountedInterest();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "K007";
                MessageData.Fd40 = PMJE;
                MessageData.Fd44 = JYRQ;
                MessageData.Fd45 = HPDQR;
                MessageData.Fd46 = ZTTS;
                MessageData.Fd72 = LLBZ;
                MessageData.Fd84 = LL;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.LX = DelSpace(MessageData.Fd41);

                return output;
            }
        }
        #endregion
    }
}
