Exemplo n.º 1
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="entity"></param>
        public override void Submit(IRepository rep, 对账单 entity)
        {
            if (!entity.关账日期.HasValue)
            {
                throw new InvalidUserOperationException("请输入 关账日期!");
            }

            entity.Submitted = true;

            if (entity.费用 == null)
            {
                entity.费用 = rep.List <费用>("from 费用 where 对账单 = :对账单", new Dictionary <string, object> {
                    { "对账单", entity }
                });
            }
            else
            {
                rep.Initialize(entity.费用, entity);
            }
            decimal sum = 0;

            foreach (费用 i in entity.费用)
            {
                if (i.收付标志 == 收付标志.收)
                {
                    sum += i.金额.Value;
                }
                else
                {
                    sum -= i.金额.Value;
                }

                if (i.凭证费用明细 != null)
                {
                    throw new InvalidUserOperationException("费用已经出凭证!");
                }
            }

            if (entity.收付标志 == 收付标志.收)
            {
                entity.金额 = sum;
            }
            else
            {
                entity.金额 = -sum;
            }
            this.Update(rep, entity);

            费用Dao fyDao = new 费用Dao();

            switch (entity.对账单类型)
            {
            case (int)车队对账单类型.应收对账单_委托人:
            case (int)车队对账单类型.应付对账单_驾驶员:
            case (int)车队对账单类型.应付对账单_对外:
            case (int)车队对账单类型.应付对账单_车主:
            {
                GenerateDzdYsyf(rep, entity);

                foreach (费用 i in entity.费用)
                {
                    fyDao.Update(rep, i);

                    // rep.Update() 无用,可能NHibernate判断无数据更改然后不更新
                }
            }
            break;

            case (int)车队对账单类型.固定资产折旧_车辆:
                GenerateDzdYsyf(rep, entity);

                foreach (费用 i in entity.费用)
                {
                    fyDao.Update(rep, i);
                }
                break;

            default:
                throw new NotSupportedException("Not Supported 对账单类型 of " + entity.对账单类型 + "!");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="entity"></param>
        public override void Submit(IRepository rep, 对账单 entity)
        {
            entity.Submitted = true;

            rep.Initialize(entity.费用, entity);
            decimal sum = 0;

            foreach (费用 i in entity.费用)
            {
                if (i.收付标志 == 收付标志.收)
                {
                    sum += i.金额.Value;
                }
                else
                {
                    sum -= i.金额.Value;
                }

                if (i.凭证费用明细 != null)
                {
                    throw new InvalidUserOperationException("费用已经出凭证!");
                }
            }
            if (entity.收付标志 == 收付标志.收)
            {
                entity.金额 = sum;
            }
            else
            {
                entity.金额 = -sum;
            }

            this.Update(rep, entity);

            费用Dao fyDao = new 费用Dao();

            switch (entity.对账单类型)
            {
            case (int)财务对账单类型.固定资产折旧:
                foreach (费用 i in entity.费用)
                {
                    fyDao.Update(rep, i);
                }

                GenerateDzdYsyf(rep, entity);
                break;

            case (int)财务对账单类型.坏账:
                break;

            case (int)财务对账单类型.应收调节款:
                foreach (费用 i in entity.费用)
                {
                    fyDao.Update(rep, i);
                }

                GenerateDzdYsyf(rep, entity);
                break;

            default:
                throw new NotSupportedException("Not Supported 对账单类型 of " + entity.对账单类型 + "!");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="entity"></param>
        public override void Submit(IRepository rep, 对账单 entity)
        {
            if (!entity.关账日期.HasValue)
            {
                throw new InvalidUserOperationException("请输入 关账日期!");
            }

            entity.Submitted = true;

            rep.Initialize(entity.费用, entity);
            decimal sum = 0;

            foreach (费用 i in entity.费用)
            {
                if (i.收付标志 == 收付标志.收)
                {
                    sum += i.金额.Value;
                }
                else
                {
                    sum -= i.金额.Value;
                }

                if (i.凭证费用明细 != null)
                {
                    throw new InvalidUserOperationException("费用已经出凭证!");
                }
            }
            if (entity.收付标志 == 收付标志.收)
            {
                entity.金额 = sum;
            }
            else
            {
                entity.金额 = -sum;
            }

            this.Update(rep, entity);

            费用Dao fyDao = new 费用Dao();

            switch (entity.对账单类型)
            {
            case (int)货代对账单类型.自动凭证应付对账单:
                Dictionary <string, object> dict = ProcessInfoHelper.ExecuteProcess("自动凭证应付对账单", new Dictionary <string, object> {
                    { "entity", entity }
                }) as Dictionary <string, object>;
                自动对账单生成凭证(rep, entity, dict);
                break;

            case (int)货代对账单类型.货代应付对账单:
            case (int)货代对账单类型.货代应收对账单:
                foreach (费用 i in entity.费用)
                {
                    fyDao.Update(rep, i);
                }

                GenerateDzdYsyf(rep, entity);
                break;

            default:
                throw new NotSupportedException("Not Supported 对账单类型 of " + entity.对账单类型 + "!");
            }
        }