Beispiel #1
0
        public static string Get相关人(IRepository rep, 普通票 票, 普通箱 箱, 合同费用项 htfyx)
        {
            object entity;
            if (箱 != null)
            {
                entity = 箱;
            }
            else
            {
                entity = 票;
            }
            string ret = null;
            if (htfyx is 委托人合同费用项)
            {
                return 票.委托人编号;
            }
            else if (htfyx is 付款合同费用项)
            {
                string mrxgr = (htfyx as 付款合同费用项).默认相关人;
                object r = EntityScript.CalculateExpression(mrxgr, entity);
                ret = string.IsNullOrEmpty(mrxgr) || r == null ? null : r.ToString().Replace("\"", "");
                if (string.IsNullOrEmpty(ret))
                {
                    ret = null;
                }
            }
            else if (htfyx is 受托人合同费用项)
            {
                object cyr = EntityScript.GetPropertyValue(票, "承运人编号");
                if (cyr != null)
                {
                    return cyr.ToString();
                }
                else
                {
                    return null;
                }
            }
            else
            {
                throw new ArgumentException("Invalid htfyx Type!");
            }

            return ret;
        }
Beispiel #2
0
 private static decimal? Get委托人理论值(IRepository rep, 普通票 票, 普通箱 箱, 委托人合同费用项 htfyx)
 {
     decimal? d = null;
     switch (htfyx.委托人合同费用项类型)
     {
         case 委托人合同费用项类型.理论值计算:
             d = (箱 != null) ? Get理论值金额(rep, htfyx, 箱) : Get理论值金额(rep, htfyx, 票);
             break;
         case 委托人合同费用项类型.代垫:
             decimal? sum = null;
             foreach (业务费用 i in 票.费用)
             {
                 bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志.付
                     && i.金额.HasValue;
                 if (b && 箱 != null)
                 {
                     b &= i.箱Id == 箱.ID;
                 }
                 if (b)
                 {
                     if (!sum.HasValue)
                     {
                         sum = 0;
                     }
                     sum += i.金额.Value;
                 }
             }
             if (sum.HasValue)
             {
                 d = sum;
             }
             else
             {
                 d = decimal.MinValue;
             }
             break;
         default:
             throw new ArgumentException("Invalid " + htfyx.委托人合同费用项类型);
     }
     return d;
 }
Beispiel #3
0
 private static decimal? Get理论值(IRepository rep, 普通票 票, 普通箱 箱, 合同费用项 htfyx)
 {
     if (htfyx is 受托人合同费用项)
     {
         return Get受托人理论值(rep, 票, 箱, htfyx as 受托人合同费用项);
     }
     else if (htfyx is 付款合同费用项)
     {
         return Get付款理论值(rep, 票, 箱, htfyx as 付款合同费用项);
     }
     else if (htfyx is 委托人合同费用项)
     {
         return Get委托人理论值(rep, 票, 箱, htfyx as 委托人合同费用项);
     }
     else
     {
         throw new ArgumentException("Invalid htfyx Type!");
     }
 }
