월 변경

This commit is contained in:
주우성
2025-06-16 20:28:18 +09:00
parent 8ed3249ab4
commit 59e80d87a4
7 changed files with 272 additions and 96 deletions

View File

@@ -1,13 +1,14 @@
package app.module.front.usecase.info.bankUI.getBankInputUI.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.monthly.getMonthlyInputStatuss.ports.GetMonthlyInputStatussPortIn;
import app.module.front.usecase.info.monthly.getMonthlyInputStatuss.ports.application.domain.GetMonthlyInputStatuss;
import app.module.front.usecase.info.monthly.getMonthlyInputStatuss.ports.application.domain.GetMonthlyInputStatussCmd;
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;
import app.module.front.usecase.info.monthly.getPrevMonthlyInputStatus.ports.GetPrevMonthlyInputStatusPortIn;
import app.module.front.usecase.info.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.front.usecase.info.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
@@ -17,15 +18,18 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.NoSuchElementException;
@Controller
@RequiredArgsConstructor
class GetBankInputUIController {
private final GetMonthlyInputStatussPortIn portIn;
private final GetPrevMonthlyInputStatusPortIn prevMonthlyInputStatusPortIn;
private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn;
private final UICodeListPortIn uiCodeListPortIn;
@GetMapping(path = "/info/bank/create/input/{id}")
@@ -33,7 +37,39 @@ class GetBankInputUIController {
@PathVariable Long id,
@PageableDefault(sort = "createAt", direction = Sort.Direction.DESC, page = 0, size = 100) Pageable pageable) {
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
// 전달 입력 상태 취득 , 데이터가 없을 경우 null
// 이전달 입력상태:NONE일 경우도 null
GetPrevMonthlyInputStatus pastMonthlyInfo =
prevMonthlyInputStatusPortIn.operate(
new GetPrevMonthlyInputStatusCmd(
id, AuthUtil.getUserSeq())).orElse(null);
//이번달 달 입력 상태 취득
GetMonthlyInputStatus currentMonthlyInfo =
getMonthlyInputStatusPortIn.operate(
new GetMonthlyInputStatusCmd(
id, AuthUtil.getUserSeq())).orElse(null);
//수정 가능 여부 판단
YearMonth yearMonth = YearMonth.parse(currentMonthlyInfo.getMonth());
LocalDate maxMonth = yearMonth.plusMonths(1).atDay(15);
LocalDate today = LocalDate.now();
boolean editable = !today.isAfter(maxMonth);
model.addAttribute("pastMonthlyInfo", pastMonthlyInfo);
model.addAttribute("currentMonthlyInfo", currentMonthlyInfo);
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.input"));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("unitList", uiCodeListPortIn.connect("code.record.unit"));
model.addAttribute("editable", editable);
return "info/bank/input";
}

View File

@@ -32,7 +32,7 @@ class GetBankOutputUIController {
@PathVariable Long id,
@PageableDefault(sort = "createAt", direction = Sort.Direction.DESC, page = 0, size = 100) Pageable pageable) {
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
return "info/bank/output";
}

View File

@@ -66,7 +66,7 @@ class GetBanksUIController {
@GetMapping(path = "/info/bank")
String operate() {
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
return "redirect:/info/bank/" + currentMonth;

View File

@@ -26,10 +26,19 @@ public class GetMonthlyInputStatus {
private String updatedBy;
public String getKoreanMonth() {
if (month != null && month.contains("-")) {
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
if (month != null) {
if (month.contains("-")) {
// 기존 처리: "2025-05" → "2025년 5월"
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
} else if (month.length() == 6) {
// 신규 처리: "202505" → "2025년 5월"
String year = month.substring(0, 4);
String monthPart = month.substring(4, 6);
return year + "년 " + Integer.parseInt(monthPart) + "월";
}
}
return "";
}
}

View File

@@ -27,9 +27,17 @@ public class GetMonthlyInputStatuss {
private String updatedBy;
public String getKoreanMonth() {
if (month != null && month.contains("-")) {
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
if (month != null) {
if (month.contains("-")) {
// 기존 처리: "2025-05" → "2025년 5월"
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
} else if (month.length() == 6) {
// 신규 처리: "202505" → "2025년 5월"
String year = month.substring(0, 4);
String monthPart = month.substring(4, 6);
return year + "년 " + Integer.parseInt(monthPart) + "월";
}
}
return "";
}

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
<html layout:decorate="~{layout/layout-none}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<div layout:fragment="content" th:classappend="'mypage'">
@@ -12,17 +12,31 @@
<p>수입 내역을 등록해 주세요.</p>
</hgroup>
<div class="component-btns">
<div class="btns-col">
<button type="button" class="btn btn-m btn-secondary btn-full">
<i class="ico-add ico-small" aria-hidden="true"></i>
<span class="btn-txt">추가 등록</span>
</button>
<button type="button" class="btn btn-m btn-link btn-full">
<span class="btn-txt">이전 정보 불러오기</span>
<section class="regist-item-area">
<p class="total" style="display: none" id="listHeader">
<span>총 <strong id="listCount">0</strong>건</span>
<button type="button" class="btn-reset" onclick="formControl.clearAllItems()" id="clearAllItems">
<i class="ico-reset ico-small" aria-hidden="true"></i>
<span>초기화</span>
</button>
</p>
<div class="item-list" style="display: none" id="listBody">
</div>
</div>
<button type="button" class="btn btn-m btn-secondary btn-full" style="margin-bottom:1.2rem"
id="addItemBtn" onclick="formControl.openAddForm()">
<i class="ico-add ico-small" aria-hidden="true"></i>
<span class="btn-txt">추가 등록</span>
</button>
<button type="button" class="btn btn-m btn-link btn-full" id="callPastInfoBtn">
<span class="btn-txt">이전 정보 불러오기</span>
</button>
</section>
</div>
</main>
@@ -31,7 +45,7 @@
<div class="component-btns fixed">
<div class="btns-row">
<!-- 비활성화 스타일/ 버튼 속성 disabled 추가-->
<button type="button" class="btn btn-l btn-primary" disabled>
<button type="button" class="btn btn-l btn-primary" id="complateBtn">
<span class="btn-txt">등록 완료</span>
</button>
</div>
@@ -51,7 +65,7 @@
<!-- 모달 팝업 -->
<div class="layer-wrap">
<div class="component-modal mypage-wrap modal01" data-props-dimm-click="true" data-state="open">
<div class="component-modal mypage-wrap addPopup" data-props-dimm-click="true" >
<div class="modal-dimm"></div>
<div class="modal-frame">
<div class="modal-container">
@@ -90,12 +104,11 @@
</div>
<div class="select-scroll">
<ul class="">
<li class="option" data-value="option1">option1</li>
<li class="option" data-value="option2">option2</li>
<li class="option" data-value="option3">option3</li>
<li class="option" data-value="option4">option4</li>
<li class="option" data-value="option5">option5</li>
<li class="option" data-value="option6">option6</li>
<th:block th:each="item : ${codeRecordCropList}">
<li class="option" th:data-value="${item.id}"
th:text="${item.codeText}">
</li>
</th:block>
</ul>
</div>
</div>
@@ -114,9 +127,9 @@
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
</p>
</div>
<div id="incomeCodeSelect" class="component-select bottom-sheet" data-props-default="수입 종류를 선택해 주세요"
<div id="transferCategorySelect" class="component-select bottom-sheet" data-props-default="수입 종류를 선택해 주세요"
data-props-type="bottomSheet">
<input type="hidden" name="incomeCode" id="incomeCode"/>
<input type="hidden" name="transferCategory" id="transferCategory"/>
<button type="button" class="select-box">
<span class="select-txt"></span>
</button>
@@ -129,62 +142,40 @@
</div>
<div class="select-scroll">
<ul class="">
<li class="option" data-value="option1">봉급</li>
<li class="option" data-value="option2">소득세</li>
<li class="option" data-value="option3">수당</li>
<li class="option" data-value="option4">직접 입력</li>
<th:block th:each="item : ${transferCategoryList}">
<li class="option" th:data-value="${item.id}"
th:text="${item.codeText}">
</li>
</th:block>
</ul>
</div>
</div>
</div>
<!-- 수당 인풋 -->
<div class="component-input input-invalid" data-option="수당">
<!-- transferCategory+Text-->
<th:block th:each="item : ${transferCategoryList}">
<div class="component-input " th:data-option="${item.codeText}">
<div class="input-field">
<input type="text" id="temp_input_invalid_0001" value="" placeholder="수입 대상을 입력해 주세요.">
<input type="text" th:id="${item.id}+'_value'" th:name="${item.id}+'_value'" value="" placeholder="수입 대상을 입력해 주세요." maxlength="30">
</div>
<ul class="input-info">
<li>수입 대상을 입력해 주세요.</li>
<li class="txt-blue">봉급 중 자동적으로 공제되는 내용에 대해서도 기입해 주시기 바랍니다.</li>
</ul>
</div>
<!-- 소득세 인풋 -->
<div class="component-input input-valid" data-option="소득세">
<div class="input-field">
<input type="text" id="temp_input_invalid_0001" value="" placeholder="수입 대상을 입력해 주세요.">
</div>
<ul class="input-info">
<li>봉급 중 자동적으로 공제되는 내용에 대해서도 기입해 주시기 바랍니다.</li>
</ul>
</div>
<!-- 봉급 인풋 -->
<div class="component-input input-valid" data-option="봉급">
<div class="input-field">
<input type="text" id="temp_input_invalid_0001" value="" placeholder="수입 대상을 입력해 주세요.">
</div>
<ul class="input-info">
<li>봉급은 세금을 포함한 금액(실수령액이 아님)입니다.</li>
</ul>
</div>
<!-- 직접입력 인풋 -->
<div class="component-input input-invalid" data-option="직접 입력">
<div class="input-field">
<input type="text" id="temp_input_invalid_0001" value="" placeholder="수입의 종류를 입력해 주세요">
</div>
<ul class="input-info">
<li>수입 종류를 입력해 주세요.</li>
<li style="display:none">수입 대상을 입력해 주세요.</li>
<li class="txt-blue" th:if="${item.msgCode}" th:text="${item.msgCode}"></li>
</ul>
</div>
</th:block>
</div>
<!-- 수입원 -->
<div class="component-input">
<div class="input-label">
<label for="temp_input_0001" class="label-txt">
<label for="sourcePurpose" class="label-txt">
수입원
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
</label>
</div>
<div class="input-field">
<input type="text" id="temp_input_0001" placeholder="수입원을 입력해 주세요">
<input type="text" id="sourcePurpose" placeholder="수입원을 입력해 주세요" name="sourcePurpose" maxlength="30">
</div>
</div>
</section>
@@ -195,12 +186,12 @@
<!-- 수량 -->
<div class="component-input">
<div class="input-label">
<label for="temp_input_0001" class="label-txt">
<label for="count" class="label-txt">
수량
</label>
</div>
<div class="input-field">
<input type="nubmer" id="temp_input_0001" placeholder="수량을 입력해 주세요">
<input type="number" id="count" placeholder="수량을 입력해 주세요" name="count" class="limitDecimalLength">
</div>
<ul class="guide-info">
<li>예 : 2, 2.5</li>
@@ -213,8 +204,9 @@
단위
</p>
</div>
<div id="select3" class="component-select bottom-sheet" data-props-default="단위를 선택해 주세요"
<div id="unitCodeSelect" class="component-select bottom-sheet" data-props-default="단위를 선택해 주세요"
data-props-type="bottomSheet">
<input type="hidden" name="unitCode" id="unitCode">
<button type="button" class="select-box">
<span class="select-txt">선택</span>
</button>
@@ -227,13 +219,11 @@
</div>
<div class="select-scroll">
<ul class="">
<li class="option" data-value="option1">option1</li>
<li class="option" data-value="option2">option2</li>
<li class="option" data-value="option3">option3</li>
<li class="option" data-value="option4">option4</li>
<li class="option" data-value="option5">option5</li>
<li class="option" data-value="option6">option6</li>
<li class="option" data-value="option7">option7</li>
<th:block th:each="item : ${unitList}">
<li class="option" th:data-value="${item.id}"
th:text="${item.codeText}">option1
</li>
</th:block>
</ul>
</div>
</div>
@@ -245,18 +235,18 @@
<section class="form-group">
<!-- 현금 -->
<div class="component-input input-invalid">
<div class="component-input ">
<div class="input-label">
<label for="temp_input_0001" class="label-txt">
<label for="price" class="label-txt">
현금
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
</label>
</div>
<div class="input-field type-price">
<input type="text" id="temp_input_0001" placeholder="금액을 입력해 주세요">
<input type="number" id="price" placeholder="금액을 입력해 주세요" name="price" class="limitAmountLength">
<span class="input-field-txt">원</span>
</div>
<ul class="input-info">
<ul class="input-info" style="display:none">
<li>금액을 입력해 주세요.</li>
</ul>
<ul class="guide-info">
@@ -281,23 +271,157 @@
</div>
</div>
<!-- //모달 팝업 -->
</div>
<section layout:fragment="script">
<script th:inline="javascript">
// ✅ ENV 구조 (전역 설정 및 상태)
let ENV = {
httpUrl: {
root: /*[[#{uri.front.info.monthly.path}]]*/'rootUrl'
root: /*[[#{uri.front.info.bank.path}]]*/ 'rootUrl',
save: /*[[|/api/front#{uri.front.info.bank.path}/create|]]*/ 'saveUrl'
},
module: {
confirmPopup: null
modalPopup: null
},
submitted: false,
};
let formControl = {
init() {
data: {
transferCategoryList: /*[[${transferCategoryList}]]*/ [],
codeRecordCropList: /*[[${codeRecordCropList}]]*/ [],
unitList: /*[[${unitList}]]*/ [],
bankList : [],
pastBankList : [],
id: /*[[${currentMonthlyInfo.id}]]*/'',
currentStatus: /*[[${currentMonthlyInfo.bankAutoTransferInputStatus}]]*/'',
pastStatus: /*[[${pastMonthlyInfo?.bankAutoTransferInputStatus}]]*/'',
editable: /*[[${editable}]]*/,
},
elementRefs: {
}
},
isSubmitted: false
};
const formControl = {
init() {
this.cacheElements();
this.bindDecimalLimit();
this.bindAmountLimit();
this.loadingLayout();
},
cacheElements() {
ENV.module.modalPopup = document.querySelector(".addPopup").ui;
},
bindDecimalLimit() {
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".limitDecimalLength").forEach(input => {
input.addEventListener("input", () => {
alert('22');
let val = input.value.replace(/[^0-9.]/g, '');
const parts = val.split('.');
if (parts.length > 2) val = parts[0] + '.' + parts.slice(1).join('');
if (parts[1]) parts[1] = parts[1].slice(0, 2);
if (val.length > 10) val = val.slice(0, 10);
input.value = parts.join('.');
});
});
});
},
bindAmountLimit() {
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".limitAmountLength").forEach(input => {
input.addEventListener("input", () => {
// 숫자 이외 문자 제거
let val = input.value.replace(/[^0-9]/g, '');
// 최대 10자리 제한
if (val.length > 10) {
val = val.slice(0, 10);
}
input.value = val;
});
});
});
},
loadingLayout() {
//아이템 추가 버튼
const addItemBtn = document.getElementById("addItemBtn");
const icon = addItemBtn.querySelector("i");
//이전 데이터 취득 버튼
const callPastInfoBtn = document.getElementById("callPastInfoBtn");
//등록 완료 버튼
const next = document.getElementById('complateBtn');
const clearAllItems = document.getElementById('clearAllItems');
if (ENV.data.pastBankList.length == 0) {
callPastInfoBtn.disabled = true;
}
if (ENV.data.editable) {
if (ENV.data.currentStatus == "NONE") {
if (ENV.data.pastStatus && ENV.data.pastStatus == "REGISTERED" && ENV.data.pastBankList.length > 0) {
this.checkUsePastData();
}
} else if (ENV.data.currentStatus == "NOTHING") {
addItemBtn.disabled = true;
icon.classList.toggle("ico-add", false);
icon.classList.toggle("ico-add-disabled", true);
callPastInfoBtn.disabled = true;
forestProductStatus.checked = true;
next.disabled = true;
} else if (ENV.data.currentStatus == "REGISTERED") {
if (ENV.data.productList.length > 0) {
ENV.data.productList.forEach(data => productRenderer.addItem(data, true));
this.updateLayout();
} else {
}
}
} else {
if (ENV.data.currentStatus == "REGISTERED") {
if (ENV.data.productList.length > 0) {
ENV.data.productList.forEach(data => productRenderer.addItem(data, false));
const header = document.getElementById('listHeader');
const count = document.getElementById('listCount');
const total = ENV.data.productList.length;
header.style.display = total > 0 ? '' : 'none';
count.textContent = total;
}
}
addItemBtn.disabled = true;
icon.classList.toggle("ico-add", false);
icon.classList.toggle("ico-add-disabled", true);
callPastInfoBtn.disabled = true;
forestProductStatus.disabled = true;
next.disabled = true;
next.style.display = "none";
clearAllItems.style.display = "none";
}
},
openAddForm() {
const modalContent = document.querySelector('.modal-content');
setTimeout(() => {
modalContent.scrollTop = 0;
}, 0);
//초기화 안됨
['cropCodeSelect', 'transferCategorySelect', 'unitCodeSelect']
.forEach(id => etUI.components.SelectBox().core.init(document.getElementById(id)));
ENV.module.modalPopup.open();
},
}
</script>

View File

@@ -435,7 +435,6 @@
<section layout:fragment="script">
<script th:inline="javascript">
// ✅ ENV 구조 (전역 설정 및 상태)
let ENV = {
httpUrl: {
root: /*[[#{uri.front.info.monthly.path}]]*/ 'rootUrl',