| @@ -395,7 +395,7 @@ open class InvoiceService( | |||||
| for (i in 2..sheet.lastRowNum){ | for (i in 2..sheet.lastRowNum){ | ||||
| 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) | ||||
| println("paymentMilestoneId--------------: $paymentMilestoneId") | |||||
| // println("paymentMilestoneId--------------: $paymentMilestoneId") | |||||
| 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).stringCellValue | invoiceNo = ExcelUtils.getCell(sheet, i, 0).stringCellValue | ||||
| @@ -23,11 +23,22 @@ open class ReportService { | |||||
| private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd") | private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd") | ||||
| private val FORMATTED_TODAY = LocalDate.now().format(DATE_FORMATTER) | private val FORMATTED_TODAY = LocalDate.now().format(DATE_FORMATTER) | ||||
| private val FINANCIAL_STATUS_REPORT = "templates/report/EX01_Financial Status Report.xlsx" | |||||
| private val PROJECT_CASH_FLOW_REPORT = "templates/report/EX02_Project Cash Flow Report.xlsx" | private val PROJECT_CASH_FLOW_REPORT = "templates/report/EX02_Project Cash Flow Report.xlsx" | ||||
| private val MONTHLY_WORK_HOURS_ANALYSIS_REPORT = "templates/report/AR08_Monthly Work Hours Analysis Report.xlsx" | private val MONTHLY_WORK_HOURS_ANALYSIS_REPORT = "templates/report/AR08_Monthly Work Hours Analysis Report.xlsx" | ||||
| private val SALART_LIST_TEMPLATE = "templates/report/Salary Template.xlsx" | private val SALART_LIST_TEMPLATE = "templates/report/Salary Template.xlsx" | ||||
| // ==============================|| GENERATE REPORT ||============================== // | // ==============================|| GENERATE REPORT ||============================== // | ||||
| fun genFinancialStatusReport(): ByteArray { | |||||
| val workbook: Workbook = createFinancialStatusReport(FINANCIAL_STATUS_REPORT) | |||||
| val outputStream: ByteArrayOutputStream = ByteArrayOutputStream() | |||||
| workbook.write(outputStream) | |||||
| workbook.close() | |||||
| return outputStream.toByteArray() | |||||
| } | |||||
| @Throws(IOException::class) | @Throws(IOException::class) | ||||
| fun generateProjectCashFlowReport(project: Project, invoices: List<Invoice>, timesheets: List<Timesheet>): ByteArray { | fun generateProjectCashFlowReport(project: Project, invoices: List<Invoice>, timesheets: List<Timesheet>): ByteArray { | ||||
| // Generate the Excel report with query results | // Generate the Excel report with query results | ||||
| @@ -68,6 +79,18 @@ open class ReportService { | |||||
| } | } | ||||
| // ==============================|| CREATE REPORT ||============================== // | // ==============================|| CREATE REPORT ||============================== // | ||||
| // EX01 Financial Report | |||||
| private fun createFinancialStatusReport( | |||||
| templatePath: String, | |||||
| ) : Workbook { | |||||
| val resource = ClassPathResource(templatePath) | |||||
| val templateInputStream = resource.inputStream | |||||
| val workbook: Workbook = XSSFWorkbook(templateInputStream) | |||||
| return workbook | |||||
| } | |||||
| @Throws(IOException::class) | @Throws(IOException::class) | ||||
| private fun createProjectCashFlowReport( | private fun createProjectCashFlowReport( | ||||
| project: Project, | project: Project, | ||||
| @@ -5,6 +5,7 @@ import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||||
| import com.ffii.tsms.modules.project.entity.* | import com.ffii.tsms.modules.project.entity.* | ||||
| import com.ffii.tsms.modules.report.service.ReportService | import com.ffii.tsms.modules.report.service.ReportService | ||||
| import com.ffii.tsms.modules.project.service.InvoiceService | import com.ffii.tsms.modules.project.service.InvoiceService | ||||
| import com.ffii.tsms.modules.report.web.model.FinancialStatusReportRequest | |||||
| import com.ffii.tsms.modules.report.web.model.ProjectCashFlowReportRequest | import com.ffii.tsms.modules.report.web.model.ProjectCashFlowReportRequest | ||||
| import com.ffii.tsms.modules.report.web.model.StaffMonthlyWorkHourAnalysisReportRequest | import com.ffii.tsms.modules.report.web.model.StaffMonthlyWorkHourAnalysisReportRequest | ||||
| import com.ffii.tsms.modules.timesheet.entity.LeaveRepository | import com.ffii.tsms.modules.timesheet.entity.LeaveRepository | ||||
| @@ -37,6 +38,18 @@ class ReportController( | |||||
| private val leaveRepository: LeaveRepository, | private val leaveRepository: LeaveRepository, | ||||
| private val invoiceService: InvoiceService) { | private val invoiceService: InvoiceService) { | ||||
| @PostMapping("/fetchProjectsFinancialStatusReport") | |||||
| @Throws(ServletRequestBindingException::class, IOException::class) | |||||
| fun getFinancialStatusReport(@RequestBody @Valid request: FinancialStatusReportRequest): ResponseEntity<Resource> { | |||||
| val reportResult: ByteArray = excelReportService.genFinancialStatusReport() | |||||
| return ResponseEntity.ok() | |||||
| .header("filename", "Financial Status Report - " + LocalDate.now() + ".xlsx") | |||||
| .body(ByteArrayResource(reportResult)) | |||||
| } | |||||
| @PostMapping("/ProjectCashFlowReport") | @PostMapping("/ProjectCashFlowReport") | ||||
| @Throws(ServletRequestBindingException::class, IOException::class) | @Throws(ServletRequestBindingException::class, IOException::class) | ||||
| fun getProjectCashFlowReport(@RequestBody @Valid request: ProjectCashFlowReportRequest): ResponseEntity<Resource> { | fun getProjectCashFlowReport(@RequestBody @Valid request: ProjectCashFlowReportRequest): ResponseEntity<Resource> { | ||||
| @@ -2,6 +2,9 @@ package com.ffii.tsms.modules.report.web.model | |||||
| import java.time.YearMonth | import java.time.YearMonth | ||||
| data class FinancialStatusReportRequest ( | |||||
| val projectId: Long | |||||
| ) | |||||
| data class ProjectCashFlowReportRequest ( | data class ProjectCashFlowReportRequest ( | ||||
| val projectId: Long | val projectId: Long | ||||
| ) | ) | ||||