Exemplo n.º 1
0
        public ActionResult GetEmployeeSalaryMonth(string SalaryMonth)
        {
            try
            {
                if (null == SalaryMonth || "".Equals(SalaryMonth))
                {
                    ModelState.AddModelError(string.Empty, "年月を入力ください");
                    TempData["ViewData"] = ViewData;
                    return(RedirectToAction("Index"));
                }
                TempData["SalaryMonth"] = SalaryMonth;
                EmployeeLoginOutput sessionEmployee = (EmployeeLoginOutput)Session["employee"];
                string        employeeId            = sessionEmployee.Id;
                SalaryService salaryService         = new SalaryService();

                EmployeeSearchSalaryOutput employeeSearchSalaryOutput = salaryService.getSalaryDetailEmployee(employeeId, SalaryMonth);
                if (employeeSearchSalaryOutput == null)
                {
                    ModelState.AddModelError(string.Empty, "当月、給料明細書まだアップロードされません");
                    TempData["ViewData"] = ViewData;
                    return(RedirectToAction("Index"));
                }
                TempData["SalaryDetailFilePath"] = employeeSearchSalaryOutput.SalaryDetailFilePath;
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                TempData["ViewData"] = ViewData;
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public ActionResult UploadSalary(HttpPostedFileBase SalaryDetailZipFile, string SalaryMonth)
 {
     try
     {
         if (SalaryDetailZipFile == null)
         {
             ModelState.AddModelError(string.Empty, "Zipfileアップロードください");
             return(SearchSalary(SalaryMonth));
         }
         string salaryDetailFileExtension = Path.GetExtension(SalaryDetailZipFile.FileName);
         if (!salaryDetailFileExtension.Equals(".zip"))
         {
             ModelState.AddModelError(string.Empty, "Zipfileアップロードください");
             return(SearchSalary(SalaryMonth));
         }
         SalaryService salaryService = new SalaryService();
         salaryService.uploadSalaryDetailZipFiles(SalaryMonth, SalaryDetailZipFile);
         TempData["SuccessMessage"] = "アップロード成功";
         return(SearchSalary(SalaryMonth));
     }catch (Exception e)
     {
         ModelState.AddModelError(string.Empty, e.Message);
         return(SearchSalary(SalaryMonth));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SalaryServiceTests"/> class.
        /// </summary>
        public SalaryServiceTests()
        {
            _taxCalculatorFactory = Mock.Of <ITaxCalculatorFactory>();
            AppConfig appConfig = AppConfigProvider.AppConfig;

            _service = new SalaryService(_taxCalculatorFactory, appConfig);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (tid.Text == string.Empty)
            {
                MessageBox.Show("please fillup the Id");
            }
            else
            {
                SalaryService SalService = new SalaryService();
                string        month      = tdate.Value.Month.ToString();
                string        year       = tyear.Value.Year.ToString();

                List <Salary> list = new List <Salary>();
                Salary        ss   = SalService.GetById(Convert.ToInt16(tid.Text), month, year);

                if (ss != null)
                {
                    list.Add(ss);
                    dataGridView1.DataSource = list;
                    tname.Text = list[0].Name;
                }
                else
                {
                    MessageBox.Show("Id not found");
                }


                // string s=list[0].Name;
            }
        }
Exemplo n.º 5
0
        public void GetSalaryByEmployeeId_ThrowException_WhenEmployeeNotFound()
        {
            //Arrange
            var employee = new Employee()
            {
                Id       = 1,
                SalaryId = 2
            };

            List <Employee> lstEmp = new List <Employee>();

            _actionFactoryMock     = new Mock <IActionFactory>();
            _repositoryFactoryMock = new Mock <IRepositoryFactory>();
            HelperSer = new Mock <HelperSer>();


            _actionFactoryMock.Setup(action => action.EmployeeService.GetAllEmployees()).Returns(lstEmp);

            SalaryService = new SalaryService(_actionFactoryMock.Object, _repositoryFactoryMock.Object, HelperSer.Object);

            //Act
            SalaryService.GetSalaryByEmployeeId(employee.Id);

            //Assert
            _actionFactoryMock.Verify(action => action.EmployeeService.GetAllEmployees(), Times.Once);
        }
Exemplo n.º 6
0
        // 以員工ID搜尋支付資料
        public SalaryPresentationModel SearchDataByEmplID()
        {
            SalaryPresentationModel salaryPresentationModel = new SalaryPresentationModel();

            if (this._salaryModel.getEmplID() == null || this._salaryModel.getEmplID() == "")
            {
                MessageBox.Show("請輸入員工ID");
            }
            else
            {
                //MessageBox.Show("yes");
                _salaryService = new SalaryService(this._salaryModel);
                _salaryModel   = _salaryService.searchByEmplID();

                salaryPresentationModel.setEmplID(_salaryModel.getEmplID());
                salaryPresentationModel.setPayway(_salaryModel.getPayway());
                salaryPresentationModel.setAccountData(_salaryModel.getAccountData());

                if (_salaryModel.getPayway() == null || _salaryModel.getPayway() == "")
                {
                    MessageBox.Show("此員工ID不存在!");
                    //MessageBox.Show(_authoModel.GetAuthoID());
                    salaryPresentationModel.setEmplID(null);
                }
            }
            return(salaryPresentationModel);
        }
Exemplo n.º 7
0
        // 呼叫service將資料新增至資料庫
        public void AddPayway()
        {
            this._salaryService = new SalaryService(_salaryModel);
            //SalaryPresentationModel salaryPresentationModel = new SalaryPresentationModel();
            int errorFlag = 0;

            if (this._salaryModel.getEmplID() == "" || (this._salaryModel.getPayway() == "Transfer" && this._salaryModel.getAccountData() == ""))
            {
                MessageBox.Show("尚有重要資料欄位為空白, 請重新確認");
                errorFlag = 1;
            }
            if (errorFlag == 1)
            {
                return;
            }

            if (_salaryService.addPayway())
            {
                MessageBox.Show("新增成功!");
            }
            else
            {
                MessageBox.Show("資料庫內已有該員工支付資料");
            }
        }
Exemplo n.º 8
0
 public ActionResult UploadSalaryDetailFile(string SalaryMonth, HttpPostedFileBase SalaryDetailFile)
 {
     try
     {
         if (SalaryDetailFile == null)
         {
             ModelState.AddModelError(string.Empty, "PDFfileアップロードください");
             TempData["ViewData"] = ViewData;
             return(RedirectToAction("SalaryUploadView"));
         }
         string salaryDetailFileExtension = Path.GetExtension(SalaryDetailFile.FileName);
         if (!salaryDetailFileExtension.Equals(".pdf"))
         {
             ModelState.AddModelError(string.Empty, "PDFfileアップロードください");
             TempData["ViewData"] = ViewData;
             return(RedirectToAction("SalaryUploadView"));
         }
         SalaryService salaryService  = new SalaryService();
         string        salaryFileName = salaryService.uploadSalaryDetailFile(SalaryMonth, SalaryDetailFile);
         TempData["SuccessMessage"] = "アップロード成功";
         return(RedirectToAction("SalaryUploadView"));
     }
     catch (Exception e)
     {
         ModelState.AddModelError(string.Empty, e.Message);
         TempData["ViewData"] = ViewData;
         return(RedirectToAction("SalaryUploadView"));
     }
 }
Exemplo n.º 9
0
 public UnitTest1()
 {
     _mockRate = new Mock <IInflationRate>(MockBehavior.Loose);
     _mockLog  = new Mock <ILog>(MockBehavior.Loose);
     //  _inflation = new InflationRate();
     //_inflationService = new InflationService(_inflation);
     _salaryService = new SalaryService(_mockRate.Object, _mockLog.Object);
     // sana sahte bir nesne verdim demiş oldum.
 }
        public void CalculateSalary_ShouldReturnCorrectValue_WithFreeOfTaxInput()
        {
            var grossSalary     = 1000m;
            var mockTaxServices = new Mock <List <ITaxCalculator> >();
            var sut             = new SalaryService(mockTaxServices.Object);

            var result = sut.CalculateNetSalary(grossSalary);

            Assert.AreEqual(grossSalary, result);
        }
Exemplo n.º 11
0
        public ActionResult SearchSalary(string SalaryMonth)
        {
            Session["SalaryMonth"] = SalaryMonth;
            SalaryService     salaryService = new SalaryService();
            List <SalaryView> salarys       = salaryService.getSalaryByMonth(SalaryMonth);

            TempData["salarys"]     = salarys;
            TempData["salaryMonth"] = SalaryMonth;
            TempData["ViewData"]    = ViewData;
            return(RedirectToAction("Index"));
        }
Exemplo n.º 12
0
 // 呼叫service, 將資料更新至資料庫
 public Boolean editPayway()
 {
     this._salaryService = new SalaryService(this._salaryModel);
     if (_salaryService.EditPayway())
     {
         MessageBox.Show("修改成功");
     }
     else
     {
         MessageBox.Show("修改失敗");
         return(false);
     }
     return(true);
 }
Exemplo n.º 13
0
        // 取得該員工薪水支付方式
        private List <String> GetEmplSalaryPayWay(String emplID)
        {
            List <String> salaryPayWayData = new List <String>();

            SalaryModel salaryModel = new SalaryModel();

            salaryModel.setEmplID(emplID);
            SalaryService salaryService = new SalaryService(salaryModel);

            salaryModel = salaryService.searchByEmplID();

            salaryPayWayData.Add(salaryModel.getPayway());
            salaryPayWayData.Add(salaryModel.getAccountData());

            return(salaryPayWayData);
        }
Exemplo n.º 14
0
        public async Task GetServiceStatusAsync(bool returnValidHttpStatusCode, bool returnValidJobProfileSalary, ServiceState expectedServiceStatus)
        {
            //Arrange
            var applicationLogger = A.Fake <IApplicationLogger>(ops => ops.Strict());
            var clientProxy       = A.Fake <IAsheHttpClientProxy>(ops => ops.Strict());

            JobProfileSalary dummyJobProfileSalary = null;

            if (returnValidJobProfileSalary)
            {
                dummyJobProfileSalary = new JobProfileSalary()
                {
                    Median = 580, Deciles = new Dictionary <int, decimal>()
                    {
                        { 10, 540 }
                    }
                };
            }

            HttpStatusCode returnHttpStatusCode;

            if (returnValidHttpStatusCode)
            {
                returnHttpStatusCode = HttpStatusCode.OK;
            }
            else
            {
                returnHttpStatusCode = HttpStatusCode.BadRequest;
            }

            var httpResponseMessage = new HttpResponseMessage {
                StatusCode = returnHttpStatusCode, Content = new StringContent(JsonConvert.SerializeObject(dummyJobProfileSalary), Encoding.UTF8, "application/json")
            };

            A.CallTo(() => clientProxy.EstimatePayMdAsync(A <string> ._)).Returns(httpResponseMessage);
            A.CallTo(() => applicationLogger.Warn(A <string> ._)).DoesNothing();
            A.CallTo(() => applicationLogger.ErrorJustLogIt(A <string> ._, A <Exception> ._)).DoesNothing();

            //Act
            IServiceStatus lmiFeed       = new SalaryService(applicationLogger, clientProxy);
            var            serviceStatus = await lmiFeed.GetCurrentStatusAsync();

            //Assert
            A.CallTo(() => clientProxy.EstimatePayMdAsync(A <string> ._)).MustHaveHappened();

            serviceStatus.Status.Should().Be(expectedServiceStatus);
        }
Exemplo n.º 15
0
        public void CalculateTax_ShouldReturn_Correct()
        {
            var grossSalary    = 3400m;
            var expectedResult = 540m;

            var servicesCollection = new List <ITaxCalculator>
            {
                new SocialTaxService(),
                new IncomeTaxService()
            };

            var salaryService = new SalaryService(servicesCollection);

            var result = salaryService.CalculateTaxes(grossSalary);

            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 16
0
        public void IsFreeOfTax_ShouldReturn_Correct_False()
        {
            var grossSalary    = 1000.1m;
            var expectedResult = false;

            var servicesCollection = new List <ITaxCalculator>
            {
                new SocialTaxService(),
                new IncomeTaxService()
            };

            var salaryService = new SalaryService(servicesCollection);

            var result = salaryService.IsFreeOfTax(grossSalary);

            Assert.AreEqual(expectedResult, result);
        }
        public void CalculateSalary_ShouldReturnCorrectValue_WithAboveFreeOfTax()
        {
            var expectedResult   = 2860m;
            var grossSalaryAbove = 3400m;

            var mockIncomeTaxService = new Mock <IncomeTaxService>();
            var mockSocialTaxService = new Mock <SocialTaxService>();
            var taxServices          = new List <ITaxCalculator>
            {
                mockIncomeTaxService.Object,
                mockSocialTaxService.Object
            };

            var sut    = new SalaryService(taxServices);
            var result = sut.CalculateNetSalary(grossSalaryAbove);

            Assert.AreEqual(expectedResult, result);
        }
        public void IsFreeOfTax_ShouldReturn_True()
        {
            var grossFreeOfTax = 1000m;
            var expectedResult = true;

            var mockIncomeTaxService = new Mock <IncomeTaxService>();
            var mockSocialTaxService = new Mock <SocialTaxService>();
            var taxServices          = new List <ITaxCalculator>
            {
                mockIncomeTaxService.Object,
                mockSocialTaxService.Object
            };

            var sut    = new SalaryService(taxServices);
            var result = sut.IsFreeOfTax(grossFreeOfTax);

            Assert.AreEqual(expectedResult, result);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (tid.Text == string.Empty || tname.Text == string.Empty || tpay.Text == string.Empty)
            {
                MessageBox.Show("please Fillup All The Fields");
            }
            else
            {
                SalaryService SalService = new SalaryService();
                string        month      = tdate.Value.Month.ToString();
                string        year       = tyear.Value.Year.ToString();

                Salary s = SalService.GetById(Convert.ToInt16(tid.Text), month, year);

                if (s != null)
                {
                    if (Double.Parse(tpay.Text) > s.Remain_salary)
                    {
                        MessageBox.Show("input payment is greater than remaining salary.");
                    }
                    else
                    {
                        s.Pay           = Double.Parse(tpay.Text);
                        s.Remain_salary = s.Remain_salary - Double.Parse(tpay.Text);

                        int result = SalService.Update(s);
                        if (result > 0)
                        {
                            MessageBox.Show("salary updated.");
                            UpdateGridView();
                        }
                        else
                        {
                            MessageBox.Show("Error");
                        }
                    }
                    UpdateGridView();
                }
                else
                {
                    MessageBox.Show("id not found");
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// The primary button control that generates the salary breakdown in a display grid.
        /// 1) It checks whether the salary input is not empty, populates a model called employeedetails with the values associated with the employee.
        /// 2) Collects the addition and the deduction components that the user has added from the UI(form) in userAdditionComponents and userDeductionComponents lists respectively.
        /// 3) The method ComputeRules() computes the static components from the web.config and dynamic components from the form input on the salary input and stores them.
        /// 4) The method PopulateGrid() is responsible for filling the display grid with the calculated components (salary Breakdown) that is displayed to the user.
        /// 5) The method CollectTemplateData() is responsible for preparing the html template that will be sent to the employee. Values which are
        /// to be added to the template are represented by placeholders which are replaced with the actual values in the method flow.
        /// 6)The method SendTemplateData() is responsible for creating a pdf from the html template and setting up the smtp mail parameters to
        /// deliver the salary slip in pdf format to the employee.
        /// 7) The method DeleteSalarySlips() is responsible for deleting the salary slips from the local store as soon as the mail is delivered
        /// to the employee.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void generateButton_Click(object sender, EventArgs e)
        {
            ICollection <Rules> userAdditionComponents  = null;
            ICollection <Rules> userDeductionComponents = null;

            if (salary.Text.ToString() != string.Empty)
            {
                decimal         salaryAmount    = Convert.ToDecimal(salary.Text);
                ISalaryService  salaryService   = new SalaryService();
                EmployeeDetails employeeDetails = new EmployeeDetails();
                employeeDetails.EmployeeName  = requiredName.Text.ToString();
                employeeDetails.DateOfJoining = dateOfJoining.Text.ToString();
                employeeDetails.PanNumber     = pan.Text.ToString();
                employeeDetails.AccountNumber = accountNumber.Text.ToString();
                employeeDetails.Designation   = designation.Text.ToString();
                employeeDetails.Salary        = salary.Text.ToString();
                employeeDetails.EmailId       = email.Text.ToString();
                employeeDetails.Month         = month.SelectedItem.ToString();
                employeeDetails.Year          = year.SelectedItem.ToString();

                if (addComponentNumber.Text != string.Empty)
                {
                    List <Rules> userRules = new List <Rules>();
                    userRules = SegregateComponents(addComponentNumber, ComputationVariety.ADDITION, userRules);
                    userAdditionComponents = FetchUserComponents(addOuterPanel.Controls, ComputationVariety.ADDITION, userRules);
                }
                if (deductComponentNumber.Text != string.Empty)
                {
                    List <Rules> userRules = new List <Rules>();
                    userRules = SegregateComponents(deductComponentNumber, ComputationVariety.SUBTRACTION, userRules);
                    userDeductionComponents = FetchUserComponents(deductOuterPanel.Controls, ComputationVariety.SUBTRACTION, userRules);
                }

                ICollection <Rules> computedRules = salaryService.ComputeRules(salaryAmount, userAdditionComponents, userDeductionComponents);
                ICollection <Rules> finalResults  = PopulateGrid(computedRules, userAdditionComponents, userDeductionComponents);
                string templateContent            = salaryService.CollectTemplateData(employeeDetails, finalResults);

                string pdfPath = salaryService.SendTemplate(employeeDetails, templateContent);
                salaryService.DeleteSalarySlips(pdfPath);
                //Mail Content;
            }
        }
        private void b_Add_Click(object sender, EventArgs e)
        {
            if (tid.Text == string.Empty || tname.Text == string.Empty || tpay.Text == string.Empty || tsalary.Text == string.Empty)
            {
                MessageBox.Show("Please Fillup all the text fields!!");
            }
            else
            {
                if (Double.Parse(tpay.Text) <= Double.Parse(tsalary.Text))
                {
                    double x = Double.Parse(tsalary.Text) - Double.Parse(tpay.Text);
                    lAmount.Text = x.ToString();



                    SalaryService sal    = new SalaryService();
                    int           result = sal.Insert(new Salary()
                    {
                        Eid           = Convert.ToInt16(tid.Text),
                        Name          = tname.Text,
                        Month         = dateTimePicker1.Value.Month.ToString(),
                        Pay           = Double.Parse(tpay.Text),
                        Total_Salary  = Double.Parse(tsalary.Text),
                        Remain_salary = x,
                        Year          = tyear.Value.Year.ToString()
                    });
                    if (result > 0)
                    {
                        MessageBox.Show("Salary added.");
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
                else
                {
                    MessageBox.Show("Payment is greater than total salary ");
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 薪资发放日提醒定时生成触发
        /// </summary>
        /// <param name="eGFunc"></param>
        private void SalarySolutionRemindTrigger(IEnumerable <XElement> eGFunc)
        {
            if (eGFunc.Count() == 0)
            {
                return;
            }

            string strAttendSolAsignId = string.Empty;

            foreach (var item in eGFunc)
            {
                if (item.Attribute("Name").Value == "SALARYSOLUTIONID")
                {
                    strAttendSolAsignId = item.Attribute("Value").Value;
                    break;
                }
            }
            SalaryService svcSalarySol = new SalaryService();

            svcSalarySol.TimingPay(svcSalarySol.GetSalarySolutionByID(strAttendSolAsignId));
        }
Exemplo n.º 23
0
        public void GetMedianDecileFromAsheFeed(string jobProfileForAsheFeed, string expectedSocCode)
        {
            //Arrange
            var applicationLogger = A.Fake <IApplicationLogger>(ops => ops.Strict());
            var clientProxy       = A.Fake <IAsheHttpClientProxy>(ops => ops.Strict());

            //Act
            var httpResponseMessage = new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            };

            A.CallTo(() => clientProxy.EstimatePayMdAsync(A <string> ._)).Returns(httpResponseMessage);
            A.CallTo(() => applicationLogger.Warn(A <string> ._)).DoesNothing();
            A.CallTo(() => applicationLogger.ErrorJustLogIt(A <string> ._, A <Exception> ._)).DoesNothing();
            ISalaryService lmiFeed = new SalaryService(applicationLogger, clientProxy);

            //Assert
            var response = lmiFeed.GetSalaryBySocAsync(jobProfileForAsheFeed);

            A.CallTo(() => clientProxy.EstimatePayMdAsync(A <string> .That.IsEqualTo(expectedSocCode))).MustHaveHappened();
            response.Result.Should().Be(null);
        }
Exemplo n.º 24
0
        public void GetSalaryByEmployeeIdAndCalulateGrossSalary()
        {
            //Arrange
            var salary = new Salary()
            {
                Incentives = 20_0,
                Basic      = 30_0,
                Bonus      = 10_0,
            };
            var employee = new Employee()
            {
                Id       = 1,
                SalaryId = 2
            };

            List <Employee> lstEmp = new List <Employee>
            {
                employee
            };

            _actionFactoryMock     = new Mock <IActionFactory>();     //Interface mocking
            _repositoryFactoryMock = new Mock <IRepositoryFactory>(); //Interface mocking
            HelperSer = new Mock <HelperSer>();                       //class mocking

            _actionFactoryMock.Setup(action => action.EmployeeService.GetAllEmployees()).Returns(lstEmp);

            _repositoryFactoryMock.Setup(repo => repo.GetRepository <Salary>().GetById(It.IsAny <int>())).Returns(salary);

            SalaryService = new SalaryService(_actionFactoryMock.Object, _repositoryFactoryMock.Object, HelperSer.Object);

            //Act
            SalaryService.GetSalaryByEmployeeId(employee.Id);

            //Assert
            _actionFactoryMock.Verify(action => action.EmployeeService.GetAllEmployees(), Times.Once);
            _repositoryFactoryMock.Verify(x => x.GetRepository <Salary>().GetById(employee.SalaryId), Times.Once);
            Assert.AreEqual(salary.GrossSalary, 600);
        }
Exemplo n.º 25
0
        public async Task GetServiceStatusExceptionAsync()
        {
            //Arrange
            var applicationLogger = A.Fake <IApplicationLogger>(ops => ops.Strict());
            var clientProxy       = A.Fake <IAsheHttpClientProxy>(ops => ops.Strict());

            //add no content to cause an exception
            var httpResponseMessage = new HttpResponseMessage();

            A.CallTo(() => clientProxy.EstimatePayMdAsync(A <string> ._)).Returns(httpResponseMessage);
            A.CallTo(() => applicationLogger.Warn(A <string> ._)).DoesNothing();
            A.CallTo(() => applicationLogger.LogExceptionWithActivityId(A <string> ._, A <Exception> ._)).Returns("Exception logged");

            //Act
            IServiceStatus lmiFeed       = new SalaryService(applicationLogger, clientProxy);
            var            serviceStatus = await lmiFeed.GetCurrentStatusAsync();

            A.CallTo(() => clientProxy.EstimatePayMdAsync(A <string> ._)).MustHaveHappened();

            serviceStatus.Status.Should().NotBe(ServiceState.Green);
            serviceStatus.Notes.Should().Contain("Exception");
            A.CallTo(() => applicationLogger.LogExceptionWithActivityId(A <string> ._, A <Exception> ._)).MustHaveHappened();
        }
Exemplo n.º 26
0
        public void AddSalary()
        {
            //Arrange
            var salary = new Salary()
            {
                Basic      = 5000_00,
                Bonus      = 0,
                Incentives = 2000_00
            };

            _repositoryFactoryMock = new Mock <IRepositoryFactory>();
            _actionFactoryMock     = new Mock <IActionFactory>();
            HelperSer = new Mock <HelperSer>();

            _repositoryFactoryMock.Setup(repo => repo.GetRepository <Salary>().Create(It.IsAny <Salary>()))
            .Returns(salary);

            //Act
            SalaryService = new SalaryService(_actionFactoryMock.Object, _repositoryFactoryMock.Object, HelperSer.Object);
            SalaryService.AddSalary(salary);

            //Assert
            _repositoryFactoryMock.Verify(repo => repo.GetRepository <Salary>().Create(salary), Times.Once);
        }
Exemplo n.º 27
0
        public static List <SalaryViewModels> getSalary(short id)
        {
            var schedule = Db.ve_Salary.Select(a => a);

            schedule = schedule.Where(x => x.ID == id);



            List <SalaryViewModels> Salary = new List <SalaryViewModels>();

            foreach (ve_Salary tmp in schedule.ToList())
            {
                SalaryService SC = new SalaryService(new SalaryFormula());

                if (tmp.Category == "主管")
                {
                    SC = new SalaryService(new BossSalaryFormula());
                }

                Salary.Add(new SalaryViewModels
                {
                    ID              = tmp.ID,
                    Name            = tmp.Name,
                    BasicSalary     = tmp.BasicSalary,
                    Category        = tmp.Category,
                    OverOffHours    = tmp.OverOffHours,
                    PrivateOffHours = tmp.PrivateOffHours,
                    WelfareOffHours = tmp.WelfareOffHours,
                    getSalary       = (int)SC.Calculate((int)tmp.BasicSalary, (int)tmp.PrivateOffHours, (int)tmp.OverOffHours)
                });
            }



            return(Salary.ToList());
        }
Exemplo n.º 28
0
 public SalaryController(SalaryServiceImpl salaryService, EmployeeServiceImpl employeeService)
 {
     _salaryService   = salaryService;
     _employeeService = employeeService;
 }
Exemplo n.º 29
0
        /// <summary>
        /// 根据传回的xml生成薪资档案
        /// </summary>
        /// <param name="eGFunc"></param>
        /// <returns></returns>
        private static string AddEmployeeSalaryArchive(IEnumerable <XElement> eGFunc)
        {
            try
            {
                if (eGFunc.Count() == 0)
                {
                    return("");
                }

                string strEmployeeID        = string.Empty;
                string strOwnerID           = string.Empty;
                string strOwnerPostID       = string.Empty;
                string strOwnerDepartmentID = string.Empty;
                string strOwnerCompanyID    = string.Empty;

                foreach (var q in eGFunc)
                {
                    string strName = q.Attribute("Name").Value;
                    switch (strName)
                    {
                    case "EMPLOYEEID":
                        strEmployeeID = q.Attribute("Value").Value;
                        break;

                    case "OWNERID":
                        strOwnerID = q.Attribute("Value").Value;
                        break;

                    case "OWNERPOSTID":
                        strOwnerPostID = q.Attribute("Value").Value;
                        break;

                    case "OWNERDEPARTMENTID":
                        strOwnerDepartmentID = q.Attribute("Value").Value;
                        break;

                    case "OWNERCOMPANYID":
                        strOwnerCompanyID = q.Attribute("Value").Value;
                        break;
                    }
                }


                SalaryService ser = new SalaryService();

                T_HR_SALARYARCHIVE entity = new T_HR_SALARYARCHIVE();
                entity.SALARYARCHIVEID = Guid.NewGuid().ToString();
                entity.EMPLOYEEID      = strEmployeeID.Replace("{", "").Replace("}", "");

                entity.CHECKSTATE         = ((int)CheckStates.UnSubmit).ToString();
                entity.EDITSTATE          = ((int)EditStates.UnActived).ToString();
                entity.CREATEDATE         = DateTime.Now;
                entity.OWNERID            = strOwnerID;
                entity.OWNERPOSTID        = strOwnerPostID;
                entity.OWNERDEPARTMENTID  = strOwnerDepartmentID;
                entity.OWNERCOMPANYID     = strOwnerCompanyID;
                entity.CREATEUSERID       = strOwnerID;
                entity.CREATEPOSTID       = strOwnerPostID;
                entity.CREATEDEPARTMENTID = strOwnerDepartmentID;
                entity.CREATECOMPANYID    = strOwnerCompanyID;
                PersonnelService  ps  = new PersonnelService();
                T_HR_EMPLOYEEPOST emp = ps.GetEmployeePostActivedByEmployeeID(entity.EMPLOYEEID);
                if (emp != null)
                {
                    entity.EMPLOYEECODE = emp.T_HR_EMPLOYEE.EMPLOYEECODE;
                    entity.EMPLOYEENAME = emp.T_HR_EMPLOYEE.EMPLOYEECNAME;

                    entity.OWNERID           = emp.T_HR_EMPLOYEE.EMPLOYEEID;
                    entity.OWNERPOSTID       = emp.T_HR_EMPLOYEE.OWNERPOSTID;
                    entity.OWNERDEPARTMENTID = emp.T_HR_EMPLOYEE.OWNERDEPARTMENTID;
                    entity.OWNERCOMPANYID    = emp.T_HR_EMPLOYEE.OWNERCOMPANYID;
                    entity.POSTLEVEL         = emp.POSTLEVEL;
                    entity.EMPLOYEEPOSTID    = emp.EMPLOYEEPOSTID;
                }
                ser.SalaryArchiveAdd(entity);
                return(entity.SALARYARCHIVEID);
            }
            catch (Exception e)
            {
                string abc = "<HR>Message=[" + e.Message + "]" + "<HR>Source=[" + e.Source + "]<HR>StackTrace=[" + e.StackTrace + "]<HR>TargetSite=[" + e.TargetSite + "]";
                Tracer.Debug(abc);
                return(abc);
            }
        }
 public CustomersController(ApplicationDbContext context, IRepositoryWrapper repo, SalaryService salaryService)
 {
     _context       = context;
     _repo          = repo;
     _salaryService = salaryService;
 }