1
0
forked from Yara724/api

the serial letter normalization added to the code to normalize the Heh , Ya , Kaf and etc to the correct character

This commit is contained in:
2026-07-27 10:38:35 +03:30
parent 778544c321
commit 182db56e15
13 changed files with 337 additions and 11 deletions

View File

@@ -7,20 +7,23 @@ import {
import { Types } from "mongoose";
import { PlateDbService } from "src/plates/entites/db-service/plate.db.service";
import { AddPlateDto } from "src/profile/dto/user/AddPlateDto";
import { PlateNormalizerService } from "src/utils/plate-normalizer/plate-normalizer.service";
@Injectable()
export class PlatesService {
constructor(
private readonly plateDbService: PlateDbService,
private readonly plateNormalizer: PlateNormalizerService,
) {}
async addPlate(currentUser, body: AddPlateDto) {
const { plate, nationalCodeOfInsurer } = body;
const normalizedAlphabet = this.plateNormalizer.normalizePlateText(String(plate.centerAlphabet || ""));
const duplicate = await this.plateDbService.findOne({
userId: currentUser,
leftDigits: plate.leftDigits,
centerAlphabet: plate.centerAlphabet,
centerAlphabet: normalizedAlphabet,
centerDigits: plate.centerDigits,
ir: plate.ir,
nationalCodeOfInsurer,
@@ -31,6 +34,7 @@ export class PlatesService {
const newPlateData = await this.plateDbService.create({
...plate,
centerAlphabet: normalizedAlphabet,
userId: currentUser,
nationalCodeOfInsurer: body.nationalCodeOfInsurer,
});