Beispiel #4
0
        private static void GenerateFy(IRepository rep, 普通票 票, 普通箱 箱, 收付标志 收付标志, 合同费用项 htfyx, IList<业务费用理论值> llzs, bool mustGenerateFy)
        {
            string 相关人 = Get相关人(rep, 票, 箱, htfyx);
            decimal? 金额 = Get理论值(rep, 票, 箱, htfyx);
            if (金额.HasValue && 金额.Value == decimal.MinValue)
            {
                return;
            }

            bool llrHaveGenerated = false;
            foreach (业务费用理论值 i in llzs)
            {
                bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志;                  ;
                if (htfyx.是否判断相关人)
                {
                    b &= i.相关人编号 == 相关人;
                }
                if (b && 箱 != null)
                {
                    b &= i.箱Id == 箱.ID;
                }
                if (b)
                {
                    llrHaveGenerated = true;
                    break;
                }
            }

            业务费用理论值 ywfylrz = null;
            if (!llrHaveGenerated)
            {
                if (金额.HasValue)
                {
                    ywfylrz = new 业务费用理论值();
                    ywfylrz.费用实体 = 票; // new 普通票 { Id = 票.ID, Version = 票.Version, 费用实体类型编号 = 票.费用实体类型编号 };
                    ywfylrz.费用项编号 = htfyx.费用项编号;
                    ywfylrz.金额 = 金额.Value;
                    ywfylrz.票 = 票;
                    ywfylrz.收付标志 = 收付标志;
                    ywfylrz.相关人编号 = Get相关人(rep, 票, 箱, htfyx);
                    if (箱 != null)
                    {
                        ywfylrz.箱 = 箱;
                        ywfylrz.箱Id = 箱.ID;
                    }

                    (new HdBaseDao<业务费用理论值>()).Save(rep, ywfylrz);
                    llzs.Add(ywfylrz);
                }
            }

            if (htfyx.是否生成实际费用)
            {
                bool generateFy = false;
                // 在外层,判断理论值是否生成过
                if (!mustGenerateFy)
                {
                    if (htfyx.是否空值全部生成)
                    {
                        // 金额为Null的时候判断时候生成过,没生成过也要生成
                        if (!金额.HasValue)
                        {
                            bool fyHaveGenerated = false;
                            foreach (业务费用 i in 票.费用)
                            {
                                bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志;
                                if (htfyx.是否判断相关人)
                                {
                                    b &= i.相关人编号 == 相关人;
                                }
                                if (b && 箱 != null)
                                {
                                    b &= i.箱Id == 箱.ID;
                                }
                                if (b)
                                {
                                    fyHaveGenerated = true;
                                    break;
                                }
                            }
                            generateFy = !fyHaveGenerated;
                        }
                    }

                    if (!generateFy)
                    {
                        // 只有理论值未生成过,且有理论值的情况下,准备生成费用
                        if (!llrHaveGenerated && ywfylrz != null)
                        {
                            // 如果理论值未生成过,要检查是否要生成费用
                            bool fyHaveGenerated = false;
                            foreach (业务费用 i in 票.费用)
                            {
                                bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志;
                                if (htfyx.是否判断相关人)
                                {
                                    b &= i.相关人编号 == 相关人;
                                }
                                if (b && 箱 != null)
                                {
                                    b &= i.箱Id == 箱.ID;
                                }
                                if (b)
                                {
                                    fyHaveGenerated = true;
                                    break;
                                }
                            }
                            generateFy = !fyHaveGenerated;
                        }
                        else
                        {
                            generateFy = false;
                        }
                    }
                }
                else
                {
                    generateFy = true;
                }

                if (generateFy)
                {
                    bool fylbSubmitted = false;
                    费用项 fyx = EntityBufferCollection.Instance.Get<费用项>(htfyx.费用项编号);
                    //int fylbbh = fyx.收入类别.Value;

                    //费用类别 fylb = EntityBufferCollection.Instance["费用类别"].Get(fylbbh) as 费用类别;
                    //System.Diagnostics.Debug.Assert(fylb.大类 == "业务额外" || fylb.大类 == "业务常规" || fylb.大类 == "业务其他");
                    IList<费用信息> list = (rep as Feng.NH.INHibernateRepository).List<费用信息>(NHibernate.Criterion.DetachedCriteria.For<费用信息>()
                        .Add(NHibernate.Criterion.Expression.Eq("费用项编号", htfyx.费用项编号))
                        .Add(NHibernate.Criterion.Expression.Eq("票.ID", 票.ID)));

                    System.Diagnostics.Debug.Assert(list.Count <= 1);
                    if (list.Count == 1)
                    {
                        if (收付标志 == 收付标志.收)
                        {
                            fylbSubmitted = list[0].Submitted;
                        }
                        else
                        {
                            fylbSubmitted = list[0].完全标志付;
                        }
                    }

                    // 完全标志还未打
                    if (!fylbSubmitted)
                    {
                        // 不生成理论值为0的
                        if (!金额.HasValue || (金额.HasValue && 金额.Value != 0))
                        {
                            业务费用 item = new 业务费用();
                            item.费用实体 = 票; // new 普通票 { Id = 票.ID, Version = 票.Version, 费用实体类型编号 = 票.费用实体类型编号 };
                            item.费用项编号 = htfyx.费用项编号;
                            item.金额 = 金额;
                            item.票 = 票;
                            item.收付标志 = 收付标志;
                            item.相关人编号 = 相关人;
                            if (箱 != null)
                            {
                                item.箱 = 箱;
                                item.箱Id = 箱.ID;
                            }

                            (new 业务费用Dao()).Save(rep, item);

                            票.费用.Add(item);
                        }
                    }
                }
            }
        }