diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-12-08 03:02:42 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-12-08 03:02:42 +0000 |
| commit | c0e1cc06e0c67cb4a941889a3d63d312d1fb8fce (patch) | |
| tree | 99dc529ed88d762808dc571d4095dc880e1bef02 /lib/general-contracts/approval-template-variables.ts | |
| parent | 4a8d125cf60254417d4e2ca75a967ff08cc8567e (diff) | |
(최겸) 구매 입찰계약 수정, 입찰기간수정
Diffstat (limited to 'lib/general-contracts/approval-template-variables.ts')
| -rw-r--r-- | lib/general-contracts/approval-template-variables.ts | 270 |
1 files changed, 123 insertions, 147 deletions
diff --git a/lib/general-contracts/approval-template-variables.ts b/lib/general-contracts/approval-template-variables.ts index 6924694e..710e6101 100644 --- a/lib/general-contracts/approval-template-variables.ts +++ b/lib/general-contracts/approval-template-variables.ts @@ -144,129 +144,75 @@ export async function mapContractToApprovalTemplateVariables( issuer: string; }> = []; - // 계약보증 - if (basicInfo.contractBond) { - const bond = typeof basicInfo.contractBond === 'string' - ? JSON.parse(basicInfo.contractBond) - : basicInfo.contractBond; - - if (bond && Array.isArray(bond)) { - bond.forEach((b: any, idx: number) => { - guarantees.push({ - type: '계약보증', - order: idx + 1, - bondNumber: b.bondNumber || '', - rate: b.rate ? `${b.rate}%` : '', - amount: formatCurrency(b.amount), - period: b.period || '', - startDate: formatDate(b.startDate), - endDate: formatDate(b.endDate), - issuer: b.issuer || '', - }); - }); - } - } - - // 지급보증 - if (basicInfo.paymentBond) { - const bond = typeof basicInfo.paymentBond === 'string' - ? JSON.parse(basicInfo.paymentBond) - : basicInfo.paymentBond; - - if (bond && Array.isArray(bond)) { - bond.forEach((b: any, idx: number) => { - guarantees.push({ - type: '지급보증', - order: idx + 1, - bondNumber: b.bondNumber || '', - rate: b.rate ? `${b.rate}%` : '', - amount: formatCurrency(b.amount), - period: b.period || '', - startDate: formatDate(b.startDate), - endDate: formatDate(b.endDate), - issuer: b.issuer || '', - }); - }); - } - } - - // 하자보증 - if (basicInfo.defectBond) { - const bond = typeof basicInfo.defectBond === 'string' - ? JSON.parse(basicInfo.defectBond) - : basicInfo.defectBond; - - if (bond && Array.isArray(bond)) { - bond.forEach((b: any, idx: number) => { - guarantees.push({ - type: '하자보증', - order: idx + 1, - bondNumber: b.bondNumber || '', - rate: b.rate ? `${b.rate}%` : '', - amount: formatCurrency(b.amount), - period: b.period || '', - startDate: formatDate(b.startDate), - endDate: formatDate(b.endDate), - issuer: b.issuer || '', - }); - }); - } - } - - // 보증 전체 비고 - const guaranteeNote = basicInfo.guaranteeNote || ''; - - // 하도급 체크리스트 - const checklistItems: Array<{ - category: string; - item1: string; - item2: string; - result: string; - department: string; - cause: string; - measure: string; - }> = []; + // // 계약보증 (첫 번째 항목만 사용) + // if (basicInfo.contractBond) { + // const bond = typeof basicInfo.contractBond === 'string' + // ? JSON.parse(basicInfo.contractBond) + // : basicInfo.contractBond; + + // if (bond && Array.isArray(bond) && bond.length > 0) { + // const b = bond[0]; + // guarantees.push({ + // type: '계약보증', + // order: 1, + // bondNumber: b.bondNumber || '', + // rate: b.rate ? `${b.rate}%` : '', + // amount: formatCurrency(b.amount), + // period: b.period || '', + // startDate: formatDate(b.startDate), + // endDate: formatDate(b.endDate), + // issuer: b.issuer || '', + // }); + // } + // } + + // // 지급보증 (첫 번째 항목만 사용) + // if (basicInfo.paymentBond) { + // const bond = typeof basicInfo.paymentBond === 'string' + // ? JSON.parse(basicInfo.paymentBond) + // : basicInfo.paymentBond; + + // if (bond && Array.isArray(bond) && bond.length > 0) { + // const b = bond[0]; + // guarantees.push({ + // type: '지급보증', + // order: 1, + // bondNumber: b.bondNumber || '', + // rate: b.rate ? `${b.rate}%` : '', + // amount: formatCurrency(b.amount), + // period: b.period || '', + // startDate: formatDate(b.startDate), + // endDate: formatDate(b.endDate), + // issuer: b.issuer || '', + // }); + // } + // } + + // // 하자보증 (첫 번째 항목만 사용) + // if (basicInfo.defectBond) { + // const bond = typeof basicInfo.defectBond === 'string' + // ? JSON.parse(basicInfo.defectBond) + // : basicInfo.defectBond; + + // if (bond && Array.isArray(bond) && bond.length > 0) { + // const b = bond[0]; + // guarantees.push({ + // type: '하자보증', + // order: 1, + // bondNumber: b.bondNumber || '', + // rate: b.rate ? `${b.rate}%` : '', + // amount: formatCurrency(b.amount), + // period: b.period || '', + // startDate: formatDate(b.startDate), + // endDate: formatDate(b.endDate), + // issuer: b.issuer || '', + // }); + // } + // } + + // // 보증 전체 비고 + // const guaranteeNote = basicInfo.guaranteeNote || ''; - if (subcontractChecklist) { - // 1-1. 작업 시 서면 발급 - checklistItems.push({ - category: '계약 시 [계약 체결 단계]', - item1: '1-1. 작업 시 서면 발급', - item2: '-', - result: subcontractChecklist.workDocumentIssued === '준수' ? '준수' : - subcontractChecklist.workDocumentIssued === '위반' ? '위반' : - subcontractChecklist.workDocumentIssued === '위반의심' ? '위반의심' : '', - department: subcontractChecklist.workDocumentIssuedDepartment || '', - cause: subcontractChecklist.workDocumentIssuedCause || '', - measure: subcontractChecklist.workDocumentIssuedMeasure || '', - }); - - // 1-2. 6대 법정 기재사항 명기 여부 - checklistItems.push({ - category: '계약 시 [계약 체결 단계]', - item1: '1-2. 6대 법정 기재사항 명기 여부', - item2: '-', - result: subcontractChecklist.sixLegalItems === '준수' ? '준수' : - subcontractChecklist.sixLegalItems === '위반' ? '위반' : - subcontractChecklist.sixLegalItems === '위반의심' ? '위반의심' : '', - department: subcontractChecklist.sixLegalItemsDepartment || '', - cause: subcontractChecklist.sixLegalItemsCause || '', - measure: subcontractChecklist.sixLegalItemsMeasure || '', - }); - - // 2. 부당 하도급 대금 결정 행위 - checklistItems.push({ - category: '계약 시 [계약 체결 단계]', - item1: '-', - item2: '2. 부당 하도급 대금 결정 행위 (대금 결정 방법)', - result: subcontractChecklist.unfairSubcontractPrice === '준수' ? '준수' : - subcontractChecklist.unfairSubcontractPrice === '위반' ? '위반' : - subcontractChecklist.unfairSubcontractPrice === '위반의심' ? '위반의심' : '', - department: subcontractChecklist.unfairSubcontractPriceDepartment || '', - cause: subcontractChecklist.unfairSubcontractPriceCause || '', - measure: subcontractChecklist.unfairSubcontractPriceMeasure || '', - }); - } // 총 계약 금액 계산 const totalContractAmount = items.reduce((sum, item) => { @@ -338,31 +284,61 @@ export async function mapContractToApprovalTemplateVariables( // 총 계약 금액 variables['총_계약금액'] = formatCurrency(totalContractAmount); - // 보증 정보 변수 - guarantees.forEach((guarantee, index) => { - const idx = index + 1; - const typeKey = String(guarantee.type); - variables[`${typeKey}_차수_${idx}`] = String(guarantee.order); - variables[`${typeKey}_증권번호_${idx}`] = String(guarantee.bondNumber || ''); - variables[`${typeKey}_보증금율_${idx}`] = String(guarantee.rate || ''); - variables[`${typeKey}_보증금액_${idx}`] = String(guarantee.amount || ''); - variables[`${typeKey}_보증기간_${idx}`] = String(guarantee.period || ''); - variables[`${typeKey}_시작일_${idx}`] = String(guarantee.startDate || ''); - variables[`${typeKey}_종료일_${idx}`] = String(guarantee.endDate || ''); - variables[`${typeKey}_발행기관_${idx}`] = String(guarantee.issuer || ''); - }); - - // 보증 전체 비고 - variables['보증_전체_비고'] = String(guaranteeNote); - - // 하도급 체크리스트 변수 - checklistItems.forEach((item, index) => { - const idx = index + 1; - variables[`점검결과_${idx === 1 ? '1_1' : idx === 2 ? '1_2' : '2'}`] = String(item.result); - variables[`귀책부서_${idx === 1 ? '1_1' : idx === 2 ? '1_2' : '2'}`] = String(item.department); - variables[`원인_${idx === 1 ? '1_1' : idx === 2 ? '1_2' : '2'}`] = String(item.cause); - variables[`대책_${idx === 1 ? '1_1' : idx === 2 ? '1_2' : '2'}`] = String(item.measure); - }); + // // 보증 정보 변수 (첫 번째 항목만 사용) + // const contractGuarantee = guarantees.find(g => g.type === '계약보증'); + // if (contractGuarantee) { + // variables['계약보증_차수_1'] = String(contractGuarantee.order); + // variables['계약보증_증권번호_1'] = String(contractGuarantee.bondNumber || ''); + // variables['계약보증_보증금율_1'] = String(contractGuarantee.rate || ''); + // variables['계약보증_보증금액_1'] = String(contractGuarantee.amount || ''); + // variables['계약보증_보증기간_1'] = String(contractGuarantee.period || ''); + // variables['계약보증_시작일_1'] = String(contractGuarantee.startDate || ''); + // variables['계약보증_종료일_1'] = String(contractGuarantee.endDate || ''); + // variables['계약보증_발행기관_1'] = String(contractGuarantee.issuer || ''); + // variables['계약보증_비고_1'] = String(guaranteeNote); // 기존 보증 전체 비고를 계약보증 비고로 사용 + // } + + // const paymentGuarantee = guarantees.find(g => g.type === '지급보증'); + // if (paymentGuarantee) { + // variables['지급보증_차수_1'] = String(paymentGuarantee.order); + // variables['지급보증_증권번호_1'] = String(paymentGuarantee.bondNumber || ''); + // variables['지급보증_보증금율_1'] = String(paymentGuarantee.rate || ''); + // variables['지급보증_보증금액_1'] = String(paymentGuarantee.amount || ''); + // variables['지급보증_보증기간_1'] = String(paymentGuarantee.period || ''); + // variables['지급보증_시작일_1'] = String(paymentGuarantee.startDate || ''); + // variables['지급보증_종료일_1'] = String(paymentGuarantee.endDate || ''); + // variables['지급보증_발행기관_1'] = String(paymentGuarantee.issuer || ''); + // variables['지급보증_비고_1'] = String(guaranteeNote); // 기존 보증 전체 비고를 지급보증 비고로 사용 + // } + + // const defectGuarantee = guarantees.find(g => g.type === '하자보증'); + // if (defectGuarantee) { + // variables['하자보증_차수_1'] = String(defectGuarantee.order); + // variables['하자보증_증권번호_1'] = String(defectGuarantee.bondNumber || ''); + // variables['하자보증_보증금율_1'] = String(defectGuarantee.rate || ''); + // variables['하자보증_보증금액_1'] = String(defectGuarantee.amount || ''); + // variables['하자보증_보증기간_1'] = String(defectGuarantee.period || ''); + // variables['하자보증_시작일_1'] = String(defectGuarantee.startDate || ''); + // variables['하자보증_종료일_1'] = String(defectGuarantee.endDate || ''); + // variables['하자보증_발행기관_1'] = String(defectGuarantee.issuer || ''); + // variables['하자보증_비고_1'] = String(guaranteeNote); // 기존 보증 전체 비고를 하자보증 비고로 사용 + // } + + // 하도급 체크리스트 변수 (새로운 템플릿 구조에 맞춤) + if (subcontractChecklist) { + variables['작업전_서면발급_체크'] = String(subcontractChecklist.workDocumentIssuedCheck || subcontractChecklist.workDocumentIssued || ''); + variables['기재사항_1'] = String(subcontractChecklist.legalItem1 || subcontractChecklist.sixLegalItems1 || ''); + variables['기재사항_2'] = String(subcontractChecklist.legalItem2 || subcontractChecklist.sixLegalItems2 || ''); + variables['기재사항_3'] = String(subcontractChecklist.legalItem3 || subcontractChecklist.sixLegalItems3 || ''); + variables['기재사항_4'] = String(subcontractChecklist.legalItem4 || subcontractChecklist.sixLegalItems4 || ''); + variables['기재사항_5'] = String(subcontractChecklist.legalItem5 || subcontractChecklist.sixLegalItems5 || ''); + variables['기재사항_6'] = String(subcontractChecklist.legalItem6 || subcontractChecklist.sixLegalItems6 || ''); + variables['부당대금_결정'] = String(subcontractChecklist.unfairPriceDecision || subcontractChecklist.unfairSubcontractPrice || ''); + variables['점검결과'] = String(subcontractChecklist.inspectionResult || subcontractChecklist.overallResult || ''); + variables['귀책부서'] = String(subcontractChecklist.responsibleDepartment || subcontractChecklist.overallDepartment || ''); + variables['원인'] = String(subcontractChecklist.cause || subcontractChecklist.overallCause || ''); + variables['대책'] = String(subcontractChecklist.countermeasure || subcontractChecklist.overallMeasure || ''); + } return variables; } |
