자동이체 수입/지출 기본로직 완성(직접입력 미구현)

This commit is contained in:
주우성
2025-06-18 10:17:28 +09:00
parent 1876c7ebb4
commit cc8647e6c8
9 changed files with 477 additions and 224 deletions

View File

@@ -13,4 +13,5 @@ public class GetBanksCmd {
private Long monthlyInputStatusId;
private Long householdSeq;
private String transferType;
}

View File

@@ -59,21 +59,27 @@ class CreateBankInputController {
if(currentMonthlyInfo!=null) {
//TODO 트렌젝션 고려
removeBanksPortIn.operate(new RemoveBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(), "code.bank.input"));
removeBanksPortIn.operate(new RemoveBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(), reqVO.getTransferType()));
if (!reqVO.getStatus() && reqVO.getBankList() != null && !reqVO.getBankList().isEmpty()) { // 등록없음 처리가 아님.
for (CreateBankInputProductReqVO item : reqVO.getBankList()) {
UICodeView code = uiCodeViewPortIn.connect(item.getTransferCategoryCode()).orElse(null);
if(code != null) {
String incomdeCode = null;
String expenseCode = null;
if(reqVO.getTransferType().equals("code.bank.input")){
incomdeCode = !code.getId().equals(reqVO.getTransferType()+".99") && code.getCodeType().equals("INPUT") ? code.getCodeValue() : null;
expenseCode = !code.getId().equals(reqVO.getTransferType()+".99") && code.getCodeType().equals("OUTPUT") ?code.getCodeValue() : null;
}
createBankPortIn.operate(new CreateBankCmd(
AuthUtil.getUserSeq(),
"code.bank.input",
reqVO.getTransferType(),
item.getCropCode(),
item.getTransferCategoryCode(),
item.getTransferCategory(),
code.getCodeType().equals("INPUT") ? code.getCodeValue() : null,
code.getCodeType().equals("OUTPUT") ?code.getCodeValue() : null,
incomdeCode,
expenseCode,
item.getSourcePurpose(),
item.getCount(),
item.getUnitCode(),
@@ -89,8 +95,8 @@ class CreateBankInputController {
AuthUtil.getUserSeq(),
currentMonthlyInfo.getMonth(),
currentMonthlyInfo.getBankAutoTransferInputStatus(),
MonthStatus.REGISTERED,
currentMonthlyInfo.getBankAutoTransferOutputStatus()
reqVO.getTransferType().equals("code.bank.input") ? MonthStatus.REGISTERED : currentMonthlyInfo.getBankAutoTransferInputStatus(),
reqVO.getTransferType().equals("code.bank.output") ? MonthStatus.REGISTERED : currentMonthlyInfo.getBankAutoTransferOutputStatus()
));
} else {
updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd(
@@ -98,8 +104,8 @@ class CreateBankInputController {
AuthUtil.getUserSeq(),
currentMonthlyInfo.getMonth(),
currentMonthlyInfo.getBankAutoTransferInputStatus(),
MonthStatus.NOTHING,
currentMonthlyInfo.getBankAutoTransferOutputStatus()
reqVO.getTransferType().equals("code.bank.input") ? MonthStatus.NOTHING : currentMonthlyInfo.getBankAutoTransferInputStatus(),
reqVO.getTransferType().equals("code.bank.output") ? MonthStatus.NOTHING : currentMonthlyInfo.getBankAutoTransferOutputStatus()
));
}
return ResponseEntity.ok(ApiResponse.success(null));

View File

@@ -66,14 +66,14 @@ class GetBankInputUIController {
if (pastMonthlyInfo != null) {
pastList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(pastMonthlyInfo.getId(), AuthUtil.getUserSeq()));
new GetBanksCmd(pastMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.input"));
}
Page<GetBanks> currentList = Page.empty();
if (currentMonthlyInfo != null) {
currentList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq()));
new GetBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.input"));
}

View File

@@ -15,6 +15,7 @@ public class CreateBankInputReqVO {
private Boolean status;
private Long id;
private String transferType;
private List<CreateBankInputProductReqVO> bankList;
public List<CreateBankInputProductReqVO> getBankList() {

View File

@@ -3,6 +3,9 @@ package app.module.front.usecase.info.bankUI.getBankOutputUI.adapters.web;
import app.module.core.config.application.enums.MonthStatus;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.front.config.application.util.AuthUtil;
import app.module.front.usecase.info.bank.getBanks.ports.GetBanksPortIn;
import app.module.front.usecase.info.bank.getBanks.ports.application.domain.GetBanks;
import app.module.front.usecase.info.bank.getBanks.ports.application.domain.GetBanksCmd;
import app.module.front.usecase.info.monthly.getMonthlyInputStatus.ports.GetMonthlyInputStatusPortIn;
import app.module.front.usecase.info.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatus;
import app.module.front.usecase.info.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatusCmd;
@@ -33,14 +36,18 @@ import java.util.NoSuchElementException;
class GetBankOutputUIController {
private final GetPrevMonthlyInputStatusPortIn prevMonthlyInputStatusPortIn;
private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn;
private final GetBanksPortIn getBanksPortIn;
private final UICodeListPortIn uiCodeListPortIn;
@GetMapping(path = "/info/bank/create/output/{id}")
String operate(Model model,
@PathVariable Long id) {
public String operate(Model model,
@PathVariable Long id
,@PageableDefault(sort = "createAt", direction = Sort.Direction.DESC, page = 0, size = 100) Pageable pageable) {
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
@@ -59,6 +66,22 @@ class GetBankOutputUIController {
new GetMonthlyInputStatusCmd(
id, AuthUtil.getUserSeq())).orElse(null);
Page<GetBanks> pastList = Page.empty();
if (pastMonthlyInfo != null) {
pastList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(pastMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.output"));
}
Page<GetBanks> currentList = Page.empty();
if (currentMonthlyInfo != null) {
currentList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.output"));
}
//수정 가능 여부 판단
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
YearMonth yearMonth = YearMonth.parse(currentMonthlyInfo.getMonth(), formatter);
@@ -71,14 +94,30 @@ class GetBankOutputUIController {
model.addAttribute("pastMonthlyInfo", pastMonthlyInfo);
model.addAttribute("currentMonthlyInfo", currentMonthlyInfo);
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.input"));
model.addAttribute("pastBankList", pastList);
model.addAttribute("bankList", currentList);
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.output"));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("unitList", uiCodeListPortIn.connect("code.record.unit"));
model.addAttribute("MonthStatus", MonthStatus.class);
model.addAttribute("editable", editable);
return "info/bank/output";
}
@GetMapping(path = "/api/front/info/bank/create/output/from")
public String operateForm(Model model) {
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.output"));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("unitList", uiCodeListPortIn.connect("code.record.unit"));
return "info/bank/outputForm";
}
}