|
|
@@ -2183,15 +2183,25 @@ open class ReportService( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
val result = costAndExpenseList.map { |
|
|
|
item -> |
|
|
|
val budget = (item["budget"] as? Double)?.times(0.8) ?: 0.0 |
|
|
|
val budgetRemain = budget - (item["manhourExpenditure"] as? Double ?: 0.0) |
|
|
|
val remainingPercent = (budgetRemain / budget) |
|
|
|
item.toMutableMap().apply { |
|
|
|
put("budgetPercentage", remainingPercent) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return costAndExpenseList |
|
|
|
return result |
|
|
|
} |
|
|
|
|
|
|
|
fun createCostAndExpenseWorkbook( |
|
|
|
templatePath: String, |
|
|
|
costAndExpenseList: List<Map<String, Any?>>, |
|
|
|
teamId: Long?, |
|
|
|
clientId: Long? |
|
|
|
clientId: Long?, |
|
|
|
budgetPercentage: Double? |
|
|
|
): Workbook{ |
|
|
|
val resource = ClassPathResource(templatePath) |
|
|
|
val templateInputStream = resource.inputStream |
|
|
@@ -2230,9 +2240,18 @@ open class ReportService( |
|
|
|
row3Cell.setCellValue(client["name"] as String) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val filterList: List<Map<String, Any?>> |
|
|
|
if(budgetPercentage != null){ |
|
|
|
filterList = costAndExpenseList.filter { ((it["budgetPercentage"] as? Double) ?: 0.0) > budgetPercentage } |
|
|
|
}else{ |
|
|
|
filterList = costAndExpenseList |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rowNum = 6 |
|
|
|
for(item in costAndExpenseList){ |
|
|
|
val index = costAndExpenseList.indexOf(item) |
|
|
|
for(item in filterList){ |
|
|
|
val index = filterList.indexOf(item) |
|
|
|
val row: Row = sheet.getRow(rowNum) ?: sheet.createRow(rowNum) |
|
|
|
val cell = row.getCell(0) ?: row.createCell(0) |
|
|
|
cell.apply { |
|
|
@@ -2290,7 +2309,7 @@ open class ReportService( |
|
|
|
|
|
|
|
val costAndExpenseList = getCostAndExpense(request.clientId, request.teamId) |
|
|
|
|
|
|
|
val workbook: Workbook = createCostAndExpenseWorkbook(COSTANDEXPENSE_REPORT, costAndExpenseList, request.clientId, request.teamId) |
|
|
|
val workbook: Workbook = createCostAndExpenseWorkbook(COSTANDEXPENSE_REPORT, costAndExpenseList, request.teamId, request.clientId, request.budgetPercentage) |
|
|
|
|
|
|
|
val outputStream: ByteArrayOutputStream = ByteArrayOutputStream() |
|
|
|
workbook.write(outputStream) |
|
|
|