feat: prepare bids by official lot selection

This commit is contained in:
2026-09-06 08:52:07 +03:00
parent 311344306b
commit 0d332afdb1
6 changed files with 162 additions and 13 deletions
+12
View File
@@ -0,0 +1,12 @@
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};
}
+1 -1
View File
@@ -5,7 +5,7 @@ export function sourceRows(tender, results) {
: (Array.isArray(results?.itemsAndSpecs) ? results.itemsAndSpecs : []);
const occurrences = new Map();
return items.map(k => {
const identity = JSON.stringify([k.id ?? k.no ?? null, k.kisim ?? null, k.name, k.quantity, k.keySpecs || []]);
const identity = JSON.stringify([k.id ?? k.no ?? null, k.kisim ?? k.lot ?? null, k.name, k.quantity, k.keySpecs || []]);
const occurrence = occurrences.get(identity) || 0;
occurrences.set(identity, occurrence + 1);
return { ...k, priceKey: JSON.stringify([identity, occurrence]) };