|
|
@@ -12,6 +12,7 @@ import com.ffii.tsms.modules.data.web.models.FinancialSummaryByProject |
|
|
import com.ffii.tsms.modules.project.entity.* |
|
|
import com.ffii.tsms.modules.project.entity.* |
|
|
import com.ffii.tsms.modules.project.service.InvoiceService |
|
|
import com.ffii.tsms.modules.project.service.InvoiceService |
|
|
import com.ffii.tsms.modules.project.service.ProjectExpenseService |
|
|
import com.ffii.tsms.modules.project.service.ProjectExpenseService |
|
|
|
|
|
import com.ffii.tsms.modules.report.service.ReportService |
|
|
import com.ffii.tsms.modules.timesheet.entity.TimesheetRepository |
|
|
import com.ffii.tsms.modules.timesheet.entity.TimesheetRepository |
|
|
import com.ffii.tsms.modules.timesheet.service.TimesheetsService |
|
|
import com.ffii.tsms.modules.timesheet.service.TimesheetsService |
|
|
import org.apache.poi.ss.usermodel.* |
|
|
import org.apache.poi.ss.usermodel.* |
|
|
@@ -37,7 +38,8 @@ open class DashboardService( |
|
|
private val salaryEffectiveService: SalaryEffectiveService, |
|
|
private val salaryEffectiveService: SalaryEffectiveService, |
|
|
private val projectExpenseRepository: ProjectExpenseRepository, |
|
|
private val projectExpenseRepository: ProjectExpenseRepository, |
|
|
private val companyHolidayService: CompanyHolidayService, |
|
|
private val companyHolidayService: CompanyHolidayService, |
|
|
private val jdbcDao: JdbcDao |
|
|
|
|
|
|
|
|
private val jdbcDao: JdbcDao, |
|
|
|
|
|
private val reportService: 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) |
|
|
@@ -1746,7 +1748,7 @@ open class DashboardService( |
|
|
+ " coalesce (sum(i.paidAmount),0) as totalReceived," |
|
|
+ " coalesce (sum(i.paidAmount),0) as totalReceived," |
|
|
+ " coalesce (sum(i.issueAmount) - sum(i.paidAmount),0) as receivable," |
|
|
+ " coalesce (sum(i.issueAmount) - sum(i.paidAmount),0) as receivable," |
|
|
+ " coalesce (round((sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8,2),0) as totalBudget," |
|
|
+ " coalesce (round((sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8,2),0) as totalBudget," |
|
|
+ " coalesce(expenditure.expenditure, 0) + + sum(coalesce(pc.expense, 0)) as totalExpenditure," |
|
|
|
|
|
|
|
|
+ " coalesce(expenditure.expenditure, 0) + sum(coalesce(pc.expense, 0)) as totalExpenditure," |
|
|
+ " coalesce(round((sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8,2),0) - (coalesce(expenditure.expenditure, 0) + + sum(coalesce(pc.expense, 0))) as expenditureReceivable," |
|
|
+ " coalesce(round((sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8,2),0) - (coalesce(expenditure.expenditure, 0) + + sum(coalesce(pc.expense, 0))) as expenditureReceivable," |
|
|
// + " (sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8 - coalesce(sum(pc.expense), 0) as expenditureReceivable," |
|
|
// + " (sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8 - coalesce(sum(pc.expense), 0) as expenditureReceivable," |
|
|
// + " coalesce ((sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8 - expenditure.expenditure,0) as expenditureReceivable," |
|
|
// + " coalesce ((sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0)))*0.8 - expenditure.expenditure,0) as expenditureReceivable," |
|
|
@@ -1802,7 +1804,27 @@ open class DashboardService( |
|
|
+ " group by expenditure.expenditure" |
|
|
+ " group by expenditure.expenditure" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
|
|
|
|
|
|
var sqlResult = jdbcDao.queryForList(sql.toString(), args) |
|
|
|
|
|
|
|
|
|
|
|
val date = LocalDate.now() |
|
|
|
|
|
val yearMonth: YearMonth = YearMonth.from(date) |
|
|
|
|
|
|
|
|
|
|
|
val teamLeadId = -1L; |
|
|
|
|
|
val startMonth = "1970-01"; |
|
|
|
|
|
val endMonth = yearMonth.toString(); |
|
|
|
|
|
|
|
|
|
|
|
val projectCodes = args["projectIds"]?.let { ids -> projectRepository.findAllById( ids as MutableList<Long>).map { project -> project.code } } ?: mutableListOf() |
|
|
|
|
|
val manhoursSpent = reportService.getManHoursSpentByTeam(teamLeadId, startMonth, endMonth) |
|
|
|
|
|
val salaryEffectiveMap = reportService.getSalaryEffectiveByTeamLead(teamLeadId) |
|
|
|
|
|
val updatedTimesheetData = reportService.updateTimesheetDataWithEffectiveSalary(manhoursSpent, salaryEffectiveMap) |
|
|
|
|
|
val projectsExpenditure = reportService.calculateProjectExpenditures(updatedTimesheetData) |
|
|
|
|
|
.filter { projectCodes.contains(it.key) } |
|
|
|
|
|
.map { it.value } |
|
|
|
|
|
.sumOf { it } |
|
|
|
|
|
|
|
|
|
|
|
sqlResult[0]["totalExpenditure"] = projectsExpenditure; |
|
|
|
|
|
|
|
|
|
|
|
return sqlResult |
|
|
} |
|
|
} |
|
|
fun CashFlowAnticipateIncome(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
fun CashFlowAnticipateIncome(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
val sql = StringBuilder("select" |
|
|
val sql = StringBuilder("select" |
|
|
|