Пример #1
0
        public async Task <Result <SaveEmpMonthlyEnteredRecordResponse> > Save(SaveEmpMonthlyEnteredRecordRequest request)
        {
            if (request == null)
            {
                _logger.LogError(Errors.EmpMonthlyEnteredRecord.SaveRecordRequestModelNullError.Message);
                return(Errors.EmpMonthlyEnteredRecord.SaveRecordRequestModelNullError);
            }

            var result = await Mediator.Send(request);

            return(result);
        }
Пример #2
0
        public async Task <Result <SaveEmpMonthlyEnteredRecordResponse> > Handle(
            SaveEmpMonthlyEnteredRecordRequest request,
            CancellationToken cancellationToken)
        {
            var record = request.Records.Count == 0
                                ? await _empMonthlyEnteredRecordRepo.DeleteAsync(request.Key, request.YearMonth)
                                : await _empMonthlyEnteredRecordRepo.SaveAsync(records : request.Records.Select(x =>
            {
                var currency = new Currency(x.Currency);
                return(new EmployeeMonthlyEnteredRecord(
                           fullname: x.Fullname,
                           email: x.Email,
                           grossContractSalary: new GrossContractedSalary(new Money(x.GrossContractSalary, currency)),
                           probationGrossContractSalary: new GrossContractedSalary(new Money(x.ProbationGrossContractSalary, currency)),
                           actualWorkingDays: x.ActualWorkingDays,
                           probationWorkingDays: x.ProbationWorkingDays,
                           taxableAnnualLeave: new TaxableAllowance(name: Constants.TAXABLE_ANNUAL_LEAVE,
                                                                    amount: new Money(x.TaxableAnnualLeave, currency)),
                           taxable13MonthSalary: new TaxableAllowance(name: Constants.TAXABLE_13MONTH_SALARY,
                                                                      amount: new Money(x.Taxable13MonthSalary, currency)),
                           taxableOthers: new TaxableAllowance(name: Constants.TAXABLE_OTHERS,
                                                               amount: new Money(x.TaxableOthers, currency)),
                           nonTaxableAllowances: new NonTaxableAllowance[] { new NonTaxableAllowance(
                                                                                 amount: new Money(x.NonTaxableAllowance, currency),
                                                                                 name: Constants.NON_TAXABLE_ALLOWANCE) },
                           paymentAdvance: new PaymentAdvance(new Money(x.PaymentAdvance, currency)),
                           adjustmentAdditions: new AdjustmentAddition[] { new AdjustmentAddition(
                                                                               amount: new Money(x.AdjustmentAddition, currency)) },
                           adjustmentDeductions: new AdjustmentDeduction[] { new AdjustmentDeduction(
                                                                                 amount: new Money(x.AdjustmentDeduction, currency)) }
                           ));
            }).ToList(), yearMonth : request.YearMonth, key : request.Key, request.StandardWorkingDays);

            var markResult = await _empMonthlySalaryRepo.MarkNotLatestAsync(request.YearMonth);

            return(record.Map(() => markResult).Map(x => new SaveEmpMonthlyEnteredRecordResponse()));
        }