Esempio n. 1
0
        private static void 批量生成费用(IRepository rep, 普通票 票, IEnumerable 箱s, 收付标志 收付标志, 合同费用项 htfyx, IList <业务费用理论值> llzs, bool mustGenerateFy)
        {
            费用项 fyx = EntityBufferCollection.Instance.Get <费用项>(htfyx.费用项编号);

            if (fyx.箱)
            {
                foreach (普通箱 箱 in 箱s)
                {
                    GenerateFy(rep, 票, 箱, 收付标志, htfyx, llzs, mustGenerateFy);
                }
            }
            else if (fyx.票)
            {
                GenerateFy(rep, 票, null, 收付标志, htfyx, llzs, mustGenerateFy);
            }
        }
Esempio n. 2
0
        public static void 批量生成费用(IRepository rep, 车辆产值 产值, IEnumerable 任务s, string 费用项编号, 收付标志? 收付标志, IList<业务费用理论值> llzs)
        {
            车队合同 wtrht = CdDataBuffer.Instance.Get车队合同(rep);
            if (wtrht != null)
            {
                foreach (车队合同费用项 htfyx in wtrht.合同费用项)
                {
                    // 如果指定费用项,则只生成此费用项下的费用
                    if (!string.IsNullOrEmpty(费用项编号)
                        && htfyx.费用项编号 != 费用项编号)
                    {
                        continue;
                    }

                    批量生成费用(rep, 产值, 任务s, htfyx, llzs, !string.IsNullOrEmpty(费用项编号));
                }
            }
        }
