Goparts ERP
[ SI 프로젝트 ] 해외 자동차부품 수출 프로그램

#1. 견적서 출력 Data Setting
Code
async function print() {
if (!estimateHData.estimateNo)
return sbAlert(
`등록된 견적서만 출력 가능합니다.\n먼저 견적서를 저장해주세요.`
)
if (flexH.cv.itemsEdited?.length || flexD.cv?.itemsEdited.length)
return sbAlert('수정중인 데이터가 있습니다.\n 먼저 견적서를 저장해주세요.')
// 부품이미지 출력 선택여부, 부품번호 출력여부 선택 팝업
const printImgData = await imagePrintChoicePopupRef.value?.open({
fileDiv: 'ESTM10', //견적,아이템,매출 등 구분값
corpCd: user.corpCd, // 회사코드
estmSaleNo: estimateHData.estimateNo, // relKey2 : 견적번호
})
// 부품번호 출력여부 세팅
flexD.cv.items.forEach((x: any) => {
x.itemPrtYn = printImgData.itemPrtYn
})
// 출력 이미지 선택시 취소하면 출력취소
if (printImgData === 'CANCEL') return
// 출력물 헤더
const { data: dataset_0 } = await queryReport('estmHeader', {
estimateNoArray: [estimateHData.estimateNo],
})
// 사용자가 필터 정렬 등 변경상태 그대로 출력하기 위해 flexD.cv.items = dataset1 그대로 보냄
const dataset_1 = flexD.cv.items
//회사인감 이미지
const { signUrlEnc } = await http.post(`/corpModify/query/image`)
openReport({
module: 'sam',
report: 'estmReport',
reportNm: '견적서',
faxReceivers: [
{
receiverNum: dataset_0[0].faxNo ?? '',
receiverName: dataset_0[0].custNm ?? '',
},
],
data: {
dataset_0, // 견적서
dataset_1, // 부품목록
dataset_2: { signUrlEnc }, // 회사인감
dataset_3: printImgData.checked, // 선택한 출력이미지 정보
},
})
}
#2. 부품주문서 디스카운트
Code
//할인율 적용
function calcDiscount() {
let discountAmt: number = 0
//할인계산방법 = 금액
if (discountTp.value === 'amt') {
if (flexH.ci?.splyAmt < discountRat.value)
return sbAlert('할인금액이 공급가 보다 클 수 없습니다.')
discountAmt = discountRat.value
//할인계산방법 = 할인비율
} else if (discountTp.value === 'percent') {
if (!flexH.ci.splyAmt || flexH.ci.splyAmt === 0)
return sbAlert('할인율을 적용하시려면 먼저 계산할 금액이 있어야 합니다.')
if (!(discountRat.value > 0 && discountRat.value < 100))
return sbAlert('할인율은 0 이하 100 이상일 수 없습니다.')
// 할인금액 = 전체 공급가 합 * 할인율
discountAmt = Math.floor(flexH.ci.splyAmt * (discountRat.value / 100))
}
// DC 할인 행 추가
flexD.addRow({
corpCd: flexH.ci.corpCd,
estimateNo: flexH.ci.estimateNo,
itemCd: 'DC',
descTxt: '할인',
estimateQty: 1,
estimatePrc: -Math.abs(discountAmt), // - 절대값 차감
estimateAmt: -Math.abs(discountAmt), // - 절대값 차감
descYn: false,
delYn: false,
})
}
#3. 매출전표 생성 전 유효성검사
Code
async function createSaleH() {
const { ci } = flexH
const { items } = flexD.cv
if (!ci?.estimateNo) return sbAlert('먼저 신규 견적서를 등록해 주세요.')
if (items.length === 0) return sbAlert('먼저 견적내역을 작성해 주세요.')
if (flexH.hasChangeData() || flexD.hasChangeData())
return sbAlert('매출전표를 생성하시려면 먼저 변경 사항을 저장해 주세요.')
// 매출생성시 매입처구분,매입단가 required
let validMsg: string = ''
items.forEach(item => {
if (item.descYn === true) return
if (!item.supplyerTp)
validMsg = '매출전표 생성시 매입처구분은 필수입력 입니다.'
})
if (validMsg !== '') return sbAlert(validMsg)
const saveData = {
estimateNo: ci.estimateNo,
saleTp: '20',
}
if (await sbConfirm('매출전표를 생성 하시겠습니까?')) {
await http.post('/estmReg/createSaleH', saveData)
sbAlert('생성 되었습니다.')
query()
}
}