자재별 구매 수량 계산 시스템 구현

- 파이프: 6,000mm 단위 + 절단여유분 2mm/조각 계산
- 볼트/너트: +5% 후 4의 배수로 올림
- 가스켓: 5의 배수로 올림
- 피팅/계기/밸브: BOM 수량 그대로
- MaterialsPage에 '필요 수량' 칼럼 추가
- 엑셀 내보내기에 구매 수량 정보 포함
- 리비전 비교시 구매 수량 변화량도 계산
This commit is contained in:
Hyungi Ahn
2025-07-23 10:41:50 +09:00
parent 5fa0ac4202
commit 905344681f
4 changed files with 235 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import * as XLSX from 'xlsx';
import { saveAs } from 'file-saver';
import { calculatePurchaseQuantity } from './purchaseCalculator';
/**
* 자재 목록을 카테고리별로 그룹화
@@ -98,6 +99,9 @@ const formatMaterialForExcel = (material, includeComparison = false) => {
const category = material.classified_category || material.category || '-';
const isPipe = category === 'PIPE';
// 구매 수량 계산
const purchaseInfo = calculatePurchaseQuantity(material);
const base = {
'카테고리': category,
'자재 설명': material.original_description || material.description || '-',
@@ -119,6 +123,11 @@ const formatMaterialForExcel = (material, includeComparison = false) => {
base['단위'] = material.unit || 'EA';
}
// 구매 수량 정보 추가
base['필요 수량'] = purchaseInfo.purchaseQuantity || 0;
base['구매 단위'] = purchaseInfo.unit || 'EA';
base['계산 과정'] = purchaseInfo.calculation || '-';
// 비교 모드인 경우 추가 정보
if (includeComparison) {
if (material.previous_quantity !== undefined) {
@@ -131,10 +140,27 @@ const formatMaterialForExcel = (material, includeComparison = false) => {
base['길이 변경(m)'] = ((currTotalLength - prevTotalLength)).toFixed(2);
base['이전 개수'] = material.previous_quantity;
base['현재 개수'] = material.current_quantity;
// 이전/현재 구매 수량 계산
const prevPurchaseInfo = calculatePurchaseQuantity({
...material,
quantity: material.previous_quantity,
totalLength: prevTotalLength
});
base['이전 필요 수량'] = prevPurchaseInfo.purchaseQuantity || 0;
base['필요 수량 변경'] = (purchaseInfo.purchaseQuantity - prevPurchaseInfo.purchaseQuantity);
} else {
base['이전 수량'] = material.previous_quantity;
base['현재 수량'] = material.current_quantity;
base['변경량'] = material.quantity_change;
// 이전/현재 구매 수량 계산
const prevPurchaseInfo = calculatePurchaseQuantity({
...material,
quantity: material.previous_quantity
});
base['이전 필요 수량'] = prevPurchaseInfo.purchaseQuantity || 0;
base['필요 수량 변경'] = (purchaseInfo.purchaseQuantity - prevPurchaseInfo.purchaseQuantity);
}
}
base['변경 유형'] = material.change_type || (