@Test public void calculateRevenueRecognitions() { long contractId = 0; recognitionService.calculateRevenueRecognitions(contractId); }
public void calculateRevenueRecognitions(long contractId) { Contract contract = contractRepository.find(contractId); if (contract.getType().equals("S")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(90)); } else if (contract.getType().equals("W")) { recognitionRepository.insert(contractId, contract.getRevenue(), contract.getDateSigned()); } else if (contract.getType().equals("D")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(30)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); } }
RecognitionService { public void calculateRevenueRecognitions(long contractId) { Contract contract = contractRepository.find(contractId); if (contract.getType().equals("S")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(90)); } else if (contract.getType().equals("W")) { recognitionRepository.insert(contractId, contract.getRevenue(), contract.getDateSigned()); } else if (contract.getType().equals("D")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(30)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); } } }
RecognitionService { public void calculateRevenueRecognitions(long contractId) { Contract contract = contractRepository.find(contractId); if (contract.getType().equals("S")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(90)); } else if (contract.getType().equals("W")) { recognitionRepository.insert(contractId, contract.getRevenue(), contract.getDateSigned()); } else if (contract.getType().equals("D")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(30)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); } }  }
RecognitionService { public void calculateRevenueRecognitions(long contractId) { Contract contract = contractRepository.find(contractId); if (contract.getType().equals("S")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(90)); } else if (contract.getType().equals("W")) { recognitionRepository.insert(contractId, contract.getRevenue(), contract.getDateSigned()); } else if (contract.getType().equals("D")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(30)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); } }  BigDecimal recognizedRevenue(long contractId, LocalDate asOf); void calculateRevenueRecognitions(long contractId); }
RecognitionService { public void calculateRevenueRecognitions(long contractId) { Contract contract = contractRepository.find(contractId); if (contract.getType().equals("S")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(90)); } else if (contract.getType().equals("W")) { recognitionRepository.insert(contractId, contract.getRevenue(), contract.getDateSigned()); } else if (contract.getType().equals("D")) { BigDecimal times = new BigDecimal(3); BigDecimal everyTimeRevenue = contract.getRevenue().divide(times, 2, BigDecimal.ROUND_HALF_UP); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned()); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(30)); recognitionRepository.insert(contractId, everyTimeRevenue, contract.getDateSigned().plusDays(60)); } }  BigDecimal recognizedRevenue(long contractId, LocalDate asOf); void calculateRevenueRecognitions(long contractId);  }