|
|
@@ -682,6 +682,10 @@ open class ReportService( |
|
|
|
val monthStyle = workbook.createDataFormat().getFormat("mmm, yyyy") |
|
|
|
val dateStyle = workbook.createDataFormat().getFormat("dd/mm/yyyy") |
|
|
|
|
|
|
|
val boldStyle = workbook.createCellStyle() |
|
|
|
val boldFont = workbook.createFont() |
|
|
|
boldFont.bold = true |
|
|
|
boldStyle.setFont(boldFont) |
|
|
|
val daysOfMonth = (1..month.lengthOfMonth()).map { day -> |
|
|
|
val date = month.withDayOfMonth(day) |
|
|
|
val formattedDate = date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) |
|
|
@@ -691,8 +695,6 @@ open class ReportService( |
|
|
|
|
|
|
|
val sheet: Sheet = workbook.getSheetAt(0) |
|
|
|
|
|
|
|
val boldFont = sheet.workbook.createFont() |
|
|
|
boldFont.bold = true |
|
|
|
// sheet.forceFormulaRecalculation = true; //Calculate formulas |
|
|
|
|
|
|
|
var rowIndex = 1 // Assuming the location is in (1,2), which is the report date field |
|
|
@@ -704,22 +706,27 @@ open class ReportService( |
|
|
|
var dayInt = 0 |
|
|
|
var tempCell: Cell |
|
|
|
|
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(columnIndex) |
|
|
|
tempCell.setCellValue(FORMATTED_TODAY) |
|
|
|
sheet.getRow(rowIndex).createCell(columnIndex).apply { |
|
|
|
setCellValue(FORMATTED_TODAY) |
|
|
|
} |
|
|
|
|
|
|
|
rowIndex = 2 |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(columnIndex) |
|
|
|
tempCell.setCellValue(month) |
|
|
|
tempCell.cellStyle.dataFormat = monthStyle |
|
|
|
sheet.getRow(rowIndex).getCell(columnIndex).apply { |
|
|
|
setCellValue(month) |
|
|
|
// cellStyle.setFont(boldStyle) |
|
|
|
|
|
|
|
cellStyle.dataFormat = monthStyle |
|
|
|
} |
|
|
|
|
|
|
|
rowIndex = 3 |
|
|
|
tempCell. sheet.getRow(rowIndex).createCell(columnIndex) |
|
|
|
tempCell.setCellValue(staff.name) |
|
|
|
sheet.getRow(rowIndex).createCell(columnIndex).apply { |
|
|
|
setCellValue(staff.name) |
|
|
|
} |
|
|
|
|
|
|
|
rowIndex = 4 |
|
|
|
tempCell.sheet.getRow(rowIndex).createCell(columnIndex) |
|
|
|
tempCell.setCellValue(staff.team.name) |
|
|
|
|
|
|
|
sheet.getRow(rowIndex).createCell(columnIndex).apply { |
|
|
|
setCellValue(staff.team.name) |
|
|
|
} |
|
|
|
|
|
|
|
rowIndex = 5 |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(columnIndex) |
|
|
@@ -731,6 +738,7 @@ open class ReportService( |
|
|
|
|
|
|
|
val ThinBorderBottom: MutableMap<String?, Any?> = mutableMapOf() |
|
|
|
ThinBorderBottom["borderBottom"] = BorderStyle.THIN |
|
|
|
ThinBorderBottom["wrapText"] = true |
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
rowIndex = 7 |
|
|
|
daysOfMonth.forEach { dayInfo -> |
|
|
@@ -738,12 +746,12 @@ open class ReportService( |
|
|
|
rowSize++ |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(0) |
|
|
|
tempCell.setCellValue(dayInfo.date) |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
tempCell.cellStyle.dataFormat = dateStyle |
|
|
|
tempCell.cellStyle.setFont(boldFont) |
|
|
|
// cellStyle.alignment = HorizontalAlignment.LEFT |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(1) |
|
|
|
tempCell.setCellValue(dayInfo.weekday) |
|
|
|
tempCell.cellStyle.setFont(boldFont) |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
// cellStyle.alignment = HorizontalAlignment.LEFT |
|
|
|
} |
|
|
|
|
|
|
@@ -751,7 +759,7 @@ open class ReportService( |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(0) |
|
|
|
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) |
|
|
|
tempCell.setCellValue("Sub-total") |
|
|
|
tempCell.cellStyle.setFont(boldFont) |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) |
|
|
|
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(1) |
|
|
@@ -760,6 +768,7 @@ open class ReportService( |
|
|
|
rowIndex += 1 |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(0) |
|
|
|
tempCell.setCellValue("Total Normal Hours [A]") |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) |
|
|
|
|
|
|
|
var normalConsumed = 0.0 |
|
|
@@ -780,8 +789,8 @@ open class ReportService( |
|
|
|
rowIndex += 1 |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(0) |
|
|
|
tempCell.setCellValue("Total Other Hours [B]") |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) |
|
|
|
tempCell.cellStyle.setFont(boldFont) |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(2) |
|
|
|
tempCell.setCellValue(otConsumed) |
|
|
|
tempCell.cellStyle.dataFormat = accountingStyle |
|
|
@@ -793,6 +802,7 @@ open class ReportService( |
|
|
|
rowIndex += 1 |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(0) |
|
|
|
tempCell.setCellValue("Total Leave Hours") |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) |
|
|
|
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) |
|
|
|
if (leaves.isNotEmpty()) { |
|
|
@@ -808,7 +818,7 @@ open class ReportService( |
|
|
|
rowIndex += 1 |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(0) |
|
|
|
tempCell.setCellValue("Total Spent Manhours [A+B]") |
|
|
|
tempCell.cellStyle.setFont(boldFont) |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) |
|
|
|
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(1) |
|
|
@@ -827,9 +837,13 @@ open class ReportService( |
|
|
|
projectList.forEachIndexed { index, title -> |
|
|
|
tempCell = sheet.getRow(7).createCell(columnIndex + index) |
|
|
|
tempCell.setCellValue(title) |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.RIGHT) |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) |
|
|
|
CellUtil.setVerticalAlignment(tempCell, VerticalAlignment.CENTER) |
|
|
|
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) |
|
|
|
columnSize++ |
|
|
|
} |
|
|
|
println(columnSize) |
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
if (timesheets.isNotEmpty()) { |
|
|
|
projectList.forEach { _ -> |
|
|
@@ -865,11 +879,16 @@ open class ReportService( |
|
|
|
///////////////////////////////////////////////////////// Leave Hours //////////////////////////////////////////////////////////////////// |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(columnIndex) |
|
|
|
tempCell.setCellValue("Leave Hours") |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setVerticalAlignment(tempCell, VerticalAlignment.CENTER) |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) |
|
|
|
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) |
|
|
|
|
|
|
|
columnIndex += 1 |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(columnIndex) |
|
|
|
tempCell.setCellValue("Daily Manhour Spent\n(Excluding Leave Hours)") |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
CellUtil.setAlignment(tempCell, HorizontalAlignment.LEFT) |
|
|
|
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) |
|
|
|
|
|
|
|
sheet.addMergedRegion(CellRangeAddress(6,6 , 2, columnIndex)) |
|
|
@@ -884,18 +903,18 @@ open class ReportService( |
|
|
|
} |
|
|
|
// cal subtotal |
|
|
|
println(rowIndex) |
|
|
|
for (i in 0 until columnSize - 2) { // minus last col |
|
|
|
tempCell = sheet.getRow(rowIndex).createCell(2 + i) |
|
|
|
for (i in 0 ..columnSize ) { // minus last col |
|
|
|
println(sheet.getRow(rowIndex).getCell(2 + i)) |
|
|
|
tempCell = sheet.getRow(rowIndex).getCell(2 + i) ?: sheet.getRow(rowIndex).createCell(2 + i) |
|
|
|
tempCell.cellFormula = "SUM(${getColumnAlphabet(2 + i)}9:${getColumnAlphabet(2 + i)}${rowIndex})" |
|
|
|
tempCell.cellStyle = boldStyle |
|
|
|
tempCell.cellStyle.dataFormat = accountingStyle |
|
|
|
tempCell.cellStyle.setFont(boldFont) |
|
|
|
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) |
|
|
|
} |
|
|
|
} |
|
|
|
return workbook |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Throws(IOException::class) |
|
|
|
private fun createSalaryList( |
|
|
|
salarys: List<Salary>, |
|
|
|