public void Check(SalaryItem record, SalaryItemFormViewModel model)
 {
     if (model.ItemType != 2)
     {
         record.Multiple = false;
     }
     if (model.ValueType == 1)
     {
         record.MinValue     = null;
         record.MaxValue     = null;
         record.InValidValue = null;
     }
     else if (model.ValueType == 2)
     {
         record.MinValue     = null;
         record.MaxValue     = null;
         record.InValidValue = null;
         record.FormulaId    = null;
     }
     if (model.UoMeasure != 1 && model.IsSalaryItem == false)
     {
         record.InputCurr = null;
     }
     if (model.IsSalaryItem == true)
     {
         record.UoMeasure = 1;
     }
     if (model.IsSalaryItem == false)
     {
         record.ItemType = 2;
     }
 }
Exemple #2
0
        /// <summary>
        /// 保存薪酬项目
        /// </summary>
        /// <param name="salaryItem">需要保存的薪酬项目</param>
        /// <returns>是否成功</returns>
        public bool SaveSalaryItem(SalaryItem salaryItem)
        {
            //throw new NotImplementedException();

            ISalaryItemDAL dAL = new SalaryItemDAL();

            if (dAL.QueryById(salaryItem.Id) != null)
            {
                if (dAL.Update(salaryItem) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (dAL.Add(salaryItem) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
 public OtherExpense UpdateObject(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
 {
     if (_validator.ValidUpdateObject(otherExpense, this))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(otherExpense.SalaryItemId.GetValueOrDefault());
         if (salaryItem == null)
         {
             salaryItem = _salaryItemService.CreateObject(otherExpense.Code, otherExpense.Name, (int)Constant.SalarySign.Expense, (int)Constant.SalaryItemType.SalarySlip, otherExpense.SalaryStatus, otherExpense.IsMainSalary, otherExpense.IsDetailSalary, false);
             otherExpense.SalaryItemId = salaryItem.Id;
         }
         else
         {
             salaryItem.Code             = otherExpense.Code;
             salaryItem.Name             = otherExpense.Name;
             salaryItem.SalaryItemStatus = otherExpense.SalaryStatus;
             _salaryItemService.UpdateObject(salaryItem);
             if (salaryItem.Errors.Any())
             {
                 otherExpense.Errors.Clear();
                 otherExpense.Errors.Add("Code", "Tidak dapat mengubah SalaryItem dengan Code ini");
             }
         }
         _repository.UpdateObject(otherExpense);
     }
     return(otherExpense);
 }
Exemple #4
0
        public SalarySlip CreateObject(SalarySlip salarySlip, ISalaryItemService _salaryItemService)
        {
            salarySlip.Errors = new Dictionary <String, String>();
            SalaryItem salaryItem = _salaryItemService.GetObjectById(salarySlip.SalaryItemId.GetValueOrDefault());

            if (salaryItem == null)
            {
                salaryItem = _salaryItemService.GetObjectByCode(salarySlip.Code);
                if (salaryItem != null)
                {
                    salarySlip.Errors = new Dictionary <string, string>();
                    salarySlip.Errors.Add("Code", "SalaryItem dengan Code ini sudah ada");
                    return(salarySlip);
                }
                salaryItem = _salaryItemService.CreateObject(salarySlip.Code, salarySlip.Name, salarySlip.SalarySign, (int)Constant.SalaryItemType.SalarySlip, (int)Constant.SalaryItemStatus.Monthly, salarySlip.IsMainSalary, salarySlip.IsDetailSalary, false);
                if (salaryItem == null)
                {
                    salarySlip.Errors = new Dictionary <string, string>();
                    salarySlip.Errors.Add("Code", "Tidak dapat membuat SalaryItem dengan Code ini");
                    return(salarySlip);
                }
                salarySlip.SalaryItemId = salaryItem.Id;
            }
            if (_validator.ValidCreateObject(salarySlip, this, _salaryItemService))
            {
                salarySlip.Index = GetQueryable().Count() + 1;
                _repository.CreateObject(salarySlip);
            }
            ;
            return(salarySlip);
        }
Exemple #5
0
 public THR UpdateObject(THR thr, ISalaryItemService _salaryItemService)
 {
     if (_validator.ValidUpdateObject(thr, this))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(thr.SalaryItemId.GetValueOrDefault());
         if (salaryItem == null)
         {
             salaryItem       = _salaryItemService.CreateObject(thr.Code, thr.Name, (int)Constant.SalarySign.Income, (int)Constant.SalaryItemType.SalarySlip, (int)Constant.SalaryItemStatus.Monthly, thr.IsMainSalary, thr.IsDetailSalary, false);
             thr.SalaryItemId = salaryItem.Id;
         }
         else
         {
             salaryItem.Code = thr.Code;
             salaryItem.Name = thr.Name;
             _salaryItemService.UpdateObject(salaryItem);
             if (salaryItem.Errors.Any())
             {
                 thr.Errors.Clear();
                 thr.Errors.Add("Code", "Tidak dapat mengubah SalaryItem dengan Code ini");
             }
         }
         _repository.UpdateObject(thr);
     }
     return(thr);
 }
Exemple #6
0
        public SalarySlip CreateObject(string Code, string Name, int SalarySign, int SalaryStatus, bool IsMainSalary, bool IsDetailSalary,
                                       bool IsEnabled, bool IsPTKP, bool IsPPH21, ISalaryItemService _salaryItemService)
        {
            SalarySlip salarySlip = new SalarySlip
            {
                Code           = Code,
                Name           = Name,
                SalarySign     = SalarySign,
                IsMainSalary   = IsMainSalary,
                IsDetailSalary = IsDetailSalary,
                IsEnabled      = IsEnabled,
                IsPTKP         = IsPTKP,
                IsPPH21        = IsPPH21,
            };
            SalaryItem salaryItem = _salaryItemService.GetObjectByCode(Code);

            if (salaryItem != null)
            {
                salarySlip.Errors = new Dictionary <string, string>();
                salarySlip.Errors.Add("Code", "SalaryItem dengan Code ini sudah ada");
                return(salarySlip);
            }
            salaryItem = _salaryItemService.CreateObject(Code, Name, SalarySign, (int)Constant.SalaryItemType.SalarySlip, SalaryStatus, IsMainSalary, IsDetailSalary, false);
            if (salaryItem == null)
            {
                salarySlip.Errors = new Dictionary <string, string>();
                salarySlip.Errors.Add("Code", "Tidak dapat membuat SalaryItem dengan Code ini");
                return(salarySlip);
            }
            salarySlip.SalaryItemId = salaryItem.Id;
            return(this.CreateObject(salarySlip, _salaryItemService));
        }
        public ActionResult Delete(int id)
        {
            var message = "OK";
            DataSource <SalaryItemViewModel> Source = new DataSource <SalaryItemViewModel>();
            SalaryItem record = _hrUnitOfWork.PayrollRepository.GetSalary(id);

            if (record != null)
            {
                AutoMapper(new Models.AutoMapperParm
                {
                    Source     = record,
                    ObjectName = "SalaryItem",
                    Transtype  = TransType.Delete
                });

                _hrUnitOfWork.PayrollRepository.Remove(record);
            }
            Source.Errors = SaveChanges(Language);
            if (Source.Errors.Count() > 0)
            {
                return(Json(Source));
            }
            else
            {
                return(Json(message));
            }
        }
        public dynamic Insert(SalaryItem model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.SalaryItems, Core.Constants.Constant.MenuGroupName.Setting))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Add record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                model = _salaryItemService.CreateObject(model);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
        public dynamic GetDefaultInfo()
        {
            SalaryItem model = new SalaryItem();

            try
            {
                model = _salaryItemService.GetQueryable().FirstOrDefault();
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Id,
                model.Code,
                model.Name,
                model.Description,
                model.IsLegacy,
                model.SalaryItemType,
                model.SalaryItemStatus,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
 public SalaryItem VHasDefaultValue(SalaryItem salaryItem)
 {
     if (salaryItem.DefaultValue < 0)
     {
         salaryItem.Errors.Add("DefaultValue", "Harus lebih besar atau sama dengan 0");
     }
     return(salaryItem);
 }
 public void Remove(SalaryItem salaryItem)
 {
     if (Context.Entry(salaryItem).State == EntityState.Detached)
     {
         context.SalaryItems.Attach(salaryItem);
     }
     context.SalaryItems.Remove(salaryItem);
 }
        public SalaryItem VHasValidCode(SalaryItem salaryItem)
        {
            Regex r = new Regex("^[A-Za-z_][A-Za-z0-9_]*$"); // "^\w+$" is equivalent to ^[A-Za-z0-9_]+$ but more broader (includes non-latin characters)

            if (!r.IsMatch(salaryItem.Code))
            {
                salaryItem.Errors.Add("Code", "Hanya boleh menggunakan huruf, angka, dan underscore, dan tidak boleh diawali oleh angka");
            }
            return(salaryItem);
        }
Exemple #13
0
        //public Formula VHasParentSalaryItem(Formula formula, ISalaryItemService _salaryItemService)
        //{
        //    SalaryItem salaryItem = _salaryItemService.GetObjectById(formula.SalaryItemId);
        //    if (salaryItem == null)
        //    {
        //        formula.Errors.Add("SalaryItem", "Tidak valid");
        //    }
        //    return formula;
        //}

        public Formula VHasFirstSalaryItem(Formula formula, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(formula.FirstSalaryItemId.GetValueOrDefault());

            if (salaryItem == null)
            {
                formula.Errors.Add("FirstSalaryItem", "Tidak valid");
            }
            return(formula);
        }
Exemple #14
0
        public THR VHasSalaryItem(THR thr, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(thr.SalaryItemId.GetValueOrDefault());

            if (salaryItem == null)
            {
                thr.Errors.Add("SalaryItem", "Tidak valid");
            }
            return(thr);
        }
Exemple #15
0
        public SalarySlip VHasSalaryItem(SalarySlip salarySlip, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(salarySlip.SalaryItemId.GetValueOrDefault());

            if (salaryItem == null)
            {
                salarySlip.Errors.Add("SalaryItem", "Tidak ada");
            }
            return(salarySlip);
        }
        public SalaryStandardDetail VHasSalaryItem(SalaryStandardDetail salaryStandardDetail, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(salaryStandardDetail.SalaryItemId);

            if (salaryItem == null)
            {
                salaryStandardDetail.Errors.Add("SalaryItem", "Tidak ada");
            }
            return(salaryStandardDetail);
        }
Exemple #17
0
        public EmployeeLoan VHasSalaryItem(EmployeeLoan employeeLoan, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(employeeLoan.SalaryItemId);

            if (salaryItem == null)
            {
                employeeLoan.Errors.Add("SalaryItem", "Tidak ada");
            }
            return(employeeLoan);
        }
Exemple #18
0
        public OtherExpense VHasSalaryItem(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(otherExpense.SalaryItemId.GetValueOrDefault());

            if (salaryItem == null)
            {
                otherExpense.Errors.Add("SalaryItem", "Tidak valid");
            }
            return(otherExpense);
        }
 public SalaryItem VHasUniqueCode(SalaryItem salaryItem, ISalaryItemService _salaryItemService)
 {
     if (String.IsNullOrEmpty(salaryItem.Code) || salaryItem.Code.Trim() == "")
     {
         salaryItem.Errors.Add("Code", "Tidak boleh kosong");
     }
     else if (_salaryItemService.IsCodeDuplicated(salaryItem))
     {
         salaryItem.Errors.Add("Code", "Tidak boleh ada duplikasi");
     }
     return(salaryItem);
 }
Exemple #20
0
 public Formula VHasSecondSalaryItem(Formula formula, ISalaryItemService _salaryItemService)
 {
     if (!formula.IsSecondValue)
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(formula.SecondSalaryItemId.GetValueOrDefault());
         if (salaryItem == null)
         {
             formula.Errors.Add("SecondSalaryItem", "Tidak valid");
         }
     }
     return(formula);
 }
        /// <summary>
        /// 列表展示薪酬标准,再由独立控制器处理薪酬标准的具体操作
        /// </summary>
        /// <returns>返回薪酬标准的列表视图</returns>
        public ActionResult SalaryStandardManage()
        {
            //装载所有的薪酬标准

            //薪酬管理业务层
            ISalaryBLL bLL = new SalaryBLL();

            //薪酬项目管理业务层,因为薪酬标准管理和薪酬项目管理是不同模块的
            ISalaryItemBLL salaryItemBLL = new SalaryItemBLL();

            //获取所有的薪酬标准,这时的薪酬标准是Model中的类型
            List <SalaryStandard> standardList = bLL.GetAllSalaryStandard();

            List <Models.SalaryStandard> standardListView = new List <Models.SalaryStandard>();

            //遍历所有薪酬标准,将其转换成视图模型中的薪酬标准
            foreach (var s in standardList)
            {
                //通过薪酬标准的id获取所有的映射关系
                List <StandardMapItem> tempMapList = bLL.GetAllStandardMapItemByStandardId(s.Id);

                Models.SalaryStandard tempStandard = new Models.SalaryStandard()
                {
                    Id                 = s.Id,
                    StandardName       = s.StandardName,
                    StandardFileNumber = s.StandardFileNumber,
                    Registrant         = s.Registrant,
                    RegistTime         = s.RegistTime,
                    DesignBy           = s.DesignBy,
                    Total              = s.Total,
                    StandardState      = s.StandardState,
                    CheckDesc          = s.CheckDesc,
                    CheckBy            = s.CheckBy
                };

                //遍历映射关系,分拆装载进视图模型薪酬标准中的字典
                foreach (var m in tempMapList)
                {
                    SalaryItem        tempSalaryItem = salaryItemBLL.GetSalaryItemById(m.ItemId);
                    Models.SalaryItem salaryItemView = new Models.SalaryItem {
                        Id = tempSalaryItem.Id, Name = tempSalaryItem.Name
                    };
                    tempStandard.ItemAmout.Add(salaryItemView, m.Amout);
                }

                standardListView.Add(tempStandard);
            }

            ViewData["standardListView"] = standardListView;

            return(View());
        }
Exemple #22
0
 public SalarySlip SoftDeleteObject(SalarySlip salarySlip, ISalaryItemService _salaryItemService)
 {
     if (_validator.ValidDeleteObject(salarySlip))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(salarySlip.SalaryItemId.GetValueOrDefault());
         _repository.SoftDeleteObject(salarySlip);
         if (salaryItem != null)
         {
             _salaryItemService.SoftDeleteObject(salaryItem);
         }
     }
     return(salarySlip);
 }
Exemple #23
0
 public THR SoftDeleteObject(THR thr, ISalaryItemService _salaryItemService)
 {
     if (_validator.ValidDeleteObject(thr))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(thr.SalaryItemId.GetValueOrDefault());
         _repository.SoftDeleteObject(thr);
         if (salaryItem != null)
         {
             _salaryItemService.SoftDeleteObject(salaryItem);
         }
     }
     return(thr);
 }
 public OtherExpense SoftDeleteObject(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
 {
     if (_validator.ValidDeleteObject(otherExpense))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectById(otherExpense.SalaryItemId.GetValueOrDefault());
         _repository.SoftDeleteObject(otherExpense);
         if (salaryItem != null)
         {
             _salaryItemService.SoftDeleteObject(salaryItem);
         }
     }
     return(otherExpense);
 }
        public string PrintError(SalaryItem obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
Exemple #26
0
        /// <summary>
        /// 处理编辑薪酬项目的请求
        /// </summary>
        /// <param name="id">薪酬项目的id</param>
        /// <returns>重定向到编辑视图</returns>
        public ActionResult EditSalatyItem(string id)
        {
            ISalaryItemBLL bLL = new SalaryItemBLL();

            SalaryItem salaryItem = bLL.GetSalaryItemById(Convert.ToInt32(id));

            Models.SalaryItem salaryItemView = new Models.SalaryItem {
                Id = salaryItem.Id, Name = salaryItem.Name
            };

            ViewData["salaryItemView"] = salaryItemView;

            return(View());
        }
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         var model = SalaryItem.GetById(id);
         TryUpdateModel(model);
         model.SaveOrUpDate();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #28
0
        public SalaryItem CreateObject(string Code, string Name, int SalarySign, int SalaryItemType, int SalaryStatus, bool IsMainSalary, bool IsDetailSalary, bool IsLegacy)
        {
            SalaryItem salaryItem = new SalaryItem
            {
                Code             = Code,
                Name             = Name,
                SalarySign       = SalarySign,
                SalaryItemType   = SalaryItemType,
                SalaryItemStatus = SalaryStatus,
                IsMainSalary     = IsMainSalary,
                IsDetailSalary   = IsDetailSalary,
                IsLegacy         = IsLegacy,
            };

            return(this.CreateObject(salaryItem));
        }
        public SalarySlipDetail CreateObject(int SalarySlipId, int SalarySign, string FirstSalaryItemCode, string Operator, string SecondSalaryItemCode, decimal SecondValue,
                                             bool HasMinValue, decimal MinValue, bool HasMaxValue, decimal MaxValue,
                                             ISalarySlipService _salarySlipService, IFormulaService _formulaService, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectByCode(FirstSalaryItemCode);
            Formula    formula    = new Formula
            {
                FirstSalaryItemId = salaryItem.Id,
                FormulaOp         = Operator,
            };

            salaryItem = _salaryItemService.GetObjectByCode(SecondSalaryItemCode);
            if (salaryItem == null)
            {
                formula.IsSecondValue = true;
                formula.SecondValue   = SecondValue;
                //formula.ValueSign = (int)Constant.SalarySign.Income;
            }
            else
            {
                formula.SecondSalaryItemId = salaryItem.Id;
            }
            _formulaService.CreateObject(formula, _salaryItemService);

            SalarySlipDetail salarySlipDetail = new SalarySlipDetail
            {
                SalarySlipId = SalarySlipId,
                SalarySign   = SalarySign,
                FormulaId    = formula.Id,
                HasMinValue  = HasMinValue,
                MinValue     = MinValue,
                HasMaxValue  = HasMaxValue,
                MaxValue     = MaxValue,
            };

            CreateObject(salarySlipDetail, _salarySlipService, _formulaService);
            if (salarySlipDetail.Errors.Any())
            {
                _formulaService.DeleteObject(formula.Id);
            }
            else
            {
                formula.SalarySlipDetailId = salarySlipDetail.Id;
                _formulaService.UpdateObject(formula, _salaryItemService);
            }
            return(salarySlipDetail);
        }
        //public SalaryItem VHasValidSign(SalaryItem salaryItem)
        //{
        //    if (salaryItem.SalarySign == 0)
        //    {
        //        salaryItem.Errors.Add("SalarySign", "Tidak valid");
        //    }
        //    return salaryItem;
        //}

        public bool ValidCreateObject(SalaryItem salaryItem, ISalaryItemService _salaryItemService)
        {
            VHasUniqueCode(salaryItem, _salaryItemService);
            if (!isValid(salaryItem))
            {
                return(false);
            }
            VHasValidCode(salaryItem);
            if (!isValid(salaryItem))
            {
                return(false);
            }
            VHasDefaultValue(salaryItem);
            //if (!isValid(salaryItem)) { return false; }
            //VHasValidSign(salaryItem);
            return(isValid(salaryItem));
        }