Sfoglia il codice sorgente

Cah Flow Report

add_swagger
MSI\2Fi 11 mesi fa
parent
commit
1eab253266
4 ha cambiato i file con 33 aggiunte e 12 eliminazioni
  1. +2
    -0
      src/main/java/com/ffii/tsms/modules/project/entity/ProjectExpenseRepository.kt
  2. +30
    -11
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt
  3. +1
    -1
      src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt
  4. BIN
      src/main/resources/templates/report/EX02_Project Cash Flow Report.xlsx

+ 2
- 0
src/main/java/com/ffii/tsms/modules/project/entity/ProjectExpenseRepository.kt Vedi File

@@ -5,4 +5,6 @@ import com.ffii.tsms.modules.project.entity.projections.ProjectExpenseSearchInfo

interface ProjectExpenseRepository : AbstractRepository<ProjectExpense, Long> {
fun findExpenseSearchInfoByDeletedFalse(): List<ProjectExpenseSearchInfo>

fun findAllByProjectIdAndDeletedFalse(projectId: Long): List<ProjectExpense>
}

+ 30
- 11
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt Vedi File

@@ -822,9 +822,12 @@ open class ReportService(
it.staff.staffId == timesheet.staff?.staffId && it.date.year == timesheet.recordDate?.year && it.date.month == timesheet.recordDate?.month
}?.hourlyRate ?: 0.0) * ((timesheet.normalConsumed ?: 0.0) + (timesheet.otConsumed ?: 0.0))
}

val sumProjectExpense = projectExpenses.sumOf { it.amount?: 0.0 }

sheet.getRow(rowIndex).apply {
createCell(1).apply {
setCellValue(actualExpenditure)
setCellValue(actualExpenditure + sumProjectExpense)
cellStyle.dataFormat = accountingStyle
}

@@ -899,8 +902,8 @@ open class ReportService(
)
}
}
println("grouped Project Expense")
println(groupedProjectExpense)
// println("grouped Project Expense")
// println(groupedProjectExpense)
// groupedTimesheets.entries.forEach { (key, value) ->
// logger.info("key: $key")
// logger.info("value: " + value.sumOf { it })
@@ -932,18 +935,23 @@ open class ReportService(
}

createCell(2).apply {
setCellValue(invoice["paidAmount"] as Double? ?: 0.0)
setCellValue(0.0)
cellStyle.dataFormat = accountingStyle
}

createCell(3).apply {
setCellValue(invoice["paidAmount"] as Double? ?: 0.0)
cellStyle.dataFormat = accountingStyle
}

createCell(4).apply {
val lastRow = rowIndex - 1
if (lastRow == 16) {
cellFormula =
"C{currentRow}-B{currentRow}".replace("{currentRow}", rowIndex.toString())
} else {
cellFormula =
"IF(B{currentRow}>0,D{lastRow}-B{currentRow},D{lastRow}+C{currentRow})".replace(
"IF(B{currentRow}>0,E{lastRow}-B{currentRow}-C{currentRow},E{lastRow}+D{currentRow}-C{currentRow})".replace(
"{currentRow}",
rowIndex.toString()
).replace("{lastRow}", lastRow.toString())
@@ -951,7 +959,7 @@ open class ReportService(
cellStyle.dataFormat = accountingStyle
}

createCell(4)?.apply {
createCell(5)?.apply {
setCellValue(
"Invoice Receipt: " + (invoice["invoiceNo"] as String? ?: "N/A").toString()
)
@@ -971,18 +979,23 @@ open class ReportService(
}

createCell(2).apply {
setCellValue(groupedInvoices[result]?.sumOf { it["paidAmount"] as Double } ?: 0.0)
setCellValue(0.0)
cellStyle.dataFormat = accountingStyle
}

createCell(3).apply {
setCellValue(groupedInvoices[result]?.sumOf { it["paidAmount"] as Double } ?: 0.0)
cellStyle.dataFormat = accountingStyle
}

createCell(4).apply {
val lastRow = rowIndex - 1
if (lastRow == 16) {
cellFormula =
"C{currentRow}-B{currentRow}".replace("{currentRow}", rowIndex.toString())
} else {
cellFormula =
"IF(B{currentRow}>0,D{lastRow}-B{currentRow},D{lastRow}+C{currentRow})".replace(
"IF(B{currentRow}>0,E{lastRow}-B{currentRow}-C{currentRow},E{lastRow}+D{currentRow}-C{currentRow})".replace(
"{currentRow}",
rowIndex.toString()
).replace("{lastRow}", lastRow.toString())
@@ -990,7 +1003,7 @@ open class ReportService(
cellStyle.dataFormat = accountingStyle
}

createCell(4)?.apply {
createCell(5)?.apply {
// setCellValue(invoice["description"].toString())
val invoiceNos = groupedInvoices[result]?.map { it["invoiceNo"] }
if (invoiceNos?.size != null && invoiceNos.size > 1) {
@@ -1023,12 +1036,17 @@ open class ReportService(
}

createCell(3).apply {
setCellValue(0.0)
cellStyle.dataFormat = accountingStyle
}

createCell(4).apply {
val lastRow = rowIndex - 1
if (lastRow == 16) {
cellFormula = "C{currentRow}-B{currentRow}".replace("{currentRow}", rowIndex.toString())
} else {
cellFormula =
"IF(B{currentRow}>0,D{lastRow}-B{currentRow},D{lastRow}+C{currentRow})".replace(
"IF(B{currentRow}>0,E{lastRow}-B{currentRow}-C{currentRow},E{lastRow}+D{currentRow}-C{currentRow})".replace(
"{currentRow}",
rowIndex.toString()
).replace("{lastRow}", lastRow.toString())
@@ -1036,12 +1054,13 @@ open class ReportService(
cellStyle.dataFormat = accountingStyle
}

createCell(4).apply {
createCell(5).apply {
setCellValue("Manpower Expenditure")
}
}
}


}

conditionalFormattingNegative(sheet)


+ 1
- 1
src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt Vedi File

@@ -89,7 +89,7 @@ class ReportController(
// val invoices = invoiceService.findAllByProjectAndPaidAmountIsNotNull(project)
val invoices = invoiceRepository.findAllByProjectCodeAndPaidAmountIsNotNullAndDeletedFalse(project.code!!)
val timesheets = timesheetRepository.findAllByProjectTaskIn(projectTasks)
val projectExpenses = projectExpenseRepository.findAll().filter { it.project == project }
val projectExpenses = projectExpenseRepository.findAllByProjectIdAndDeletedFalse(project.id!!)
val monthlyStaffSalaryEffective = salaryEffectiveService.getMonthlyStaffSalaryData(timesheets.minByOrNull { it.recordDate!! }?.recordDate ?: LocalDate.parse("2012-01-01"), timesheets.maxByOrNull { it.recordDate!! }?.recordDate ?: LocalDate.now())

val reportResult: ByteArray = excelReportService.generateProjectCashFlowReport(project, invoices, timesheets, projectExpenses, monthlyStaffSalaryEffective, request.dateType)


BIN
src/main/resources/templates/report/EX02_Project Cash Flow Report.xlsx Vedi File


Caricamento…
Annulla
Salva