Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cb2 10594 #81

Merged
merged 43 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5c0c30e
rectifying data type mismatches, add un-defined Enums and attributes,…
Jan 26, 2024
96b894e
add AdrCertificateDetails interface and parsing function
Jan 26, 2024
722ebfd
adding guidanceNotes Enum
Jan 26, 2024
f373b0a
adding m145 attribute as per documentation change
Jan 29, 2024
e8eb827
feat: adr details added, test resource for technoical record added, u…
Feb 1, 2024
a5488b4
style: rearrange enums
Feb 2, 2024
e456415
fix: replace ! with ? for optional attributes
Feb 2, 2024
c9025ce
fix: memosApplyEnum value updated
Feb 2, 2024
43ed027
fix: 2 new attributes added to adrDetails, as per documentation
Feb 2, 2024
d15b265
feat: tab le definition
Feb 2, 2024
d3404d9
fix: enum updated
Feb 2, 2024
dcfac2a
feat: adr tables added to the tech record list of tables
Feb 8, 2024
6feb0fc
feat: new function added for partial upsert based on condition attribute
Feb 8, 2024
2a0a721
feat: some adr table detail updated
Feb 8, 2024
59ba45a
feat: upsert fun ctionality added for adr-details attributes in tech …
Feb 8, 2024
c31cf13
feat: adr parts added to tech record integration test
Feb 8, 2024
01fdc81
feat: docker's mysql image updated to version 8 - consistent with rec…
Feb 8, 2024
957c9b4
feat: adr attribute values updated
Feb 8, 2024
f0e39d5
feat: test updated as adr attribute values updated in json file
Feb 8, 2024
01f08d9
fix: changes reverted back to original
Feb 8, 2024
37f2490
fix: changes reverted back to original
meys-bjss Feb 8, 2024
deff3e3
fix: changes reverted back to original
meys-bjss Feb 8, 2024
847fd26
feat: cleaning and bringing in adr pass certificate
Feb 9, 2024
e00b564
feat: cleaning and bringing in adr pass certificate
Feb 9, 2024
7803cc3
feat: cleaning and bringing in adr pass certificate
Feb 9, 2024
11d4cb3
fix: removed async keyword to avoid error when running the test
Feb 9, 2024
a4efb62
fix: bringing in to be able to run integration tests on my mac and be…
Feb 9, 2024
c604751
fix: bringing in to be able to run integration tests on my mac and be…
Feb 9, 2024
cdf0c3f
Merge branch 'feature/CB2-10594' of https://github.com/dvsa/cvs-tsk-u…
Feb 9, 2024
d433a3c
fix: bringing in to be able to run integration tests on my mac and be…
Feb 9, 2024
7c9f140
fix: updating adr pass certificate function
Feb 12, 2024
cbf62ab
fix: updating adr pass certificate field name
Feb 12, 2024
9a1ca1c
fix: updating adr pass certificate var name
Feb 12, 2024
0514dc3
feat: adding integration tests for additional test scenarios
Feb 12, 2024
f833b02
feat: adding adr pass certificate attribute
Feb 12, 2024
64f8c63
feat: adding adr pass certificate attribute test to unit test
Feb 12, 2024
fb74bdc
fix: syntax fixed
Feb 12, 2024
7e85d06
fix: updating for tank statement attributes, add conditions for missi…
Feb 13, 2024
0c6845c
fix: updating for tank statement attributes
Feb 13, 2024
485fa8f
fix: updating for tank statement attributes
Feb 13, 2024
cd24248
fix: updating for tank statement attributes
Feb 13, 2024
f4bbfbd
fix: updating for tank statement attributes
Feb 13, 2024
17ef513
Merge branch 'feature/CB2-10564' into feature/CB2-10594
meys-bjss Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 89 additions & 66 deletions src/models/adr-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export interface AdditionalNotes {

export interface Tank {
tankDetails?: TankDetails;
tankStatement?: TankStatement;
}

export interface TankDetails {
Expand All @@ -132,6 +131,7 @@ export interface TankDetails {
tankTypeAppNo?: string;
tc2Details?: Tc2Details;
tc3Details?: Tc3Details;
tankStatement?: TankStatement;
}

export interface TankStatement {
Expand All @@ -149,7 +149,6 @@ export interface Tc2Details {
tc2IntermediateExpiryDate?: string;
}


export type Tc3Details = Tc3DetailsItem[];

export interface Tc3DetailsItem {
Expand All @@ -170,7 +169,9 @@ export const parseAdrDetails = (
"additionalNotes"
)!;
const additionalNotes: AdditionalNotes = {
number: parseStringArray(additionalNotesImage.getList("number")) as additionalNotesNumberEnum[],
number: parseStringArray(
additionalNotesImage.getList("number")!
) as additionalNotesNumberEnum[],
// guidanceNotes: parseStringArray(
// additionalNotesImage.getList("guidanceNotes")
// ) as additionalNotesguidanceNotesEnum[],
Expand All @@ -180,19 +181,19 @@ export const parseAdrDetails = (
"applicantDetails"
)!;
const applicantDetails: ApplicantDetails = {
name: applicantDetailsImage.getString("name"),
street: applicantDetailsImage.getString("street"),
town: applicantDetailsImage.getString("town"),
city: applicantDetailsImage.getString("city"),
postcode: applicantDetailsImage.getString("postcode"),
name: applicantDetailsImage.getString("name")!,
street: applicantDetailsImage.getString("street")!,
town: applicantDetailsImage.getString("town")!,
city: applicantDetailsImage.getString("city")!,
postcode: applicantDetailsImage.getString("postcode")!,
};

const vehicleDetailsImage: DynamoDbImage = adrDetails.getMap(
"vehicleDetails"
)!;
const vehicleDetails: VehicleDetails = {
type: vehicleDetailsImage.getString("type") as VehicleDetailsTypeEnum,
approvalDate: vehicleDetailsImage.getString("approvalDate"),
type: vehicleDetailsImage.getString("type")! as VehicleDetailsTypeEnum,
approvalDate: vehicleDetailsImage.getString("approvalDate")!,
};

const tankImage: DynamoDbImage = adrDetails.getMap("tank")!;
Expand All @@ -201,100 +202,122 @@ export const parseAdrDetails = (

const tc2DetailsImage: DynamoDbImage = tankDetailsImage.getMap("tc2Details")!;
const tc2Details: Tc2Details = {
tc2Type: tc2DetailsImage.getString("tc2Type") as Tc2TypeEnum,
tc2Type: tc2DetailsImage.getString("tc2Type")! as Tc2TypeEnum,
tc2IntermediateApprovalNo: tc2DetailsImage.getString(
"tc2IntermediateApprovalNo"
),
)!,
tc2IntermediateExpiryDate: tc2DetailsImage.getString(
"tc2IntermediateExpiryDate"
),
)!,
};

const tc3DetailsImage: DynamoDbImage = tankDetailsImage.getList(
"tc3Details"
)!;
const tc3Details: Tc3Details = [];

for (const key of tc3DetailsImage.getKeys()) {
const tc3DetailsItemImage = tc3DetailsImage.getMap(key)!;
tc3Details.push({
tc3Type: tc3DetailsItemImage.getString("tc3Type") as Tc3TypeEnum,
tc3PeriodicNumber: tc3DetailsItemImage.getString("tc3PeriodicNumber"),
tc3PeriodicExpiryDate: tc3DetailsItemImage.getString(
"tc3PeriodicExpiryDate"
),
});
if (tc3DetailsImage) {
for (const key of tc3DetailsImage.getKeys()!) {
const tc3DetailsItemImage = tc3DetailsImage.getMap(key)!;
tc3Details.push({
tc3Type: tc3DetailsItemImage.getString("tc3Type")! as Tc3TypeEnum,
tc3PeriodicNumber: tc3DetailsItemImage.getString("tc3PeriodicNumber")!,
tc3PeriodicExpiryDate: tc3DetailsItemImage.getString(
"tc3PeriodicExpiryDate"
)!,
});
}
}

const tankStatementImage: DynamoDbImage = tankDetailsImage.getMap(
"tankStatement"
)!;
const tankStatement: TankStatement = {};

if (tankStatementImage) {
tankStatement.substancesPermitted = tankStatementImage.getString(
"substancesPermitted"
)! as substancesPermittedEnum;
tankStatement.select = tankStatementImage.getString(
"select"
)! as tankStatementSelectEnum;
tankStatement.statement = tankStatementImage.getString("statement")!;
tankStatement.productListRefNo = tankStatementImage.getString(
"productListRefNo"
)!;
tankStatement.productListUnNo = parseStringArray(
tankStatementImage.getList("productListUnNo")!
);
tankStatement.productList = tankStatementImage.getString("productList")!;
}

const tankDetails: TankDetails = {
tankManufacturer: tankDetailsImage.getString("tankManufacturer"),
yearOfManufacture: tankDetailsImage.getNumber("yearOfManufacture"),
tankCode: tankDetailsImage.getString("tankCode"),
specialProvisions: tankDetailsImage.getString("specialProvisions"),
tankManufacturer: tankDetailsImage.getString("tankManufacturer")!,
yearOfManufacture: tankDetailsImage.getNumber("yearOfManufacture")!,
tankCode: tankDetailsImage.getString("tankCode")!,
specialProvisions: tankDetailsImage.getString("specialProvisions")!,
tankManufacturerSerialNo: tankDetailsImage.getString(
"tankManufacturerSerialNo"
),
tankTypeAppNo: tankDetailsImage.getString("tankTypeAppNo"),
)!,
tankTypeAppNo: tankDetailsImage.getString("tankTypeAppNo")!,
tc2Details,
tc3Details,
};

const tankStatementImage: DynamoDbImage = tankImage.getMap("tankStatement")!;
const tankStatement: TankStatement = {
substancesPermitted: tankStatementImage.getString("substancesPermitted") as substancesPermittedEnum,
select: tankStatementImage.getString("select") as tankStatementSelectEnum,
statement: tankStatementImage.getString("statement"),
productListRefNo: tankStatementImage.getString("productListRefNo"),
productListUnNo: parseStringArray(
tankStatementImage.getList("productListUnNo")
),
productList: tankStatementImage.getString("productList"),
tankStatement,
};

const tank: Tank = {
tankDetails,
tankStatement,
};


const additionalExaminerNotesImage: DynamoDbImage = adrDetails.getList(
"additionalExaminerNotes"
)!;
const additionalExaminerNotes: AdditionalExaminerNotes = [];

for (const key of additionalExaminerNotesImage.getKeys()) {
const additionalExaminerNotesItemImage = additionalExaminerNotesImage.getMap(key)!;
additionalExaminerNotes.push({
note: additionalExaminerNotesItemImage.getString("note"),
createdAtDate: additionalExaminerNotesItemImage.getString("createdAtDate"),
lastUpdatedBy: additionalExaminerNotesItemImage.getString("lastUpdatedBy"),
});
if (additionalExaminerNotesImage) {
for (const key of additionalExaminerNotesImage.getKeys()) {
const additionalExaminerNotesItemImage = additionalExaminerNotesImage.getMap(
key
)!;
additionalExaminerNotes.push({
note: additionalExaminerNotesItemImage.getString("note")!,
createdAtDate: additionalExaminerNotesItemImage.getString(
"createdAtDate"
)!,
lastUpdatedBy: additionalExaminerNotesItemImage.getString(
"lastUpdatedBy"
)!,
});
}
}


return {
vehicleDetails,
listStatementApplicable: adrDetails.getBoolean("listStatementApplicable"),
batteryListNumber: adrDetails.getString("batteryListNumber"),
declarationsSeen: adrDetails.getBoolean("declarationsSeen"),
brakeDeclarationsSeen: adrDetails.getBoolean("brakeDeclarationsSeen"),
brakeDeclarationIssuer: adrDetails.getString("brakeDeclarationIssuer"),
brakeEndurance: adrDetails.getBoolean("brakeEndurance"),
weight: adrDetails.getNumber("weight"),
newCertificateRequested: adrDetails.getBoolean("newCertificateRequested"),
compatibilityGroupJ: adrDetails.getString("compatibilityGroupJ") as compatibilityGroupJEnum,
documents: parseStringArray(adrDetails.getList("documents")),
listStatementApplicable: adrDetails.getBoolean("listStatementApplicable")!,
batteryListNumber: adrDetails.getString("batteryListNumber")!,
declarationsSeen: adrDetails.getBoolean("declarationsSeen")!,
brakeDeclarationsSeen: adrDetails.getBoolean("brakeDeclarationsSeen")!,
brakeDeclarationIssuer: adrDetails.getString("brakeDeclarationIssuer")!,
brakeEndurance: adrDetails.getBoolean("brakeEndurance")!,
weight: adrDetails.getNumber("weight")!,
newCertificateRequested: adrDetails.getBoolean("newCertificateRequested")!,
compatibilityGroupJ: adrDetails.getString(
"compatibilityGroupJ"
)! as compatibilityGroupJEnum,
documents: parseStringArray(adrDetails.getList("documents"))!,
permittedDangerousGoods: parseStringArray(
adrDetails.getList("permittedDangerousGoods")
adrDetails.getList("permittedDangerousGoods")!
) as permittedDangerousGoodsEnum[],
additionalExaminerNotes,
applicantDetails,
dangerousGoods: adrDetails.getBoolean("dangerousGoods"),
memosApply: parseStringArray(adrDetails.getList("memosApply")) as memosApplyEnum[],
m145Statement: adrDetails.getBoolean("m145Statement"),
dangerousGoods: adrDetails.getBoolean("dangerousGoods")!,
memosApply: parseStringArray(
adrDetails.getList("memosApply")!
) as memosApplyEnum[],
m145Statement: adrDetails.getBoolean("m145Statement")!,
additionalNotes,
adrTypeApprovalNo: adrDetails.getString("adrTypeApprovalNo"),
adrCertificateNotes: adrDetails.getString("adrCertificateNotes"),
adrTypeApprovalNo: adrDetails.getString("adrTypeApprovalNo")!,
adrCertificateNotes: adrDetails.getString("adrCertificateNotes")!,
tank,
};
};
14 changes: 7 additions & 7 deletions src/services/tech-record-document-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ const upsertTechRecords = async (
?.tc2IntermediateApprovalNo,
techRecord.adrDetails.tank?.tankDetails?.tc2Details
?.tc2IntermediateExpiryDate,
techRecord.adrDetails.tank?.tankStatement?.substancesPermitted,
// techRecord.adrDetails.tank?.tankStatement?.select,
techRecord.adrDetails.tank?.tankStatement?.statement,
techRecord.adrDetails.tank?.tankStatement?.productListRefNo,
techRecord.adrDetails.tank?.tankStatement?.productList,
techRecord.adrDetails.tank?.tankDetails?.tankStatement?.substancesPermitted,
// techRecord.adrDetails.tank?.tankDetails?.tankStatement?.select,
techRecord.adrDetails.tank?.tankDetails?.tankStatement?.statement,
techRecord.adrDetails.tank?.tankDetails?.tankStatement?.productListRefNo,
techRecord.adrDetails.tank?.tankDetails?.tankStatement?.productList,
techRecord.adrDetails.m145Statement,
// techRecord.adrDetails.newCertificateRequested,
],
Expand Down Expand Up @@ -845,12 +845,12 @@ const upsertAdrProductListUnNo = async (
adrDetailsId: string,
techRecord: TechRecord
): Promise<void> => {
if (techRecord.adrDetails?.tank?.tankStatement?.productListUnNo) {
if (techRecord.adrDetails?.tank?.tankDetails?.tankStatement?.productListUnNo) {
debugLog(
`upsertTechRecords: Upserting ADR tankStatement productListUnNo (adr-details-id: ${adrDetailsId})...`
);

for (const productListUnNo of techRecord.adrDetails?.tank?.tankStatement
for (const productListUnNo of techRecord.adrDetails?.tank?.tankDetails?.tankStatement
?.productListUnNo) {
const productListUnNoId = await upsertAdrProductListUnNoList(
connection,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/tech-record-document-conversion.intTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ export const techRecordDocumentConversion = () =>

// productListUnNo removed from payload
delete techRecordDocumentJsonNew.techRecord.L[0].M.adrDetails.M
.tank.M.tankStatement.M.productListUnNo;
.tank.M.tankDetails.M.tankStatement.M.productListUnNo;

const event = {
Records: [
Expand Down Expand Up @@ -1206,7 +1206,7 @@ export const techRecordDocumentConversion = () =>
S: "different_tankManufacturer",
};
// update missing attribute to NULL
techRecordDocumentJsonNew.techRecord.L[0].M.adrDetails.M.tank.M.tankStatement.M.productListUnNo = { NULL: true };
techRecordDocumentJsonNew.techRecord.L[0].M.adrDetails.M.tank.M.tankDetails.M.tankStatement.M.productListUnNo = { NULL: true };

const event = {
Records: [
Expand Down
Loading
Loading