| @@ -1,50 +0,0 @@ | |||||
| package com.ffii.tsms.modules.project.entity | |||||
| import com.ffii.core.entity.BaseEntity | |||||
| import com.ffii.tsms.modules.data.entity.Staff | |||||
| import jakarta.persistence.* | |||||
| import jakarta.validation.constraints.NotNull | |||||
| import java.time.LocalDateTime | |||||
| @Entity | |||||
| @Table(name = "expense") | |||||
| open class Expense : BaseEntity<Long>(){ | |||||
| @NotNull | |||||
| @OneToOne | |||||
| @JoinColumn(name = "projectId") | |||||
| open var project: Project? = null | |||||
| @NotNull | |||||
| @OneToOne | |||||
| @JoinColumn(name = "staffId") | |||||
| open var staff: Staff? = null | |||||
| @NotNull | |||||
| @Column(name = "description", length = 255) | |||||
| open var description: String? = null | |||||
| @NotNull | |||||
| @Column(name = "amount") | |||||
| open var amount: Double? = null | |||||
| @Column(name = "supporting") | |||||
| open var supporting: Int? = null | |||||
| @NotNull | |||||
| @Column(name = "decision") | |||||
| open var decision: Int? = null | |||||
| @Column(name = "approvedAmount") | |||||
| open var approvedAmount: Double? = null | |||||
| @Column(name = "verifiedDatetime") | |||||
| open var verifiedDatetime: LocalDateTime? = null | |||||
| @Column(name = "verifiedBy") | |||||
| open var verifiedBy: Int? = null | |||||
| @Column(name = "remark", length = 1500) | |||||
| open var remark: String? = null | |||||
| } | |||||
| @@ -1,8 +0,0 @@ | |||||
| package com.ffii.tsms.modules.project.entity | |||||
| import com.ffii.core.support.AbstractRepository | |||||
| import com.ffii.tsms.modules.project.entity.projections.ExpenseSearchInfo | |||||
| interface ExpenseRepository : AbstractRepository<Expense, Long> { | |||||
| fun findExpenseSearchInfoByDeletedFalse(): List<ExpenseSearchInfo> | |||||
| } | |||||
| @@ -0,0 +1,37 @@ | |||||
| package com.ffii.tsms.modules.project.entity | |||||
| import com.ffii.core.entity.BaseEntity | |||||
| import com.ffii.tsms.modules.data.entity.Team | |||||
| import jakarta.persistence.* | |||||
| import jakarta.validation.constraints.NotNull | |||||
| import java.time.LocalDate | |||||
| @Entity | |||||
| @Table(name = "project_expense") | |||||
| open class ProjectExpense : BaseEntity<Long>(){ | |||||
| // @NotNull | |||||
| @Column(name = "expenseNo", length = 45) | |||||
| open var expenseNo: String? = null | |||||
| @NotNull | |||||
| @Column(name = "issueDate") | |||||
| open var issueDate: LocalDate? = null | |||||
| @Column(name = "receiptDate") | |||||
| open var receiptDate: LocalDate? = null | |||||
| @NotNull | |||||
| @Column(name = "amount") | |||||
| open var amount: Double? = null | |||||
| @NotNull | |||||
| @OneToOne | |||||
| @JoinColumn(name = "projectId") | |||||
| open var project: Project? = null | |||||
| @NotNull | |||||
| @OneToOne | |||||
| @JoinColumn(name = "teamId") | |||||
| open var team: Team? = null | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| package com.ffii.tsms.modules.project.entity | |||||
| import com.ffii.core.support.AbstractRepository | |||||
| import com.ffii.tsms.modules.project.entity.projections.ProjectExpenseSearchInfo | |||||
| interface ProjectExpenseRepository : AbstractRepository<ProjectExpense, Long> { | |||||
| fun findExpenseSearchInfoByDeletedFalse(): List<ProjectExpenseSearchInfo> | |||||
| } | |||||
| @@ -1,10 +1,12 @@ | |||||
| package com.ffii.tsms.modules.project.entity.projections | package com.ffii.tsms.modules.project.entity.projections | ||||
| import org.springframework.beans.factory.annotation.Value | import org.springframework.beans.factory.annotation.Value | ||||
| import java.time.LocalDate | |||||
| import java.time.LocalDateTime | import java.time.LocalDateTime | ||||
| interface ExpenseSearchInfo { | |||||
| interface ProjectExpenseSearchInfo { | |||||
| val id: Long | val id: Long | ||||
| val expenseNo: String | |||||
| @get:Value("#{target.project.code}") | @get:Value("#{target.project.code}") | ||||
| val projectCode: String | val projectCode: String | ||||
| @@ -12,15 +14,13 @@ interface ExpenseSearchInfo { | |||||
| @get:Value("#{target.project.name}") | @get:Value("#{target.project.name}") | ||||
| val projectName: String | val projectName: String | ||||
| @get:Value("#{target.staff.staffId}") | |||||
| val staffCode: String | |||||
| @get:Value("#{target.team.name}") | |||||
| val teamName: String | |||||
| @get:Value("#{target.staff.name}") | |||||
| val staffName: String | |||||
| @get:Value("#{target.team.code}") | |||||
| val teamCode: String | |||||
| val description: String | |||||
| val amount: Double | val amount: Double | ||||
| val approvedAmount: Double? | |||||
| val verifiedDatetime: LocalDateTime | |||||
| val remark: String | |||||
| val issueDate: LocalDate | |||||
| val receiptDate: LocalDate? | |||||
| } | } | ||||
| @@ -1,21 +0,0 @@ | |||||
| package com.ffii.tsms.modules.project.service | |||||
| import com.ffii.core.support.AbstractIdEntityService | |||||
| import com.ffii.core.support.JdbcDao | |||||
| import com.ffii.tsms.modules.project.entity.Expense | |||||
| import com.ffii.tsms.modules.project.entity.ExpenseRepository | |||||
| import com.ffii.tsms.modules.project.entity.Invoice | |||||
| import com.ffii.tsms.modules.project.entity.InvoiceRepository | |||||
| import com.ffii.tsms.modules.project.entity.projections.ExpenseSearchInfo | |||||
| import org.springframework.stereotype.Service | |||||
| @Service | |||||
| open class ExpenseService( | |||||
| private val expenseRepository: ExpenseRepository, | |||||
| private val jdbcDao: JdbcDao, | |||||
| ) : AbstractIdEntityService<Expense, Long, ExpenseRepository>(jdbcDao, expenseRepository){ | |||||
| open fun findExpenseSearchInfo(): List<ExpenseSearchInfo> { | |||||
| return expenseRepository.findExpenseSearchInfoByDeletedFalse() | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| package com.ffii.tsms.modules.project.service | |||||
| import com.ffii.core.support.AbstractIdEntityService | |||||
| import com.ffii.core.support.JdbcDao | |||||
| import com.ffii.tsms.modules.project.entity.ProjectExpense | |||||
| import com.ffii.tsms.modules.project.entity.ProjectExpenseRepository | |||||
| import com.ffii.tsms.modules.project.entity.projections.ProjectExpenseSearchInfo | |||||
| import org.springframework.stereotype.Service | |||||
| @Service | |||||
| open class ProjectExpenseService( | |||||
| private val projectExpenseRepository: ProjectExpenseRepository, | |||||
| private val jdbcDao: JdbcDao, | |||||
| ) : AbstractIdEntityService<ProjectExpense, Long, ProjectExpenseRepository>(jdbcDao, projectExpenseRepository){ | |||||
| open fun findProjectExpenseSearchInfo(): List<ProjectExpenseSearchInfo> { | |||||
| return projectExpenseRepository.findExpenseSearchInfoByDeletedFalse() | |||||
| } | |||||
| } | |||||
| @@ -1,18 +0,0 @@ | |||||
| package com.ffii.tsms.modules.project.web | |||||
| import com.ffii.tsms.modules.project.entity.projections.ExpenseSearchInfo | |||||
| import com.ffii.tsms.modules.project.service.ExpenseService | |||||
| import org.springframework.web.bind.annotation.GetMapping | |||||
| import org.springframework.web.bind.annotation.RequestMapping | |||||
| import org.springframework.web.bind.annotation.RestController | |||||
| @RestController | |||||
| @RequestMapping("/expense") | |||||
| class ExpenseController( | |||||
| private val expenseService: ExpenseService, | |||||
| ) { | |||||
| @GetMapping | |||||
| fun allExpense(): List<ExpenseSearchInfo> { | |||||
| return expenseService.findExpenseSearchInfo() | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| package com.ffii.tsms.modules.project.web | |||||
| import com.ffii.tsms.modules.project.entity.projections.ProjectExpenseSearchInfo | |||||
| import com.ffii.tsms.modules.project.service.ProjectExpenseService | |||||
| import org.springframework.web.bind.annotation.GetMapping | |||||
| import org.springframework.web.bind.annotation.RequestMapping | |||||
| import org.springframework.web.bind.annotation.RestController | |||||
| @RestController | |||||
| @RequestMapping("/project-expense") | |||||
| class ProjectExpenseController( | |||||
| private val projectExpenseService: ProjectExpenseService, | |||||
| ) { | |||||
| @GetMapping | |||||
| fun allProjectExpense(): List<ProjectExpenseSearchInfo> { | |||||
| return projectExpenseService.findProjectExpenseSearchInfo() | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset derek:project_expense | |||||
| CREATE TABLE project_expense ( | |||||
| id INT NOT NULL AUTO_INCREMENT, | |||||
| version INT NOT NULL DEFAULT '0', | |||||
| created datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
| createdBy VARCHAR(30) NULL, | |||||
| modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
| modifiedBy VARCHAR(30) NULL, | |||||
| deleted TINYINT(1) NOT NULL DEFAULT '0', | |||||
| expenseNo VARCHAR(150) NULL, | |||||
| issueDate DATE NOT NULL, | |||||
| receiptDate date NULL, | |||||
| amount DECIMAL(16,2) NOT NULL, | |||||
| projectId INT NOT NULL, | |||||
| teamId INT NOT NULL, | |||||
| CONSTRAINT pk_project_expense PRIMARY KEY (id) | |||||
| ); | |||||
| ALTER TABLE project_expense ADD CONSTRAINT FK_PROJECT_EXPENSE_ON_PROJECTID FOREIGN KEY (projectId) REFERENCES project (id); | |||||
| ALTER TABLE project_expense ADD CONSTRAINT FK_PROJECT_EXPENSE_ON_TEAMID FOREIGN KEY (teamId) REFERENCES team (id); | |||||