//更新到正式表
        public void UpdateToFormalTable()
        {
            if (另一人录入的记录 == null || this.内容不同的字段.Count > 0)
            {
                return;
            }

            MonthlyWageLoanItem m = MonthlyWageLoanItem.AddMonthlyWageLoanItem(this.员工编号, this.年, this.月);

            this.CopyWatchMember(m);

            m.创建人  = this.录入人;
            m.创建时间 = DateTime.Now;
            m.Save();

            //更新生效标记
            if (!this.已生效)
            {
                this.生效时间 = DateTime.Now;
                this.Save();

                MonthlyWageLoanItemEntry opposite = 另一人录入的记录;
                opposite.生效时间 = DateTime.Now;
                opposite.Save();
            }
        }
        public static MonthlyWageLoanItem AddMonthlyWageLoanItem(string emplid, int year, int month)
        {
            MonthlyWageLoanItem item = GetMonthlyWageLoanItem(emplid, year, month);

            if (item == null)
            {
                item      = new MonthlyWageLoanItem();
                item.标识   = Guid.NewGuid();
                item.员工编号 = emplid;
                item.年    = year;
                item.月    = month;
                item.创建人  = AccessController.CurrentUser == null ? "系统" : AccessController.CurrentUser.姓名;
                item.创建时间 = DateTime.Now;
                item.Save();
            }
            return(item);
        }
        protected override void OnSaving()
        {
            if (this.期间 == null)
            {
                this.期间 = GetPeriod(年, 月);
            }

            MonthlyWageLoanItem found = GetMonthlyWageLoanItem(this.员工编号, this.期间);

            if (found != null && found.标识 != this.标识)
            {
                throw new Exception("已存在该员工的报销记录,不能重复创建。");
            }
            else
            {
                base.OnSaving();
            }

            MONTHLYWAGELOANITEM_CACHE.Set(CacheKey, this, TimeSpan.FromHours(10));
        }
        public static MonthlyWageLoanItem GetMonthlyWageLoanItem(Guid id)
        {
            MonthlyWageLoanItem obj = (MonthlyWageLoanItem)Session.DefaultSession.GetObjectByKey(typeof(MonthlyWageLoanItem), id);

            return(obj);
        }
Exemplo n.º 5
0
        //自动创建借款记录
        public static List <MonthlyWageLoanItem> AutoGenerateMonthlyWageLoanItems(int year, int month)
        {
            List <MonthlyWageLoanItem> list = new List <MonthlyWageLoanItem>();
            //获取正在执行的借款标准
            //2018-9-13 部分员工可能会有多条执行标准,查询结果按开始时间先后排序,执行的原则是新的标准会替代旧的标准,所以实际会计算多次,后计算的覆盖旧的
            List <WageLoan> wageLoanList = GetWageLoans(year, month);

            foreach (WageLoan wl in wageLoanList)
            {
                SalaryResult sr = SalaryResult.GetFromCache(wl.员工编号, year, month);
                //如果已经发上表工资
                if (sr != null)
                {
                    if (sr.企业排班天数 == 0)
                    {
                        continue;
                    }

                    string  班别     = sr.班别.Trim();
                    decimal 月借款额度  = wl.月借款额度;
                    decimal 排班天数   = sr.企业排班天数;
                    decimal 实际出勤天数 = sr.实际出勤天数;
                    decimal 实际借款金额 = 0;

                    if (班别 == "6") //行政班
                    {
                        if (sr.实际出勤天数 > 10)
                        {
                            实际借款金额 = 月借款额度 - 月借款额度 / (decimal)21.75 * (排班天数 - 实际出勤天数);
                        }
                        else
                        {
                            实际借款金额 = (月借款额度 / (decimal)21.75) * 实际出勤天数;
                        }
                    }
                    else
                    {
                        if (班别 == "8") //特殊+业务代表+司机
                        {
                            实际借款金额 = (月借款额度 / 排班天数) * 实际出勤天数;
                        }
                        else
                        {
                            实际借款金额 = (月借款额度 / 26) * 实际出勤天数;
                        }
                    }

                    MonthlyWageLoanItem item = MonthlyWageLoanItem.AddMonthlyWageLoanItem(wl.员工编号, year, month);
                    item.姓名     = sr.姓名;
                    item.约定税率   = wl.约定税率;
                    item.月借款标准  = wl.月借款额度;
                    item.应出勤天数  = sr.企业排班天数;
                    item.实际出勤天数 = sr.实际出勤天数;
                    item.实际借款金额 = Math.Round(实际借款金额, 2, MidpointRounding.AwayFromZero);
                    item.代缴个税   = Math.Round(item.实际借款金额 * wl.约定税率 * (decimal)0.01, 2, MidpointRounding.AwayFromZero);
                    item.税后实发金额 = item.实际借款金额 - item.代缴个税;
                    item.Save();

                    list.Add(item);
                }
            }
            return(list);
        }