public List <Paystub> GetPaystubs(DateTime date) { var paystubs = new List <Paystub>(); var timesheets = _timesheetRepository.GetTimesheetsForLastTwoWeeks(date); var timesheetsByEmployee = timesheets.GroupBy(t => t.EmployeeId); foreach (var employeesTimesheets in timesheetsByEmployee) { var employee = _employeeRepository.Get(employeesTimesheets.First().EmployeeId); var employeeState = employee.State; var employeePayRate = employee.HourlyRate; var calculator = new OvertimeCalculatorFactory().GetCalculator(employeeState); // This was clean until I split these up into weeks. Clean this up? var firstWeekTimesheets = employeesTimesheets .Select(t => t) .Where(d => d.Date >= date.AddDays(-6) && d.Date <= date); var secondWeekTimesheets = employeesTimesheets .Select(t => t) .Where(d => d.Date >= date.AddDays(-13) && d.Date <= date.AddDays(-7)); var firstDto = calculator.CalculatePay(firstWeekTimesheets.Select(t => t), employeePayRate); var secondDto = calculator.CalculatePay(secondWeekTimesheets.Select(t => t), employeePayRate); var dto = new PayDto(firstDto.RegularHoursWorked + secondDto.RegularHoursWorked, firstDto.OvertimeHoursWorked + secondDto.OvertimeHoursWorked, firstDto.RegularPay + secondDto.RegularPay, firstDto.OvertimePay + secondDto.OvertimePay); var paystub = new Paystub(employee, date.AddDays(-13), date, dto); paystubs.Add(paystub); } return(paystubs); }
public virtual async Task <PaymentDto> PayAsync(PayDto input) { var payment = await _repository.GetAsync(input.PaymentId); var configurations = await GetPayeeConfigurationsAsync(payment); foreach (var property in input.ExtraProperties) { configurations.AddIfNotContains(new KeyValuePair <string, object>(property.Key, property.Value)); } await _paymentManager.StartPaymentAsync(payment, configurations); return(MapToGetOutputDto(payment)); }
public async Task <IActionResult> Pay([FromBody] PayDto dto) { var paymentIntentService = new PaymentIntentService(); PaymentIntent paymentIntent = null; try { if (dto.ConfirmPaymentRequest.PaymentMethodId != null) { var createOptions = new PaymentIntentCreateOptions { PaymentMethod = dto.ConfirmPaymentRequest.PaymentMethodId, Amount = (int)(dto.Amount * 100), Currency = "usd", ConfirmationMethod = "manual", Confirm = true }; if (!string.IsNullOrEmpty(dto.ConfirmPaymentRequest.CustomerId)) { createOptions.Customer = dto.ConfirmPaymentRequest.CustomerId; } paymentIntent = await paymentIntentService.CreateAsync(createOptions); } if (dto.ConfirmPaymentRequest.PaymentIntentId != null) { var confirmOptions = new PaymentIntentConfirmOptions { }; paymentIntent = await paymentIntentService.ConfirmAsync( dto.ConfirmPaymentRequest.PaymentIntentId, confirmOptions ); } } catch (StripeException e) { return(BadRequest(new { error = e.StripeError.Message })); } return(GeneratePaymentResponse(paymentIntent)); }
public IDataResult <bool> Pay(PayDto pay) { if (rentalService.IsRentCheck(new Rental { CarId = pay.CarId, RentDate = pay.RentDate, ReturnDate = pay.ReturnDate })) { var car = carService.GetById(pay.CarId); var day = pay.ReturnDate - pay.RentDate; var totlDays = day.TotalDays == 0 ? 1 : day.TotalDays; if (((decimal)totlDays * car.Data.DailyPrice) != pay.AmountPay) { return(new SuccessDataResult <bool>(false)); } Add(new CreditCard { CardNumber = pay.CardNumber, CVV = pay.CVV, ExpirationDate = pay.ExpirationDate, NameOnTheCard = pay.NameOnTheCard }); return(new SuccessDataResult <bool>(true)); } return(new ErrorDataResult <bool>(false)); }
public Task <PaymentDto> PayAsync(PayDto input) { return(_service.PayAsync(input)); }
public IActionResult Add(PayDto pay) { var result = _creditCardService.Pay(pay); return(Ok(result)); }