Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @CommandHandler
- def on( command: AddCATPayablesCommand): ResultOfAddingPayablesDto = {
- command.filesForLanguageCombinations.flatMap { case (languageCombination, fileId) =>
- fileContentRepository.fileContentDTOById(fileId) match {
- case Some(fileDto) => fileViewModelDao.findById(fileId).map(_.name) match {
- case Some(fileName) => command.financeType match {
- case FullCATAnalysisFinanceTypeDto =>
- command.jobAssignmentIds
- .filter(jobAssignmentQueryService.jobAssignmentLanguages(_) contains languageCombination)
- .map { jobAssignmentId =>
- payablesService.addCATPayable(
- languageCombination,
- jobAssignmentId,
- fileName,
- fileDto,
- command.calculationUnitId,
- command.selectedPriceProfileOriginForPayables)
- }
- case TotalQuantityFinanceTypeDto => command.jobAssignmentIds.map { jobAssignmentId =>
- payablesService.addPayable(
- languageCombination,
- jobAssignmentId,
- fileName,
- fileDto,
- command.calculationUnitId,
- command.selectedPriceProfileOriginForPayables)
- }
- }
- case None => {
- log.error(s"Skipping file with fileId = $fileId because file view model was not found")
- Seq.empty
- }
- }
- case None => {
- log.error(s"Skipping file with fileId = $fileId because content was not found")
- Seq.empty
- }
- }
- }.foldLeft(ResultOfAddingPayablesDto.empty) { (result, item) =>
- result.withAnotherResult(item)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement