use analysis order id as valis tellimuse id (#92)

* use order analysis id as valis tellimuse id

* send analysis order id in xml
This commit is contained in:
Helena
2025-09-10 16:54:12 +03:00
committed by GitHub
parent b31de91daf
commit 99e62b91a5
12 changed files with 29 additions and 26 deletions

View File

@@ -6,11 +6,12 @@ type ProcessedMessage = {
hasPartialAnalysisResponse: boolean;
hasFullAnalysisResponse: boolean;
medusaOrderId: string | undefined;
analysisOrderId: number | undefined;
};
type GroupedResults = {
processed: Pick<ProcessedMessage, 'messageId' | 'medusaOrderId'>[];
waitingForResults: Pick<ProcessedMessage, 'messageId' | 'medusaOrderId'>[];
processed: Pick<ProcessedMessage, 'messageId' | 'analysisOrderId'>[];
waitingForResults: Pick<ProcessedMessage, 'messageId' | 'analysisOrderId'>[];
};
export default async function syncAnalysisResults() {
@@ -37,14 +38,14 @@ export default async function syncAnalysisResults() {
}
const groupedResults = processedMessages.reduce((acc, result) => {
if (result.medusaOrderId) {
if (result.analysisOrderId) {
if (result.hasAnalysisResponse) {
if (!acc.processed) {
acc.processed = [];
}
acc.processed.push({
messageId: result.messageId,
medusaOrderId: result.medusaOrderId,
analysisOrderId: result.analysisOrderId,
});
} else {
if (!acc.waitingForResults) {
@@ -52,7 +53,7 @@ export default async function syncAnalysisResults() {
}
acc.waitingForResults.push({
messageId: result.messageId,
medusaOrderId: result.medusaOrderId,
analysisOrderId: result.analysisOrderId,
});
}
}

View File

@@ -37,7 +37,7 @@ export async function POST(request: NextRequest) {
},
orderedAnalysisElementsIds: idsToSend.map(({ analysisElementId }) => analysisElementId).filter(Boolean) as number[],
orderedAnalysesIds: idsToSend.map(({ analysisId }) => analysisId).filter(Boolean) as number[],
orderId: medusaOrderId,
orderId: medreportOrder.id,
orderCreatedAt: new Date(medreportOrder.created_at),
});

View File

@@ -29,7 +29,7 @@ export async function POST(request: Request) {
},
orderedAnalysisElementsIds: orderedAnalysisElementsIds.map(({ analysisElementId }) => analysisElementId).filter(Boolean) as number[],
orderedAnalysesIds: orderedAnalysisElementsIds.map(({ analysisId }) => analysisId).filter(Boolean) as number[],
orderId: medusaOrderId,
orderId: analysisOrder.id,
orderCreatedAt: new Date(analysisOrder.created_at),
});