1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.coeus.s2sgen.impl.budget;
17
18 import org.apache.commons.lang3.StringUtils;
19 import org.kuali.coeus.common.api.person.KcPersonRepositoryService;
20 import org.kuali.coeus.common.api.rolodex.RolodexService;
21 import org.kuali.coeus.common.budget.api.core.BudgetContract;
22 import org.kuali.coeus.common.budget.api.nonpersonnel.BudgetLineItemCalculatedAmountContract;
23 import org.kuali.coeus.common.budget.api.nonpersonnel.BudgetLineItemContract;
24 import org.kuali.coeus.common.budget.api.nonpersonnel.BudgetRateAndBaseContract;
25 import org.kuali.coeus.common.budget.api.period.BudgetPeriodContract;
26 import org.kuali.coeus.common.budget.api.personnel.*;
27 import org.kuali.coeus.common.budget.api.rate.RateClassContract;
28 import org.kuali.coeus.common.api.org.OrganizationRepositoryService;
29 import org.kuali.coeus.common.api.person.KcPersonContract;
30 import org.kuali.coeus.common.budget.api.rate.RateClassType;
31 import org.kuali.coeus.common.budget.api.personnel.BudgetPersonContract;
32 import org.kuali.coeus.common.api.rolodex.RolodexContract;
33 import org.kuali.coeus.propdev.api.budget.ProposalDevelopmentBudgetExtContract;
34 import org.kuali.coeus.propdev.api.budget.modular.BudgetModularIdcContract;
35 import org.kuali.coeus.propdev.api.core.DevelopmentProposalContract;
36 import org.kuali.coeus.propdev.api.location.ProposalSiteContract;
37 import org.kuali.coeus.propdev.api.person.ProposalPersonContract;
38 import org.kuali.coeus.propdev.api.s2s.S2SConfigurationService;
39 import org.kuali.coeus.s2sgen.impl.datetime.S2SDateTimeService;
40 import org.kuali.coeus.s2sgen.impl.person.S2SProposalPersonService;
41 import org.kuali.coeus.s2sgen.impl.util.FieldValueConstants;
42 import org.kuali.coeus.s2sgen.impl.validate.S2SErrorHandlerService;
43 import org.kuali.coeus.propdev.api.core.ProposalDevelopmentDocumentContract;
44 import org.kuali.coeus.sys.api.model.ScaleTwoDecimal;
45 import org.kuali.coeus.s2sgen.api.core.ConfigurationConstants;
46 import org.kuali.coeus.s2sgen.api.core.S2SException;
47 import org.kuali.coeus.common.budget.api.core.category.BudgetCategoryMapContract;
48 import org.kuali.coeus.common.budget.api.core.category.BudgetCategoryMapService;
49 import org.kuali.coeus.common.budget.api.core.category.BudgetCategoryMappingContract;
50 import org.kuali.coeus.common.budget.api.personnel.BudgetPersonSalaryService;
51 import org.kuali.coeus.common.api.sponsor.hierarchy.SponsorHierarchyService;
52
53 import org.springframework.beans.factory.annotation.Autowired;
54 import org.springframework.beans.factory.annotation.Qualifier;
55 import org.springframework.stereotype.Component;
56
57 import java.math.BigDecimal;
58 import java.math.RoundingMode;
59 import java.util.*;
60
61
62
63
64
65
66 @Component("s2SBudgetCalculatorService")
67 public class S2SBudgetCalculatorServiceImpl implements
68 S2SBudgetCalculatorService {
69 public static final String VALUE_UNKNOWN = "Unknown";
70 private static final int MAX_KEY_PERSON_COUNT = 8;
71 private static final String CATEGORY_TYPE_OTHER_DIRECT_COST = "O";
72 private static final String LASALARIES = "LASALARIES";
73 private static final String PERSONNEL_TYPE_GRAD = "Grad";
74 private static final String PERSONNEL_TYPE_POSTDOC = "PostDoc";
75 private static final String PERSONNEL_TYPE_UNDERGRAD = "UnderGrad";
76 private static final String PERSONNEL_TYPE_SEC = "Sec";
77 private static final String PERSONNEL_TYPE_OTHER = "Other";
78 private static final String PERSONNEL_TYPE_OTHER_PROFESSIONALS = "Other Professionals";
79 private static final String PERSONNEL_TYPE_ALLOCATED_ADMIN_SUPPORT = "Allocated Admin Support";
80 private static final String ROLE_GRADUATE_STUDENTS = "Graduate Students";
81 private static final String ROLE_POST_DOCTORAL_ASSOCIATES = "Post Doctoral Associates";
82 private static final String ROLE_GRADUATE_UNDERGRADUATE_STUDENTS = "Undergraduate Students";
83 private static final String ROLE_GRADUATE_SECRETARIAL_OR_CLERICAL = "Secretarial / Clerical";
84 private static final String ROLE_GRADUATE_OTHER = "Other";
85 private static final String ROLE_GRADUATE_OTHER_PROFESSIONALS = "Other Professionals";
86 private static final String ROLE_GRADUATE_ALLOCATED_ADMIN_SUPPORT = "Allocated Admin Support";
87 private static final String TARGET_CATEGORY_CODE_01 = "01";
88 private static final String OTHER_DIRECT_COSTS = "Other Direct Costs";
89 private static final String ALL_OTHER_COSTS = "All Other Costs";
90 private static final String DESCRIPTION = "Description";
91 private static final String DESCRIPTION_LA = "LA ";
92 private static final String KEYPERSON_CO_PD_PI = "CO-PD/PI";
93 private static final String NID_PD_PI = "PD/PI";
94 private static final String NID_CO_PD_PI = "CO-INVESTIGATOR";
95 private static final String KEYPERSON_OTHER = "Other (Specify)";
96 public static final String SPONSOR = "S2S";
97 private static final String PRINCIPAL_INVESTIGATOR_ROLE = "PD/PI";
98 private static final BigDecimal POINT_ZERO_ONE = new ScaleTwoDecimal(0.01).bigDecimalValue();
99
100 @Autowired
101 @Qualifier("budgetCategoryMapService")
102 private BudgetCategoryMapService budgetCategoryMapService;
103
104 @Autowired
105 @Qualifier("s2SConfigurationService")
106 private S2SConfigurationService s2SConfigurationService;
107
108 @Autowired
109 @Qualifier("budgetPersonSalaryService")
110 private BudgetPersonSalaryService budgetPersonSalaryService;
111
112 @Autowired
113 @Qualifier("organizationRepositoryService")
114 private OrganizationRepositoryService organizationRepositoryService;
115
116 @Autowired
117 @Qualifier("sponsorHierarchyService")
118 private SponsorHierarchyService sponsorHierarchyService;
119
120 @Autowired
121 @Qualifier("kcPersonRepositoryService")
122 private KcPersonRepositoryService kcPersonRepositoryService;
123
124 @Autowired
125 @Qualifier("tbnPersonService")
126 private TbnPersonService tbnPersonService;
127
128 @Autowired
129 @Qualifier("rolodexService")
130 private RolodexService rolodexService;
131
132 @Autowired
133 @Qualifier("s2SDateTimeService")
134 private S2SDateTimeService s2SDateTimeService;
135
136 @Autowired
137 @Qualifier("s2SProposalPersonService")
138 private S2SProposalPersonService s2SProposalPersonService;
139
140 @Autowired
141 @Qualifier("s2SErrorHandlerService")
142 private S2SErrorHandlerService s2SErrorHandlerService;
143
144 @Autowired
145 @Qualifier("s2SCommonBudgetService")
146 private S2SCommonBudgetService s2SCommonBudgetService;
147
148 @Override
149 public String getParticipantSupportCategoryCode() {
150 return s2SConfigurationService.getValueAsString(ConfigurationConstants.BUDGET_CATEGORY_TYPE_PARTICIPANT_SUPPORT);
151 }
152
153 @Override
154 public List<? extends BudgetLineItemContract> getMatchingLineItems(List<? extends BudgetLineItemContract> lineItems, List<String> budgetCategoryType) {
155 List<BudgetLineItemContract> result = new ArrayList<BudgetLineItemContract>();
156 for (BudgetLineItemContract lineItem : lineItems) {
157 if (budgetCategoryType.contains(lineItem.getBudgetCategory().getBudgetCategoryType().getCode())) {
158 result.add(lineItem);
159 }
160 }
161 return result;
162 }
163
164
165
166
167
168
169
170
171
172
173 @Override
174 public BudgetSummaryDto getBudgetInfo(ProposalDevelopmentDocumentContract pdDoc, List<BudgetPeriodDto> budgetPeriodInfos)
175 throws S2SException {
176 ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService.getBudget(pdDoc.getDevelopmentProposal());
177 BudgetSummaryDto budgetSummaryInfo = new BudgetSummaryDto();
178 if (budget == null) {
179 return budgetSummaryInfo;
180 }
181
182 budgetSummaryInfo.setBudgetPeriods(budgetPeriodInfos);
183 budgetSummaryInfo.setCumTotalCosts(budget.getTotalCost());
184 budgetSummaryInfo.setCumTotalIndirectCosts(budget.getTotalIndirectCost());
185 budgetSummaryInfo.setCumTotalDirectCosts(budget.getTotalDirectCost());
186 if (budget.getSubmitCostSharingFlag()) {
187 budgetSummaryInfo.setCumTotalCostSharing(budget.getCostSharingAmount());
188 }
189
190 ScaleTwoDecimal totalDirectCostSharing = ScaleTwoDecimal.ZERO;
191 ScaleTwoDecimal totalIndirectCostSharing = ScaleTwoDecimal.ZERO;
192 ScaleTwoDecimal lineItemCost = ScaleTwoDecimal.ZERO;
193 ScaleTwoDecimal lineItemCostSharingAmount = ScaleTwoDecimal.ZERO;
194 ScaleTwoDecimal fringeCost = ScaleTwoDecimal.ZERO;
195 ScaleTwoDecimal fringeCostSharingAmount = ScaleTwoDecimal.ZERO;
196 ScaleTwoDecimal budgetDetailsCost = ScaleTwoDecimal.ZERO;
197 ScaleTwoDecimal budgetDetailsCostSharingAmount = ScaleTwoDecimal.ZERO;
198 ScaleTwoDecimal budgetDetailsFringeCost = ScaleTwoDecimal.ZERO;
199 ScaleTwoDecimal budgetDetailsFringeCostSharingAmount = ScaleTwoDecimal.ZERO;
200 ScaleTwoDecimal totPersFunds = ScaleTwoDecimal.ZERO;
201 ScaleTwoDecimal totPersNonFunds = ScaleTwoDecimal.ZERO;
202 String budgetCategoryTypePersonnel = s2SConfigurationService.getValueAsString(
203 ConfigurationConstants.S2SBUDGET_BUDGET_CATEGORY_TYPE_PERSONNEL);
204 String rateTypeSupportStaffSalaries = s2SConfigurationService.getValueAsString(
205 ConfigurationConstants.S2SBUDGET_RATE_TYPE_SUPPORT_STAFF_SALARIES);
206 String rateTypeAdministrativeSalaries = s2SConfigurationService.getValueAsString(
207 ConfigurationConstants.S2SBUDGET_RATE_TYPE_ADMINISTRATIVE_SALARIES);
208
209 for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) {
210 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
211 totalDirectCostSharing = totalDirectCostSharing.add(lineItem.getCostSharingAmount());
212 if (lineItem
213 .getBudgetCategory()
214 .getBudgetCategoryType()
215 .getCode()
216 .equals(budgetCategoryTypePersonnel)) {
217 lineItemCost = lineItemCost.add(lineItem.getLineItemCost());
218 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
219 lineItemCostSharingAmount = lineItemCostSharingAmount.add(lineItem.getCostSharingAmount());
220 }
221 }
222
223 for (BudgetLineItemCalculatedAmountContract lineItemCalAmt : lineItem.getBudgetLineItemCalculatedAmounts()) {
224 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
225 if (lineItemCalAmt.getRateClass().getRateClassType().getCode().equals(RateClassType.OVERHEAD.getRateClassType())) {
226 totalIndirectCostSharing = totalIndirectCostSharing.add(lineItemCalAmt.getCalculatedCostSharing());
227 }
228 else {
229 totalDirectCostSharing = totalDirectCostSharing.add(lineItemCalAmt.getCalculatedCostSharing());
230 }
231 }
232 if ((lineItemCalAmt.getRateClass().getCode().equals(
233 s2SConfigurationService.getValueAsString(
234 ConfigurationConstants.S2SBUDGET_RATE_CLASS_CODE_EMPLOYEE_BENEFITS)) && !lineItemCalAmt.getRateTypeCode()
235 .equals(rateTypeSupportStaffSalaries))
236 || (lineItemCalAmt.getRateClass().getCode().equals(
237 s2SConfigurationService.getValueAsString(
238 ConfigurationConstants.S2SBUDGET_RATE_CLASS_CODE_VACATION)) && !lineItemCalAmt.getRateTypeCode()
239 .equals(rateTypeAdministrativeSalaries))) {
240 if (lineItem
241 .getBudgetCategory()
242 .getBudgetCategoryType()
243 .getCode()
244 .equals(budgetCategoryTypePersonnel)) {
245 fringeCost = fringeCost.add(lineItemCalAmt.getCalculatedCost());
246 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
247 fringeCostSharingAmount = fringeCostSharingAmount.add(lineItemCalAmt.getCalculatedCostSharing());
248 }
249 }
250 }
251 if (lineItemCalAmt
252 .getRateClass()
253 .getRateClassType().getCode()
254 .equals(s2SConfigurationService.getValueAsString(
255 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_LAB_ALLOCATION_SALARIES))) {
256 budgetDetailsCost = budgetDetailsCost.add(lineItemCalAmt.getCalculatedCost());
257 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
258 budgetDetailsCostSharingAmount = budgetDetailsCostSharingAmount.add(lineItemCalAmt
259 .getCalculatedCostSharing());
260 }
261 }
262 if ((lineItemCalAmt
263 .getRateClass()
264 .getRateClassType().getCode()
265 .equals(s2SConfigurationService.getValueAsString(
266 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_EMPLOYEE_BENEFITS)) && lineItemCalAmt.getRateTypeCode()
267 .equals(rateTypeSupportStaffSalaries))
268 || (lineItemCalAmt
269 .getRateClass()
270 .getRateClassType().getCode()
271 .equals(s2SConfigurationService.getValueAsString(
272 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_VACATION)) && lineItemCalAmt.getRateTypeCode()
273 .equals(rateTypeAdministrativeSalaries))) {
274 budgetDetailsFringeCost = budgetDetailsFringeCost.add(lineItemCalAmt.getCalculatedCost());
275 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
276 budgetDetailsFringeCostSharingAmount = budgetDetailsFringeCostSharingAmount.add(lineItemCalAmt
277 .getCalculatedCostSharing());
278 }
279 }
280
281 }
282 }
283 }
284 if (budget.getSubmitCostSharingFlag()) {
285 budgetSummaryInfo.setCumTotalDirectCostSharing(totalDirectCostSharing);
286 budgetSummaryInfo.setCumTotalIndirectCostSharing(totalIndirectCostSharing);
287 }
288 totPersFunds = totPersFunds.add(lineItemCost).add(fringeCost).add(budgetDetailsCost).add(budgetDetailsFringeCost);
289 totPersNonFunds = totPersNonFunds.add(lineItemCostSharingAmount).add(fringeCostSharingAmount)
290 .add(budgetDetailsCostSharingAmount).add(budgetDetailsFringeCostSharingAmount);
291
292 budgetSummaryInfo.setCumTotalNonFundsForPersonnel(totPersNonFunds);
293 budgetSummaryInfo.setCumTotalFundsForPersonnel(totPersFunds);
294
295 OtherDirectCostInfoDto otherDirectCostInfo = new OtherDirectCostInfoDto();
296 List<OtherDirectCostInfoDto> cvOtherDirectCost = new ArrayList<OtherDirectCostInfoDto>();
297 List<Map<String, String>> cvOtherCosts = new ArrayList<Map<String, String>>();
298
299 ScaleTwoDecimal cumAlterations = ScaleTwoDecimal.ZERO;
300 ScaleTwoDecimal cumConsultants = ScaleTwoDecimal.ZERO;
301 ScaleTwoDecimal cumMaterials = ScaleTwoDecimal.ZERO;
302 ScaleTwoDecimal cumPubs = ScaleTwoDecimal.ZERO;
303 ScaleTwoDecimal cumSubAward = ScaleTwoDecimal.ZERO;
304 ScaleTwoDecimal cumComputer = ScaleTwoDecimal.ZERO;
305 ScaleTwoDecimal cumEquipRental = ScaleTwoDecimal.ZERO;
306 ScaleTwoDecimal cumAll = ScaleTwoDecimal.ZERO;
307 ScaleTwoDecimal cumOtherType1 = ScaleTwoDecimal.ZERO;
308 ScaleTwoDecimal cumPartStipends = ScaleTwoDecimal.ZERO;
309 ScaleTwoDecimal cumPartSubsistence = ScaleTwoDecimal.ZERO;
310 ScaleTwoDecimal cumPartTuition = ScaleTwoDecimal.ZERO;
311 ScaleTwoDecimal cumPartOther = ScaleTwoDecimal.ZERO;
312 ScaleTwoDecimal cumPartTravel = ScaleTwoDecimal.ZERO;
313 int cumParticipantCount = 0;
314 ScaleTwoDecimal cumAlterationsCostSharing = ScaleTwoDecimal.ZERO;
315 ScaleTwoDecimal cumConsultantsCostSharing = ScaleTwoDecimal.ZERO;
316 ScaleTwoDecimal cumMaterialsCostSharing = ScaleTwoDecimal.ZERO;
317 ScaleTwoDecimal cumPubsCostSharing = ScaleTwoDecimal.ZERO;
318 ScaleTwoDecimal cumSubAwardCostSharing = ScaleTwoDecimal.ZERO;
319 ScaleTwoDecimal cumComputerCostSharing = ScaleTwoDecimal.ZERO;
320 ScaleTwoDecimal cumEquipRentalCostSharing = ScaleTwoDecimal.ZERO;
321 ScaleTwoDecimal cumAllCostSharing = ScaleTwoDecimal.ZERO;
322 ScaleTwoDecimal cumOtherType1CostSharing = ScaleTwoDecimal.ZERO;
323 ScaleTwoDecimal cumPartStipendsCostSharing = ScaleTwoDecimal.ZERO;
324 ScaleTwoDecimal cumPartSubsistenceCostSharing = ScaleTwoDecimal.ZERO;
325 ScaleTwoDecimal cumPartTuitionCostSharing = ScaleTwoDecimal.ZERO;
326 ScaleTwoDecimal cumPartOtherCostSharing = ScaleTwoDecimal.ZERO;
327 ScaleTwoDecimal cumPartTravelCostSharing = ScaleTwoDecimal.ZERO;
328 ScaleTwoDecimal participantTotalCostSharing = ScaleTwoDecimal.ZERO;
329
330 ScaleTwoDecimal totalDomesticTravel = ScaleTwoDecimal.ZERO;
331 ScaleTwoDecimal totalForeignTravel = ScaleTwoDecimal.ZERO;
332 ScaleTwoDecimal totalDomesticTravelNonFund = ScaleTwoDecimal.ZERO;
333 ScaleTwoDecimal totalForeignTravelNonFund = ScaleTwoDecimal.ZERO;
334 ScaleTwoDecimal cumTotalEquipFund = ScaleTwoDecimal.ZERO;
335 ScaleTwoDecimal cumTotalEquipNonFund = ScaleTwoDecimal.ZERO;
336 ScaleTwoDecimal totCountOtherPersonnel = ScaleTwoDecimal.ZERO;
337
338 if (budgetPeriodInfos != null) {
339 for (BudgetPeriodDto budgetPeriodInfo : budgetPeriodInfos) {
340 cvOtherDirectCost = budgetPeriodInfo.getOtherDirectCosts();
341 otherDirectCostInfo = cvOtherDirectCost.get(0);
342 cumAlterations = cumAlterations.add(otherDirectCostInfo.getAlterations());
343 cumConsultants = cumConsultants.add(otherDirectCostInfo.getConsultants());
344 cumMaterials = cumMaterials.add(otherDirectCostInfo.getmaterials());
345 cumPubs = cumPubs.add(otherDirectCostInfo.getpublications());
346 cumSubAward = cumSubAward.add(otherDirectCostInfo.getsubAwards());
347 cumComputer = cumComputer.add(otherDirectCostInfo.getcomputer());
348 cumEquipRental = cumEquipRental.add(otherDirectCostInfo.getEquipRental());
349 cumAll = cumAll.add(otherDirectCostInfo.gettotalOtherDirect());
350
351 cumPartStipends = cumPartStipends.add(otherDirectCostInfo.getPartStipends() == null ? ScaleTwoDecimal.ZERO
352 : otherDirectCostInfo.getPartStipends());
353 cumPartTravel = cumPartTravel.add(otherDirectCostInfo.getPartTravel() == null ? ScaleTwoDecimal.ZERO
354 : otherDirectCostInfo.getPartTravel());
355 cumPartSubsistence = cumPartSubsistence.add(otherDirectCostInfo.getPartSubsistence() == null ? ScaleTwoDecimal.ZERO
356 : otherDirectCostInfo.getPartSubsistence());
357 cumPartTuition = cumPartTuition.add(otherDirectCostInfo.getPartTuition() == null ? ScaleTwoDecimal.ZERO
358 : otherDirectCostInfo.getPartTuition());
359 cumPartOther = cumPartOther.add(otherDirectCostInfo.getPartOther() == null ? ScaleTwoDecimal.ZERO
360 : otherDirectCostInfo.getPartOther());
361 cumParticipantCount = cumParticipantCount
362 + (otherDirectCostInfo.getParticpantTotalCount() == 0 ? 0 : otherDirectCostInfo.getParticpantTotalCount());
363 if (budget.getSubmitCostSharingFlag()) {
364 cumAlterationsCostSharing = cumAlterationsCostSharing.add(otherDirectCostInfo.getAlterationsCostSharing());
365 cumConsultantsCostSharing = cumConsultantsCostSharing.add(otherDirectCostInfo.getConsultantsCostSharing());
366 cumMaterialsCostSharing = cumMaterialsCostSharing.add(otherDirectCostInfo.getMaterialsCostSharing());
367 cumPubsCostSharing = cumPubsCostSharing.add(otherDirectCostInfo.getPublicationsCostSharing());
368 cumSubAwardCostSharing = cumSubAwardCostSharing.add(otherDirectCostInfo.getSubAwardsCostSharing());
369 cumComputerCostSharing = cumComputerCostSharing.add(otherDirectCostInfo.getComputerCostSharing());
370 cumEquipRentalCostSharing = cumEquipRentalCostSharing.add(otherDirectCostInfo.getEquipRentalCostSharing());
371 cumAllCostSharing = cumAllCostSharing.add(otherDirectCostInfo.getTotalOtherDirectCostSharing());
372
373 cumPartStipendsCostSharing = cumPartStipendsCostSharing
374 .add(otherDirectCostInfo.getPartStipendsCostSharing() == null ? ScaleTwoDecimal.ZERO
375 : otherDirectCostInfo.getPartStipendsCostSharing());
376 cumPartTravelCostSharing = cumPartTravelCostSharing
377 .add(otherDirectCostInfo.getPartTravelCostSharing() == null ? ScaleTwoDecimal.ZERO : otherDirectCostInfo
378 .getPartTravelCostSharing());
379 cumPartSubsistenceCostSharing = cumPartSubsistenceCostSharing.add(otherDirectCostInfo
380 .getPartSubsistenceCostSharing() == null ? ScaleTwoDecimal.ZERO : otherDirectCostInfo
381 .getPartSubsistenceCostSharing());
382 cumPartTuitionCostSharing = cumPartTuitionCostSharing
383 .add(otherDirectCostInfo.getPartTuitionCostSharing() == null ? ScaleTwoDecimal.ZERO : otherDirectCostInfo
384 .getPartTuitionCostSharing());
385
386 cumPartOtherCostSharing = cumPartOtherCostSharing
387 .add(otherDirectCostInfo.getPartOtherCostSharing() == null ? ScaleTwoDecimal.ZERO : otherDirectCostInfo
388 .getPartOtherCostSharing());
389 }
390 else {
391 cumAlterationsCostSharing = cumAlterationsCostSharing.add(ScaleTwoDecimal.ZERO);
392 cumConsultantsCostSharing = cumConsultantsCostSharing.add(ScaleTwoDecimal.ZERO);
393 cumMaterialsCostSharing = cumMaterialsCostSharing.add(ScaleTwoDecimal.ZERO);
394 cumPubsCostSharing = cumPubsCostSharing.add(ScaleTwoDecimal.ZERO);
395 cumSubAwardCostSharing = cumSubAwardCostSharing.add(ScaleTwoDecimal.ZERO);
396 cumComputerCostSharing = cumComputerCostSharing.add(ScaleTwoDecimal.ZERO);
397 cumEquipRentalCostSharing = cumEquipRentalCostSharing.add(ScaleTwoDecimal.ZERO);
398 cumAllCostSharing = cumAllCostSharing.add(ScaleTwoDecimal.ZERO);
399 cumPartStipendsCostSharing = cumPartStipendsCostSharing.add(ScaleTwoDecimal.ZERO);
400 cumPartTravelCostSharing = cumPartTravelCostSharing.add(ScaleTwoDecimal.ZERO);
401 cumPartSubsistenceCostSharing = cumPartSubsistenceCostSharing.add(ScaleTwoDecimal.ZERO);
402 cumPartTuitionCostSharing = cumPartTuitionCostSharing.add(ScaleTwoDecimal.ZERO);
403 cumPartOtherCostSharing = cumPartOtherCostSharing.add(ScaleTwoDecimal.ZERO);
404 }
405 totalDomesticTravel = totalDomesticTravel.add(budgetPeriodInfo.getDomesticTravelCost());
406 totalForeignTravel = totalForeignTravel.add(budgetPeriodInfo.getForeignTravelCost());
407 totalDomesticTravelNonFund = totalDomesticTravelNonFund.add(budgetPeriodInfo.getDomesticTravelCostSharing());
408 totalForeignTravelNonFund = totalForeignTravelNonFund.add(budgetPeriodInfo.getForeignTravelCostSharing());
409 totCountOtherPersonnel = totCountOtherPersonnel.add(budgetPeriodInfo.getOtherPersonnelTotalNumber());
410
411 for (EquipmentDto equipmentInfo : budgetPeriodInfo.getEquipment()) {
412 cumTotalEquipFund = cumTotalEquipFund.add(equipmentInfo.getTotalFund());
413 cumTotalEquipNonFund = cumTotalEquipNonFund.add(equipmentInfo.getTotalNonFund());
414 }
415
416 Map<String, String> hmOthers = new HashMap<String, String>();
417 cvOtherCosts = otherDirectCostInfo.getOtherCosts();
418 for (int l = 0; l < cvOtherCosts.size(); l++) {
419 hmOthers = cvOtherCosts.get(l);
420 cumOtherType1 = cumOtherType1.add(new ScaleTwoDecimal(hmOthers.get(CostConstants.KEY_COST)));
421 cumOtherType1CostSharing = cumOtherType1CostSharing.add(new ScaleTwoDecimal(hmOthers
422 .get(CostConstants.KEY_COSTSHARING)));
423 }
424 }
425 }
426
427 budgetSummaryInfo.setCumDomesticTravelNonFund(totalDomesticTravelNonFund);
428 budgetSummaryInfo.setCumForeignTravelNonFund(totalForeignTravelNonFund);
429 budgetSummaryInfo.setCumTravelNonFund(totalDomesticTravelNonFund.add(totalForeignTravelNonFund));
430 budgetSummaryInfo.setCumDomesticTravel(totalDomesticTravel);
431 budgetSummaryInfo.setCumForeignTravel(totalForeignTravel);
432 budgetSummaryInfo.setCumTravel(totalDomesticTravel.add(totalForeignTravel));
433 budgetSummaryInfo.setpartOtherCost(cumPartOther);
434 budgetSummaryInfo.setpartStipendCost(cumPartStipends);
435 budgetSummaryInfo.setpartTravelCost(cumPartTravel);
436 budgetSummaryInfo.setPartSubsistence(cumPartSubsistence);
437 budgetSummaryInfo.setPartTuition(cumPartTuition);
438 budgetSummaryInfo.setparticipantCount(cumParticipantCount);
439
440 if (budget.getSubmitCostSharingFlag()) {
441
442 budgetSummaryInfo.setPartOtherCostSharing(cumPartOtherCostSharing);
443 budgetSummaryInfo.setPartStipendCostSharing(cumPartStipendsCostSharing);
444 budgetSummaryInfo.setPartTravelCostSharing(cumPartTravelCostSharing);
445 budgetSummaryInfo.setPartSubsistenceCostSharing(cumPartSubsistenceCostSharing);
446 budgetSummaryInfo.setPartTuitionCostSharing(cumPartTuitionCostSharing);
447 }
448
449 OtherDirectCostInfoDto summaryOtherDirectCostInfo = new OtherDirectCostInfoDto();
450 summaryOtherDirectCostInfo.setAlterations(cumAlterations);
451 summaryOtherDirectCostInfo.setcomputer(cumComputer);
452 summaryOtherDirectCostInfo.setConsultants(cumConsultants);
453 summaryOtherDirectCostInfo.setmaterials(cumMaterials);
454 summaryOtherDirectCostInfo.setpublications(cumPubs);
455 summaryOtherDirectCostInfo.setsubAwards(cumSubAward);
456 summaryOtherDirectCostInfo.setEquipRental(cumEquipRental);
457 summaryOtherDirectCostInfo.settotalOtherDirect(cumAll);
458
459 summaryOtherDirectCostInfo.setPartStipends(cumPartStipends);
460 summaryOtherDirectCostInfo.setPartTravel(cumPartTravel);
461 summaryOtherDirectCostInfo.setPartSubsistence(cumPartSubsistence);
462 summaryOtherDirectCostInfo.setPartTuition(cumPartTuition);
463 summaryOtherDirectCostInfo.setPartOther(cumPartOther);
464 summaryOtherDirectCostInfo.setParticipantTotal(cumPartStipends.add(cumPartTravel.add(cumPartOther.add(cumPartSubsistence
465 .add(cumPartTravel)))));
466 summaryOtherDirectCostInfo.setParticipantTotalCount(cumParticipantCount);
467
468 summaryOtherDirectCostInfo.setAlterationsCostSharing(cumAlterationsCostSharing);
469 summaryOtherDirectCostInfo.setComputerCostSharing(cumComputerCostSharing);
470 summaryOtherDirectCostInfo.setConsultantsCostSharing(cumConsultantsCostSharing);
471 summaryOtherDirectCostInfo.setMaterialsCostSharing(cumMaterialsCostSharing);
472 summaryOtherDirectCostInfo.setPublicationsCostSharing(cumPubsCostSharing);
473 summaryOtherDirectCostInfo.setSubAwardsCostSharing(cumSubAwardCostSharing);
474 summaryOtherDirectCostInfo.setEquipRentalCostSharing(cumEquipRentalCostSharing);
475 summaryOtherDirectCostInfo.setTotalOtherDirectCostSharing(cumAllCostSharing);
476
477 summaryOtherDirectCostInfo.setPartStipendsCostSharing(cumPartStipendsCostSharing);
478 summaryOtherDirectCostInfo.setPartTravelCostSharing(cumPartTravelCostSharing);
479 summaryOtherDirectCostInfo.setPartTuitionCostSharing(cumPartTuitionCostSharing);
480 summaryOtherDirectCostInfo.setPartSubsistenceCostSharing(cumPartSubsistenceCostSharing);
481 summaryOtherDirectCostInfo.setPartOtherCostSharing(cumPartOtherCostSharing);
482
483 participantTotalCostSharing = participantTotalCostSharing.add(cumPartStipendsCostSharing);
484 participantTotalCostSharing = participantTotalCostSharing.add(cumPartTravelCostSharing);
485 participantTotalCostSharing = participantTotalCostSharing.add(cumPartOtherCostSharing);
486 participantTotalCostSharing = participantTotalCostSharing.add(cumPartTuitionCostSharing);
487 participantTotalCostSharing = participantTotalCostSharing.add(cumPartSubsistenceCostSharing);
488 summaryOtherDirectCostInfo.setParticipantTotalCostSharing(participantTotalCostSharing);
489
490 List<Map<String, String>> cvAllOthers = new ArrayList<Map<String, String>>();
491 HashMap<String, String> hmAllOthers = new HashMap<String, String>();
492 hmAllOthers.put(CostConstants.KEY_COST, cumOtherType1.toString());
493 hmAllOthers.put(CostConstants.KEY_COSTSHARING, cumOtherType1CostSharing.toString());
494 cvAllOthers.add(hmAllOthers);
495 summaryOtherDirectCostInfo.setOtherCosts(cvAllOthers);
496
497 List<OtherDirectCostInfoDto> cvCumOtherDirectCost = new ArrayList<OtherDirectCostInfoDto>();
498
499 cvCumOtherDirectCost.add(summaryOtherDirectCostInfo);
500 budgetSummaryInfo.setOtherDirectCosts(cvCumOtherDirectCost);
501
502 budgetSummaryInfo.setCumEquipmentFunds(cumTotalEquipFund);
503 budgetSummaryInfo.setCumEquipmentNonFunds(cumTotalEquipNonFund);
504
505
506 budgetSummaryInfo.setCumFee(ScaleTwoDecimal.ZERO);
507
508 ScaleTwoDecimal totSrFunds = ScaleTwoDecimal.ZERO;
509 ScaleTwoDecimal totSrNonFunds = ScaleTwoDecimal.ZERO;
510
511 if (budgetPeriodInfos != null) {
512 for (BudgetPeriodDto budgetPeriodInfo : budgetPeriodInfos) {
513 totSrFunds = totSrFunds.add(budgetPeriodInfo.getTotalFundsKeyPersons());
514 totSrNonFunds = totSrNonFunds.add(budgetPeriodInfo.getTotalNonFundsKeyPersons());
515 }
516 }
517 budgetSummaryInfo.setCumTotalFundsForSrPersonnel(totSrFunds);
518 budgetSummaryInfo.setCumTotalNonFundsForSrPersonnel(totSrNonFunds);
519
520
521
522 budgetSummaryInfo.setCumTotalFundsForOtherPersonnel(totPersFunds.subtract(totSrFunds));
523 budgetSummaryInfo.setCumTotalNonFundsForOtherPersonnel(totPersNonFunds.subtract(totSrNonFunds));
524 budgetSummaryInfo.setCumNumOtherPersonnel(totCountOtherPersonnel);
525 return budgetSummaryInfo;
526 }
527
528
529
530
531
532
533
534
535 @Override
536 public List<BudgetPeriodDto> getBudgetPeriods(ProposalDevelopmentDocumentContract pdDoc) throws S2SException {
537 List<BudgetPeriodDto> budgetPeriods = new ArrayList<BudgetPeriodDto>();
538 ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService.getBudget(pdDoc.getDevelopmentProposal());
539 if (budget == null) {
540 return budgetPeriods;
541 }
542
543 for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) {
544 BudgetPeriodDto bpData = new BudgetPeriodDto();
545 ScaleTwoDecimal totalCostSharing = ScaleTwoDecimal.ZERO;
546 ScaleTwoDecimal totalDirectCostSharing = ScaleTwoDecimal.ZERO;
547 ScaleTwoDecimal totalIndirectCostSharing = ScaleTwoDecimal.ZERO;
548 bpData.setLineItemCount(budgetPeriod.getBudgetLineItems().size());
549 if (budget.getSubmitCostSharingFlag()) {
550 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
551 if (lineItem.getSubmitCostSharingFlag()) {
552 totalCostSharing = totalCostSharing.add(lineItem.getCostSharingAmount());
553 }
554 for (BudgetLineItemCalculatedAmountContract lineItemCalculatedAmt : lineItem.getBudgetLineItemCalculatedAmounts()) {
555 if (lineItem.getSubmitCostSharingFlag()) {
556 if (lineItemCalculatedAmt.getRateClass().getRateClassType().getCode()
557 .equals(RateClassType.OVERHEAD.getRateClassType())) {
558 totalIndirectCostSharing = totalIndirectCostSharing.add(lineItemCalculatedAmt
559 .getCalculatedCostSharing());
560 }
561 else {
562 totalDirectCostSharing = totalDirectCostSharing.add(lineItemCalculatedAmt
563 .getCalculatedCostSharing());
564 }
565 }
566 }
567 }
568 totalDirectCostSharing = totalDirectCostSharing.add(totalCostSharing);
569 }
570
571
572
573 bpData.setFinalVersionFlag(pdDoc.getDevelopmentProposal().getFinalBudget() != null ? "Y" : "N");
574 bpData.setProposalNumber(pdDoc.getDevelopmentProposal().getProposalNumber());
575 bpData.setBudgetPeriod(budgetPeriod.getBudgetPeriod());
576 bpData.setVersion(budget.getBudgetVersionNumber());
577 bpData.setStartDate(new java.sql.Date(budgetPeriod.getStartDate().getTime()));
578 bpData.setEndDate(new java.sql.Date(budgetPeriod.getEndDate().getTime()));
579 bpData.setTotalCosts(budgetPeriod.getTotalCost());
580 bpData.setDirectCostsTotal(budgetPeriod.getTotalDirectCost());
581 bpData.setTotalIndirectCost(budgetPeriod.getTotalIndirectCost());
582 bpData.setCostSharingAmount(budgetPeriod.getCostSharingAmount());
583 if (budget.getSubmitCostSharingFlag()) {
584 bpData.setTotalDirectCostSharing(totalDirectCostSharing);
585 bpData.setTotalIndirectCostSharing(totalIndirectCostSharing);
586 }
587 bpData.setCognizantFedAgency(getCognizantFedAgency(pdDoc.getDevelopmentProposal()));
588
589 bpData.setIndirectCosts(getIndirectCosts(budget, budgetPeriod));
590 bpData.setEquipment(getEquipment(budgetPeriod, budget));
591 bpData.setOtherDirectCosts(getOtherDirectCosts(budgetPeriod, budget));
592 if (bpData.getOtherDirectCosts().size() > 0) {
593 OtherDirectCostInfoDto otherCostInfo = bpData.getOtherDirectCosts().get(0);
594 bpData.setDomesticTravelCost(otherCostInfo.getDomTravel());
595
596 bpData.setForeignTravelCost(otherCostInfo.getForeignTravel());
597 bpData.setTotalTravelCost(otherCostInfo.getTotTravel());
598 if (budget.getSubmitCostSharingFlag()) {
599
600 bpData.setDomesticTravelCostSharing(otherCostInfo.getDomTravelCostSharing());
601 bpData.setForeignTravelCostSharing(otherCostInfo.getForeignTravelCostSharing());
602 bpData.setTotalTravelCostSharing(otherCostInfo.getTotTravelCostSharing());
603 }
604
605 bpData.setpartOtherCost(otherCostInfo.getPartOther());
606 bpData.setpartStipendCost(otherCostInfo.getPartStipends());
607 bpData.setpartTravelCost(otherCostInfo.getPartTravel());
608 bpData.setPartSubsistence(otherCostInfo.getPartSubsistence());
609 bpData.setPartTuition(otherCostInfo.getPartTuition());
610 bpData.setparticipantCount(otherCostInfo.getParticpantTotalCount());
611 if (budget.getSubmitCostSharingFlag()) {
612 bpData.setPartOtherCostSharing(otherCostInfo.getPartOtherCostSharing());
613 bpData.setPartStipendCostSharing(otherCostInfo.getPartStipendsCostSharing());
614 bpData.setPartTravelCostSharing(otherCostInfo.getPartTravelCostSharing());
615 bpData.setPartTuitionCostSharing(otherCostInfo.getPartTuitionCostSharing());
616 bpData.setPartSubsistenceCostSharing(otherCostInfo.getPartSubsistenceCostSharing());
617 }
618 }
619 List<List<KeyPersonDto>> keyPersonList = getKeyPersons(
620 budgetPeriod,pdDoc,MAX_KEY_PERSON_COUNT, budget);
621 List<KeyPersonDto> keyPersons = new ArrayList<KeyPersonDto>();
622 List<KeyPersonDto> extraPersons = new ArrayList<KeyPersonDto>();
623 if (keyPersonList.size() > 0) {
624 keyPersons = keyPersonList.get(0);
625 }
626 if (keyPersonList.size() > 1) {
627 extraPersons = keyPersonList.get(1);
628 }
629
630 bpData.setKeyPersons(keyPersons);
631 bpData.setExtraKeyPersons(extraPersons);
632
633 ScaleTwoDecimal totalKeyPersonSum = ScaleTwoDecimal.ZERO;
634 ScaleTwoDecimal totalKeyPersonSumCostSharing = ScaleTwoDecimal.ZERO;
635 ScaleTwoDecimal totalAttKeyPersonSum = ScaleTwoDecimal.ZERO;
636 ScaleTwoDecimal totalAttKeyPersonSumCostSharing = ScaleTwoDecimal.ZERO;
637 if (keyPersons != null) {
638 for (KeyPersonDto keyPerson : keyPersons) {
639 totalKeyPersonSum = totalKeyPersonSum.add(keyPerson.getFundsRequested());
640 if (budget.getSubmitCostSharingFlag()) {
641 totalKeyPersonSumCostSharing = totalKeyPersonSumCostSharing.add(keyPerson.getNonFundsRequested());
642 }
643 }
644 }
645
646 if (extraPersons != null) {
647 for (KeyPersonDto keyPerson : extraPersons) {
648 totalAttKeyPersonSum = totalAttKeyPersonSum.add(keyPerson.getFundsRequested());
649 if (budget.getSubmitCostSharingFlag()) {
650
651 totalAttKeyPersonSumCostSharing = totalAttKeyPersonSumCostSharing.add(keyPerson.getNonFundsRequested());
652 }
653 }
654 }
655 bpData.setTotalFundsKeyPersons(totalKeyPersonSum.add(totalAttKeyPersonSum));
656 bpData.setTotalFundsAttachedKeyPersons(totalAttKeyPersonSum);
657 bpData.setTotalNonFundsKeyPersons(totalKeyPersonSumCostSharing.add(totalAttKeyPersonSumCostSharing));
658 bpData.setTotalNonFundsAttachedKeyPersons(totalAttKeyPersonSumCostSharing);
659
660 List<OtherPersonnelDto> otherPersonnel = getOtherPersonnel(budgetPeriod, pdDoc);
661 bpData.setOtherPersonnel(otherPersonnel);
662 ScaleTwoDecimal otherPersonnelCount = ScaleTwoDecimal.ZERO;
663 ScaleTwoDecimal otherPersonnelTotalFunds = ScaleTwoDecimal.ZERO;
664 ScaleTwoDecimal otherPersonnelTotalNonFunds = ScaleTwoDecimal.ZERO;
665
666 for (OtherPersonnelDto otherPersonnelInfo : otherPersonnel) {
667 otherPersonnelCount = otherPersonnelCount.add(new ScaleTwoDecimal(otherPersonnelInfo.getNumberPersonnel()));
668 otherPersonnelTotalFunds = otherPersonnelTotalFunds.add(otherPersonnelInfo.getCompensation().getFundsRequested());
669 otherPersonnelTotalNonFunds = otherPersonnelTotalNonFunds.add(otherPersonnelInfo.getCompensation()
670 .getNonFundsRequested());
671 }
672 bpData.setTotalOtherPersonnelFunds(otherPersonnelTotalFunds);
673 bpData.setOtherPersonnelTotalNumber(otherPersonnelCount);
674 bpData.setTotalCompensation(otherPersonnelTotalFunds.add(totalKeyPersonSum).add(totalAttKeyPersonSum));
675 bpData.setTotalOtherPersonnelNonFunds(otherPersonnelTotalNonFunds);
676 bpData.setTotalCompensationCostSharing(otherPersonnelTotalNonFunds.add(totalKeyPersonSumCostSharing).add(
677 totalAttKeyPersonSumCostSharing));
678
679 budgetPeriods.add(bpData);
680 }
681 return budgetPeriods;
682 }
683
684 protected String getCognizantFedAgency(DevelopmentProposalContract developmentProposal) {
685 StringBuilder fedAgency = new StringBuilder();
686 ProposalSiteContract applicantOrganization = developmentProposal.getApplicantOrganization();
687 if (applicantOrganization != null && applicantOrganization.getOrganization() != null
688 && applicantOrganization.getOrganization().getCognizantAuditor() != null) {
689 fedAgency.append(organizationRepositoryService.getCognizantFedAgency(applicantOrganization.getOrganization()));
690 }
691 if (fedAgency.toString().length() == 0) {
692 fedAgency.append(VALUE_UNKNOWN);
693 }
694 return fedAgency.toString();
695 }
696
697
698
699
700
701
702
703
704
705
706 protected List<OtherPersonnelDto> getOtherPersonnel(BudgetPeriodContract budgetPeriod, ProposalDevelopmentDocumentContract pdDoc) {
707 List<OtherPersonnelDto> cvOtherPersonnel = new ArrayList<OtherPersonnelDto>();
708 cvOtherPersonnel.add(getOtherPersonnelDetails(
709 budgetPeriod,pdDoc,
710 s2SConfigurationService.getValueAsString(
711 ConfigurationConstants.S2SBUDGET_CATEGORY_01_GRADUATES),PERSONNEL_TYPE_GRAD,
712 ROLE_GRADUATE_STUDENTS));
713 cvOtherPersonnel.add(getOtherPersonnelDetails(
714 budgetPeriod,pdDoc,
715 s2SConfigurationService.getValueAsString(
716 ConfigurationConstants.S2SBUDGET_CATEGORY_01_POSTDOCS),PERSONNEL_TYPE_POSTDOC,
717 ROLE_POST_DOCTORAL_ASSOCIATES));
718 cvOtherPersonnel.add(getOtherPersonnelDetails(
719 budgetPeriod,pdDoc,
720 s2SConfigurationService.getValueAsString(
721 ConfigurationConstants.S2SBUDGET_CATEGORY_01_UNDERGRADS),PERSONNEL_TYPE_UNDERGRAD,
722 ROLE_GRADUATE_UNDERGRADUATE_STUDENTS));
723 cvOtherPersonnel.add(getOtherPersonnelDetails(
724 budgetPeriod,pdDoc,
725 s2SConfigurationService.getValueAsString(
726 ConfigurationConstants.S2SBUDGET_CATEGORY_01_SECRETARIAL),PERSONNEL_TYPE_SEC,
727 ROLE_GRADUATE_SECRETARIAL_OR_CLERICAL));
728 cvOtherPersonnel.add(getOtherPersonnelDetails(
729 budgetPeriod,pdDoc,
730 s2SConfigurationService.getValueAsString(
731 ConfigurationConstants.S2SBUDGET_CATEGORY_01_OTHER),PERSONNEL_TYPE_OTHER,
732 ROLE_GRADUATE_OTHER));
733 cvOtherPersonnel.add(getOtherPersonnelDetails(
734 budgetPeriod,pdDoc,
735 s2SConfigurationService.getValueAsString(
736 ConfigurationConstants.S2SBUDGET_CATEGORY_01_OTHER_PROFS),PERSONNEL_TYPE_OTHER_PROFESSIONALS,
737 ROLE_GRADUATE_OTHER_PROFESSIONALS));
738 cvOtherPersonnel.add(getOtherPersonnelDetails(
739 budgetPeriod,pdDoc,
740 LASALARIES,PERSONNEL_TYPE_ALLOCATED_ADMIN_SUPPORT,
741 ROLE_GRADUATE_ALLOCATED_ADMIN_SUPPORT));
742 return cvOtherPersonnel;
743 }
744
745
746
747
748
749
750
751
752
753
754
755
756
757 protected OtherPersonnelDto getOtherPersonnelDetails(BudgetPeriodContract budgetPeriod, ProposalDevelopmentDocumentContract pdDoc,
758 String category, String personnelType, String role) {
759 OtherPersonnelDto otherPersonnelInfo = new OtherPersonnelDto();
760
761 int count = 0;
762 ScaleTwoDecimal salaryRequested = ScaleTwoDecimal.ZERO;
763 ScaleTwoDecimal salaryCostSharing = ScaleTwoDecimal.ZERO;
764 ScaleTwoDecimal lineItemCost = ScaleTwoDecimal.ZERO;
765 ScaleTwoDecimal lineItemCostSharingAmount = ScaleTwoDecimal.ZERO;
766 ScaleTwoDecimal mrLaCost = ScaleTwoDecimal.ZERO;
767 ScaleTwoDecimal mrLaCostSharingAmount = ScaleTwoDecimal.ZERO;
768
769 ScaleTwoDecimal fringeCost = ScaleTwoDecimal.ZERO;
770 ScaleTwoDecimal fringeCostSharingAmount = ScaleTwoDecimal.ZERO;
771 ScaleTwoDecimal mrLaFringeCost = ScaleTwoDecimal.ZERO;
772 ScaleTwoDecimal mrLaFringeCostSharingAmount = ScaleTwoDecimal.ZERO;
773 ScaleTwoDecimal budgetLineItemFringeCost = ScaleTwoDecimal.ZERO;
774 ScaleTwoDecimal budgetLineItemFringeCostSharingAmount = ScaleTwoDecimal.ZERO;
775
776 ScaleTwoDecimal bdSalary = ScaleTwoDecimal.ZERO;
777 ScaleTwoDecimal bdFringe = ScaleTwoDecimal.ZERO;
778 ScaleTwoDecimal bdFunds = ScaleTwoDecimal.ZERO;
779 ScaleTwoDecimal bdSalaryCostSharing = ScaleTwoDecimal.ZERO;
780 ScaleTwoDecimal bdFringeCostSharing = ScaleTwoDecimal.ZERO;
781 ScaleTwoDecimal bdNonFunds = ScaleTwoDecimal.ZERO;
782
783 BigDecimal academicMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
784 BigDecimal summerMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
785 BigDecimal calendarMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
786 BigDecimal cycleMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
787
788 BigDecimal numberOfMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
789 String rateTypeSupportStaffSalaries = s2SConfigurationService.getValueAsString(
790 ConfigurationConstants.S2SBUDGET_RATE_TYPE_SUPPORT_STAFF_SALARIES);
791 String rateClassCodeEmployeeBenefits = s2SConfigurationService.getValueAsString(
792 ConfigurationConstants.S2SBUDGET_RATE_CLASS_CODE_EMPLOYEE_BENEFITS);
793 String rateClassCodeVacation = s2SConfigurationService.getValueAsString(
794 ConfigurationConstants.S2SBUDGET_RATE_CLASS_CODE_VACATION);
795 String rateTypeAdministrativeSalaries = s2SConfigurationService.getValueAsString(
796 ConfigurationConstants.S2SBUDGET_RATE_TYPE_ADMINISTRATIVE_SALARIES);
797 Map<String, String> personJobCodes = new HashMap<String, String>();
798 boolean personExistsAsProposalPerson = false;
799
800
801
802 if (category.equalsIgnoreCase(LASALARIES)) {
803 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
804
805 for (BudgetLineItemCalculatedAmountContract lineItemCalculatedAmount : lineItem
806 .getBudgetLineItemCalculatedAmounts()) {
807 if (lineItemCalculatedAmount
808 .getRateClass()
809 .getRateClassType().getCode()
810 .equals(s2SConfigurationService.getValueAsString(
811 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_LAB_ALLOCATION_SALARIES))) {
812 mrLaCost = mrLaCost.add(lineItemCalculatedAmount.getCalculatedCost());
813 if(lineItem.getSubmitCostSharingFlag()){
814 mrLaCostSharingAmount = mrLaCostSharingAmount.add(lineItemCalculatedAmount
815 .getCalculatedCostSharing());
816 }
817 }
818
819
820 if ((lineItemCalculatedAmount
821 .getRateClass()
822 .getRateClassType().getCode()
823 .equals(s2SConfigurationService.getValueAsString(
824 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_EMPLOYEE_BENEFITS)) && lineItemCalculatedAmount
825 .getRateTypeCode().equals(
826 rateTypeSupportStaffSalaries))
827 || (lineItemCalculatedAmount
828 .getRateClass()
829 .getRateClassType().getCode()
830 .equals(s2SConfigurationService.getValueAsString(
831 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_VACATION)) && lineItemCalculatedAmount
832 .getRateTypeCode().equals(
833 rateTypeAdministrativeSalaries))) {
834 mrLaFringeCost = mrLaFringeCost.add(lineItemCalculatedAmount.getCalculatedCost());
835 if(lineItem.getSubmitCostSharingFlag()){
836 mrLaFringeCostSharingAmount = mrLaFringeCostSharingAmount.add(lineItemCalculatedAmount
837 .getCalculatedCostSharing());
838 }
839 }
840 }
841 }
842 }
843 else{
844 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
845 List<? extends BudgetCategoryMappingContract> budgetCategoryList = budgetCategoryMapService.findCatMappingByTargetAndMappingName(category, SPONSOR);
846
847 for (BudgetCategoryMappingContract categoryMapping : budgetCategoryList) {
848 if (categoryMapping.getBudgetCategoryCode().equals(lineItem.getBudgetCategory().getCode())) {
849 List<? extends BudgetPersonnelDetailsContract> lineItemPersonDetails = lineItem.getBudgetPersonnelDetailsList();
850 boolean personExist = !lineItemPersonDetails.isEmpty();
851 if (personExist) {
852 for (BudgetPersonnelDetailsContract personDetails : lineItemPersonDetails) {
853 if (categoryMapping.getBudgetCategoryCode().equals(lineItem.getBudgetCategory().getCode())) {
854 String budgetPersonId = personDetails.getPersonId();
855 personExistsAsProposalPerson = false;
856
857
858 for (ProposalPersonContract proposalPerson : pdDoc.getDevelopmentProposal().getProposalPersons()) {
859 if (budgetPersonId.equals(proposalPerson.getPersonId())
860 || (proposalPerson.getRolodexId() != null && budgetPersonId.equals(proposalPerson
861 .getRolodexId().toString()))) {
862 personExistsAsProposalPerson = true;
863 break;
864 }
865 }
866 if (!personExistsAsProposalPerson) {
867 salaryRequested = salaryRequested.add(personDetails.getSalaryRequested());
868 if(lineItem.getSubmitCostSharingFlag()){
869 salaryCostSharing = salaryCostSharing.add(personDetails.getCostSharingAmount());
870 }
871 numberOfMonths = s2SDateTimeService.getNumberOfMonths(personDetails.getStartDate(),
872 personDetails.getEndDate()).bigDecimalValue();
873 if (personDetails.getPeriodTypeCode().equals(
874 s2SConfigurationService.getValueAsString(
875 ConfigurationConstants.S2SBUDGET_PERIOD_TYPE_ACADEMIC_MONTHS))) {
876 if (lineItem.getSubmitCostSharingFlag()) {
877 academicMonths = academicMonths.add(personDetails.getPercentEffort().bigDecimalValue()
878 .multiply(numberOfMonths).multiply(POINT_ZERO_ONE));
879 } else {
880 academicMonths = academicMonths.add(personDetails.getPercentCharged().bigDecimalValue()
881 .multiply(numberOfMonths).multiply(POINT_ZERO_ONE));
882 }
883 }
884 else if (personDetails.getPeriodTypeCode().equals(
885 s2SConfigurationService.getValueAsString(
886 ConfigurationConstants.S2SBUDGET_PERIOD_TYPE_SUMMER_MONTHS))) {
887 if (lineItem.getSubmitCostSharingFlag()) {
888 summerMonths = summerMonths.add(personDetails.getPercentEffort().bigDecimalValue().multiply(numberOfMonths)
889 .multiply(POINT_ZERO_ONE));
890 } else {
891 summerMonths = summerMonths.add(personDetails.getPercentCharged().bigDecimalValue().multiply(numberOfMonths)
892 .multiply(POINT_ZERO_ONE));
893 }
894
895 }
896 else if (personDetails.getPeriodTypeCode().equals(
897 s2SConfigurationService.getValueAsString(
898 ConfigurationConstants.S2SBUDGET_PERIOD_TYPE_CALENDAR_MONTHS))) {
899 if (lineItem.getSubmitCostSharingFlag()) {
900 calendarMonths = calendarMonths.add(personDetails.getPercentEffort().bigDecimalValue().multiply(numberOfMonths)
901 .multiply(POINT_ZERO_ONE));
902 } else {
903 calendarMonths = calendarMonths.add(personDetails.getPercentCharged().bigDecimalValue().multiply(numberOfMonths)
904 .multiply(POINT_ZERO_ONE));
905 }
906 }
907 else if (personDetails.getPeriodTypeCode().equals(
908 s2SConfigurationService.getValueAsString(
909 ConfigurationConstants.S2SBUDGET_PERIOD_TYPE_CYCLE_MONTHS))) {
910 cycleMonths = cycleMonths.add(personDetails.getPercentEffort().bigDecimalValue().multiply(numberOfMonths)
911 .multiply(POINT_ZERO_ONE));
912 }
913
914
915
916
917
918 personJobCodes.put(personDetails.getPersonId() + personDetails.getJobCode(), "");
919
920 for (BudgetPersonnelCalculatedAmountContract personCalculatedAmount : personDetails
921 .getBudgetPersonnelCalculatedAmounts()) {
922 if ((personCalculatedAmount.getRateClass().getCode().equals(
923 rateClassCodeEmployeeBenefits) && !personCalculatedAmount
924 .getRateTypeCode().equals(
925 rateTypeSupportStaffSalaries))
926 || (personCalculatedAmount.getRateClass().getCode().equals(
927 rateClassCodeVacation) && !personCalculatedAmount
928 .getRateTypeCode().equals(
929 rateTypeAdministrativeSalaries))) {
930 fringeCost = fringeCost.add(personCalculatedAmount.getCalculatedCost());
931 if(lineItem.getSubmitCostSharingFlag()){
932 fringeCostSharingAmount = fringeCostSharingAmount.add(personCalculatedAmount
933 .getCalculatedCostSharing());
934 }
935 }
936 }
937 }
938 }
939 }
940 }
941 else {
942
943
944
945
946 lineItemCost = lineItemCost.add(lineItem.getLineItemCost());
947 if(lineItem.getSubmitCostSharingFlag()){
948 lineItemCostSharingAmount = lineItemCostSharingAmount.add(lineItem.getCostSharingAmount());
949 }
950 count = lineItem.getQuantity();
951 for (BudgetLineItemCalculatedAmountContract lineItemCalculatedAmount : lineItem
952 .getBudgetLineItemCalculatedAmounts()) {
953
954
955 if (lineItemCalculatedAmount.getRateClass().getRateClassType().getCode().equalsIgnoreCase("E")) {
956 fringeCost = fringeCost.add(lineItemCalculatedAmount.getCalculatedCost());
957 }
958 if ((lineItemCalculatedAmount.getRateClass().getCode().equals(
959 rateClassCodeEmployeeBenefits) && !lineItemCalculatedAmount
960 .getRateTypeCode().equals(
961 rateTypeSupportStaffSalaries))
962 || (lineItemCalculatedAmount.getRateClass().getCode().equals(
963 rateClassCodeVacation) && !lineItemCalculatedAmount
964 .getRateTypeCode().equals(
965 rateTypeAdministrativeSalaries))) {
966 if(lineItem.getSubmitCostSharingFlag()){
967 fringeCostSharingAmount = fringeCostSharingAmount.add(lineItemCalculatedAmount
968 .getCalculatedCostSharing());
969 }
970 }
971 }
972 }
973 }
974 }
975 }
976 }
977
978 bdSalary = bdSalary.add(salaryRequested).add(lineItemCost).add(mrLaCost);
979 bdSalaryCostSharing = bdSalaryCostSharing.add(salaryCostSharing).add(lineItemCostSharingAmount).add(mrLaCostSharingAmount);
980
981
982 bdFringe = bdFringe.add(fringeCost).add(budgetLineItemFringeCost).add(mrLaFringeCost);
983 bdFringeCostSharing = bdFringeCostSharing.add(fringeCostSharingAmount).add(budgetLineItemFringeCostSharingAmount)
984 .add(mrLaFringeCostSharingAmount);
985
986 bdNonFunds = bdSalaryCostSharing.add(bdFringeCostSharing);
987 bdFunds = bdSalary.add(bdFringe);
988
989 count = personJobCodes.isEmpty() ? count : personJobCodes.size();
990 otherPersonnelInfo.setNumberPersonnel(count);
991 otherPersonnelInfo.setPersonnelType(personnelType);
992 otherPersonnelInfo.setRole(role);
993
994 CompensationDto compensationInfo = new CompensationDto();
995
996 compensationInfo.setBaseSalary(ScaleTwoDecimal.ZERO);
997 compensationInfo.setFringe(bdFringe);
998 compensationInfo.setFundsRequested(bdFunds);
999 compensationInfo.setRequestedSalary(bdSalary);
1000 compensationInfo.setSummerMonths(new ScaleTwoDecimal(summerMonths));
1001 compensationInfo.setAcademicMonths(new ScaleTwoDecimal(academicMonths));
1002 compensationInfo.setCalendarMonths(new ScaleTwoDecimal(calendarMonths));
1003
1004
1005 compensationInfo.setFringeCostSharing(bdFringeCostSharing);
1006 compensationInfo.setNonFundsRequested(bdNonFunds);
1007 compensationInfo.setCostSharingAmount(bdSalaryCostSharing);
1008
1009
1010 otherPersonnelInfo.setCompensation(compensationInfo);
1011 return otherPersonnelInfo;
1012 }
1013
1014
1015
1016
1017
1018
1019
1020
1021 @Override
1022 public IndirectCostDto getIndirectCosts(BudgetContract budget, BudgetPeriodContract budgetPeriod) {
1023 List<IndirectCostDetailsDto> indirectCostDetailList = new ArrayList<IndirectCostDetailsDto>();
1024 IndirectCostDetailsDto indirectCostDetails;
1025 ScaleTwoDecimal baseCost = ScaleTwoDecimal.ZERO;
1026 ScaleTwoDecimal baseCostSharing = ScaleTwoDecimal.ZERO;
1027 ScaleTwoDecimal calculatedCost = ScaleTwoDecimal.ZERO;
1028 ScaleTwoDecimal calculatedCostSharing = ScaleTwoDecimal.ZERO;
1029 ScaleTwoDecimal appliedRate = ScaleTwoDecimal.ZERO;
1030 ScaleTwoDecimal totalIndirectCosts = ScaleTwoDecimal.ZERO;
1031 ScaleTwoDecimal totalIndirectCostSharing = ScaleTwoDecimal.ZERO;
1032
1033 String description = "";
1034 boolean firstLoop = true;
1035
1036 if (budget.getModularBudgetFlag()) {
1037 for (BudgetModularIdcContract budgetModularIdc : budgetPeriod.getBudgetModular().getBudgetModularIdcs()) {
1038 if (firstLoop) {
1039 appliedRate = appliedRate.add(budgetModularIdc.getIdcRate());
1040 description = budgetModularIdc.getDescription();
1041 firstLoop = false;
1042 }
1043 baseCost = baseCost.add(budgetModularIdc.getIdcBase());
1044 calculatedCost = calculatedCost.add(budgetModularIdc.getFundsRequested());
1045 }
1046 indirectCostDetails = new IndirectCostDetailsDto();
1047 indirectCostDetails.setBase(baseCost);
1048 indirectCostDetails.setBaseCostSharing(baseCostSharing);
1049 indirectCostDetails.setCostSharing(calculatedCostSharing);
1050 indirectCostDetails.setCostType(description);
1051 indirectCostDetails.setFunds(calculatedCost);
1052 indirectCostDetails.setRate(appliedRate);
1053 indirectCostDetailList.add(indirectCostDetails);
1054 totalIndirectCosts = totalIndirectCosts.add(calculatedCost);
1055 totalIndirectCostSharing = totalIndirectCostSharing.add(calculatedCostSharing);
1056 }
1057 else {
1058 Map<String, IndirectCostDetailsDto> costDetailsMap = new HashMap<String, IndirectCostDetailsDto>();
1059 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
1060 for (BudgetRateAndBaseContract rateBase : lineItem.getBudgetRateAndBaseList()) {
1061 RateClassContract rateClass = rateBase.getRateClass();
1062 if (rateClass.getRateClassType().getCode().equals(RateClassType.OVERHEAD.getRateClassType())) {
1063 String rateClassCode = rateClass.getCode();
1064 String rateTypeCode = rateBase.getRateTypeCode();
1065 appliedRate = rateBase.getAppliedRate();
1066 StringBuilder keyBuilder = new StringBuilder();
1067 keyBuilder.append(rateClassCode);
1068 keyBuilder.append("-");
1069 keyBuilder.append(rateTypeCode);
1070 keyBuilder.append("-");
1071 keyBuilder.append(appliedRate);
1072 String key = keyBuilder.toString();
1073 if (costDetailsMap.get(key) == null) {
1074 indirectCostDetails = new IndirectCostDetailsDto();
1075 indirectCostDetails.setBase(rateBase.getBaseCost() == null ? ScaleTwoDecimal.ZERO : rateBase
1076 .getBaseCost());
1077 indirectCostDetails.setBaseCostSharing(rateBase.getBaseCostSharing() == null ? ScaleTwoDecimal.ZERO
1078 : rateBase.getBaseCostSharing());
1079 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1080 indirectCostDetails.setCostSharing(rateBase.getCalculatedCostSharing() == null ? ScaleTwoDecimal.ZERO
1081 : rateBase.getCalculatedCostSharing());
1082 }
1083 indirectCostDetails.setCostType(rateClass.getDescription());
1084 indirectCostDetails.setFunds(rateBase.getCalculatedCost() == null ? ScaleTwoDecimal.ZERO : rateBase
1085 .getCalculatedCost());
1086 indirectCostDetails.setRate(appliedRate);
1087 }
1088 else {
1089 indirectCostDetails = costDetailsMap.get(key);
1090 baseCost = indirectCostDetails.getBase().add(
1091 rateBase.getBaseCost() == null ? ScaleTwoDecimal.ZERO : rateBase.getBaseCost());
1092 baseCostSharing = indirectCostDetails.getBaseCostSharing().add(
1093 rateBase.getBaseCostSharing() == null ? ScaleTwoDecimal.ZERO : rateBase.getBaseCostSharing());
1094 calculatedCost = indirectCostDetails.getFunds().add(
1095 rateBase.getCalculatedCost() == null ? ScaleTwoDecimal.ZERO : rateBase.getCalculatedCost());
1096 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1097 calculatedCostSharing = indirectCostDetails.getCostSharing().add(
1098 rateBase.getCalculatedCostSharing() == null ? ScaleTwoDecimal.ZERO : rateBase
1099 .getCalculatedCostSharing());
1100 } else if (!lineItem.getSubmitCostSharingFlag()&& budget.getSubmitCostSharingFlag()) {
1101 calculatedCostSharing = indirectCostDetails.getCostSharing();
1102 }
1103 indirectCostDetails.setBase(baseCost);
1104 indirectCostDetails.setBaseCostSharing(baseCostSharing);
1105 indirectCostDetails.setCostSharing(calculatedCostSharing);
1106 indirectCostDetails.setFunds(calculatedCost);
1107 }
1108 costDetailsMap.put(key, indirectCostDetails);
1109
1110 indirectCostDetailList = new ArrayList<IndirectCostDetailsDto>(costDetailsMap.values());
1111 totalIndirectCosts = totalIndirectCosts.add(rateBase.getCalculatedCost() == null ? ScaleTwoDecimal.ZERO
1112 : rateBase.getCalculatedCost());
1113 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1114 totalIndirectCostSharing = totalIndirectCostSharing
1115 .add(rateBase.getCalculatedCostSharing() == null ? ScaleTwoDecimal.ZERO : rateBase
1116 .getCalculatedCostSharing());
1117 }
1118 }
1119 }
1120 }
1121 }
1122 IndirectCostDto indirectCostInfo = new IndirectCostDto();
1123 indirectCostInfo.setIndirectCostDetails(indirectCostDetailList);
1124 indirectCostInfo.setTotalIndirectCosts(totalIndirectCosts);
1125 indirectCostInfo.setTotalIndirectCostSharing(totalIndirectCostSharing);
1126 return indirectCostInfo;
1127 }
1128
1129
1130
1131
1132
1133
1134
1135
1136 protected List<OtherDirectCostInfoDto> getOtherDirectCosts(BudgetPeriodContract budgetPeriod, BudgetContract budget) {
1137 OtherDirectCostInfoDto otherDirectCostInfo = new OtherDirectCostInfoDto();
1138
1139 List<CostDto> costInfoList = new ArrayList<CostDto>();
1140 List<String> filterTargetCategoryCodes = new ArrayList<String>();
1141 filterTargetCategoryCodes.add(s2SConfigurationService.getValueAsString(
1142 ConfigurationConstants.S2SBUDGET_TARGET_CATEGORY_CODE_EQUIPMENT_COST));
1143 List<String> filterCategoryTypes = new ArrayList<String>();
1144 filterCategoryTypes.add(s2SConfigurationService.getValueAsString(
1145 ConfigurationConstants.S2SBUDGET_FILTER_CATEGORY_TYPE_PERSONNEL));
1146 List<? extends BudgetCategoryMapContract> budgetCategoryMapList = getBudgetCategoryMapList(filterTargetCategoryCodes, filterCategoryTypes);
1147
1148 boolean recordAdded;
1149 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
1150 for (BudgetCategoryMapContract budgetCategoryMap : budgetCategoryMapList) {
1151 recordAdded = false;
1152 for (BudgetCategoryMappingContract budgetCategoryMapping : budgetCategoryMap.getBudgetCategoryMappings()) {
1153 if (lineItem.getBudgetCategory().getCode().equals(budgetCategoryMapping.getBudgetCategoryCode())) {
1154 CostDto costInfo = new CostDto();
1155 costInfo.setBudgetPeriod(budgetPeriod.getBudgetPeriod().intValue());
1156 costInfo.setCost(lineItem.getLineItemCost());
1157 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1158 costInfo.setCostSharing(lineItem.getCostSharingAmount());
1159 }
1160 costInfo.setCategory(budgetCategoryMap.getDescription());
1161 costInfo.setCategoryType(budgetCategoryMap.getCategoryType());
1162 if (lineItem.getQuantity() != null) {
1163 costInfo.setQuantity(lineItem.getQuantity());
1164 }
1165 costInfoList.add(costInfo);
1166 recordAdded = true;
1167 break;
1168 }
1169 }
1170 if (recordAdded) {
1171 break;
1172 }
1173 }
1174
1175 CostDto lineItemcostInfo = new CostDto();
1176 lineItemcostInfo.setBudgetPeriod(budgetPeriod.getBudgetPeriod().intValue());
1177 lineItemcostInfo.setCategory(OTHER_DIRECT_COSTS);
1178 lineItemcostInfo.setCategoryType(CATEGORY_TYPE_OTHER_DIRECT_COST);
1179 lineItemcostInfo.setQuantity(1);
1180
1181 ScaleTwoDecimal totalCost = ScaleTwoDecimal.ZERO;
1182 ScaleTwoDecimal totalCostSharing = ScaleTwoDecimal.ZERO;
1183 for (BudgetLineItemCalculatedAmountContract lineItemCalculatedAmt : lineItem.getBudgetLineItemCalculatedAmounts()) {
1184 if (lineItemCalculatedAmt
1185 .getRateClass()
1186 .getRateClassType().getCode()
1187 .equals(s2SConfigurationService.getValueAsString(
1188 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_SALARIES_MS))) {
1189 totalCost = totalCost.add(lineItemCalculatedAmt.getCalculatedCost());
1190 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1191 totalCostSharing = totalCostSharing.add(lineItemCalculatedAmt.getCalculatedCostSharing());
1192 }
1193 }
1194 }
1195 lineItemcostInfo.setCost(totalCost);
1196 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1197 lineItemcostInfo.setCostSharing(totalCostSharing);
1198 }
1199 StringBuilder description = new StringBuilder();
1200 description.append(DESCRIPTION_LA);
1201 description.append(totalCost);
1202 description.append(";");
1203 lineItemcostInfo.setDescription(description.toString());
1204 costInfoList.add(lineItemcostInfo);
1205 }
1206
1207 ScaleTwoDecimal totalOtherDirect = ScaleTwoDecimal.ZERO;
1208 ScaleTwoDecimal totalTravelCost = ScaleTwoDecimal.ZERO;
1209 ScaleTwoDecimal totalParticipantCost = ScaleTwoDecimal.ZERO;
1210 ScaleTwoDecimal totalOtherDirectCostSharing = ScaleTwoDecimal.ZERO;
1211
1212 ScaleTwoDecimal totalTravelCostSharing = ScaleTwoDecimal.ZERO;
1213 ScaleTwoDecimal totalParticipantCostSharing = ScaleTwoDecimal.ZERO;
1214
1215 ScaleTwoDecimal materialCost = ScaleTwoDecimal.ZERO;
1216 ScaleTwoDecimal materialCostSharing = ScaleTwoDecimal.ZERO;
1217 ScaleTwoDecimal consultantCost = ScaleTwoDecimal.ZERO;
1218 ScaleTwoDecimal consultantCostSharing = ScaleTwoDecimal.ZERO;
1219 ScaleTwoDecimal publicationCost = ScaleTwoDecimal.ZERO;
1220 ScaleTwoDecimal publicationCostSharing = ScaleTwoDecimal.ZERO;
1221 ScaleTwoDecimal computerCost = ScaleTwoDecimal.ZERO;
1222 ScaleTwoDecimal computerCostSharing = ScaleTwoDecimal.ZERO;
1223 ScaleTwoDecimal alterationsCost = ScaleTwoDecimal.ZERO;
1224 ScaleTwoDecimal alterationsCostSharing = ScaleTwoDecimal.ZERO;
1225 ScaleTwoDecimal subContractCost = ScaleTwoDecimal.ZERO;
1226 ScaleTwoDecimal subContractCostSharing = ScaleTwoDecimal.ZERO;
1227 ScaleTwoDecimal equipmentRentalCost = ScaleTwoDecimal.ZERO;
1228 ScaleTwoDecimal equipmentRentalCostSharing = ScaleTwoDecimal.ZERO;
1229 ScaleTwoDecimal domesticTravelCost = ScaleTwoDecimal.ZERO;
1230 ScaleTwoDecimal domesticTravelCostSharing = ScaleTwoDecimal.ZERO;
1231 ScaleTwoDecimal foreignTravelCost = ScaleTwoDecimal.ZERO;
1232 ScaleTwoDecimal foreignTravelCostSharing = ScaleTwoDecimal.ZERO;
1233 ScaleTwoDecimal partStipendsCost = ScaleTwoDecimal.ZERO;
1234 ScaleTwoDecimal partStipendsCostSharing = ScaleTwoDecimal.ZERO;
1235 ScaleTwoDecimal partTravelCost = ScaleTwoDecimal.ZERO;
1236 ScaleTwoDecimal partTravelCostSharing = ScaleTwoDecimal.ZERO;
1237 ScaleTwoDecimal partTuitionCost = ScaleTwoDecimal.ZERO;
1238 ScaleTwoDecimal partTuitionCostSharing = ScaleTwoDecimal.ZERO;
1239 ScaleTwoDecimal partSubsistenceCost = ScaleTwoDecimal.ZERO;
1240 ScaleTwoDecimal partSubsistenceCostSharing = ScaleTwoDecimal.ZERO;
1241 ScaleTwoDecimal partOtherCost = ScaleTwoDecimal.ZERO;
1242 ScaleTwoDecimal partOtherCostSharing = ScaleTwoDecimal.ZERO;
1243 ScaleTwoDecimal otherDirectCost = ScaleTwoDecimal.ZERO;
1244 ScaleTwoDecimal otherDirectCostSharing = ScaleTwoDecimal.ZERO;
1245 ScaleTwoDecimal otherCost = ScaleTwoDecimal.ZERO;
1246 ScaleTwoDecimal otherCostSharing = ScaleTwoDecimal.ZERO;
1247
1248 for (CostDto costInfo : costInfoList) {
1249 if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1250 ConfigurationConstants.S2SBUDGET_MATERIALS_AND_SUPPLIES_CATEGORY))) {
1251 if (budget.getSubmitCostSharingFlag()) {
1252 materialCostSharing = materialCostSharing.add(costInfo.getCostSharing());
1253 }
1254 }
1255 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1256 ConfigurationConstants.S2SBUDGET_CONSULTANT_COSTS_CATEGORY))) {
1257 consultantCost = consultantCost.add(costInfo.getCost());
1258 if (budget.getSubmitCostSharingFlag()) {
1259 consultantCostSharing = consultantCostSharing.add(costInfo.getCostSharing());
1260 }
1261 }
1262 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1263 ConfigurationConstants.S2SBUDGET_PUBLICATION_COSTS_CATEGORY))) {
1264 publicationCost = publicationCost.add(costInfo.getCost());
1265 if (budget.getSubmitCostSharingFlag()) {
1266 publicationCostSharing = publicationCostSharing.add(costInfo.getCostSharing());
1267 }
1268 }
1269 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1270 ConfigurationConstants.S2SBUDGET_COMPUTER_SERVICES_CATEGORY))) {
1271 computerCost = computerCost.add(costInfo.getCost());
1272 if (budget.getSubmitCostSharingFlag()) {
1273 computerCostSharing = computerCostSharing.add(costInfo.getCostSharing());
1274 }
1275 }
1276 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1277 ConfigurationConstants.S2SBUDGET_ALTERATIONS_CATEGORY))) {
1278 alterationsCost = alterationsCost.add(costInfo.getCost());
1279 if (budget.getSubmitCostSharingFlag()) {
1280 alterationsCostSharing = alterationsCostSharing.add(costInfo.getCostSharing());
1281 }
1282 }
1283 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1284 ConfigurationConstants.S2SBUDGET_SUBCONTRACT_CATEGORY))) {
1285 subContractCost = subContractCost.add(costInfo.getCost());
1286 if (budget.getSubmitCostSharingFlag()) {
1287 subContractCostSharing = subContractCostSharing.add(costInfo.getCostSharing());
1288 }
1289 }
1290 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1291 ConfigurationConstants.S2SBUDGET_EQUIPMENT_RENTAL_CATEGORY))) {
1292 equipmentRentalCost = equipmentRentalCost.add(costInfo.getCost());
1293 if (budget.getSubmitCostSharingFlag()) {
1294 equipmentRentalCostSharing = equipmentRentalCostSharing.add(costInfo.getCostSharing());
1295 }
1296 }
1297 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1298 ConfigurationConstants.S2SBUDGET_DOMESTIC_TRAVEL_CATEGORY))) {
1299 domesticTravelCost = domesticTravelCost.add(costInfo.getCost());
1300 if (budget.getSubmitCostSharingFlag()) {
1301 domesticTravelCostSharing = domesticTravelCostSharing.add(costInfo.getCostSharing());
1302 }
1303 }
1304 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1305 ConfigurationConstants.S2SBUDGET_FOREIGN_TRAVEL_CATEGORY))) {
1306 foreignTravelCost = foreignTravelCost.add(costInfo.getCost());
1307 if (budget.getSubmitCostSharingFlag()) {
1308 foreignTravelCostSharing = foreignTravelCostSharing.add(costInfo.getCostSharing());
1309 }
1310 }
1311 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1312 ConfigurationConstants.S2SBUDGET_PARTICIPANT_STIPENDS_CATEGORY))) {
1313 partStipendsCost = partStipendsCost.add(costInfo.getCost());
1314 if (budget.getSubmitCostSharingFlag()) {
1315 partStipendsCostSharing = partStipendsCostSharing.add(costInfo.getCostSharing());
1316 totalParticipantCostSharing = totalParticipantCostSharing.add(costInfo.getCostSharing());
1317 }
1318 totalParticipantCost = totalParticipantCost.add(costInfo.getCost());
1319 }
1320 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1321 ConfigurationConstants.S2SBUDGET_PARTICIPANT_TRAVEL_CATEGORY))) {
1322 partTravelCost = partTravelCost.add(costInfo.getCost());
1323 if (budget.getSubmitCostSharingFlag()) {
1324 partTravelCostSharing = partTravelCostSharing.add(costInfo.getCostSharing());
1325 totalParticipantCostSharing = totalParticipantCostSharing.add(costInfo.getCostSharing());
1326 }
1327 totalParticipantCost = totalParticipantCost.add(costInfo.getCost());
1328 }
1329 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1330 ConfigurationConstants.S2SBUDGET_PARTICIPANT_TUITION_CATEGORY))) {
1331 partTuitionCost = partTuitionCost.add(costInfo.getCost());
1332 if (budget.getSubmitCostSharingFlag()) {
1333 partTuitionCostSharing = partTuitionCostSharing.add(costInfo.getCostSharing());
1334 totalParticipantCostSharing = totalParticipantCostSharing.add(costInfo.getCostSharing());
1335 }
1336 totalParticipantCost = totalParticipantCost.add(costInfo.getCost());
1337 }
1338 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1339 ConfigurationConstants.S2SBUDGET_PARTICIPANT_SUBSISTENCE_CATEGORY))) {
1340 partSubsistenceCost = partSubsistenceCost.add(costInfo.getCost());
1341 if (budget.getSubmitCostSharingFlag()) {
1342 partSubsistenceCostSharing = partSubsistenceCostSharing.add(costInfo.getCostSharing());
1343 totalParticipantCostSharing = totalParticipantCostSharing.add(costInfo.getCostSharing());
1344 }
1345 totalParticipantCost = totalParticipantCost.add(costInfo.getCost());
1346 }
1347 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1348 ConfigurationConstants.S2SBUDGET_PARTICIPANT_OTHER_CATEGORY))) {
1349 partOtherCost = partOtherCost.add(costInfo.getCost());
1350 if (budget.getSubmitCostSharingFlag()) {
1351 partOtherCostSharing = partOtherCostSharing.add(costInfo.getCostSharing());
1352 totalParticipantCostSharing = totalParticipantCostSharing.add(costInfo.getCostSharing());
1353 }
1354 totalParticipantCost = totalParticipantCost.add(costInfo.getCost());
1355 }
1356 else if (costInfo.getCategory().equals(s2SConfigurationService.getValueAsString(
1357 ConfigurationConstants.S2SBUDGET_OTHER_DIRECT_COSTS_CATEGORY))) {
1358 otherDirectCost = otherDirectCost.add(costInfo.getCost());
1359 if (budget.getSubmitCostSharingFlag()) {
1360 otherDirectCostSharing = otherDirectCostSharing.add(costInfo.getCostSharing());
1361 }
1362 }
1363 else {
1364 otherCost = otherCost.add(costInfo.getCost());
1365 if (budget.getSubmitCostSharingFlag()) {
1366 otherCostSharing = otherCostSharing.add(costInfo.getCostSharing());
1367 }
1368 }
1369 }
1370
1371 otherDirectCostInfo.setmaterials(materialCost);
1372 otherDirectCostInfo.setMaterialsCostSharing(materialCostSharing);
1373 otherDirectCostInfo.setConsultants(consultantCost);
1374 otherDirectCostInfo.setConsultantsCostSharing(consultantCostSharing);
1375 otherDirectCostInfo.setpublications(publicationCost);
1376 otherDirectCostInfo.setPublicationsCostSharing(publicationCostSharing);
1377 otherDirectCostInfo.setcomputer(computerCost);
1378 otherDirectCostInfo.setComputerCostSharing(computerCostSharing);
1379 otherDirectCostInfo.setAlterations(alterationsCost);
1380 otherDirectCostInfo.setAlterationsCostSharing(alterationsCostSharing);
1381 otherDirectCostInfo.setsubAwards(subContractCost);
1382 otherDirectCostInfo.setSubAwardsCostSharing(subContractCostSharing);
1383 otherDirectCostInfo.setEquipRental(equipmentRentalCost);
1384 otherDirectCostInfo.setEquipRentalCostSharing(equipmentRentalCostSharing);
1385 otherDirectCostInfo.setDomTravel(domesticTravelCost);
1386 otherDirectCostInfo.setDomTravelCostSharing(domesticTravelCostSharing);
1387 otherDirectCostInfo.setForeignTravel(foreignTravelCost);
1388 otherDirectCostInfo.setForeignTravelCostSharing(foreignTravelCostSharing);
1389 otherDirectCostInfo.setPartStipends(partStipendsCost);
1390 otherDirectCostInfo.setPartStipendsCostSharing(partStipendsCostSharing);
1391 otherDirectCostInfo.setPartTravel(partTravelCost);
1392 otherDirectCostInfo.setPartTravelCostSharing(partTravelCostSharing);
1393 otherDirectCostInfo.setPartTuition(partTuitionCost);
1394 otherDirectCostInfo.setPartTuitionCostSharing(partTuitionCostSharing);
1395 otherDirectCostInfo.setPartSubsistence(partSubsistenceCost);
1396 otherDirectCostInfo.setPartSubsistenceCostSharing(partSubsistenceCostSharing);
1397 otherDirectCostInfo.setPartOther(partOtherCost);
1398 otherDirectCostInfo.setPartOtherCostSharing(partOtherCostSharing);
1399 otherDirectCostInfo.setParticipantTotal(totalParticipantCost);
1400 otherDirectCostInfo.setParticipantTotalCostSharing(totalParticipantCostSharing);
1401 otherDirectCostInfo.setParticipantTotalCount(budgetPeriod.getNumberOfParticipants() == null ? 0 : budgetPeriod.getNumberOfParticipants());
1402
1403 totalOtherDirect = totalOtherDirect.add(materialCost);
1404 totalOtherDirect = totalOtherDirect.add(consultantCost);
1405 totalOtherDirect = totalOtherDirect.add(publicationCost);
1406 totalOtherDirect = totalOtherDirect.add(computerCost);
1407 totalOtherDirect = totalOtherDirect.add(alterationsCost);
1408 totalOtherDirect = totalOtherDirect.add(subContractCost);
1409 totalOtherDirect = totalOtherDirect.add(equipmentRentalCost);
1410 totalOtherDirect = totalOtherDirect.add(otherDirectCost);
1411 totalOtherDirect = totalOtherDirect.add(otherCost);
1412
1413 totalTravelCost = totalTravelCost.add(domesticTravelCost);
1414 totalTravelCost = totalTravelCost.add(foreignTravelCost);
1415 if (budget.getSubmitCostSharingFlag()) {
1416 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(materialCostSharing);
1417 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(consultantCostSharing);
1418 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(publicationCostSharing);
1419 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(computerCostSharing);
1420 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(alterationsCostSharing);
1421 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(subContractCostSharing);
1422 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(equipmentRentalCostSharing);
1423 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(otherDirectCostSharing);
1424 totalOtherDirectCostSharing = totalOtherDirectCostSharing.add(otherCostSharing);
1425
1426 totalTravelCostSharing = totalTravelCostSharing.add(domesticTravelCostSharing);
1427 totalTravelCostSharing = totalTravelCostSharing.add(foreignTravelCostSharing);
1428 }
1429 otherDirectCostInfo.settotalOtherDirect(totalOtherDirect);
1430 otherDirectCostInfo.setTotalOtherDirectCostSharing(totalOtherDirectCostSharing);
1431 otherDirectCostInfo.setTotTravel(totalTravelCost);
1432 otherDirectCostInfo.setTotTravelCostSharing(totalTravelCostSharing);
1433
1434 List<Map<String, String>> otherCostDetails = new ArrayList<Map<String, String>>();
1435 Map<String, String> hmOtherDirectCostDetails = new HashMap<String, String>();
1436 hmOtherDirectCostDetails.put(CostConstants.KEY_COST, otherDirectCost.toString());
1437 hmOtherDirectCostDetails
1438 .put(DESCRIPTION,OTHER_DIRECT_COSTS);
1439 hmOtherDirectCostDetails.put(CostConstants.KEY_COSTSHARING, otherDirectCostSharing.toString());
1440 otherCostDetails.add(hmOtherDirectCostDetails);
1441
1442 Map<String, String> hmOtherCostDetails = new HashMap<String, String>();
1443 hmOtherCostDetails.put(CostConstants.KEY_COST, otherCost.toString());
1444 hmOtherCostDetails
1445 .put(DESCRIPTION,ALL_OTHER_COSTS);
1446 hmOtherCostDetails.put(CostConstants.KEY_COSTSHARING, otherCostSharing.toString());
1447 otherCostDetails.add(hmOtherCostDetails);
1448
1449 otherDirectCostInfo.setOtherCosts(otherCostDetails);
1450 List<OtherDirectCostInfoDto> otherDirectCosts = new ArrayList<OtherDirectCostInfoDto>();
1451 otherDirectCosts.add(otherDirectCostInfo);
1452 return otherDirectCosts;
1453 }
1454
1455 private boolean canBudgetLineItemCostSharingInclude(BudgetContract budget, BudgetLineItemContract lineItem) {
1456 return budget.getSubmitCostSharingFlag() && lineItem.getSubmitCostSharingFlag();
1457 }
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469 @Override
1470 public List<? extends BudgetCategoryMapContract> getBudgetCategoryMapList(List<String> filterTargetCategoryCodes, List<String> filterCategoryTypes) {
1471 List<? extends BudgetCategoryMappingContract> budgetCategoryMappingList;
1472 List<BudgetCategoryMapContract> budgetCategoryMapList = new ArrayList<BudgetCategoryMapContract>();
1473 budgetCategoryMappingList = budgetCategoryMapService.findCatMappingByMappingName(SPONSOR);
1474
1475 boolean targetMatched;
1476 boolean duplicateExists;
1477 for (BudgetCategoryMappingContract categoryMapping : budgetCategoryMappingList) {
1478 targetMatched = true;
1479
1480 if (filterTargetCategoryCodes.size() > 0) {
1481 for (String targetCategoryCode : filterTargetCategoryCodes) {
1482 if (categoryMapping.getTargetCategoryCode().equals(targetCategoryCode)) {
1483 targetMatched = false;
1484 break;
1485 }
1486 }
1487 }
1488
1489 if (targetMatched) {
1490 Iterator<? extends BudgetCategoryMapContract> filterList = budgetCategoryMapService.findCatMapByTargetAndMappingName(
1491 categoryMapping.getTargetCategoryCode(), categoryMapping.getMappingName()).iterator();
1492
1493 while (filterList.hasNext()) {
1494 BudgetCategoryMapContract filterMap = filterList.next();
1495 targetMatched = true;
1496 if (filterCategoryTypes.size() > 0) {
1497 for (String categoryType : filterCategoryTypes) {
1498 if (filterMap.getCategoryType().trim().equals(categoryType.trim())) {
1499 targetMatched = false;
1500 break;
1501 }
1502 }
1503 }
1504
1505 if (targetMatched) {
1506
1507 duplicateExists = false;
1508 for (BudgetCategoryMapContract map : budgetCategoryMapList) {
1509 if (filterMap.getTargetCategoryCode().equals(map.getTargetCategoryCode())) {
1510 duplicateExists = true;
1511 break;
1512 }
1513 }
1514 if (!duplicateExists) {
1515 budgetCategoryMapList.add(filterMap);
1516 }
1517 }
1518 }
1519 }
1520 }
1521 return budgetCategoryMapList;
1522 }
1523
1524
1525
1526
1527
1528
1529
1530
1531 protected List<EquipmentDto> getEquipment(BudgetPeriodContract budgetPeriod, BudgetContract budget) {
1532 List<CostDto> cvExtraEquipment = new ArrayList<CostDto>();
1533 CostDto equipCostInfo;
1534 List<? extends BudgetCategoryMapContract> budgetCategoryMapList = getBudgetCategoryMapList(new ArrayList<String>(), new ArrayList<String>());
1535
1536 ScaleTwoDecimal totalEquipFund = ScaleTwoDecimal.ZERO;
1537 ScaleTwoDecimal totalExtraEquipFund = ScaleTwoDecimal.ZERO;
1538 ScaleTwoDecimal totalEquipNonFund = ScaleTwoDecimal.ZERO;
1539 ScaleTwoDecimal totalExtraEquipNonFund = ScaleTwoDecimal.ZERO;
1540 Map<String, CostDto> costInfoMap = new HashMap<String, CostDto>();
1541 List<CostDto> costInfos = new ArrayList<CostDto>();
1542 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
1543 for (BudgetCategoryMapContract budgetCategoryMap : budgetCategoryMapList) {
1544 equipCostInfo = new CostDto();
1545 for (BudgetCategoryMappingContract budgetCategoryMapping : budgetCategoryMap.getBudgetCategoryMappings()) {
1546 if (lineItem.getBudgetCategory().getCode().equals(budgetCategoryMapping.getBudgetCategoryCode())
1547 && (budgetCategoryMapping.getTargetCategoryCode().equals( s2SConfigurationService.getValueAsString(
1548 ConfigurationConstants.S2SBUDGET_TARGET_CATEGORY_CODE_EQUIPMENT_COST)))
1549 && (budgetCategoryMapping.getMappingName().equals(SPONSOR))) {
1550 equipCostInfo.setBudgetPeriod(budgetPeriod.getBudgetPeriod().intValue());
1551 equipCostInfo.setCategory(budgetCategoryMap.getDescription());
1552 equipCostInfo.setCategoryType(budgetCategoryMap.getCategoryType());
1553 if (lineItem.getLineItemDescription() != null)
1554 equipCostInfo.setDescription(lineItem.getLineItemDescription());
1555 else
1556 equipCostInfo.setDescription(lineItem.getCostElementBO().getDescription());
1557 totalEquipFund = totalEquipFund.add(lineItem.getLineItemCost());
1558 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1559 totalEquipNonFund = totalEquipNonFund.add(lineItem.getCostSharingAmount());
1560 }
1561
1562 StringBuilder keyBuilder = new StringBuilder();
1563 keyBuilder.append(budgetCategoryMap.getCategoryType());
1564 keyBuilder.append("-");
1565 keyBuilder.append(lineItem.getLineItemDescription());
1566 String key = keyBuilder.toString();
1567 if (costInfoMap.get(key) == null) {
1568 equipCostInfo = new CostDto();
1569 equipCostInfo.setBudgetPeriod(budgetPeriod.getBudgetPeriod().intValue());
1570 equipCostInfo.setCategory(budgetCategoryMap.getDescription());
1571 equipCostInfo.setCategoryType(budgetCategoryMap.getCategoryType());
1572 if (lineItem.getLineItemDescription() != null)
1573 equipCostInfo.setDescription(lineItem.getLineItemDescription());
1574 else
1575 equipCostInfo.setDescription(lineItem.getCostElementBO().getDescription());
1576 equipCostInfo.setCost(lineItem.getLineItemCost());
1577 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1578 equipCostInfo.setCostSharing(lineItem.getCostSharingAmount());
1579 }
1580 }
1581 else {
1582 equipCostInfo = costInfoMap.get(key);
1583 equipCostInfo.setCost(equipCostInfo.getCost().add(lineItem.getLineItemCost()));
1584 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1585 equipCostInfo.setCostSharing(equipCostInfo.getCostSharing().add(lineItem.getCostSharingAmount()));
1586 }
1587 }
1588 costInfoMap.put(key, equipCostInfo);
1589 costInfos.add(equipCostInfo);
1590 }
1591 }
1592 }
1593 }
1594 EquipmentDto equipmentInfo = new EquipmentDto();
1595
1596 if (costInfos.size() > 10) {
1597 for (int j = costInfos.size() - 1; j > 9; j--) {
1598 cvExtraEquipment.add(costInfos.get(j));
1599 CostDto extraCostInfo = (CostDto) costInfos.get(j);
1600 totalExtraEquipFund = totalExtraEquipFund.add(extraCostInfo.getCost());
1601 totalExtraEquipNonFund = totalExtraEquipNonFund.add(extraCostInfo.getCostSharing());
1602 costInfos.remove(j);
1603 }
1604 Collections.reverse(cvExtraEquipment);
1605 equipmentInfo.setExtraEquipmentList(cvExtraEquipment);
1606 equipmentInfo.setTotalExtraNonFund(totalExtraEquipNonFund);
1607 }
1608 equipmentInfo.setTotalExtraFund(totalExtraEquipFund);
1609
1610 equipmentInfo.setEquipmentList(costInfos);
1611 equipmentInfo.setTotalFund(totalEquipFund);
1612 equipmentInfo.setTotalNonFund(totalEquipNonFund);
1613
1614 List<EquipmentDto> equipmentInfos = new ArrayList<EquipmentDto>();
1615 equipmentInfos.add(equipmentInfo);
1616 return equipmentInfos;
1617 }
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627 protected List<List<KeyPersonDto>> getKeyPersons(BudgetPeriodContract budgetPeriod, ProposalDevelopmentDocumentContract pdDoc,
1628 int numKeyPersons, BudgetContract budget) {
1629 List<KeyPersonDto> keyPersons = new ArrayList<KeyPersonDto>();
1630 List<KeyPersonDto> seniorPersons = new ArrayList<KeyPersonDto>();
1631 KeyPersonDto keyPerson = new KeyPersonDto();
1632 ProposalPersonContract principalInvestigator = s2SProposalPersonService.getPrincipalInvestigator(pdDoc);
1633
1634
1635 List<ProposalPersonContract> propPersons = new ArrayList<ProposalPersonContract>();
1636 if (principalInvestigator != null) {
1637 propPersons.add(principalInvestigator);
1638 keyPerson.setPersonId(principalInvestigator.getPersonId());
1639 keyPerson.setRolodexId(principalInvestigator.getRolodexId());
1640 keyPerson.setFirstName(principalInvestigator.getFirstName() == null ? FieldValueConstants.VALUE_UNKNOWN
1641 : principalInvestigator.getFirstName());
1642 keyPerson.setLastName(principalInvestigator.getLastName() == null ? FieldValueConstants.VALUE_UNKNOWN : principalInvestigator
1643 .getLastName());
1644 keyPerson.setMiddleName(principalInvestigator.getMiddleName());
1645 keyPerson.setRole(PRINCIPAL_INVESTIGATOR_ROLE);
1646 keyPerson.setNonMITPersonFlag(isPersonNonMITPerson(principalInvestigator));
1647 keyPersons.add(keyPerson);
1648 }
1649
1650 for (ProposalPersonContract coInvestigator : s2SProposalPersonService.getCoInvestigators(pdDoc)) {
1651 propPersons.add(coInvestigator);
1652 keyPerson = new KeyPersonDto();
1653 keyPerson.setPersonId(coInvestigator.getPersonId());
1654 keyPerson.setRolodexId(coInvestigator.getRolodexId());
1655 keyPerson.setFirstName(coInvestigator.getFirstName() == null ? FieldValueConstants.VALUE_UNKNOWN : coInvestigator
1656 .getFirstName());
1657 keyPerson.setLastName(coInvestigator.getLastName() == null ? FieldValueConstants.VALUE_UNKNOWN : coInvestigator.getLastName());
1658 keyPerson.setMiddleName(coInvestigator.getMiddleName());
1659 keyPerson.setNonMITPersonFlag(isPersonNonMITPerson(coInvestigator));
1660
1661 if (sponsorHierarchyService.isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) {
1662 if (coInvestigator.isMultiplePi()){
1663 keyPerson.setRole(NID_PD_PI);
1664 }else{
1665 keyPerson.setRole(NID_CO_PD_PI);
1666 }
1667 }else{
1668 keyPerson.setRole(KEYPERSON_CO_PD_PI);
1669 }
1670 keyPersons.add(keyPerson);
1671 }
1672
1673 for (ProposalPersonContract propPerson : s2SProposalPersonService.getKeyPersons(pdDoc)) {
1674 propPersons.add(propPerson);
1675 keyPerson = new KeyPersonDto();
1676 keyPerson.setPersonId(propPerson.getPersonId());
1677 keyPerson.setRolodexId(propPerson.getRolodexId());
1678 keyPerson.setFirstName(propPerson.getFirstName() == null ? FieldValueConstants.VALUE_UNKNOWN : propPerson.getFirstName());
1679 keyPerson.setLastName(propPerson.getLastName() == null ? FieldValueConstants.VALUE_UNKNOWN : propPerson.getLastName());
1680 keyPerson.setMiddleName(propPerson.getMiddleName());
1681 keyPerson.setNonMITPersonFlag(isPersonNonMITPerson(propPerson));
1682
1683 keyPerson.setRole(getBudgetPersonRoleOther());
1684 keyPerson.setKeyPersonRole(propPerson.getProjectRole());
1685 keyPersons.add(keyPerson);
1686 }
1687
1688 boolean personAlreadyAdded = false;
1689 List<? extends BudgetCategoryMappingContract> budgetCategoryList = budgetCategoryMapService.findCatMappingByTargetAndMappingName(TARGET_CATEGORY_CODE_01, SPONSOR);
1690 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
1691 for (BudgetPersonnelDetailsContract budgetPersonnelDetails : lineItem.getBudgetPersonnelDetailsList()) {
1692 personAlreadyAdded = false;
1693 for (ProposalPersonContract proposalPerson : pdDoc.getDevelopmentProposal().getProposalPersons()) {
1694 if (proposalPersonEqualsBudgetPerson(proposalPerson, budgetPersonnelDetails)) {
1695 personAlreadyAdded = true;
1696 break;
1697 }
1698 }
1699 if (!personAlreadyAdded) {
1700 if (budgetPersonnelDetails.getBudgetPerson().getNonEmployeeFlag()) {
1701 if (budgetPersonnelDetails.getBudgetPerson().getRolodexId() != null) {
1702 RolodexContract rolodexPerson = rolodexService.getRolodex(budgetPersonnelDetails.getBudgetPerson().getRolodexId());
1703 keyPerson = new KeyPersonDto();
1704 keyPerson.setRolodexId(rolodexPerson.getRolodexId());
1705 keyPerson.setFirstName(rolodexPerson.getFirstName() == null ? FieldValueConstants.VALUE_UNKNOWN
1706 : rolodexPerson.getFirstName());
1707 keyPerson.setLastName(rolodexPerson.getLastName() == null ? FieldValueConstants.VALUE_UNKNOWN : rolodexPerson
1708 .getLastName());
1709 keyPerson.setMiddleName(rolodexPerson.getMiddleName());
1710 keyPerson.setRole(StringUtils.isNotBlank(rolodexPerson.getTitle()) ? rolodexPerson.getTitle()
1711 : getBudgetPersonRoleOther());
1712 keyPerson.setNonMITPersonFlag(true);
1713
1714 if (isSeniorLineItem(budgetCategoryList, lineItem.getBudgetCategory().getCode())) {
1715 keyPersons.add(keyPerson);
1716 }
1717 }else if (StringUtils.isNotBlank(budgetPersonnelDetails.getBudgetPerson().getTbnId())) {
1718 TbnPersonContract tbnPerson = tbnPersonService.getTbnPerson(budgetPersonnelDetails.getBudgetPerson().getTbnId());
1719 if (tbnPerson != null) {
1720 keyPerson = new KeyPersonDto();
1721 String[] tbnNames = tbnPerson.getPersonName().split(" ");
1722 int nameIndex = 0;
1723 keyPerson.setPersonId(tbnPerson.getId());
1724 keyPerson.setFirstName(tbnNames.length >= 1 ? tbnNames[nameIndex++] : FieldValueConstants.VALUE_UNKNOWN);
1725 keyPerson.setMiddleName(tbnNames.length >= 3 ? tbnNames[nameIndex++] : " ");
1726 keyPerson.setLastName(tbnNames.length >= 2 ? tbnNames[nameIndex++] : FieldValueConstants.VALUE_UNKNOWN);
1727 keyPerson.setRole(tbnPerson.getPersonName());
1728 keyPerson.setNonMITPersonFlag(false);
1729
1730 if (isSeniorLineItem( budgetCategoryList, lineItem.getBudgetCategory().getCode())) {
1731 keyPersons.add(keyPerson);
1732 }
1733
1734 }
1735 }
1736 }else {
1737
1738 KcPersonContract kcPerson = kcPersonRepositoryService.findKcPersonByPersonId(budgetPersonnelDetails.getBudgetPerson().getPersonId());
1739 if (kcPerson != null) {
1740 keyPerson = new KeyPersonDto();
1741 keyPerson.setPersonId(kcPerson.getPersonId());
1742 keyPerson.setFirstName(kcPerson.getFirstName() == null ? FieldValueConstants.VALUE_UNKNOWN : kcPerson
1743 .getFirstName());
1744 keyPerson.setLastName(kcPerson.getLastName() == null ? FieldValueConstants.VALUE_UNKNOWN : kcPerson
1745 .getLastName());
1746 keyPerson.setMiddleName(kcPerson.getMiddleName());
1747 keyPerson.setNonMITPersonFlag(false);
1748 keyPerson.setRole(getBudgetPersonRoleOther());
1749 if (isSeniorLineItem( budgetCategoryList, lineItem.getBudgetCategory().getCode())) {
1750 keyPersons.add(keyPerson);
1751 }
1752 }
1753 }
1754 }
1755 }
1756 }
1757 for(KeyPersonDto seniorPerson : keyPersons){
1758 if(seniorPerson.getRole().equals(NID_PD_PI)||hasPersonnelBudget(budgetPeriod,seniorPerson)){
1759 seniorPersons.add(seniorPerson);
1760 }
1761 }
1762
1763 List<KeyPersonDto> nKeyPersons = getNKeyPersons(seniorPersons, true, numKeyPersons);
1764 List<KeyPersonDto> extraPersons = getNKeyPersons(seniorPersons, false, numKeyPersons);
1765 CompensationDto compensationInfo;
1766 for (KeyPersonDto keyPersonInfo : nKeyPersons) {
1767 keyPerson = keyPersonInfo;
1768 compensationInfo = getCompensation(keyPerson, budgetPeriod, pdDoc.getDevelopmentProposal().getProposalNumber(), budget);
1769 keyPerson.setAcademicMonths(compensationInfo.getAcademicMonths());
1770 keyPerson.setCalendarMonths(compensationInfo.getCalendarMonths());
1771 keyPerson.setSummerMonths(compensationInfo.getSummerMonths());
1772 keyPerson.setBaseSalary(compensationInfo.getBaseSalary());
1773 keyPerson.setRequestedSalary(compensationInfo.getRequestedSalary());
1774 keyPerson.setFundsRequested(compensationInfo.getFundsRequested());
1775 keyPerson.setFringe(compensationInfo.getFringe());
1776
1777 keyPerson.setCostSharingAmount(compensationInfo.getCostSharingAmount());
1778 keyPerson.setNonFundsRequested(compensationInfo.getNonFundsRequested());
1779 keyPerson.setFringeCostSharing(compensationInfo.getFringeCostSharing());
1780
1781 }
1782
1783 if (extraPersons != null) {
1784 for (KeyPersonDto keyPersonInfo : extraPersons) {
1785 keyPerson = keyPersonInfo;
1786 compensationInfo = getCompensation(keyPerson, budgetPeriod, pdDoc.getDevelopmentProposal().getProposalNumber(), budget);
1787
1788 keyPerson.setAcademicMonths(compensationInfo.getAcademicMonths());
1789 keyPerson.setCalendarMonths(compensationInfo.getCalendarMonths());
1790 keyPerson.setSummerMonths(compensationInfo.getSummerMonths());
1791 keyPerson.setBaseSalary(compensationInfo.getBaseSalary());
1792 keyPerson.setRequestedSalary(compensationInfo.getRequestedSalary());
1793 keyPerson.setFundsRequested(compensationInfo.getFundsRequested());
1794 keyPerson.setFringe(compensationInfo.getFringe());
1795
1796 keyPerson.setCostSharingAmount(compensationInfo.getCostSharingAmount());
1797 keyPerson.setNonFundsRequested(compensationInfo.getNonFundsRequested());
1798 keyPerson.setFringeCostSharing(compensationInfo.getFringeCostSharing());
1799
1800 }
1801 }
1802
1803 List<List<KeyPersonDto>> listKeyPersons = new ArrayList<List<KeyPersonDto>>();
1804 listKeyPersons.add(nKeyPersons);
1805 listKeyPersons.add(extraPersons);
1806 return listKeyPersons;
1807 }
1808
1809 private Boolean hasPersonnelBudget(BudgetPeriodContract budgetPeriod,KeyPersonDto keyPerson){
1810
1811 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
1812 for (BudgetPersonnelDetailsContract budgetPersonnelDetails : lineItem.getBudgetPersonnelDetailsList()) {
1813 if( budgetPersonnelDetails.getPersonId().equals(keyPerson.getPersonId())){
1814 return true;
1815 }
1816 }
1817 }
1818 return false;
1819 }
1820
1821 private String getBudgetPersonRoleOther() {
1822 return KEYPERSON_OTHER;
1823 }
1824
1825 private boolean isSeniorLineItem(List<? extends BudgetCategoryMappingContract> budgetCategoryList, String budgetCategoryCode) {
1826 boolean isSeniorLineItem = false;
1827 for (BudgetCategoryMappingContract categoryMapping : budgetCategoryList) {
1828 if (categoryMapping.getBudgetCategoryCode().equals(budgetCategoryCode)) {
1829 isSeniorLineItem = true;
1830 }
1831 }
1832 return isSeniorLineItem;
1833 }
1834
1835 protected boolean proposalPersonEqualsBudgetPerson(ProposalPersonContract proposalPerson, BudgetPersonnelDetailsContract budgetPersonnelDetails) {
1836 boolean equal = false;
1837 if (proposalPerson != null && budgetPersonnelDetails != null) {
1838 String budgetPersonId = budgetPersonnelDetails.getPersonId();
1839 if ((proposalPerson.getPersonId() != null && proposalPerson.getPersonId().equals(budgetPersonId))
1840 || (proposalPerson.getRolodexId() != null && proposalPerson.getRolodexId().toString().equals(budgetPersonId))) {
1841 equal = true;
1842 }
1843 }
1844 return equal;
1845 }
1846
1847
1848
1849
1850
1851
1852
1853
1854 @Override
1855 public boolean isPersonNonMITPerson(ProposalPersonContract proposalPerson) {
1856 return proposalPerson.getPersonId() == null;
1857 }
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869 protected CompensationDto getCompensation(KeyPersonDto keyPerson, BudgetPeriodContract budgetPeriod, String proposalNumber, BudgetContract budget) {
1870 CompensationDto compensationInfo = new CompensationDto();
1871 BigDecimal summerMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
1872 BigDecimal academicMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
1873 BigDecimal calendarMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
1874 ScaleTwoDecimal totalSal = ScaleTwoDecimal.ZERO;
1875 ScaleTwoDecimal fringe = ScaleTwoDecimal.ZERO;
1876 ScaleTwoDecimal baseAmount = ScaleTwoDecimal.ZERO;
1877 ScaleTwoDecimal totalSalCostSharing = ScaleTwoDecimal.ZERO;
1878 ScaleTwoDecimal fringeCostSharing = ScaleTwoDecimal.ZERO;
1879 BigDecimal numberOfMonths = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
1880 String budgetCatagoryCodePersonnel = s2SConfigurationService.getValueAsString(
1881 ConfigurationConstants.S2SBUDGET_BUDGET_CATEGORY_CODE_PERSONNEL);
1882
1883 for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
1884
1885 for (BudgetPersonnelDetailsContract personDetails : lineItem.getBudgetPersonnelDetailsList()) {
1886 if (keyPersonEqualsBudgetPerson(keyPerson, personDetails)) {
1887 numberOfMonths = s2SDateTimeService.getNumberOfMonths(personDetails.getStartDate(), personDetails.getEndDate()).bigDecimalValue();
1888 if (personDetails.getPeriodTypeCode().equals(
1889 s2SConfigurationService.getValueAsString(
1890 ConfigurationConstants.S2SBUDGET_PERIOD_TYPE_ACADEMIC_MONTHS))) {
1891 if (lineItem.getSubmitCostSharingFlag()) {
1892 academicMonths = academicMonths.add(personDetails.getPercentEffort().bigDecimalValue()
1893 .multiply(numberOfMonths).multiply(POINT_ZERO_ONE));
1894 } else {
1895 academicMonths = academicMonths.add(personDetails.getPercentCharged().bigDecimalValue()
1896 .multiply(numberOfMonths).multiply(POINT_ZERO_ONE));
1897 }
1898 }
1899 else if (personDetails.getPeriodTypeCode().equals(
1900 s2SConfigurationService.getValueAsString(
1901 ConfigurationConstants.S2SBUDGET_PERIOD_TYPE_SUMMER_MONTHS))) {
1902 if (lineItem.getSubmitCostSharingFlag()) {
1903 summerMonths = summerMonths.add(personDetails.getPercentEffort().bigDecimalValue().multiply(numberOfMonths)
1904 .multiply(POINT_ZERO_ONE));
1905 } else {
1906 summerMonths = summerMonths.add(personDetails.getPercentCharged().bigDecimalValue().multiply(numberOfMonths)
1907 .multiply(POINT_ZERO_ONE));
1908 }
1909 }
1910 else {
1911 if (StringUtils.isNotBlank(personDetails.getBudgetPerson().getTbnId())) {
1912 if (lineItem.getBudgetCategory()
1913 .getCode().equals(budgetCatagoryCodePersonnel)) {
1914 if (lineItem.getSubmitCostSharingFlag()) {
1915 calendarMonths = calendarMonths.add(personDetails.getPercentEffort().bigDecimalValue().multiply(numberOfMonths)
1916 .multiply(POINT_ZERO_ONE));
1917 } else {
1918 calendarMonths = calendarMonths.add(personDetails.getPercentCharged().bigDecimalValue().multiply(numberOfMonths)
1919 .multiply(POINT_ZERO_ONE));
1920 }
1921 }
1922 }else {
1923 if (lineItem.getSubmitCostSharingFlag()) {
1924 calendarMonths = calendarMonths.add(personDetails.getPercentEffort().bigDecimalValue().multiply(numberOfMonths)
1925 .multiply(POINT_ZERO_ONE));
1926 }
1927 else {
1928 calendarMonths = calendarMonths.add(personDetails.getPercentCharged().bigDecimalValue().multiply(numberOfMonths)
1929 .multiply(POINT_ZERO_ONE));
1930 }
1931 }
1932 }
1933 if (StringUtils.isNotBlank(personDetails.getBudgetPerson().getTbnId() ) ){
1934 if(lineItem.getBudgetCategory()
1935 .getCode().equals(budgetCatagoryCodePersonnel)){
1936 totalSal = totalSal.add(personDetails.getSalaryRequested());
1937 }
1938 }else{
1939 totalSal = totalSal.add(personDetails.getSalaryRequested());
1940 }
1941 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1942 if (StringUtils.isNotBlank(personDetails.getBudgetPerson().getTbnId() ) ){
1943 if(lineItem.getBudgetCategory()
1944 .getCode().equals(budgetCatagoryCodePersonnel)){
1945 totalSalCostSharing = totalSalCostSharing.add(personDetails.getCostSharingAmount());
1946 }
1947 }else{
1948 totalSalCostSharing = totalSalCostSharing.add(personDetails.getCostSharingAmount());
1949 }
1950 }
1951 for (BudgetPersonnelCalculatedAmountContract personCalculatedAmt : personDetails.getBudgetPersonnelCalculatedAmounts()) {
1952 if ((personCalculatedAmt
1953 .getRateClass()
1954 .getRateClassType().getCode()
1955 .equals(s2SConfigurationService.getValueAsString(
1956 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_EMPLOYEE_BENEFITS)) && !personCalculatedAmt
1957 .getRateTypeCode().equals(
1958 s2SConfigurationService.getValueAsString(
1959 ConfigurationConstants.S2SBUDGET_RATE_TYPE_SUPPORT_STAFF_SALARIES)))
1960 || (personCalculatedAmt
1961 .getRateClass()
1962 .getRateClassType().getCode()
1963 .equals(s2SConfigurationService.getValueAsString(
1964 ConfigurationConstants.S2SBUDGET_RATE_CLASS_TYPE_VACATION)) && !personCalculatedAmt
1965 .getRateTypeCode().equals(
1966 s2SConfigurationService.getValueAsString(
1967 ConfigurationConstants.S2SBUDGET_RATE_TYPE_ADMINISTRATIVE_SALARIES)))) {
1968 if (StringUtils.isNotBlank(personDetails.getBudgetPerson().getTbnId() ) ){
1969 if(lineItem.getBudgetCategory()
1970 .getCode().equals(budgetCatagoryCodePersonnel)){
1971 fringe = fringe.add(personCalculatedAmt.getCalculatedCost());
1972 }
1973 }
1974 else{
1975 fringe = fringe.add(personCalculatedAmt.getCalculatedCost());
1976 }
1977 if (canBudgetLineItemCostSharingInclude(budget, lineItem)) {
1978 if (StringUtils.isNotBlank(personDetails.getBudgetPerson().getTbnId() ) ){
1979 if(lineItem.getBudgetCategory()
1980 .getCode().equals(budgetCatagoryCodePersonnel)){
1981 fringeCostSharing = fringeCostSharing.add(personCalculatedAmt.getCalculatedCostSharing());
1982 }
1983 }
1984 else{
1985 fringeCostSharing = fringeCostSharing.add(personCalculatedAmt.getCalculatedCostSharing());
1986 }
1987 }
1988 }
1989 }
1990 BudgetPersonContract budgetPerson = personDetails.getBudgetPerson();
1991 if (budgetPerson != null) {
1992 baseAmount = budgetPerson.getCalculationBase();
1993
1994
1995
1996 String apptTypeCode = budgetPerson.getAppointmentType().getCode();
1997 if (!apptTypeCode.equals(s2SConfigurationService.getValueAsString(
1998 ConfigurationConstants.S2SBUDGET_APPOINTMENT_TYPE_SUM_EMPLOYEE))
1999 && !apptTypeCode.equals(s2SConfigurationService.getValueAsString(
2000 ConfigurationConstants.S2SBUDGET_APPOINTMENT_TYPE_TMP_EMPLOYEE))) {
2001 baseAmount = budgetPerson.getCalculationBase();
2002 }
2003 }
2004 }
2005
2006 }
2007 }
2008 compensationInfo.setAcademicMonths(new ScaleTwoDecimal(academicMonths));
2009 compensationInfo.setCalendarMonths(new ScaleTwoDecimal(calendarMonths));
2010 compensationInfo.setSummerMonths(new ScaleTwoDecimal(summerMonths));
2011 compensationInfo.setRequestedSalary(totalSal);
2012 compensationInfo.setBaseSalary(baseAmount);
2013 compensationInfo.setCostSharingAmount(totalSalCostSharing);
2014 compensationInfo.setFringe(fringe);
2015 compensationInfo.setFundsRequested(totalSal.add(fringe));
2016 compensationInfo.setFringeCostSharing(fringeCostSharing);
2017 compensationInfo.setNonFundsRequested(totalSalCostSharing.add(fringeCostSharing));
2018 return compensationInfo;
2019 }
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032 protected List<KeyPersonDto> getNKeyPersons(List<KeyPersonDto> keyPersons, boolean firstN, int n) {
2033 KeyPersonDto keyPersonInfo, previousKeyPersonInfo;
2034 int size = keyPersons.size();
2035
2036 for (int i = size - 1; i > 0; i--) {
2037 keyPersonInfo = (KeyPersonDto) (keyPersons.get(i));
2038 previousKeyPersonInfo = (KeyPersonDto) (keyPersons.get(i - 1));
2039 if (keyPersonInfo.getPersonId() != null && previousKeyPersonInfo.getPersonId() != null
2040 && keyPersonInfo.getPersonId().equals(previousKeyPersonInfo.getPersonId())) {
2041 keyPersons.remove(i);
2042 }
2043 else if (keyPersonInfo.getRolodexId() != null && previousKeyPersonInfo.getRolodexId() != null
2044 && keyPersonInfo.getRolodexId().equals(previousKeyPersonInfo.getRolodexId())) {
2045 keyPersons.remove(i);
2046 }
2047 }
2048
2049 size = keyPersons.size();
2050 if (firstN) {
2051 List<KeyPersonDto> firstNPersons = new ArrayList<KeyPersonDto>();
2052
2053
2054 if (size > n) {
2055 size = n;
2056 }
2057
2058 for (int i = 0; i < size; i++) {
2059 firstNPersons.add(keyPersons.get(i));
2060 }
2061 return firstNPersons;
2062 }
2063 else {
2064
2065 List<KeyPersonDto> extraPersons = new ArrayList<KeyPersonDto>();
2066 for (int i = n; i < size; i++) {
2067 extraPersons.add(keyPersons.get(i));
2068 }
2069 return extraPersons;
2070 }
2071 }
2072
2073 @Override
2074 public ScaleTwoDecimal getBaseSalaryByPeriod(Long budgetId, int budgetPeriod, KeyPersonDto person ) {
2075 return budgetPersonSalaryService.findBaseSalaryForFirstPeriod(budgetId, person.getPersonId() != null ? person.getPersonId() : person.getRolodexId().toString(), budgetPeriod);
2076 }
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086 @Override
2087 public boolean keyPersonEqualsBudgetPerson(KeyPersonDto keyPersonInfo, BudgetPersonnelDetailsContract budgetPersonnelDetails) {
2088 boolean equal = false;
2089 if (keyPersonInfo != null && budgetPersonnelDetails != null) {
2090 String budgetPersonId = budgetPersonnelDetails.getPersonId();
2091 if ((keyPersonInfo.getPersonId() != null && keyPersonInfo.getPersonId().equals(budgetPersonId))
2092 || (keyPersonInfo.getRolodexId() != null && keyPersonInfo.getRolodexId().toString().equals(budgetPersonId))) {
2093 equal = true;
2094 }
2095 }
2096 return equal;
2097 }
2098
2099 public void setBudgetCategoryMapService(BudgetCategoryMapService budgetCategoryMapService) {
2100 this.budgetCategoryMapService = budgetCategoryMapService;
2101 }
2102
2103 public BudgetCategoryMapService getBudgetCategoryMapService() {
2104 return budgetCategoryMapService;
2105 }
2106
2107 public S2SConfigurationService getS2SConfigurationService() {
2108 return s2SConfigurationService;
2109 }
2110
2111 public void setS2SConfigurationService(S2SConfigurationService s2SConfigurationService) {
2112 this.s2SConfigurationService = s2SConfigurationService;
2113 }
2114
2115 public BudgetPersonSalaryService getBudgetPersonSalaryService() {
2116 return budgetPersonSalaryService;
2117 }
2118
2119 public void setBudgetPersonSalaryService(BudgetPersonSalaryService budgetPersonSalaryService) {
2120 this.budgetPersonSalaryService = budgetPersonSalaryService;
2121 }
2122
2123 public OrganizationRepositoryService getOrganizationRepositoryService() {
2124 return organizationRepositoryService;
2125 }
2126
2127 public void setOrganizationRepositoryService(OrganizationRepositoryService organizationRepositoryService) {
2128 this.organizationRepositoryService = organizationRepositoryService;
2129 }
2130
2131 public SponsorHierarchyService getSponsorHierarchyService() {
2132 return sponsorHierarchyService;
2133 }
2134
2135 public void setSponsorHierarchyService(SponsorHierarchyService sponsorHierarchyService) {
2136 this.sponsorHierarchyService = sponsorHierarchyService;
2137 }
2138
2139 public KcPersonRepositoryService getKcPersonRepositoryService() {
2140 return kcPersonRepositoryService;
2141 }
2142
2143 public void setKcPersonRepositoryService(KcPersonRepositoryService kcPersonRepositoryService) {
2144 this.kcPersonRepositoryService = kcPersonRepositoryService;
2145 }
2146
2147 public TbnPersonService getTbnPersonService() {
2148 return tbnPersonService;
2149 }
2150
2151 public void setTbnPersonService(TbnPersonService tbnPersonService) {
2152 this.tbnPersonService = tbnPersonService;
2153 }
2154
2155 public RolodexService getRolodexService() {
2156 return rolodexService;
2157 }
2158
2159 public void setRolodexService(RolodexService rolodexService) {
2160 this.rolodexService = rolodexService;
2161 }
2162
2163 public S2SDateTimeService getS2SDateTimeService() {
2164 return s2SDateTimeService;
2165 }
2166
2167 public void setS2SDateTimeService(S2SDateTimeService s2SDateTimeService) {
2168 this.s2SDateTimeService = s2SDateTimeService;
2169 }
2170
2171 public S2SProposalPersonService getS2SProposalPersonService() {
2172 return s2SProposalPersonService;
2173 }
2174
2175 public void setS2SProposalPersonService(S2SProposalPersonService s2SProposalPersonService) {
2176 this.s2SProposalPersonService = s2SProposalPersonService;
2177 }
2178
2179 public S2SErrorHandlerService getS2SErrorHandlerService() {
2180 return s2SErrorHandlerService;
2181 }
2182
2183 public void setS2SErrorHandlerService(S2SErrorHandlerService s2SErrorHandlerService) {
2184 this.s2SErrorHandlerService = s2SErrorHandlerService;
2185 }
2186
2187 public S2SCommonBudgetService getS2SCommonBudgetService() {
2188 return s2SCommonBudgetService;
2189 }
2190
2191 public void setS2SCommonBudgetService(S2SCommonBudgetService s2SCommonBudgetService) {
2192 this.s2SCommonBudgetService = s2SCommonBudgetService;
2193 }
2194 }