[BO] 일계부 지출 등록, 수정
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.SaveDailyExpensePortOut;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseCmd;
|
||||||
|
import app.module.core.config.application.annotation.CreateCommand;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SaveDailyExpenseDao implements SaveDailyExpensePortOut {
|
||||||
|
private final SaveDailyExpenseMapper dailyExpenseMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GetDailyExpenseDto detail(GetDailyExpenseCmd command) {
|
||||||
|
|
||||||
|
return dailyExpenseMapper.getDailyExpense(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@CreateCommand
|
||||||
|
@Override
|
||||||
|
public void create(GetDailyExpenseCmd findCmd, SaveDailyExpenseCmd command) {
|
||||||
|
Integer existCount = dailyExpenseMapper.getRecordExistCount(findCmd);
|
||||||
|
if (existCount == 0) {
|
||||||
|
dailyExpenseMapper.createDailyExpense(command);
|
||||||
|
|
||||||
|
log.debug("[CreateDailyExpense] command={}", command);
|
||||||
|
} else {
|
||||||
|
dailyExpenseMapper.updateDailyExpense(command);
|
||||||
|
|
||||||
|
log.debug("[UpdateDailyExpense] command={}", command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseCmd;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface SaveDailyExpenseMapper {
|
||||||
|
/**
|
||||||
|
* 일계부 지출 데이터 조회
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 지출 데이터
|
||||||
|
*/
|
||||||
|
GetDailyExpenseDto getDailyExpense(GetDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 데이터 존재 여부
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 중복 개수
|
||||||
|
*/
|
||||||
|
Integer getRecordExistCount(GetDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록
|
||||||
|
*
|
||||||
|
* @param command 등록 데이터
|
||||||
|
*/
|
||||||
|
void createDailyExpense(SaveDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 수정
|
||||||
|
*
|
||||||
|
* @param command 수정 데이터
|
||||||
|
*/
|
||||||
|
void updateDailyExpense(SaveDailyExpenseCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal;
|
||||||
|
|
||||||
|
import app.module.core.config.application.enums.DailyInputType;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class GetDailyExpenseDto {
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
private DailyInputType inputType;
|
||||||
|
private Boolean credit;
|
||||||
|
private String expenseKind;
|
||||||
|
private String sourcePurpose;
|
||||||
|
private String quantity;
|
||||||
|
private String unitCode;
|
||||||
|
private String unitLabel;
|
||||||
|
private String unitSelf;
|
||||||
|
private Long price;
|
||||||
|
private Long estimatedValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.DailyExpenseUIReqVO;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.SaveDailyExpenseReqVO;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.validator.SaveDailyExpenseValidator;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.SaveDailyExpensePortIn;
|
||||||
|
import app.module.core.config.application.exception.NoRecordDataException;
|
||||||
|
import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
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/household/daily/expense")
|
||||||
|
public class SaveDailyExpenseController {
|
||||||
|
private final DailyRecordPortIn dailyRecordPortIn;
|
||||||
|
private final SaveDailyExpensePortIn dailyExpensePortIn;
|
||||||
|
private final SaveDailyExpenseValidator dailyExpenseValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 조회
|
||||||
|
*
|
||||||
|
* @param id 지출 일련번호
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/{id}")
|
||||||
|
ResponseEntity<?> detail(@PathVariable("id") String id, @ModelAttribute DailyExpenseUIReqVO reqVO) {
|
||||||
|
|
||||||
|
reqVO.setId(Long.parseLong(id));
|
||||||
|
|
||||||
|
GetDailyExpenseDto detail = dailyExpensePortIn.detail(reqVO);
|
||||||
|
if (detail == null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록 처리
|
||||||
|
*
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
* @param bindingResult BindingResult
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/save")
|
||||||
|
ResponseEntity<?> create(@Valid @RequestBody SaveDailyExpenseReqVO formVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
dailyExpenseValidator.validate(formVO, bindingResult);
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getFieldErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(formVO.getDailyId());
|
||||||
|
|
||||||
|
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||||
|
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||||
|
formVO.setDailyId(dailyRecord.getId());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyExpensePortIn.create(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 유효성 체크 및 데이터 조회
|
||||||
|
*
|
||||||
|
* @param dailyRecordSeq 항목 일련번호
|
||||||
|
*/
|
||||||
|
private DailyRecordDto vaildGetDailyRecord(Long dailyRecordSeq) {
|
||||||
|
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(dailyRecordSeq);
|
||||||
|
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||||
|
throw new NoRecordDataException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dailyRecord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DailyExpenseUIReqVO {
|
||||||
|
/**
|
||||||
|
* 검색 월(yyyyMM)
|
||||||
|
*/
|
||||||
|
private String searchMonth;
|
||||||
|
/**
|
||||||
|
* 검색 그룸번호
|
||||||
|
*/
|
||||||
|
private Integer groupNo;
|
||||||
|
/**
|
||||||
|
* 임가 일련번호
|
||||||
|
*/
|
||||||
|
private Long householdSeq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 항목 일련번호
|
||||||
|
*/
|
||||||
|
private Long dailyId;
|
||||||
|
/**
|
||||||
|
* 지출 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.core.config.application.enums.DailyInputType;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class SaveDailyExpenseReqVO extends DailyExpenseUIReqVO {
|
||||||
|
/**
|
||||||
|
* 등록 유형
|
||||||
|
*/
|
||||||
|
private DailyInputType inputType;
|
||||||
|
/**
|
||||||
|
* 외상판매 여부
|
||||||
|
*/
|
||||||
|
private Boolean credit;
|
||||||
|
/**
|
||||||
|
* 지출의 종류 직접입력
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "지출 종류를 입력해 주세요.")
|
||||||
|
private String expenseKind;
|
||||||
|
/**
|
||||||
|
* 용도
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "용도를 입력해 주세요.")
|
||||||
|
private String sourcePurpose;
|
||||||
|
/**
|
||||||
|
* 수량
|
||||||
|
*/
|
||||||
|
private Double quantity;
|
||||||
|
/**
|
||||||
|
* 단위 코드
|
||||||
|
*/
|
||||||
|
private String unitCode;
|
||||||
|
/**
|
||||||
|
* 단위 직접 입력
|
||||||
|
*/
|
||||||
|
private String unitSelf;
|
||||||
|
/**
|
||||||
|
* 현금
|
||||||
|
*/
|
||||||
|
private Long price;
|
||||||
|
/**
|
||||||
|
* 현물평가액
|
||||||
|
*/
|
||||||
|
private Long estimatedValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.validator;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.SaveDailyExpenseReqVO;
|
||||||
|
import app.module.core.config.constants.CommonConstants;
|
||||||
|
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 SaveDailyExpenseValidator implements Validator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> clazz) {
|
||||||
|
return SaveDailyExpenseReqVO.class.equals(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Object target, Errors errors) {
|
||||||
|
SaveDailyExpenseReqVO vo = (SaveDailyExpenseReqVO) target;
|
||||||
|
|
||||||
|
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"quantity", "valid.common.required",
|
||||||
|
"수량을 입력해 주세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"unitCode", "valid.common.required",
|
||||||
|
"단위를 선택해 주세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"unitSelf", "valid.common.required",
|
||||||
|
"단위를 입력해 주세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"price", "valid.common.required",
|
||||||
|
"현금 또는 현물평가액을 입력해 주세요.");
|
||||||
|
errors.rejectValue(
|
||||||
|
"estimatedValue", "valid.common.required",
|
||||||
|
"현금 또는 현물평가액을 입력해 주세요.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.DailyExpenseUIReqVO;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.SaveDailyExpenseReqVO;
|
||||||
|
|
||||||
|
public interface SaveDailyExpensePortIn {
|
||||||
|
/**
|
||||||
|
* 일계부 지출 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 지출 상세
|
||||||
|
*/
|
||||||
|
GetDailyExpenseDto detail(DailyExpenseUIReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록
|
||||||
|
*
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(SaveDailyExpenseReqVO formVO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseCmd;
|
||||||
|
|
||||||
|
public interface SaveDailyExpensePortOut {
|
||||||
|
/**
|
||||||
|
* 일계부 지출 조회
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 지출 상세
|
||||||
|
*/
|
||||||
|
GetDailyExpenseDto detail(GetDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록
|
||||||
|
*
|
||||||
|
* @param findCmd 검색 조건
|
||||||
|
* @param command 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(GetDailyExpenseCmd findCmd, SaveDailyExpenseCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.DailyExpenseUIReqVO;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.SaveDailyExpenseReqVO;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.SaveDailyExpensePortIn;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.SaveDailyExpensePortOut;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseCmd;
|
||||||
|
import app.module.core.config.constants.DailyRecordConstants;
|
||||||
|
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SaveDailyExpenseService implements SaveDailyExpensePortIn {
|
||||||
|
private final SaveDailyExpensePortOut portOut;
|
||||||
|
private final DailyRecordPortIn dailyRecordPortIn;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GetDailyExpenseDto detail(DailyExpenseUIReqVO reqVO) {
|
||||||
|
GetDailyExpenseCmd findCmd = new GetDailyExpenseCmd(
|
||||||
|
reqVO.getSearchMonth(),
|
||||||
|
reqVO.getGroupNo(),
|
||||||
|
reqVO.getHouseholdSeq(),
|
||||||
|
reqVO.getId());
|
||||||
|
|
||||||
|
return portOut.detail(findCmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void create(SaveDailyExpenseReqVO formVO) {
|
||||||
|
GetDailyExpenseCmd findCmd = new GetDailyExpenseCmd(
|
||||||
|
formVO.getSearchMonth(),
|
||||||
|
formVO.getGroupNo(),
|
||||||
|
formVO.getHouseholdSeq(),
|
||||||
|
formVO.getId());
|
||||||
|
|
||||||
|
SaveDailyExpenseCmd command =
|
||||||
|
new SaveDailyExpenseCmd(
|
||||||
|
formVO.getId(),
|
||||||
|
formVO.getDailyId(),
|
||||||
|
formVO.getInputType(),
|
||||||
|
DailyRecordConstants.EXPENSE_CATEGORY,
|
||||||
|
(formVO.getCredit() ? DailyRecordConstants.EXPENSE_INCOME_MARK : null),
|
||||||
|
formVO.getCredit(),
|
||||||
|
formVO.getExpenseKind(),
|
||||||
|
formVO.getSourcePurpose(),
|
||||||
|
formVO.getQuantity(),
|
||||||
|
formVO.getUnitCode(),
|
||||||
|
formVO.getUnitSelf(),
|
||||||
|
formVO.getPrice(),
|
||||||
|
formVO.getEstimatedValue());
|
||||||
|
|
||||||
|
portOut.create(findCmd, command);
|
||||||
|
|
||||||
|
dailyRecordPortIn.updateByAllStatus(findCmd.getSearchMonth(), findCmd.getGroupNo(), findCmd.getHouseholdSeq());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GetDailyExpenseCmd {
|
||||||
|
/**
|
||||||
|
* 검색 월(yyyyMM)
|
||||||
|
*/
|
||||||
|
private String searchMonth;
|
||||||
|
/**
|
||||||
|
* 검색 그룸번호
|
||||||
|
*/
|
||||||
|
private Integer groupNo;
|
||||||
|
/**
|
||||||
|
* 임가 일련번호
|
||||||
|
*/
|
||||||
|
private Long householdSeq;
|
||||||
|
/**
|
||||||
|
* 지출 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||||
|
import app.module.core.config.application.enums.DailyInputType;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class SaveDailyExpenseCmd extends AuditCommand {
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
private DailyInputType inputType;
|
||||||
|
/**
|
||||||
|
* 유형
|
||||||
|
*/
|
||||||
|
private String category;
|
||||||
|
/**
|
||||||
|
* 수입 부호
|
||||||
|
*/
|
||||||
|
private String incomeMark;
|
||||||
|
private Boolean credit;
|
||||||
|
private String expenseKind;
|
||||||
|
private String sourcePurpose;
|
||||||
|
private Double quantity;
|
||||||
|
private String unitCode;
|
||||||
|
private String unitSelf;
|
||||||
|
private Long price;
|
||||||
|
private Long estimatedValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.SaveDailyExpenseMapper">
|
||||||
|
|
||||||
|
<select id="getDailyExpense"
|
||||||
|
resultType="app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto">
|
||||||
|
select ds.id, ds.daily_record_seq, ds.input_type, ds.is_credit as credit
|
||||||
|
, ds.expense_kind, ds.source_purpose
|
||||||
|
, ds.quantity, ds.unit_code, ds.unit_self, ds.price, ds.estimated_value
|
||||||
|
from daily_expense ds
|
||||||
|
<include refid="app.module.core.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||||
|
where ds.is_deleted = false
|
||||||
|
and ds.id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getRecordExistCount" resultType="int">
|
||||||
|
select count(1)
|
||||||
|
from daily_expense ds
|
||||||
|
<include refid="app.module.core.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||||
|
where ds.is_deleted = false
|
||||||
|
<if test="id != null and id != '0'">
|
||||||
|
and ds.id = #{id}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="createDailyExpense" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into daily_expense (
|
||||||
|
daily_record_seq, input_type, category, income_mark
|
||||||
|
, is_credit, expense_kind, source_purpose
|
||||||
|
, quantity, unit_code, unit_self, price, estimated_value
|
||||||
|
, is_deleted
|
||||||
|
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||||
|
) values (
|
||||||
|
#{dailyRecordSeq}, #{inputType}, #{category}, #{incomeMark}
|
||||||
|
, #{credit}, #{expenseKind}, #{sourcePurpose}
|
||||||
|
, #{quantity}, #{unitCode}, #{unitSelf}, #{price}, #{estimatedValue}
|
||||||
|
, false
|
||||||
|
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateDailyExpense">
|
||||||
|
update daily_expense set <include refid="common.fields.UpdateBaseSet"/>
|
||||||
|
, is_credit = #{credit}
|
||||||
|
, income_mark = #{incomeMark}
|
||||||
|
, expense_kind = #{expenseKind}
|
||||||
|
, source_purpose = #{sourcePurpose}
|
||||||
|
, quantity = #{quantity}
|
||||||
|
, unit_code = #{unitCode}
|
||||||
|
, unit_self = #{unitSelf}
|
||||||
|
, price = #{price}
|
||||||
|
, estimated_value = #{estimatedValue}
|
||||||
|
where is_deleted = false
|
||||||
|
and daily_record_seq = #{dailyRecordSeq}
|
||||||
|
and id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||||
|
layout:decorate="~{layout/layout}">
|
||||||
|
|
||||||
|
<div class="layer-wrap" th:fragment="modalFragment">
|
||||||
|
<form autocomplete="off" method="get" name="reqExpenseForm" data-modal-id=".modal-daily-expense">
|
||||||
|
<input type="hidden" name="householdSeq" th:value="${seq}">
|
||||||
|
<input type="hidden" name="searchMonth">
|
||||||
|
<input type="hidden" name="groupNo">
|
||||||
|
<input type="hidden" name="id">
|
||||||
|
<input type="hidden" name="dailyId">
|
||||||
|
|
||||||
|
<div class="component-modal mypage-wrap modal01 modal-daily-expense" data-props-dimm-click="true" data-state="close">
|
||||||
|
<div class="modal-dimm"></div>
|
||||||
|
<div class="modal-frame">
|
||||||
|
<div class="modal-container">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h3 class="modal-tit">
|
||||||
|
일계부 수입
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-content-inner">
|
||||||
|
<table class="type-form confirm">
|
||||||
|
<colgroup>
|
||||||
|
<col width="8%" />
|
||||||
|
<col width="25.3%" />
|
||||||
|
<col width="8%" />
|
||||||
|
<col width="25.3%" />
|
||||||
|
<col width="8%" />
|
||||||
|
<col width="25.3%" />
|
||||||
|
</colgroup>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>외상 또는 카드 구입 여부</th>
|
||||||
|
<td class="radio-group" colspan="4">
|
||||||
|
<div class="component-input">
|
||||||
|
<label class="radio-inner">
|
||||||
|
<input type="radio" id="isCredit_N" name="credit" value="false" checked>
|
||||||
|
<span class="radio-item">
|
||||||
|
<span class="radio-txt">N</span>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="component-input">
|
||||||
|
<label class="radio-inner">
|
||||||
|
<input type="radio" id="isCredit_Y" name="credit" value="true">
|
||||||
|
<span class="radio-item">
|
||||||
|
<span class="radio-txt">Y</span>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>지출의 종류<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||||
|
<td>
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="text" id="expenseKind" name="expenseKind" maxlength="30">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<th>용도<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||||
|
<td>
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="text" id="sourcePurpose" name="sourcePurpose" maxlength="30">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>수량</th>
|
||||||
|
<td>
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="number" inputmode="decimal" pattern="[0-9]*" id="quantity" name="quantity" min="1" max="9999999999"
|
||||||
|
maxlength="10" oninput="limitMaxLength(this);">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<th>단위</th>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="d-flex">
|
||||||
|
<div class="component-select">
|
||||||
|
<select class="select-list" name="unitCode" onchange="selectedUnit(this);" required>
|
||||||
|
<option value="">선택</option>
|
||||||
|
<option th:each="item : ${recordUnit}"
|
||||||
|
th:value="${item.id}"
|
||||||
|
th:text="${item.codeText}">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="component-input unit-self-input">
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="text" id="unitSelf" name="unitSelf" maxlength="30" disabled>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>현금(원)<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||||
|
<td>
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="number" inputmode="numeric" pattern="[0-9]*" id="price" name="price" step="0" min="1" max="9999999999"
|
||||||
|
maxlength="10" oninput="limitMaxLength(this); priceDisabled(this, this.form.estimatedValue)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<th>현물평가액(원)<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||||
|
<td>
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="number" inputmode="numeric" pattern="[0-9]*" id="estimatedValue" name="estimatedValue" step="0" min="1" max="9999999999"
|
||||||
|
maxlength="10" oninput="limitMaxLength(this); priceDisabled(this, this.form.price)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="component-btns bottom-btn-group">
|
||||||
|
<div class="btns-row align-right">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="saveDailyExpense();">
|
||||||
|
<span class="btn-txt">등록</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="modal-close"></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script th:inline="javascript">
|
||||||
|
// form 초기화
|
||||||
|
const resetDailyExpenseForm = () => {
|
||||||
|
const form = document.reqExpenseForm;
|
||||||
|
if (!form) return;
|
||||||
|
|
||||||
|
form.expenseKind.value = '';
|
||||||
|
form.sourcePurpose.value = '';
|
||||||
|
form.quantity.value = '';
|
||||||
|
form.unitCode.value = '';
|
||||||
|
form.unitSelf.value = '';
|
||||||
|
form.price.value = '';
|
||||||
|
form.estimatedValue.value = '';
|
||||||
|
|
||||||
|
document.getElementById('isCredit_N').checked = true;
|
||||||
|
priceDisabledReset(form.price, form.estimatedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 일계부 상세 값 set
|
||||||
|
const setDailyExpenseFormData = (data) => {
|
||||||
|
const form = document.reqExpenseForm;
|
||||||
|
if (!form) return;
|
||||||
|
|
||||||
|
// 폼에 값 세팅
|
||||||
|
form.expenseKind.value = data.expenseKind || '';
|
||||||
|
form.sourcePurpose.value = data.sourcePurpose || '';
|
||||||
|
form.quantity.value = data.quantity || '';
|
||||||
|
form.unitCode.value = data.unitCode || '';
|
||||||
|
form.unitSelf.value = data.unitSelf || '';
|
||||||
|
form.price.value = data.price || '';
|
||||||
|
form.estimatedValue.value = data.estimatedValue || '';
|
||||||
|
|
||||||
|
// 기타 UI 처리
|
||||||
|
selectedUnit(form.unitCode);
|
||||||
|
if (form.price.value !== '') {
|
||||||
|
priceDisabled(form.price, form.estimatedValue);
|
||||||
|
} else {
|
||||||
|
priceDisabled(form.estimatedValue, form.price);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 라디오 버튼 처리
|
||||||
|
document.getElementById('isCredit_Y').checked = data.credit === true;
|
||||||
|
document.getElementById('isCredit_N').checked = data.credit === false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script th:inline="javascript">
|
||||||
|
// 일계부 등록 모달창 띄우기
|
||||||
|
const showDailyExpenseModal = (id) => {
|
||||||
|
const mf = document.reqExpenseForm;
|
||||||
|
mf.searchMonth.value = document.reqForm.recordMonth.value;
|
||||||
|
mf.groupNo.value = document.reqForm.groupNo.value;
|
||||||
|
mf.dailyId.value = document.reqForm.dailyId.value;
|
||||||
|
mf.id.value = (id === undefined) ? '' : id;
|
||||||
|
|
||||||
|
resetDailyExpenseForm();
|
||||||
|
|
||||||
|
if (id !== null && id !== undefined) {
|
||||||
|
const obj = $(f).serializeObject();
|
||||||
|
obj.id = mf.id.value;
|
||||||
|
obj.searchMonth = obj.recordMonth;
|
||||||
|
|
||||||
|
ajaxUtil._ajaxAsyncMethod(
|
||||||
|
`/api/household/daily/expense/${id}`,
|
||||||
|
obj,
|
||||||
|
function (rstData, status) {
|
||||||
|
setDailyExpenseFormData(rstData);
|
||||||
|
|
||||||
|
document.querySelector($(mf).data('modalId')).ui.open();
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
console.error('Do nothing error.')
|
||||||
|
},
|
||||||
|
'get'
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
document.querySelector($(mf).data('modalId')).ui.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveDailyExpense = () => {
|
||||||
|
const mf = document.reqExpenseForm;
|
||||||
|
let obj = $(mf).serializeObject();
|
||||||
|
obj.inputType = 'SELF';
|
||||||
|
obj.id = (obj.id === '' ? '0' : obj.id);
|
||||||
|
|
||||||
|
ajaxUtil._ajaxAsyncNoWaiting(
|
||||||
|
'/api/household/daily/expense/save',
|
||||||
|
obj,
|
||||||
|
function () {
|
||||||
|
alert('등록이 완료되었습니다.');
|
||||||
|
|
||||||
|
document.querySelector($(mf).data('modalId')).ui.close();
|
||||||
|
|
||||||
|
getDailyRecordsView(f.dailyId.value, f.groupNo.value, f.dayGroupText.value);
|
||||||
|
},
|
||||||
|
function (code, rstData) {
|
||||||
|
console.error('Do nothing. code: '+ code, rstData);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</html>
|
||||||
@@ -173,6 +173,7 @@
|
|||||||
form.estimatedValue.value = '';
|
form.estimatedValue.value = '';
|
||||||
|
|
||||||
document.getElementById('isCredit_N').checked = true;
|
document.getElementById('isCredit_N').checked = true;
|
||||||
|
priceDisabledReset(form.price, form.estimatedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 일계부 상세 값 set
|
// 일계부 상세 값 set
|
||||||
|
|||||||
@@ -599,7 +599,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>${item.isCredit ? "Y" : "N"}</td> <!-- 외상 또는 카드구입 -->
|
<td>${item.isCredit ? "Y" : "N"}</td> <!-- 외상 또는 카드구입 -->
|
||||||
<td class="underline">${ifNullHyphen(item.expenseKind)}</td><!-- 지출의 종류 -->
|
<td class="underline"><a href="javascript:void(0);" onclick="showDailyExpenseModal(${item.id});">${ifNullHyphen(item.expenseKind)}</a></td> <!-- 지출의 종류 -->
|
||||||
<td>${ifNullHyphen(item.sourcePurpose)}</td><!-- 용도 -->
|
<td>${ifNullHyphen(item.sourcePurpose)}</td><!-- 용도 -->
|
||||||
<td class="align-right">${ifNullHyphen(item.quantity)}</td><!-- 수량 -->
|
<td class="align-right">${ifNullHyphen(item.quantity)}</td><!-- 수량 -->
|
||||||
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
||||||
@@ -812,6 +812,8 @@
|
|||||||
showDailyIncomeModal();
|
showDailyIncomeModal();
|
||||||
} else if (currentStep === 'WORK') {
|
} else if (currentStep === 'WORK') {
|
||||||
showDailyWorkModal();
|
showDailyWorkModal();
|
||||||
|
} else if (currentStep === 'EXPENSE') {
|
||||||
|
showDailyExpenseModal();
|
||||||
} else {
|
} else {
|
||||||
alert('TODO : 추가');
|
alert('TODO : 추가');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,7 @@
|
|||||||
<!-- 일계부 모달 -->
|
<!-- 일계부 모달 -->
|
||||||
<th:block th:replace="households/modal/modal-daily-income :: modalFragment"/>
|
<th:block th:replace="households/modal/modal-daily-income :: modalFragment"/>
|
||||||
<th:block th:replace="households/modal/modal-daily-work :: modalFragment"/>
|
<th:block th:replace="households/modal/modal-daily-work :: modalFragment"/>
|
||||||
|
<th:block th:replace="households/modal/modal-daily-expense :: modalFragment"/>
|
||||||
|
|
||||||
<!-- 조사원 매핑 모달 -->
|
<!-- 조사원 매핑 모달 -->
|
||||||
<th:block th:replace="common/modal-researcher-mapping :: modalFragment"/>
|
<th:block th:replace="common/modal-researcher-mapping :: modalFragment"/>
|
||||||
@@ -341,6 +342,22 @@
|
|||||||
disableArea.classList.add('input-disabled');
|
disableArea.classList.add('input-disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const priceDisabledReset = (el, disableEl) => {
|
||||||
|
let wrap = null;
|
||||||
|
|
||||||
|
if (el.value === '') {
|
||||||
|
wrap = el.closest('td');
|
||||||
|
wrap.querySelector('input').disabled = false;
|
||||||
|
wrap.querySelector('.component-input').classList.remove('input-disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disableEl.value === '') {
|
||||||
|
wrap = disableEl.closest('td');
|
||||||
|
wrap.querySelector('input').disabled = false;
|
||||||
|
wrap.querySelector('.component-input').classList.remove('input-disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,16 @@ public class DailyRecordConstants {
|
|||||||
* [정책] 외상판매 Y 일 경우 지출부호 91206 적재
|
* [정책] 외상판매 Y 일 경우 지출부호 91206 적재
|
||||||
*/
|
*/
|
||||||
public static final String INCOME_EXPENSE_MARK = "91206";
|
public static final String INCOME_EXPENSE_MARK = "91206";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지출의 유형
|
||||||
|
* [정책] 2 고정
|
||||||
|
*/
|
||||||
|
public static final String EXPENSE_CATEGORY = "2";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지출의 수입부호
|
||||||
|
* [정책] 외상판매 Y 일 경우 수입부호 52210 적재
|
||||||
|
*/
|
||||||
|
public static final String EXPENSE_INCOME_MARK = "52210";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package app.module.front.usecase.daily.expense.ports.application;
|
package app.module.front.usecase.daily.expense.ports.application;
|
||||||
|
|
||||||
|
import app.module.core.config.constants.DailyRecordConstants;
|
||||||
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||||
@@ -98,8 +99,8 @@ public class DailyExpenseService implements DailyExpensePortIn {
|
|||||||
formVO.getId(),
|
formVO.getId(),
|
||||||
formVO.getDailyRecordSeq(),
|
formVO.getDailyRecordSeq(),
|
||||||
formVO.getInputType(),
|
formVO.getInputType(),
|
||||||
"2", // [정책] 2 고정
|
DailyRecordConstants.EXPENSE_CATEGORY,
|
||||||
(formVO.getCredit() ? "52210" : null), // [정책] 외상판매 Y 일 경우 수입부호 52210 적재
|
(formVO.getCredit() ? DailyRecordConstants.EXPENSE_INCOME_MARK : null),
|
||||||
formVO.getCredit(),
|
formVO.getCredit(),
|
||||||
formVO.getExpenseKind(),
|
formVO.getExpenseKind(),
|
||||||
formVO.getSourcePurpose(),
|
formVO.getSourcePurpose(),
|
||||||
|
|||||||
Reference in New Issue
Block a user