feat(expense): 영수증 파일명 규칙 변경 + 등록 폼 필수 검증
- zip 첨부 파일명: 날짜_이름_분류_결제수단_금액_가맹점.확장자 (날짜=사용일) - 가맹점 없으면 생략, 금액 쉼표 표기, 금지문자 정리 - db.approved_attachments 에 category/method/amount/merchant 추가 - 등록 폼: 사용일/분류/결제수단/금액/가맹점 필수 — 누락 시 경고창 + 포커스 (가맹점 input required, 금액 1원 이상) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
<input type="number" name="amount" min="0" step="1" required placeholder="원" />
|
||||
</label>
|
||||
<label class="erp-field erp-field-wide"><span>가맹점/사용처</span>
|
||||
<input type="text" name="merchant" placeholder="예) 스타벅스 강남점" />
|
||||
<input type="text" name="merchant" placeholder="예) 스타벅스 강남점" required />
|
||||
</label>
|
||||
<label class="erp-field erp-field-wide"><span>메모</span>
|
||||
<input type="text" name="memo" placeholder="비고" />
|
||||
@@ -258,8 +258,37 @@
|
||||
}
|
||||
resetBtn.addEventListener("click", () => setEditing("", null));
|
||||
|
||||
// 필수 입력 검증 — 누락 시 경고창
|
||||
function validateRequired() {
|
||||
const required = [
|
||||
["spent_at", "사용일"],
|
||||
["category", "분류"],
|
||||
["method", "결제수단"],
|
||||
["amount", "금액"],
|
||||
["merchant", "가맹점/사용처"],
|
||||
];
|
||||
const missing = [];
|
||||
for (const [field, label] of required) {
|
||||
const val = (form[field].value || "").trim();
|
||||
if (!val) missing.push([form[field], label]);
|
||||
}
|
||||
// 금액은 0 이하도 미입력 취급
|
||||
if (!missing.some(([f]) => f === form.amount)) {
|
||||
if (!(parseInt(form.amount.value, 10) > 0)) {
|
||||
missing.push([form.amount, "금액(1원 이상)"]);
|
||||
}
|
||||
}
|
||||
if (missing.length) {
|
||||
alert("다음 항목을 입력하세요:\n- " + missing.map(([, l]) => l).join("\n- "));
|
||||
missing[0][0].focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
if (!validateRequired()) return;
|
||||
const id = form.id.value.trim();
|
||||
const payload = {
|
||||
spent_at: form.spent_at.value,
|
||||
|
||||
Reference in New Issue
Block a user