13 lines
968 B
JavaScript
13 lines
968 B
JavaScript
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};
|
||
}
|