in src/TransferVehicleOwnership.ts [100:116]
export async function validateAndUpdateRegistration(
txn: TransactionExecutor,
vin: string,
currentOwner: string,
newOwner: string
): Promise<void> {
const primaryOwner: dom.Value = await findPrimaryOwnerForVehicle(txn, vin);
const govIdValue: dom.Value = primaryOwner.get("GovId");
if (govIdValue !== null && govIdValue.stringValue() !== currentOwner) {
log("Incorrect primary owner identified for vehicle, unable to transfer.");
}
else {
const documentId: string = await getDocumentId(txn, PERSON_TABLE_NAME, "GovId", newOwner);
await updateVehicleRegistration(txn, vin, documentId);
log("Successfully transferred vehicle ownership!");
}
}