feat(ocr) - schema updated, allowed payment model to allow both - claim and ocr data

This commit is contained in:
2025-09-03 23:05:23 +05:30
parent 155f338a15
commit 399c47dcfd
7 changed files with 166 additions and 160 deletions

View File

@@ -16,10 +16,17 @@ export async function validateTransactions(
throw new Error("Payment not found");
}
// Choose service lines from claim if present, otherwise direct payment service lines(OCR Based datas)
const serviceLines = paymentRecord.claim
? paymentRecord.claim.serviceLines
: paymentRecord.serviceLines;
if (!serviceLines || serviceLines.length === 0) {
throw new Error("No service lines available for this payment");
}
for (const txn of serviceLineTransactions) {
const line = paymentRecord.claim.serviceLines.find(
(sl) => sl.id === txn.serviceLineId
);
const line = serviceLines.find((sl) => sl.id === txn.serviceLineId);
if (!line) {
throw new Error(`Invalid service line: ${txn.serviceLineId}`);