Esempio n. 3
0
        static void DisplayManagerPzsfmx_SelectedDataValueChanged(object sender, SelectedDataValueChangedEventArgs e)
        {
            if (e.DataControlName == "收付款方式" || e.DataControlName == "收付标志")
            {
                Xceed.Grid.Cell cell = e.Container as Xceed.Grid.Cell;
                cell.ParentRow.Cells["票据号码"].ReadOnly   = true;
                cell.ParentRow.Cells["银行账户编号"].ReadOnly = true;
                cell.ParentRow.Cells["出票银行"].ReadOnly   = true;
                cell.ParentRow.Cells["承兑期限"].ReadOnly   = true;
                cell.ParentRow.Cells["付款人编号"].ReadOnly  = true;

                if (cell.ParentRow.Cells["收付款方式"].Value != null && cell.ParentRow.Cells["收付标志"].Value != null)
                {
                    收付标志  a = (收付标志)cell.ParentRow.Cells["收付标志"].Value;
                    收付款方式 b = (收付款方式)cell.ParentRow.Cells["收付款方式"].Value;
                    switch (a)
                    {
                    case 收付标志.收:
                        cell.ParentRow.Cells["票据号码"].ReadOnly   = !(b == 收付款方式.现金支票 || b == 收付款方式.转账支票 || b == 收付款方式.银行承兑汇票 || b == 收付款方式.银行本票汇票);
                        cell.ParentRow.Cells["银行账户编号"].ReadOnly = !(b == 收付款方式.转账支票 || b == 收付款方式.银行本票汇票 || b == 收付款方式.银行收付);
                        cell.ParentRow.Cells["出票银行"].ReadOnly   = !(b == 收付款方式.银行承兑汇票);
                        cell.ParentRow.Cells["承兑期限"].ReadOnly   = !(b == 收付款方式.银行承兑汇票);
                        cell.ParentRow.Cells["付款人编号"].ReadOnly  = !(b == 收付款方式.银行承兑汇票);
                        if (b == 收付款方式.银行承兑汇票)
                        {
                            cell.ParentRow.Cells["付款人编号"].Value = (cell.ParentRow.GridControl.FindForm() as ArchiveDetailForm).DisplayManager.DataControls["相关人编号"].SelectedDataValue;
                        }
                        else
                        {
                            cell.ParentRow.Cells["付款人编号"].Value = null;
                        }
                        break;

                    case 收付标志.付:
                        cell.ParentRow.Cells["票据号码"].ReadOnly   = !(b == 收付款方式.现金支票 || b == 收付款方式.转账支票 || b == 收付款方式.银行承兑汇票);
                        cell.ParentRow.Cells["银行账户编号"].ReadOnly = !(b == 收付款方式.银行收付 || b == 收付款方式.电汇);
                        cell.ParentRow.Cells["出票银行"].ReadOnly   = true;
                        cell.ParentRow.Cells["承兑期限"].ReadOnly   = true;
                        cell.ParentRow.Cells["付款人编号"].ReadOnly  = true;
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        public static int 批量生成费用(IRepository rep, 车辆产值 票, IEnumerable 箱, string 费用项编号, 收付标志? 收付标志)
        {
            int cnt = 0;

            // 需按照委托人合同和付款合同生成相应费用和费用理论值
            // 如果总体来生成,则按照:
            // 如果费用已经打了完全标志,则不生成。如果相应理论值已经生成过,也不生成。
            // 如果单个费用项来生成,则不管理论值是否已经生成过
            // Todo: 理论值可能显示生成票的,后来信息完全了再生成箱的,此时要删除票的
            //using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository(票.GetType()))
            {
                try
                {
                    rep.BeginTransaction();

                    IList<业务费用理论值> llzs = (rep as Feng.NH.INHibernateRepository).List<业务费用理论值>(NHibernate.Criterion.DetachedCriteria.For<业务费用理论值>()
                                            .Add(NHibernate.Criterion.Expression.Eq("费用实体.ID", 票.ID)));

                    rep.Initialize(票.费用, 票);

                    process_fy_generate.批量生成费用(rep, 票, 箱, 费用项编号, 收付标志, llzs);

                    ////  有几项(发票税,贴息费)要看收款费用
                    // 不行,会多生成
                    //批量生成费用付款(rep, 费用实体类型, 票, 箱, 费用项编号, 收付标志, llzs);

                    rep.CommitTransaction();
                }
                catch (Exception ex)
                {
                    rep.RollbackTransaction();
                    ServiceProvider.GetService<IExceptionProcess>().ProcessWithNotify(ex);
                }
            }
            return cnt;
        }
Esempio n. 5
0
 public static int 批量生成费用(IRepository rep, int 费用实体类型, 普通票 票, IEnumerable 箱, string 费用项编号, 收付标志? 收付标志)
 {
     return 批量生成费用(rep, 费用实体类型, 票, 箱, 费用项编号, 收付标志, false);
 }
Esempio n. 6
0
        public static void AddFees(凭证 master, IList<费用> list, IControlManager<凭证费用明细> detailCm, bool add, 收付标志? asDzd收付标志)
        {
            if (list == null)
                return;

            List<费用> newList = new List<费用>();
            foreach (费用 i in list)
            {
                if (i.凭证费用明细 == null)
                {
                    newList.Add(i);
                }
            }

            IList<凭证费用明细> ret = new List<凭证费用明细>();
            if (!asDzd收付标志.HasValue)
            {
                // 费用实体类型. 收付标志, 费用项编号, 相关人编号
                Dictionary<Tuple<int, 收付标志, string, string>, IList<费用>> dict = Utility.GroupFyToPzYsyf(newList);

                foreach (KeyValuePair<Tuple<int, 收付标志, string, string>, IList<费用>> kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        sum += k4.金额.Value;
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.Item1);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.Item1;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用 = kvp.Value;
                    pzs1.费用项编号 = kvp.Key.Item3;
                    pzs1.金额 = sum;
                    pzs1.收付标志 = kvp.Key.Item2;
                    pzs1.相关人编号 = kvp.Key.Item4;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }
            else
            {
                Dictionary<Tuple<int, string>, IList<费用>> dict = Utility.GroupFyToDzdYsyf(newList);

                foreach (KeyValuePair<Tuple<int, string>, IList<费用>> kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        if (k4.收付标志 == asDzd收付标志.Value)
                        {
                            sum += k4.金额.Value;
                        }
                        else
                        {
                            sum -= k4.金额.Value;
                        }
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.First);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.First;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用 = kvp.Value;
                    pzs1.费用项编号 = "000";    // 常规应收应付
                    pzs1.金额 = sum;
                    pzs1.收付标志 = asDzd收付标志.Value;
                    pzs1.相关人编号 = kvp.Key.Item2;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }

            if (add)
            {
                foreach (凭证费用明细 item in ret)
                {
                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                    detailCm.EndEdit();

                    foreach (费用 i in item.费用)
                    {
                        i.凭证费用明细 = item;
                    }
                }
            }
            else
            {
                if (ret.Count == 0)
                    return;

                System.Diagnostics.Debug.Assert(ret.Count <= 1, "选出多个凭证费用明细,请查证!");
                System.Diagnostics.Debug.Assert(ret[0].费用项编号 == detailCm.DisplayManagerT.CurrentEntity.费用项编号, "凭证费用明细费用项和选择的费用项不同!");
                System.Diagnostics.Debug.Assert(ret[0].相关人编号 == detailCm.DisplayManagerT.CurrentEntity.相关人编号, "凭证费用明细费用项和选择的相关人不同!");
                System.Diagnostics.Debug.Assert(ret[0].收付标志 == detailCm.DisplayManagerT.CurrentEntity.收付标志, "凭证费用明细费用项和选择的相关人不同!");

                using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<费用>())
                {
                    rep.Initialize(detailCm.DisplayManagerT.CurrentEntity.费用, detailCm.DisplayManagerT.CurrentEntity);
                }

                if (detailCm.DisplayManagerT.CurrentEntity.费用 == null)
                {
                    detailCm.DisplayManagerT.CurrentEntity.费用 = new List<费用>();
                }
                foreach (费用 i in ret[0].费用)
                {
                    i.凭证费用明细 = detailCm.DisplayManagerT.CurrentEntity;
                }

                detailCm.EditCurrent();
                detailCm.EndEdit();
            }
        }
Esempio n. 7
0
 private static void 批量生成费用(IRepository rep, 普通票 票, IEnumerable 箱s, 收付标志 收付标志, 合同费用项 htfyx, IList<业务费用理论值> llzs, bool mustGenerateFy)
 {
     费用项 fyx = EntityBufferCollection.Instance.Get<费用项>(htfyx.费用项编号);
     if (fyx.箱)
     {
         foreach (普通箱 箱 in 箱s)
         {
             GenerateFy(rep, 票, 箱, 收付标志, htfyx, llzs, mustGenerateFy);
         }
     }
     else if (fyx.票)
     {
         GenerateFy(rep, 票, null, 收付标志, htfyx, llzs, mustGenerateFy);
     }
 }
Esempio n. 8
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);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        public static void 批量生成费用收款(IRepository rep, int 费用实体类型, 普通票 票, IEnumerable 箱s, string 费用项编号, 收付标志? 收付标志, IList<业务费用理论值> llzs)
        {
            if (!收付标志.HasValue || 收付标志.Value == Hd.Model.收付标志.收)
            {
                // 生成委托人合同费用
                委托人合同 wtrht = HdDataBuffer.Instance.Get委托人合同(rep, 费用实体类型, 票.委托人编号);
                if (wtrht != null)
                {
                    foreach (委托人合同费用项 htfyx in wtrht.合同费用项)
                    {
                        // 如果指定费用项,则只生成此费用项下的费用
                        if (!string.IsNullOrEmpty(费用项编号)
                            && htfyx.费用项编号 != 费用项编号)
                        {
                            continue;
                        }

                        批量生成费用(rep, 票, 箱s, Hd.Model.收付标志.收, htfyx, llzs, !string.IsNullOrEmpty(费用项编号));
                    }
                }
            }
        }
Esempio n. 10
0
        public static void 批量生成费用付款(IRepository rep, int 费用实体类型, 普通票 票, IEnumerable 箱s, string 费用项编号, 收付标志? 收付标志, IList<业务费用理论值> llzs, bool service)
        {
            if (!收付标志.HasValue || 收付标志.Value == Hd.Model.收付标志.付)
            {
                // 生成付款费用
                付款合同 fkht = HdDataBuffer.Instance.Get付款合同(rep, 费用实体类型);
                if (fkht != null)
                {
                    foreach (付款合同费用项 htfyx in fkht.合同费用项)
                    {
                        // 如果指定费用项,则只生成此费用项下的费用
                        if (!string.IsNullOrEmpty(费用项编号)
                            && htfyx.费用项编号 != 费用项编号)
                        {
                            continue;
                        }

                        // 不是服务运行时(即界面上点按钮),付款合同费用项.是否生成实际费用 = false 不生产费用
                        if (!service && !htfyx.是否生成实际费用)
                        {
                            continue;
                        }

                        批量生成费用(rep, 票, 箱s, Hd.Model.收付标志.付, htfyx, llzs, !string.IsNullOrEmpty(费用项编号));
                    }
                }
                if (费用实体类型 == 11)
                {
                    bool? cybz = ConvertHelper.ToBoolean(EntityScript.GetPropertyValue(票, "承运标志"));
                    if (cybz.HasValue && cybz.Value)
                    {
                        // 受托人合同
                        string str = ConvertHelper.ToString(EntityScript.GetPropertyValue(票, "承运人编号"));
                        if (!string.IsNullOrEmpty(str))
                        {
                            // 生成付款费用
                            受托人合同 strht = HdDataBuffer.Instance.Get受托人合同(rep, 费用实体类型, str);
                            if (strht != null)
                            {
                                foreach (受托人合同费用项 htfyx in strht.合同费用项)
                                {
                                    // 如果指定费用项,则只生成此费用项下的费用
                                    if (!string.IsNullOrEmpty(费用项编号)
                                        && htfyx.费用项编号 != 费用项编号)
                                    {
                                        continue;
                                    }

                                    批量生成费用(rep, 票, 箱s, Hd.Model.收付标志.付, htfyx, llzs, !string.IsNullOrEmpty(费用项编号));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 11
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);
                        }
                    }
                }
            }
        }