Пример #1
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);
 }
Пример #2
0
 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);
 }
Пример #3
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);
        }
Пример #4
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));
        }
Пример #5
0
        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
            }));
        }
Пример #6
0
 public OtherExpense CreateObject(OtherExpense otherExpense, ISalaryItemService _salaryItemService)
 {
     otherExpense.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(otherExpense, this))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectByCode(otherExpense.Code);
         if (salaryItem != null)
         {
             otherExpense.Errors = new Dictionary <string, string>();
             otherExpense.Errors.Add("Code", "SalaryItem dengan Code ini sudah ada");
             return(otherExpense);
         }
         salaryItem = _salaryItemService.CreateObject(otherExpense.Code, otherExpense.Name, (int)Constant.SalarySign.Expense, (int)Constant.SalaryItemType.OtherExpense, otherExpense.SalaryStatus, otherExpense.IsMainSalary, otherExpense.IsDetailSalary, false);
         if (salaryItem == null)
         {
             otherExpense.Errors = new Dictionary <string, string>();
             otherExpense.Errors.Add("Code", "Tidak dapat membuat SalaryItem dengan Code ini");
             return(otherExpense);
         }
         otherExpense.SalaryItemId = salaryItem.Id;
         _repository.CreateObject(otherExpense);
     }
     return(otherExpense);
 }
Пример #7
0
 public THR CreateObject(THR thr, ISalaryItemService _salaryItemService)
 {
     thr.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(thr, this))
     {
         SalaryItem salaryItem = _salaryItemService.GetObjectByCode(thr.Code);
         if (salaryItem != null)
         {
             thr.Errors = new Dictionary <string, string>();
             thr.Errors.Add("Code", "SalaryItem dengan Code ini sudah ada");
             return(thr);
         }
         salaryItem = _salaryItemService.CreateObject(thr.Code, thr.Name, (int)Constant.SalarySign.Income, (int)Constant.SalaryItemType.THR, (int)Constant.SalaryItemStatus.Monthly, thr.IsMainSalary, thr.IsDetailSalary, false);
         if (salaryItem == null)
         {
             thr.Errors = new Dictionary <string, string>();
             thr.Errors.Add("Code", "Tidak dapat membuat SalaryItem dengan Code ini");
             return(thr);
         }
         thr.SalaryItemId = salaryItem.Id;
         _repository.CreateObject(thr);
     }
     return(thr);
 }