Browse Source

update report

tags/Baseline_30082024_BACKEND_UAT
cyril.tsui 1 year ago
parent
commit
b89945212d
6 changed files with 15 additions and 15 deletions
  1. +4
    -4
      src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt
  2. +10
    -10
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt
  3. +1
    -1
      src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt
  4. BIN
      src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx
  5. BIN
      src/main/resources/templates/report/AR05_Project Completion Report.xlsx
  6. BIN
      src/main/resources/templates/report/AR06_Project Completion Report with Outstanding Accounts Receivable v02.xlsx

+ 4
- 4
src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt View File

@@ -362,7 +362,7 @@ open class InvoiceService(


// Check the import invoice with the data in DB // Check the import invoice with the data in DB
for (i in 2..sheet.lastRowNum){ for (i in 2..sheet.lastRowNum){
val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString()
val sheetInvoice = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString()
val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue
checkInvoiceNo(sheetInvoice, invoices, invoicesResult, true) checkInvoiceNo(sheetInvoice, invoices, invoicesResult, true)
checkProjectCode(sheetProjectCode, projects, newProjectCodes) checkProjectCode(sheetProjectCode, projects, newProjectCodes)
@@ -398,7 +398,7 @@ open class InvoiceService(
// val paymentMilestoneId = getMilestonePaymentId(ExcelUtils.getCell(sheet, i, 1).stringCellValue, ExcelUtils.getCell(sheet, i, 5).stringCellValue) // val paymentMilestoneId = getMilestonePaymentId(ExcelUtils.getCell(sheet, i, 1).stringCellValue, ExcelUtils.getCell(sheet, i, 5).stringCellValue)
// val milestonePayment = milestonePaymentRepository.findById(paymentMilestoneId).orElseThrow() // val milestonePayment = milestonePaymentRepository.findById(paymentMilestoneId).orElseThrow()
val invoice = Invoice().apply { val invoice = Invoice().apply {
invoiceNo = ExcelUtils.getCell(sheet, i, 0).toString()
invoiceNo = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString()
projectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue projectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue
projectName = ExcelUtils.getCell(sheet, i, 2).stringCellValue projectName = ExcelUtils.getCell(sheet, i, 2).stringCellValue
team = ExcelUtils.getCell(sheet, i, 3).stringCellValue team = ExcelUtils.getCell(sheet, i, 3).stringCellValue
@@ -447,7 +447,7 @@ open class InvoiceService(
val duplicateItemsInInvoice = checkDuplicateItemInImportedInvoice(sheet,2,0) val duplicateItemsInInvoice = checkDuplicateItemInImportedInvoice(sheet,2,0)


for (i in 2..sheet.lastRowNum){ for (i in 2..sheet.lastRowNum){
val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString()
val sheetInvoice = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString()
val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue
checkInvoiceNo(sheetInvoice, invoices, invoicesResult, false) checkInvoiceNo(sheetInvoice, invoices, invoicesResult, false)
checkProjectCode(sheetProjectCode, projects, newProjectCodes) checkProjectCode(sheetProjectCode, projects, newProjectCodes)
@@ -489,7 +489,7 @@ open class InvoiceService(
} }


for (i in 2..sheet.lastRowNum){ for (i in 2..sheet.lastRowNum){
val invoice = getInvoiceByInvoiceNo(ExcelUtils.getCell(sheet, i, 0).toString())
val invoice = getInvoiceByInvoiceNo(BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString())
invoice.paidAmount = ExcelUtils.getCell(sheet, i, 5).numericCellValue.toBigDecimal() invoice.paidAmount = ExcelUtils.getCell(sheet, i, 5).numericCellValue.toBigDecimal()
invoice.receiptDate = ExcelUtils.getCell(sheet, i, 4).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() invoice.receiptDate = ExcelUtils.getCell(sheet, i, 4).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()
saveAndFlush(invoice) saveAndFlush(invoice)


+ 10
- 10
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt View File

@@ -65,7 +65,7 @@ open class ReportService(
var rowIndex = startRow var rowIndex = startRow
var columnIndex = startColumn var columnIndex = startColumn
result.forEachIndexed { index, obj -> result.forEachIndexed { index, obj ->
var tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
var tempCell = (sheet.getRow(rowIndex) ?: sheet.createRow(rowIndex)).createCell(columnIndex)
tempCell.setCellValue((index + 1).toDouble()) tempCell.setCellValue((index + 1).toDouble())
val keys = obj.keys.toList() val keys = obj.keys.toList()
keys.forEachIndexed { keyIndex, key -> keys.forEachIndexed { keyIndex, key ->
@@ -1846,22 +1846,22 @@ open class ReportService(
if (args != null) { if (args != null) {
var statusFilter: String = "" var statusFilter: String = ""
if (args.containsKey("teamId")) if (args.containsKey("teamId"))
sql.append("and t.id = :teamId")
sql.append(" and t.id = :teamId")
if (args.containsKey("custId")) if (args.containsKey("custId"))
sql.append("and c.id = :custId")
sql.append(" and c.id = :custId")
if (args.containsKey("subsidiaryId")) if (args.containsKey("subsidiaryId"))
sql.append("and ss.id = :subsidiaryId")
sql.append(" and ss.id = :subsidiaryId")
if (args.containsKey("status")) if (args.containsKey("status"))
statusFilter = when (args.get("status")) { statusFilter = when (args.get("status")) {
"Potential Overconsumption" -> "and " +
"Potential Overconsumption" -> " and " +
" (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= :lowerLimit " + " (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= :lowerLimit " +
" and (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) <= 1 " + " and (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) <= 1 " +
" or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= :lowerLimit " + " or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= :lowerLimit " +
" and (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) <= 1 " " and (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) <= 1 "
"All" -> "and " +
"All" -> " and " +
" (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= :lowerLimit " + " (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= :lowerLimit " +
" or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= :lowerLimit " " or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= :lowerLimit "
// "Overconsumption" -> "and " +
// "Overconsumption" -> " and " +
// " ((COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= 1 " + // " ((COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= 1 " +
// " or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= 1) " // " or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= 1) "


@@ -2403,7 +2403,7 @@ open class ReportService(


for(item in queryList){ for(item in queryList){
val hourlyRate = (item.getValue("hourlyRate") as BigDecimal).toDouble() val hourlyRate = (item.getValue("hourlyRate") as BigDecimal).toDouble()
if(item["code"] !in costAndExpenseList){
if(item["code"] !in costAndExpenseList.map { it["code"] }){
costAndExpenseList.add( costAndExpenseList.add(
mapOf( mapOf(
"code" to item["code"], "code" to item["code"],
@@ -2414,13 +2414,13 @@ open class ReportService(
"budget" to item["expectedTotalFee"], "budget" to item["expectedTotalFee"],
"totalManhours" to item["normalConsumed"] as Double + item["otConsumed"] as Double, "totalManhours" to item["normalConsumed"] as Double + item["otConsumed"] as Double,
"manhourExpenditure" to (hourlyRate * item["normalConsumed"] as Double ) "manhourExpenditure" to (hourlyRate * item["normalConsumed"] as Double )
+ (hourlyRate * item["otConsumed"]as Double * otFactor)
+ (hourlyRate * item["otConsumed"] as Double * otFactor)
) )
) )
}else{ }else{
val existingMap = costAndExpenseList.find { it.containsValue(item["code"]) }!! val existingMap = costAndExpenseList.find { it.containsValue(item["code"]) }!!
costAndExpenseList[costAndExpenseList.indexOf(existingMap)] = existingMap.toMutableMap().apply { costAndExpenseList[costAndExpenseList.indexOf(existingMap)] = existingMap.toMutableMap().apply {
put("totalManhours", get("manhours") as Double + (item["normalConsumed"] as Double + item["otConsumed"] as Double))
put("totalManhours", get("totalManhours") as Double + (item["normalConsumed"] as Double + item["otConsumed"] as Double))
put("manhourExpenditure", get("manhourExpenditure") as Double + ((hourlyRate * item["normalConsumed"] as Double ) put("manhourExpenditure", get("manhourExpenditure") as Double + ((hourlyRate * item["normalConsumed"] as Double )
+ (hourlyRate * item["otConsumed"]as Double * otFactor))) + (hourlyRate * item["otConsumed"]as Double * otFactor)))
} }


+ 1
- 1
src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt View File

@@ -256,7 +256,7 @@ open class TimesheetsService(


timesheetRepository.saveAll(timesheetList) timesheetRepository.saveAll(timesheetList)
logger.info("---------end-------") logger.info("---------end-------")
logger.info("Not Exist Project List: "+ notExistProjectList.joinToString(", "))
logger.info("Not Exist Project List: "+ notExistProjectList.distinct().joinToString(", "))


return if (sheet.lastRowNum > 0) "Import Excel success btw " + notExistProjectList.joinToString(", ") else "Import Excel failure" return if (sheet.lastRowNum > 0) "Import Excel success btw " + notExistProjectList.joinToString(", ") else "Import Excel failure"
} }

BIN
src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx View File


BIN
src/main/resources/templates/report/AR05_Project Completion Report.xlsx View File


BIN
src/main/resources/templates/report/AR06_Project Completion Report with Outstanding Accounts Receivable v02.xlsx View File


Loading…
Cancel
Save