16 package emlab.gen.role.investment;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.beans.factory.annotation.Configurable;
20 import org.springframework.data.annotation.Transient;
21 import org.springframework.data.neo4j.annotation.NodeEntity;
22 import org.springframework.transaction.annotation.Transactional;
53 long futureTimePoint = getCurrentTick()+pgt.getExpectedLeadtime()+pgt.getExpectedPermittime();
54 double expectedInstalledCapacity = reps.powerPlantRepository.calculateCapacityOfExpectedOperationalPowerPlantsInMarketAndTechnology(targetInvestor.getInvestorMarket(), pgt, futureTimePoint);
55 double pgtNodeLimit = Double.MAX_VALUE;
59 .findOneByTechnologyAndMarket(pgt, targetInvestor.getInvestorMarket());
60 if (pgtLimit != null) {
61 pgtNodeLimit = pgtLimit.getUpperCapacityLimit(futureTimePoint);
63 double targetCapacity = target.getTrend().getValue(futureTimePoint);
64 double installedCapacityDeviation = 0;
65 if (pgtNodeLimit > targetCapacity) {
66 installedCapacityDeviation = targetCapacity - expectedInstalledCapacity;
68 installedCapacityDeviation = pgtNodeLimit - expectedInstalledCapacity;
71 if (installedCapacityDeviation > 0 && installedCapacityDeviation > pgt.getCapacity()) {
73 double powerPlantCapacityRatio = installedCapacityDeviation/pgt.getCapacity();
76 plant.specifyNotPersist(getCurrentTick(), targetInvestor, reps.powerGridNodeRepository.findFirstPowerGridNodeByElectricitySpotMarket(targetInvestor.getInvestorMarket()), pgt);
77 plant.setActualNominalCapacity(pgt.getCapacity()*powerPlantCapacityRatio);
79 BigBank bigbank = reps.genericRepository.findFirst(BigBank.class);
81 double investmentCostPayedByEquity = plant.getActualInvestedCapital() * (1 - targetInvestor.getDebtRatioOfInvestments())*powerPlantCapacityRatio;
82 double investmentCostPayedByDebt = plant.getActualInvestedCapital() * targetInvestor.getDebtRatioOfInvestments()*powerPlantCapacityRatio;
83 double downPayment = investmentCostPayedByEquity;
84 createSpreadOutDownPayments(targetInvestor, manufacturer, downPayment, plant);
86 double amount = determineLoanAnnuities(investmentCostPayedByDebt, plant.getTechnology().getDepreciationTime(),
87 targetInvestor.getLoanInterestRate());
89 Loan loan = reps.loanRepository.createLoan(targetInvestor, bigbank, amount, plant.getTechnology().getDepreciationTime(),
90 getCurrentTick(), plant);
92 plant.createOrUpdateLoan(loan);
101 int buildingTime = (int) plant.getActualLeadtime();
102 for (
int i = 0; i < buildingTime; i++) {
103 reps.nonTransactionalCreateRepository.createCashFlow(agent, manufacturer, totalDownPayment / buildingTime,
104 CashFlow.DOWNPAYMENT, getCurrentTick() + i, plant);
109 public double determineLoanAnnuities(
double totalLoan,
double payBackTime,
double interestRate) {
111 double q = 1 + interestRate;
112 double annuity = totalLoan * (Math.pow(q, payBackTime) * (q - 1)) / (Math.pow(q, payBackTime) - 1);