Files
ihaleist/src/services/bidLots.js
T

13 lines
968 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const rowLot = (row, assignments = {}) => String(row.kisim ?? row.lot ?? assignments[row.priceKey] ?? '').trim();
export function selectBidLots(rows, partial = {}) {
if (!partial.enabled) return {rows, errors:[],lots:[]};
const lots = [...new Set(rows.map(r=>rowLot(r,partial.assignments)).filter(Boolean))];
const selected = new Set(partial.selected || []);
const errors = [];
if (!partial.source?.trim()) errors.push('Kısmi teklif izninin resmi doküman ve madde kaynağını yazın.');
if (rows.some(r=>!rowLot(r,partial.assignments))) errors.push('Kısmi teklif için her kalemin resmi kısım numarası belirlenmeli.');
if (!lots.some(l=>selected.has(l))) errors.push('En az bir resmi kısım seçin.');
if ([...selected].some(l=>!lots.includes(l))) errors.push('Seçili bir kısım güncel kalemlerde bulunamadı; seçimi yeniden kontrol edin.');
return {rows:rows.filter(r=>selected.has(rowLot(r,partial.assignments))),errors,lots};
}