fix: invalidate preparation approval for changed portfolio products
This commit is contained in:
@@ -4,7 +4,7 @@ import { preparationDeadlineProblem } from '../services/preparationDeadline';
|
||||
import { bidValidityForForm, bidTypeForForm } from '../services/bidTerms';
|
||||
import { createBidWorkbook, downloadBidWorkbook } from '../services/bidWorkbook';
|
||||
import { getToken } from '../services/auth';
|
||||
import { listDocuments, downloadDocument, validateDocumentTextReview } from '../services/account';
|
||||
import { getAllUserData, listDocuments, downloadDocument, validateDocumentTextReview } from '../services/account';
|
||||
import { tenderDateKey } from '../services/tenderCalendar';
|
||||
import React, { useState, useMemo, useEffect, useRef, useId } from 'react';
|
||||
import { bidRowTotal, validateBidRows, bidTotal, bidAmount } from '../services/bidValidation';
|
||||
@@ -115,7 +115,7 @@ export const BidPackageBuilder = ({ results, tender: selectedTender, initialFocu
|
||||
|
||||
const kalemToplami = useMemo(() => bidTotal(satirlar), [satirlar]);
|
||||
const latestDraft = useRef('');
|
||||
latestDraft.current = JSON.stringify([firma,teklifTuru,gecerlilikGun,kisim,goturuBedel,fiyatlar,sourceSnapshot,reviewedSource,checks,manualDocuments,partialBid,itemSource]);
|
||||
latestDraft.current = JSON.stringify([firma,teklifTuru,gecerlilikGun,kisim,goturuBedel,fiyatlar,sourceSnapshot,reviewedSource,checks,manualDocuments,partialBid,itemSource,userProfile.scrapedCapabilities?.healthPortfolio]);
|
||||
const mounted = useRef(true);
|
||||
const printWindow = useRef(null);
|
||||
const [printing,setPrinting] = useState(false);
|
||||
@@ -137,7 +137,7 @@ export const BidPackageBuilder = ({ results, tender: selectedTender, initialFocu
|
||||
const [deadlineNow,setDeadlineNow] = useState(() => new Date());
|
||||
useEffect(() => {const timer=setInterval(()=>setDeadlineNow(new Date()),30000);return ()=>clearInterval(timer);},[]);
|
||||
const deadlineProblem = preparationDeadlineProblem(tender,deadlineNow);
|
||||
const kontrolEksikleri = preparationBlockers(lotSelection.rows, documents, checks, {...vault,deadlineDate:tenderDateKey(tender),tenderIkn:tender.ikn});
|
||||
const kontrolEksikleri = preparationBlockers(lotSelection.rows, documents, checks, {...vault,healthPortfolio:userProfile.scrapedCapabilities?.healthPortfolio || [],deadlineDate:tenderDateKey(tender),tenderIkn:tender.ikn});
|
||||
const analizEksik = effectiveResults.sourceReview?.status === 'partial';
|
||||
const hazir = !deadlineProblem && eksikler.length === 0 && toplam > 0 && !kalemEksik && !turCeliskisi && !sureEksik && !kaynakKontrolGerekli && kontrolEksikleri.length === 0 && lotSelection.errors.length === 0 && !analizEksik && !sourceOptions.needsSelection;
|
||||
|
||||
@@ -181,12 +181,14 @@ export const BidPackageBuilder = ({ results, tender: selectedTender, initialFocu
|
||||
// Open during the click; async validation must not lose popup activation.
|
||||
printWindow.current = belgeYazdir('Dosya kontrolü', '<p>Belgeler kontrol ediliyor…</p>');
|
||||
setPrinting(true);
|
||||
const currentFiles = await listDocuments();
|
||||
const linkedPortfolio=lotSelection.rows.some(row=>checks.products?.[row.priceKey]?.portfolioId);
|
||||
const readPortfolio=async()=>linkedPortfolio ? (await getAllUserData()).firma_profil?.scrapedCapabilities?.healthPortfolio || [] : [];
|
||||
const [currentFiles,currentPortfolio] = await Promise.all([listDocuments(),readPortfolio()]);
|
||||
const reviewedText = effectiveResults.sourceReview?.humanReview;
|
||||
if (reviewedText) await validateDocumentTextReview(reviewedText,tender.ikn);
|
||||
if (!mounted.current || session !== getToken() || submitted !== latestDraft.current)
|
||||
throw new Error('Form, kaynak veya oturum değişti. Güncel bilgilerle yeniden çıktı oluşturun.');
|
||||
const currentVault = {loading:false,error:null,documents:currentFiles.belgeler || [],deadlineDate:tenderDateKey(tender),tenderIkn:tender.ikn};
|
||||
const currentVault = {healthPortfolio:currentPortfolio,loading:false,error:null,documents:currentFiles.belgeler || [],deadlineDate:tenderDateKey(tender),tenderIkn:tender.ikn};
|
||||
setVault(currentVault);
|
||||
const fileErrors = preparationBlockers(lotSelection.rows, documents, checks, currentVault);
|
||||
if (fileErrors.length) throw new Error(fileErrors.join(' '));
|
||||
@@ -196,6 +198,9 @@ export const BidPackageBuilder = ({ results, tender: selectedTender, initialFocu
|
||||
if (tip === 'excel') {
|
||||
const buffer = await createBidWorkbook(f,satirlar);
|
||||
if (reviewedText) await validateDocumentTextReview(reviewedText,tender.ikn);
|
||||
const finalPortfolio=await readPortfolio();
|
||||
const finalErrors=preparationBlockers(lotSelection.rows,documents,checks,{...currentVault,healthPortfolio:finalPortfolio});
|
||||
if(finalErrors.length)throw new Error(finalErrors.join(' '));
|
||||
if (!mounted.current || session !== getToken() || submitted !== latestDraft.current)
|
||||
throw new Error('Form veya oturum değişti; Excel çıktısını yeniden oluşturun.');
|
||||
const finalDeadlineProblem=preparationDeadlineProblem(tender);
|
||||
|
||||
Reference in New Issue
Block a user