ocr 등록 수입 추가
This commit is contained in:
@@ -110,7 +110,7 @@ public class DailyExpenseService implements DailyExpensePortIn {
|
|||||||
formVO.getEstimatedValue()));
|
formVO.getEstimatedValue()));
|
||||||
|
|
||||||
portOut.create(findCmd, command);
|
portOut.create(findCmd, command);
|
||||||
|
formVO.setId(command.getId());
|
||||||
dailyRecordPortIn.updateByAllStatus(findCmd.getSearchMonth(), findCmd.getGroupNo(), findCmd.getHouseholdSeq());
|
dailyRecordPortIn.updateByAllStatus(findCmd.getSearchMonth(), findCmd.getGroupNo(), findCmd.getHouseholdSeq());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package app.module.front.usecase.daily.receipt.adapters.web;
|
package app.module.front.usecase.daily.receipt.adapters.web;
|
||||||
|
|
||||||
|
import app.module.core.config.application.enums.FileUploadType;
|
||||||
import app.module.core.config.application.exception.NoRecordDataException;
|
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.adapters.persistence.model.DailyRecordDto;
|
||||||
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
@@ -8,6 +9,8 @@ import app.module.core.usecase.file.createFile.ports.application.domain.CreateFi
|
|||||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
|
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
|
||||||
import app.module.core.usecase.file.saveToStorage.ports.SaveToStoragePortIn;
|
import app.module.core.usecase.file.saveToStorage.ports.SaveToStoragePortIn;
|
||||||
import app.module.core.usecase.file.saveToStorage.ports.application.domain.SaveToStorage;
|
import app.module.core.usecase.file.saveToStorage.ports.application.domain.SaveToStorage;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.CreateDailyExpenseReqVO;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
|
||||||
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
|
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
|
||||||
import app.module.front.usecase.daily.income.adapters.web.model.DailyInputType;
|
import app.module.front.usecase.daily.income.adapters.web.model.DailyInputType;
|
||||||
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
||||||
@@ -16,11 +19,13 @@ import app.module.front.usecase.daily.receipt.ports.DailyReceiptPortIn;
|
|||||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
@@ -33,6 +38,7 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(path = "/api/record/receipt")
|
||||||
public class DailyReceiptController {
|
public class DailyReceiptController {
|
||||||
|
|
||||||
private final DailyRecordPortIn dailyRecordPortIn;
|
private final DailyRecordPortIn dailyRecordPortIn;
|
||||||
@@ -41,12 +47,12 @@ public class DailyReceiptController {
|
|||||||
private final CreateFilePortIn createFilePortIn;
|
private final CreateFilePortIn createFilePortIn;
|
||||||
private final RestTemplate restTemplate;
|
private final RestTemplate restTemplate;
|
||||||
private final DailyReceiptPortIn dailyReceiptPortIn;
|
private final DailyReceiptPortIn dailyReceiptPortIn;
|
||||||
|
private final DailyExpensePortIn dailyExpensePortIn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 일계부 영수증 등록
|
* 일계부 영수증 등록
|
||||||
*/
|
*/
|
||||||
@PostMapping(path = "/api/record/receipt")
|
@PostMapping(path = "")
|
||||||
ResponseEntity<?> operate( @RequestPart(value = "file") MultipartFile file) throws IOException {
|
ResponseEntity<?> operate( @RequestPart(value = "file") MultipartFile file) throws IOException {
|
||||||
// 파일 유효성 검사
|
// 파일 유효성 검사
|
||||||
if (file == null || file.isEmpty()) {
|
if (file == null || file.isEmpty()) {
|
||||||
@@ -106,9 +112,12 @@ public class DailyReceiptController {
|
|||||||
* @param id 수입 일련번호
|
* @param id 수입 일련번호
|
||||||
* @param reqVOList 영수증 데이터
|
* @param reqVOList 영수증 데이터
|
||||||
*/
|
*/
|
||||||
@PostMapping(path = "/api/record/income/receipt/{searchMonth}/{groupNo}/form/{id}")
|
@PostMapping(path = "/{inputType}/{searchMonth}/{groupNo}/form/{id}")
|
||||||
ResponseEntity<?> createReceipt(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
ResponseEntity<?> createReceipt(
|
||||||
, @PathVariable("id") String id,
|
@PathVariable("inputType") String inputType,
|
||||||
|
@PathVariable("searchMonth") String searchMonth,
|
||||||
|
@PathVariable("groupNo") String groupNo,
|
||||||
|
@PathVariable("id") String id,
|
||||||
@RequestPart(value = "reqVO") List<CreateReceiptFileReqVO> reqVOList,
|
@RequestPart(value = "reqVO") List<CreateReceiptFileReqVO> reqVOList,
|
||||||
@RequestPart(value = "file") List<MultipartFile> files ) throws IOException {
|
@RequestPart(value = "file") List<MultipartFile> files ) throws IOException {
|
||||||
|
|
||||||
@@ -141,22 +150,46 @@ public class DailyReceiptController {
|
|||||||
|
|
||||||
// 1. 레코드 저장
|
// 1. 레코드 저장
|
||||||
for(ReceiptItem item : createReceiptFileReqVO.getOcr().getItems()){
|
for(ReceiptItem item : createReceiptFileReqVO.getOcr().getItems()){
|
||||||
CreateDailyIncomeReqVO formVO = new CreateDailyIncomeReqVO();
|
if("income".equals(inputType)) {
|
||||||
formVO.setSearchMonth(searchMonth);
|
CreateDailyIncomeReqVO formVO = new CreateDailyIncomeReqVO();
|
||||||
formVO.setGroupNo(Integer.parseInt(groupNo));
|
formVO.setSearchMonth(searchMonth);
|
||||||
formVO.setId(Long.parseLong(id));
|
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
formVO.setId(Long.parseLong(id));
|
||||||
formVO.setInputType(DailyInputType.OCR);
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
formVO.setCredit(false);
|
formVO.setInputType(DailyInputType.OCR);
|
||||||
formVO.setSourcePurpose(createReceiptFileReqVO.getOcr().getStoreName());
|
formVO.setCredit(false);
|
||||||
formVO.setIncomeKind(item.getName());
|
formVO.setSourcePurpose(createReceiptFileReqVO.getOcr().getStoreName());
|
||||||
formVO.setQuantity((double) item.getQuantity());
|
formVO.setIncomeKind(item.getName());
|
||||||
formVO.setPrice((long) item.getTotalPrice());
|
formVO.setQuantity((double) item.getQuantity());
|
||||||
log.debug("formVO: {}", formVO);
|
formVO.setPrice((long) item.getTotalPrice());
|
||||||
dailyIncomePortIn.create(formVO);
|
log.debug("formVO: {}", formVO);
|
||||||
|
dailyIncomePortIn.create(formVO);
|
||||||
|
//has 파일에 매핑 시키기
|
||||||
|
dailyReceiptPortIn.insertReceiptMappingFile(new CreateReceiptHasFileReqVO(FileUploadType.INCOME.getName(),formVO.getId(),createFile.getId()));
|
||||||
|
|
||||||
|
}else if ("expense".equals(inputType)) {
|
||||||
|
|
||||||
|
CreateDailyExpenseReqVO formVO = new CreateDailyExpenseReqVO();
|
||||||
|
formVO.setSearchMonth(searchMonth);
|
||||||
|
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||||
|
formVO.setId(Long.parseLong(id));
|
||||||
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
|
formVO.setInputType(DailyInputType.OCR);
|
||||||
|
|
||||||
|
formVO.setCredit(false);
|
||||||
|
formVO.setSourcePurpose(createReceiptFileReqVO.getOcr().getStoreName());
|
||||||
|
formVO.setExpenseKind(item.getName());
|
||||||
|
formVO.setQuantity((double) item.getQuantity());
|
||||||
|
formVO.setPrice((long) item.getTotalPrice());
|
||||||
|
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyExpensePortIn.create(formVO);
|
||||||
|
|
||||||
|
//has 파일에 매핑 시키기
|
||||||
|
dailyReceiptPortIn.insertReceiptMappingFile(new CreateReceiptHasFileReqVO(FileUploadType.EXPENSE.getName(),formVO.getId(),createFile.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
//has 파일에 매핑 시키기
|
|
||||||
dailyReceiptPortIn.insertReceiptMappingFile(new CreateReceiptHasFileReqVO("INCOME",formVO.getId(),createFile.getId()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
<div class="component-btns type-tab"
|
<div class="component-btns type-tab"
|
||||||
th:if="not ${detail.updated}">
|
th:if="not ${detail.updated}">
|
||||||
<div class="btns-row">
|
<div class="btns-row">
|
||||||
<button type="button" class="btn active">수기 등록</button>
|
<button type="button" id="btnSelf" class="btn active" onclick="modalControl.changeModal('self')">수기 등록</button>
|
||||||
<!--/* TODO : 2차 오픈 */-->
|
<button type="button" id="btnOcr" class="btn" onclick="modalControl.changeModal('ocr')">영수증 등록</button>
|
||||||
<!--<button type="button" class="btn">영수증 등록</button>-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -17,157 +16,199 @@
|
|||||||
<form name="reqModalForm">
|
<form name="reqModalForm">
|
||||||
<input type="hidden" name="inputType" th:value="${#strings.defaultString(detail.inputType, 'SELF')}">
|
<input type="hidden" name="inputType" th:value="${#strings.defaultString(detail.inputType, 'SELF')}">
|
||||||
<input type="hidden" name="id" th:value="${detail.id}">
|
<input type="hidden" name="id" th:value="${detail.id}">
|
||||||
<section class="form-group">
|
<!--/* 수기 등록 s */-->
|
||||||
<div class="segment-label">
|
<div id="modelSelf">
|
||||||
<p class="label-txt">
|
<section class="form-group">
|
||||||
외상 또는 카드 구입 여부
|
<div class="segment-label">
|
||||||
</p>
|
<p class="label-txt">
|
||||||
</div>
|
외상 또는 카드 구입 여부
|
||||||
<div class="component-segment">
|
</p>
|
||||||
<div class="component-radio">
|
</div>
|
||||||
<label class="radio-inner">
|
<div class="component-segment">
|
||||||
<input type="radio" name="credit" value="true" th:checked="${detail.credit}">
|
<div class="component-radio">
|
||||||
<span class="radio-item">
|
<label class="radio-inner">
|
||||||
<span class="radio-txt">예</span>
|
<input type="radio" name="credit" value="true" th:checked="${detail.credit}">
|
||||||
</span>
|
<span class="radio-item">
|
||||||
</label>
|
<span class="radio-txt">예</span>
|
||||||
</div>
|
</span>
|
||||||
<div class="component-radio">
|
</label>
|
||||||
<label class="radio-inner">
|
|
||||||
<input type="radio" name="credit" value="false" th:checked="not ${detail.credit}">
|
|
||||||
<span class="radio-item">
|
|
||||||
<span class="radio-txt">아니오</span>
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<section class="form-group">
|
|
||||||
<div class="component-input">
|
|
||||||
<div class="input-label">
|
|
||||||
<label for="expenseKind" class="label-txt">
|
|
||||||
지출의 종류<i class="ico-required-mark" role="img" aria-label="필수">*</i>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="input-field">
|
|
||||||
<input type="text" id="expenseKind" name="expenseKind" th:value="${detail.expenseKind}" maxlength="30" placeholder="지출의 종류를 입력해 주세요">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="component-input">
|
|
||||||
<div class="input-label">
|
|
||||||
<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="sourcePurpose" name="sourcePurpose" th:value="${detail.sourcePurpose}" maxlength="30" placeholder="용도를 입력해 주세요">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<section class="form-group">
|
|
||||||
<div class="component-input">
|
|
||||||
<div class="input-label">
|
|
||||||
<label for="quantity" class="label-txt">
|
|
||||||
수량
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="input-field">
|
|
||||||
<input type="number" inputmode="decimal" pattern="[0-9]*" id="quantity" name="quantity" min="1" max="9999999999"
|
|
||||||
th:value="${detail.quantity}" maxlength="10" placeholder="수량을 입력해 주세요">
|
|
||||||
</div>
|
|
||||||
<ul class="guide-info">
|
|
||||||
<li>예 : 2, 2.5</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="select-group">
|
|
||||||
<div class="select-label">
|
|
||||||
<p class="label-txt">
|
|
||||||
단위
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div id="unitCode" class="component-select bottom-sheet" data-props-default="단위를 선택해 주세요" data-props-type="bottomSheet">
|
|
||||||
<input type="hidden" name="unitCode" data-type="select" th:value="${detail.unitCode}">
|
|
||||||
<button type="button" class="select-box">
|
|
||||||
<span class="select-txt"></span>
|
|
||||||
</button>
|
|
||||||
<div class="select-options">
|
|
||||||
<div class="select-header">
|
|
||||||
<p>단위</p>
|
|
||||||
<button type="button" class="select-close">
|
|
||||||
<span class="hide-txt">닫기</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="select-scroll">
|
<div class="component-radio">
|
||||||
<ul class="">
|
<label class="radio-inner">
|
||||||
<li class="option" th:each="uiCode : ${recordUnit}"
|
<input type="radio" name="credit" value="false" th:checked="not ${detail.credit}">
|
||||||
th:data-value="${uiCode.id}"
|
<span class="radio-item">
|
||||||
th:text="${uiCode.codeText}"
|
<span class="radio-txt">아니오</span>
|
||||||
th:selected="${uiCode.id eq detail.unitCode ? 'current' : ''}"
|
</span>
|
||||||
></li>
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<section class="form-group">
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-label">
|
||||||
|
<label for="expenseKind" class="label-txt">
|
||||||
|
지출의 종류<i class="ico-required-mark" role="img" aria-label="필수">*</i>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="text" id="expenseKind" name="expenseKind" th:value="${detail.expenseKind}" maxlength="30" placeholder="지출의 종류를 입력해 주세요">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-label">
|
||||||
|
<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="sourcePurpose" name="sourcePurpose" th:value="${detail.sourcePurpose}" maxlength="30" placeholder="용도를 입력해 주세요">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<section class="form-group">
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-label">
|
||||||
|
<label for="quantity" class="label-txt">
|
||||||
|
수량
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="number" inputmode="decimal" pattern="[0-9]*" id="quantity" name="quantity" min="1" max="9999999999"
|
||||||
|
th:value="${detail.quantity}" maxlength="10" placeholder="수량을 입력해 주세요">
|
||||||
|
</div>
|
||||||
|
<ul class="guide-info">
|
||||||
|
<li>예 : 2, 2.5</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="select-group">
|
||||||
|
<div class="select-label">
|
||||||
|
<p class="label-txt">
|
||||||
|
단위
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div id="unitCode" class="component-select bottom-sheet" data-props-default="단위를 선택해 주세요" data-props-type="bottomSheet">
|
||||||
|
<input type="hidden" name="unitCode" data-type="select" th:value="${detail.unitCode}">
|
||||||
|
<button type="button" class="select-box">
|
||||||
|
<span class="select-txt"></span>
|
||||||
|
</button>
|
||||||
|
<div class="select-options">
|
||||||
|
<div class="select-header">
|
||||||
|
<p>단위</p>
|
||||||
|
<button type="button" class="select-close">
|
||||||
|
<span class="hide-txt">닫기</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="select-scroll">
|
||||||
|
<ul class="">
|
||||||
|
<li class="option" th:each="uiCode : ${recordUnit}"
|
||||||
|
th:data-value="${uiCode.id}"
|
||||||
|
th:text="${uiCode.codeText}"
|
||||||
|
th:selected="${uiCode.id eq detail.unitCode ? 'current' : ''}"
|
||||||
|
></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="component-input" data-option="직접 입력">
|
||||||
|
<div class="input-field">
|
||||||
|
<input type="text" name="unitSelf" th:value="${detail.unitSelf}" maxlength="30" placeholder="단위를 입력해 주세요">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<section class="form-group">
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-label">
|
||||||
|
<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="number" inputmode="numeric" pattern="[0-9]*" id="price" name="price" min="1" max="9999999999"
|
||||||
|
th:value="${detail.price}" maxlength="10" placeholder="금액을 입력해 주세요">
|
||||||
|
<span class="input-field-txt">원</span>
|
||||||
|
</div>
|
||||||
|
<ul class="guide-info">
|
||||||
|
<li>예 : 30000</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="component-input">
|
||||||
|
<div class="input-label">
|
||||||
|
<label for="estimatedValue" class="label-txt">
|
||||||
|
현물평가액
|
||||||
|
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="input-field type-price">
|
||||||
|
<input type="number" inputmode="numeric" pattern="[0-9]*" id="estimatedValue" name="estimatedValue" min="1" max="9999999999"
|
||||||
|
th:value="${detail.estimatedValue}" maxlength="10" placeholder="금액을 입력해 주세요">
|
||||||
|
<span class="input-field-txt">원</span>
|
||||||
|
</div>
|
||||||
|
<ul class="guide-info">
|
||||||
|
<li>예 : 30000</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="component-btns">
|
||||||
|
<div class="btns-row">
|
||||||
|
<button type="button" class="btn btn-full btn-l btn-primary" onclick="modalControl.createVaild();">
|
||||||
|
<span class="btn-txt">등록</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--/* 수기 등록 e */-->
|
||||||
|
<!--/* 영수증 등록 s */-->
|
||||||
|
<div id="modelOcr" style="display: none;">
|
||||||
|
<section class="form-group">
|
||||||
|
<div class="segment-label">
|
||||||
|
<p class="label-txt">
|
||||||
|
영수증 첨부
|
||||||
|
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="component-segment">
|
||||||
|
<div class="component-file">
|
||||||
|
<div class="file-list" id="file-upload-container">
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-m btn-link btn-full" onclick="modalControl.addFileInput();">
|
||||||
|
<i class="ico-add ico-small" aria-hidden="true"></i>
|
||||||
|
<span class="btn-txt">사진 첨부</span>
|
||||||
|
</button>
|
||||||
|
<ul class="guide-info">
|
||||||
|
<li>영수증은 일일 최대 3개 등록하실 수 있습니다.</li>
|
||||||
|
<li>
|
||||||
|
최대 갯수 등록 후에는 수기 입력만 가능합니다. <br>
|
||||||
|
(사진 1개당 5MB 이하)
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
<div class="component-input" data-option="직접 입력">
|
|
||||||
<div class="input-field">
|
<div class="component-btns">
|
||||||
<input type="text" name="unitSelf" th:value="${detail.unitSelf}" maxlength="30" placeholder="단위를 입력해 주세요">
|
<div class="btns-row">
|
||||||
|
<!-- 버튼비활성 스타일 속성에 disabled 추가 -->
|
||||||
|
<button type="button" onclick="modalControl.onSubmitReceiptFile();" class="btn btn-full btn-l btn-primary">
|
||||||
|
<span class="btn-txt">등록</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
<!--/* 영수증 등록 e */-->
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<section class="form-group">
|
|
||||||
<div class="component-input">
|
|
||||||
<div class="input-label">
|
|
||||||
<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="number" inputmode="numeric" pattern="[0-9]*" id="price" name="price" min="1" max="9999999999"
|
|
||||||
th:value="${detail.price}" maxlength="10" placeholder="금액을 입력해 주세요">
|
|
||||||
<span class="input-field-txt">원</span>
|
|
||||||
</div>
|
|
||||||
<ul class="guide-info">
|
|
||||||
<li>예 : 30000</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="component-input">
|
|
||||||
<div class="input-label">
|
|
||||||
<label for="estimatedValue" class="label-txt">
|
|
||||||
현물평가액
|
|
||||||
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="input-field type-price">
|
|
||||||
<input type="number" inputmode="numeric" pattern="[0-9]*" id="estimatedValue" name="estimatedValue" min="1" max="9999999999"
|
|
||||||
th:value="${detail.estimatedValue}" maxlength="10" placeholder="금액을 입력해 주세요">
|
|
||||||
<span class="input-field-txt">원</span>
|
|
||||||
</div>
|
|
||||||
<ul class="guide-info">
|
|
||||||
<li>예 : 30000</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="component-btns">
|
|
||||||
<div class="btns-row">
|
|
||||||
<button type="button" class="btn btn-full btn-l btn-primary" onclick="modalControl.createVaild();">
|
|
||||||
<span class="btn-txt">등록</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,8 @@
|
|||||||
create: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
|
create: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
|
||||||
remove: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
|
remove: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
|
||||||
reset: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/reset|]]*/'resetUrl',
|
reset: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/reset|]]*/'resetUrl',
|
||||||
|
receipt: /*[[|/api/record/receipt|]]*/'receiptUrl',
|
||||||
|
receiptCreate: /*[[|/api/record/receipt/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'receiptCreateUrl',
|
||||||
},
|
},
|
||||||
modal: {
|
modal: {
|
||||||
// 등록 버튼
|
// 등록 버튼
|
||||||
@@ -164,6 +166,7 @@
|
|||||||
krip.daily.baseBindUI();
|
krip.daily.baseBindUI();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
let uploadedReceipt =[];
|
||||||
|
|
||||||
let modalControl = {
|
let modalControl = {
|
||||||
_bindModelUI() {
|
_bindModelUI() {
|
||||||
@@ -214,6 +217,19 @@
|
|||||||
$input.val('').attr('disabled', true);
|
$input.val('').attr('disabled', true);
|
||||||
$input.parent().parent().closest('.component-input').addClass('input-disabled');
|
$input.parent().parent().closest('.component-input').addClass('input-disabled');
|
||||||
},
|
},
|
||||||
|
changeModal(type) {
|
||||||
|
if (type === 'self') {
|
||||||
|
$('#modelSelf').show();
|
||||||
|
$('#btnSelf').addClass('active');
|
||||||
|
$('#modelOcr').hide();
|
||||||
|
$('#btnOcr').removeClass('active');
|
||||||
|
} else {
|
||||||
|
$('#modelSelf').hide();
|
||||||
|
$('#btnSelf').removeClass('active');
|
||||||
|
$('#modelOcr').show();
|
||||||
|
$('#btnOcr').addClass('active');
|
||||||
|
}
|
||||||
|
},
|
||||||
createVaild() {
|
createVaild() {
|
||||||
modalControl.create();
|
modalControl.create();
|
||||||
},
|
},
|
||||||
@@ -231,6 +247,224 @@
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
addFileInput() {
|
||||||
|
// 새로운 input type="file" 요소 생성
|
||||||
|
const fileInput = document.createElement('input');
|
||||||
|
fileInput.type = 'file';
|
||||||
|
fileInput.accept = 'image/*';
|
||||||
|
fileInput.style.display = 'none';
|
||||||
|
fileInput.name = 'file';
|
||||||
|
|
||||||
|
// 파일 선택 시 이벤트 처리
|
||||||
|
fileInput.addEventListener('change', (event) => {
|
||||||
|
const files = event.target.files;
|
||||||
|
const previewContainer = $('#file-upload-container');
|
||||||
|
|
||||||
|
if (files.length === 0) {
|
||||||
|
const para = document.createElement('p');
|
||||||
|
para.textContent = '선택된 파일이 없습니다.';
|
||||||
|
para.classList.add('error');
|
||||||
|
previewContainer.append(para);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Array.from(files).forEach(file => {
|
||||||
|
if (!file.type.startsWith('image/')) {
|
||||||
|
const para = document.createElement('p');
|
||||||
|
para.textContent = `파일 ${file.name}: 유효한 이미지 파일이 아닙니다.`;
|
||||||
|
para.classList.add('error');
|
||||||
|
previewContainer.append(para);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append('file', file);
|
||||||
|
ajaxUtil._showWaiting();
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: ENV.httpUrl.receipt,
|
||||||
|
data: formData,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
enctype: 'multipart/form-data',
|
||||||
|
beforeSend: function(xhr) {
|
||||||
|
xhr.setRequestHeader(
|
||||||
|
$("meta[name='_csrf_header']").attr("content"),
|
||||||
|
$("meta[name='_csrf']").attr("content")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
success(res) {
|
||||||
|
// 썸네일 생성
|
||||||
|
const imgSrc = URL.createObjectURL(file);
|
||||||
|
const fileItemId = `file-item-${Math.random().toString(36).substr(2, 9)}`;
|
||||||
|
const fileItem = $(`
|
||||||
|
<div class="file-item" id="${fileItemId}">
|
||||||
|
<img class="profile-image-add" src="${imgSrc}" alt="${file.name}"/>
|
||||||
|
<button type="button" class="btn-delete"><span class="hide-txt">삭제</span></button>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
previewContainer.append(fileItem);
|
||||||
|
|
||||||
|
// 파일 정보와 서버 응답 저장
|
||||||
|
uploadedReceipt.push({
|
||||||
|
fileId: fileItemId,
|
||||||
|
file: file,
|
||||||
|
receiptResVO: res
|
||||||
|
});
|
||||||
|
|
||||||
|
// 삭제 버튼 이벤트 추가
|
||||||
|
fileItem.find('.btn-delete').on('click', function() {
|
||||||
|
modalControl.deleteFile(fileItemId);
|
||||||
|
fileItem.remove()
|
||||||
|
});
|
||||||
|
ajaxUtil._hideWaiting();
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
const resJson = xhr.responseJSON || {};
|
||||||
|
const errorMessage = resJson.error || `HTTP ${xhr.status}: 요청 처리 중 오류가 발생했습니다.`;
|
||||||
|
console.error('영수증 업로드 실패:', xhr, errorMessage);
|
||||||
|
|
||||||
|
etUI.dialog.alert({
|
||||||
|
title: '영수증 업로드 실패',
|
||||||
|
message: '정상적으로 인식되지 않은 사진이 있습니다. 정확한 사진을 첨부해주세요.',
|
||||||
|
type: 'alert',
|
||||||
|
callback: function () {
|
||||||
|
fileInput.value = '';
|
||||||
|
},
|
||||||
|
});
|
||||||
|
ajaxUtil._hideWaiting();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 입력 필드 초기화
|
||||||
|
fileInput.value = '';
|
||||||
|
const container = document.getElementById('file-upload-container');
|
||||||
|
container.appendChild(fileInput);
|
||||||
|
|
||||||
|
// 파일 선택 창 열기
|
||||||
|
fileInput.click();
|
||||||
|
},
|
||||||
|
deleteFile(fileItemId) {
|
||||||
|
const index = uploadedReceipt.findIndex(item => item.fileId === fileItemId);
|
||||||
|
if (index !== -1) {
|
||||||
|
URL.revokeObjectURL(uploadedReceipt[index].imgSrc); // 메모리 해제
|
||||||
|
$(`#${fileItemId}`).remove();
|
||||||
|
uploadedReceipt.splice(index, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSubmitReceiptFile(){
|
||||||
|
const receiptDataList = uploadedReceipt;
|
||||||
|
if (!receiptDataList.length) {
|
||||||
|
etUI.dialog.alert({
|
||||||
|
title: '등록 실패',
|
||||||
|
message: '등록할 영수증 데이터가 없습니다.',
|
||||||
|
type: 'alert',
|
||||||
|
callback: function () {
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const f = document.reqModalForm;
|
||||||
|
|
||||||
|
let formData = new FormData();
|
||||||
|
|
||||||
|
const reqVOList = receiptDataList.map(item => ({
|
||||||
|
file: { name: item.file.name },
|
||||||
|
fileUploadType: 'EXPENSE',
|
||||||
|
ocr: item.receiptResVO
|
||||||
|
}));
|
||||||
|
receiptDataList.forEach(item => {
|
||||||
|
formData.append('file', item.file);
|
||||||
|
});
|
||||||
|
formData.append('reqVO', new Blob([JSON.stringify(reqVOList)], { type: 'application/json' }));
|
||||||
|
|
||||||
|
ajaxUtil._showWaiting();
|
||||||
|
|
||||||
|
console.log("receiptDataList",receiptDataList);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: ENV.httpUrl.receiptCreate.replace('{id}', f.id.value ? f.id.value : '0'),
|
||||||
|
data: formData,
|
||||||
|
contentType: false, // * 중요 *
|
||||||
|
processData: false, // * 중요 *
|
||||||
|
enctype: 'multipart/form-data', // * 중요 *
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader(
|
||||||
|
$("meta[name='_csrf_header']").attr("content"),
|
||||||
|
$("meta[name='_csrf']").attr("content"));
|
||||||
|
},
|
||||||
|
success(res) {
|
||||||
|
etUI.dialog.alert({
|
||||||
|
title: '등록',
|
||||||
|
message: '영수증이 성공적으로 등록되었습니다.',
|
||||||
|
type: 'alert',
|
||||||
|
callback: function () {
|
||||||
|
// 초기화
|
||||||
|
uploadedReceipt.forEach(item => URL.revokeObjectURL(item.imgSrc));
|
||||||
|
uploadedReceipt.length = 0;
|
||||||
|
$('#file-upload-container').empty();
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
statusCode: {
|
||||||
|
400: function (res) {
|
||||||
|
const resJson = res.responseJSON || {};
|
||||||
|
const errorMessage = resJson.error || '잘못된 요청입니다.';
|
||||||
|
etUI.dialog.alert({
|
||||||
|
title: '등록 실패',
|
||||||
|
message: '영수증이 등록 실패하였습니다.',
|
||||||
|
type: 'alert',
|
||||||
|
callback: function () {
|
||||||
|
// 초기화
|
||||||
|
uploadedReceipt.forEach(item => URL.revokeObjectURL(item.imgSrc));
|
||||||
|
uploadedReceipt.length = 0;
|
||||||
|
$('#file-upload-container').empty();
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
500: function (res) {
|
||||||
|
const resJson = res.responseJSON || {};
|
||||||
|
const errorMessage = resJson.error || '서버 오류가 발생했습니다.';
|
||||||
|
console.log(`서버 오류: ${errorMessage}`);
|
||||||
|
etUI.dialog.alert({
|
||||||
|
title: '등록 실패',
|
||||||
|
message: '영수증이 등록 실패하였습니다.',
|
||||||
|
type: 'alert',
|
||||||
|
callback: function () {
|
||||||
|
// 초기화
|
||||||
|
uploadedReceipt.forEach(item => URL.revokeObjectURL(item.imgSrc));
|
||||||
|
uploadedReceipt.length = 0;
|
||||||
|
$('#file-upload-container').empty();
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
const errorMessage = xhr.responseJSON?.error || `HTTP ${xhr.status}`;
|
||||||
|
console.log(`영수증 업로드 실패: ${errorMessage}`);
|
||||||
|
etUI.dialog.alert({
|
||||||
|
title: '등록 실패',
|
||||||
|
message: '영수증이 등록 실패하였습니다.',
|
||||||
|
type: 'alert',
|
||||||
|
callback: function () {
|
||||||
|
// 초기화
|
||||||
|
uploadedReceipt.forEach(item => URL.revokeObjectURL(item.imgSrc));
|
||||||
|
uploadedReceipt.length = 0;
|
||||||
|
$('#file-upload-container').empty();
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ajaxUtil._hideWaiting();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
<div class="component-btns type-tab"
|
<div class="component-btns type-tab"
|
||||||
th:if="not ${detail.updated}">
|
th:if="not ${detail.updated}">
|
||||||
<div class="btns-row">
|
<div class="btns-row">
|
||||||
<button type="button" class="btn active" onclick="modalControl.changeModal('self')">수기 등록</button>
|
<button type="button" id="btnSelf" class="btn active" onclick="modalControl.changeModal('self')">수기 등록</button>
|
||||||
<th:block th:if="${@systemProperties['spring.profiles.active'] eq 'local'}">
|
<th:block th:if="${@systemProperties['spring.profiles.active'] eq 'local'}">
|
||||||
<button type="button" class="btn" onclick="modalControl.changeModal('ocr')">영수증 등록</button>
|
<button type="button" id="btnOcr" class="btn" onclick="modalControl.changeModal('ocr')">영수증 등록</button>
|
||||||
</th:block>
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -163,7 +163,7 @@
|
|||||||
remove: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
|
remove: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
|
||||||
reset: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/reset|]]*/'resetUrl',
|
reset: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/reset|]]*/'resetUrl',
|
||||||
receipt: /*[[|/api/record/receipt|]]*/'receiptUrl',
|
receipt: /*[[|/api/record/receipt|]]*/'receiptUrl',
|
||||||
receiptCreate: /*[[|/api/record/income/receipt/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'receiptCreateUrl',
|
receiptCreate: /*[[|/api/record/receipt/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'receiptCreateUrl',
|
||||||
},
|
},
|
||||||
modal: {
|
modal: {
|
||||||
// 등록 버튼
|
// 등록 버튼
|
||||||
@@ -244,10 +244,14 @@
|
|||||||
changeModal(type) {
|
changeModal(type) {
|
||||||
if (type === 'self') {
|
if (type === 'self') {
|
||||||
$('#modelSelf').show();
|
$('#modelSelf').show();
|
||||||
|
$('#btnSelf').addClass('active');
|
||||||
$('#modelOcr').hide();
|
$('#modelOcr').hide();
|
||||||
|
$('#btnOcr').removeClass('active');
|
||||||
} else {
|
} else {
|
||||||
$('#modelSelf').hide();
|
$('#modelSelf').hide();
|
||||||
|
$('#btnSelf').removeClass('active');
|
||||||
$('#modelOcr').show();
|
$('#modelOcr').show();
|
||||||
|
$('#btnOcr').addClass('active');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createVaild() {
|
createVaild() {
|
||||||
|
|||||||
Reference in New Issue
Block a user