[FO] 지출 CRUD, 수지출의 부호 추가 및 유효성체크
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package app.module.front.usecase.daily.expense.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.expense.persistence.model.CreateDailyExpenseCmd;
|
||||
import app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto;
|
||||
import app.module.front.usecase.daily.expense.persistence.model.RemoveDailyExpenseCmd;
|
||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DailyExpenseMapper {
|
||||
/**
|
||||
* 일계부 지출 목록 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 수입 목록
|
||||
*/
|
||||
List<DailyExpenseDto> getDailyExpenseList(DailyExpenseUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 지출 데이터 존재 여부
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 중복 개수
|
||||
*/
|
||||
Integer getRecordExistCount(DailyExpenseUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 지출 등록
|
||||
*
|
||||
* @param command 등록 데이터
|
||||
*/
|
||||
void createDailyExpense(CreateDailyExpenseCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 지출 수정
|
||||
*
|
||||
* @param command 수정 데이터
|
||||
*/
|
||||
void updateDailyExpense(CreateDailyExpenseCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 지출 삭제
|
||||
*
|
||||
* @param command 삭제 데이터
|
||||
*/
|
||||
void removeDailyExpense(RemoveDailyExpenseCmd command);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.front.usecase.daily.expense.persistence.model;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class CreateDailyExpenseCmd extends FrontAuditCommand {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String inputType;
|
||||
private Boolean credit;
|
||||
private String incomeMarkCode;
|
||||
private String categoryCode;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
private Integer quantity;
|
||||
private String unitCode;
|
||||
private Integer price;
|
||||
private Integer estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.module.front.usecase.daily.expense.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyExpenseDto {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
// TODO : SELF, OCR
|
||||
private String inputType;
|
||||
private Boolean credit;
|
||||
private String categoryCode;
|
||||
private String categoryLabel;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
private Integer quantity;
|
||||
private String unitCode;
|
||||
private String unitLabel;
|
||||
private Integer price;
|
||||
private Integer estimatedValue;
|
||||
|
||||
/**
|
||||
* 수정 가능 여부
|
||||
* @return true=가능, false=불가능(등록 상태)
|
||||
*/
|
||||
public boolean isUpdated() {
|
||||
return this.id != null && this.id != 0L;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.front.usecase.daily.expense.persistence.model;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class RemoveDailyExpenseCmd extends FrontAuditCommand {
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package app.module.front.usecase.daily.expense.service;
|
||||
|
||||
import app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto;
|
||||
import app.module.front.usecase.daily.expense.web.model.CreateDailyExpenseReqVO;
|
||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
||||
import app.module.front.usecase.daily.expense.web.model.RemoveDailyExpenseReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyExpenseService {
|
||||
/**
|
||||
* 일계부 수입 목록 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return
|
||||
*/
|
||||
List<DailyExpenseDto> getDailyExpenseList(DailyExpenseUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 수입 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return
|
||||
*/
|
||||
DailyExpenseDto getDailyExpense(DailyExpenseUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 수입 등록
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
*/
|
||||
void create(CreateDailyExpenseReqVO formVO);
|
||||
|
||||
/**
|
||||
* 일계부 수입 삭제
|
||||
*
|
||||
* @param formVO 삭제 검색 조건
|
||||
*/
|
||||
void remove(RemoveDailyExpenseReqVO formVO);
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package app.module.front.usecase.daily.expense.service;
|
||||
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import app.module.front.config.application.util.AuditUtil;
|
||||
import app.module.front.usecase.daily.expense.persistence.DailyExpenseMapper;
|
||||
import app.module.front.usecase.daily.expense.persistence.model.CreateDailyExpenseCmd;
|
||||
import app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto;
|
||||
import app.module.front.usecase.daily.expense.persistence.model.RemoveDailyExpenseCmd;
|
||||
import app.module.front.usecase.daily.expense.web.model.CreateDailyExpenseReqVO;
|
||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
||||
import app.module.front.usecase.daily.expense.web.model.RemoveDailyExpenseReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyExpenseServiceImpl implements DailyExpenseService {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyExpenseMapper DailyExpenseMapper;
|
||||
|
||||
@Override
|
||||
public List<DailyExpenseDto> getDailyExpenseList(DailyExpenseUIReqVO reqVO) {
|
||||
return this.getRefineIncomeList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyExpenseDto getDailyExpense(DailyExpenseUIReqVO reqVO) {
|
||||
List<DailyExpenseDto> list = this.getRefineIncomeList(reqVO);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
private List<DailyExpenseDto> getRefineIncomeList(DailyExpenseUIReqVO reqVO) {
|
||||
List<DailyExpenseDto> list = DailyExpenseMapper.getDailyExpenseList(reqVO);
|
||||
|
||||
List<UICodeElement> recordIncome = uiCodeListPortIn.connect("code.record.expense");
|
||||
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
||||
|
||||
for (DailyExpenseDto dto : list) {
|
||||
dto.setCategoryLabel(this.getCodeLabel(dto.getCategoryCode(), recordIncome));
|
||||
dto.setUnitLabel(this.getCodeLabel(dto.getUnitCode(), recordUnit));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 코드명 조회
|
||||
* @param code 코드
|
||||
* @param codeList 공통 코드 목록
|
||||
* @return
|
||||
*/
|
||||
private String getCodeLabel(String code, List<UICodeElement> codeList) {
|
||||
String returnValue = null;
|
||||
for (UICodeElement codeSetup : codeList) {
|
||||
if (codeSetup.getCodeValue().equalsIgnoreCase(code)) {
|
||||
returnValue = codeSetup.getCodeText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(CreateDailyExpenseReqVO formVO) {
|
||||
CreateDailyExpenseCmd command = AuditUtil.create(
|
||||
new CreateDailyExpenseCmd(
|
||||
formVO.getId(),
|
||||
formVO.getDailyRecordSeq(),
|
||||
formVO.getInputType(),
|
||||
formVO.getCredit(),
|
||||
(formVO.getCredit() ? "52210" : null), // [정책] 외상판매 Y 일 경우 수입부호 52210 적재
|
||||
formVO.getCategoryCode(),
|
||||
formVO.getCategorySelf(),
|
||||
formVO.getSourcePurpose(),
|
||||
formVO.getQuantity(),
|
||||
formVO.getUnitCode(),
|
||||
formVO.getPrice(),
|
||||
formVO.getEstimatedValue()));
|
||||
|
||||
DailyExpenseUIReqVO existReqVO = new DailyExpenseUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
||||
existReqVO.setId(formVO.getId());
|
||||
|
||||
Integer existCount = DailyExpenseMapper.getRecordExistCount(existReqVO);
|
||||
if (existCount == 0) {
|
||||
DailyExpenseMapper.createDailyExpense(command);
|
||||
|
||||
log.debug("[CreateDailyExpense] record={}", command);
|
||||
} else {
|
||||
DailyExpenseMapper.updateDailyExpense(command);
|
||||
|
||||
log.debug("[UpdateDailyExpense] record={}", command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemoveDailyExpenseReqVO formVO) {
|
||||
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
||||
RemoveDailyExpenseCmd command = AuditUtil.delete(
|
||||
new RemoveDailyExpenseCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
id,
|
||||
formVO.getDailyRecordSeq()));
|
||||
|
||||
DailyExpenseUIReqVO existReqVO = new DailyExpenseUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
||||
existReqVO.setId(id);
|
||||
|
||||
Integer existCount = DailyExpenseMapper.getRecordExistCount(existReqVO);
|
||||
if (existCount != 0) {
|
||||
DailyExpenseMapper.removeDailyExpense(command);
|
||||
|
||||
log.debug("[RemoveDailyExpense] record={}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package app.module.front.usecase.daily.expense.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.front.usecase.daily.expense.service.DailyExpenseService;
|
||||
import app.module.front.usecase.daily.expense.web.model.CreateDailyExpenseReqVO;
|
||||
import app.module.front.usecase.daily.expense.web.model.RemoveDailyExpenseReqVO;
|
||||
import app.module.front.usecase.daily.expense.web.validator.CreateDailyExpenseValidator;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/api/record/expense")
|
||||
public class DailyExpenseController {
|
||||
private final CoreUtil coreUtil;
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final DailyExpenseService DailyExpenseService;
|
||||
private final CreateDailyExpenseValidator createDailyExpenseValidator;
|
||||
|
||||
/**
|
||||
* 일계부 지출 등록 처리
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param id 수입 일련번호
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @PathVariable("id") String id
|
||||
, @Valid @RequestBody CreateDailyExpenseReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyExpenseValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
formVO.setSearchMonth(searchMonth);
|
||||
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
formVO.setId(Long.parseLong(id));
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
DailyExpenseService.create(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 지출 삭제 처리
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
|
||||
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @Valid @RequestBody RemoveDailyExpenseReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
log.debug("before formVO: {}", formVO);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
DailyExpenseService.remove(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 지출 전체 삭제 처리
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
|
||||
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
RemoveDailyExpenseReqVO formVO = new RemoveDailyExpenseReqVO();
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
DailyExpenseService.remove(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 유효성 체크 및 데이터 조회
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("getRecordUIReq: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package app.module.front.usecase.daily.expense.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto;
|
||||
import app.module.front.usecase.daily.expense.service.DailyExpenseService;
|
||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/expense")
|
||||
public class DailyExpenseUIController {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final DailyExpenseService DailyExpenseService;
|
||||
|
||||
/**
|
||||
* 일계부 지출 목록 화면
|
||||
*
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
DailyExpenseUIReqVO reqVO = new DailyExpenseUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
List<DailyExpenseDto> expenseList = DailyExpenseService.getDailyExpenseList(reqVO);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("expenseList", expenseList);
|
||||
|
||||
return "record/expense/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 지출 등록 화면
|
||||
*
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param id 수입 일련번호
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @PathVariable("id") String id) {
|
||||
|
||||
DailyExpenseUIReqVO reqVO = new DailyExpenseUIReqVO(searchMonth, groupNo);
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
reqVO.setId(0L);
|
||||
} else {
|
||||
reqVO.setId(Long.parseLong(id));
|
||||
}
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyExpenseDto detail = new DailyExpenseDto();
|
||||
if (reqVO.getId() != 0L) {
|
||||
detail = DailyExpenseService.getDailyExpense(reqVO);
|
||||
if (detail == null || !detail.isUpdated()) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("recordExpense", uiCodeListPortIn.connect("code.record.expense"));
|
||||
model.addAttribute("recordCrop", uiCodeListPortIn.connect("code.record.crop"));
|
||||
model.addAttribute("recordUnit", uiCodeListPortIn.connect("code.record.unit"));
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", detail);
|
||||
|
||||
return "record/expense/form";
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 유효성 체크 및 데이터 조회
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("getRecordUIReq: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package app.module.front.usecase.daily.expense.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class CreateDailyExpenseReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
/**
|
||||
* 등록 유형(SELF, OCR)
|
||||
*/
|
||||
private String inputType;
|
||||
/**
|
||||
* 외상판매 여부
|
||||
*/
|
||||
private Boolean credit;
|
||||
/**
|
||||
* 지출의 종류 코드
|
||||
*/
|
||||
@NotBlank(message = "지출 종류를 선택해 주세요.")
|
||||
private String categoryCode;
|
||||
/**
|
||||
* 지출의 종류 직접입력
|
||||
*/
|
||||
private String categorySelf;
|
||||
/**
|
||||
* 용도
|
||||
*/
|
||||
@NotBlank(message = "용도를 입력해 주세요.")
|
||||
private String sourcePurpose;
|
||||
/**
|
||||
* 수량
|
||||
*/
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 단위 코드
|
||||
*/
|
||||
private String unitCode;
|
||||
/**
|
||||
* 현금
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 현물평가액
|
||||
*/
|
||||
private Integer estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.front.usecase.daily.expense.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class DailyExpenseUIReqVO extends DailyUIReqVO {
|
||||
public DailyExpenseUIReqVO(String month, String no) {
|
||||
setSearchMonth(month);
|
||||
if (!StringUtils.isBlank(no)) {
|
||||
setGroupNo(Integer.parseInt(no));
|
||||
}
|
||||
}
|
||||
|
||||
public DailyExpenseUIReqVO(String month, Integer no) {
|
||||
setSearchMonth(month);
|
||||
setGroupNo(no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.front.usecase.daily.expense.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class RemoveDailyExpenseReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package app.module.front.usecase.daily.expense.web.validator;
|
||||
|
||||
import app.module.front.usecase.daily.expense.web.model.CreateDailyExpenseReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CreateDailyExpenseValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return CreateDailyExpenseReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyExpenseReqVO vo = (CreateDailyExpenseReqVO) target;
|
||||
|
||||
if (StringUtils.isBlank(vo.getCategoryCode())) {
|
||||
errors.rejectValue(
|
||||
"categoryCode", "valid.common.required",
|
||||
"지출 종류를 선택해 주세요.");
|
||||
}
|
||||
|
||||
if ("SELF".equals(vo.getCategoryCode()) && StringUtils.isBlank(vo.getCategorySelf())) {
|
||||
errors.rejectValue(
|
||||
"categorySelf", "valid.common.required",
|
||||
"지출 종류를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"price", "valid.common.required",
|
||||
"현금 또는 현물평가액을 입력 해주세요.");
|
||||
errors.rejectValue(
|
||||
"estimatedValue", "valid.common.required",
|
||||
"현금 또는 현물평가액을 입력 해주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class CreateDailyIncomeCmd extends FrontAuditCommand {
|
||||
private String inputType;
|
||||
private Boolean credit;
|
||||
private String cropCode;
|
||||
private String expenseMarkCode;
|
||||
private String categoryCode;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
|
||||
@@ -80,6 +80,7 @@ public class DailyIncomeServiceImpl implements DailyIncomeService {
|
||||
formVO.getInputType(),
|
||||
formVO.getCredit(),
|
||||
formVO.getCropCode(),
|
||||
(formVO.getCredit() ? "91206" : null), // [정책] 외상판매 Y 일 경우 지출부호 91206 적재
|
||||
formVO.getCategoryCode(),
|
||||
formVO.getCategorySelf(),
|
||||
formVO.getSourcePurpose(),
|
||||
|
||||
@@ -13,9 +13,9 @@ public enum DailyTargetStatus {
|
||||
* 등록 없음
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* 등록 완료
|
||||
*/
|
||||
DONE,
|
||||
// /**
|
||||
// * 등록 완료
|
||||
// */
|
||||
// DONE,
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user