Skip to content

Commit

Permalink
CB2-10316: Generate Welsh Certificate (#97)
Browse files Browse the repository at this point in the history
* feat(vta-1618): duplicated appropriate templates ready for welsh conversion (#87)

feat(vta-1618): added failWelsh template

feat(vta-1618): added passNoSeatbeltFieldsWelsh template

feat(vta-1618): added passWelsh template

feat(vta-1618): added VTG30Welsh template

* VTA-1574: Generate Welsh Certificate HGV Pass (#88)

* feat(vta-1574): added models and updated logic to use vtg5 bilingual

* feat(vta-1574): updated naming convention so it makes more sense

* feat(vta-1574): added html verification test for vtg5

* feat(vta-1574): added tests for VTG5W

* feat(vta-1574): added tests for hgv pass bilingual

* feat(vta-1574): updated unit tests

* feat(vta-1574): refactored naming convention for statics

* feat(vta-1574): added welsh crest logo to passNoSeatbelts hbs

* feat(vta-1574): refactored unit tests, added welsh mileage translation

* feat(vta-1574): applied welsh miles logic to odometer history

* feat(vta-1574): refactored static

* VTA-1575: Generate Welsh certificate Trailer - Pass (#90)

* feat(vta-1575): welsh certificate for trailer pass

* feat(vta-1575): corrected data model on welsh trailer cert

* feat(vta-1575): identification number not registration number

* feat(vta-1575): regid or heading welsh

* feat(vta-1575): corrected regid or heading in bilingual model

* VTA-1576: Generate Welsh Certificate PSV Pass (#92)

* feat(vta-1576): added new models, updated enums and configs

* feat(vta-1576): corrected typo

* feat(vta-1576): added new tests

* feat(vta-1576): corrected formatting

* feat(cb2-9560): rebased against develop and removed loggers

* feat(cb2-9560): added logger for debug

* feat(cb2-9560): removed loggers used for debug

* CB2-9558: updated no data available, km and mi translations (#94)

* feat(cb2-9558): updated no data available, km and mi translations

* feat(cb2-9558): corrected typo on statics

* feat(cb2-9558): updated translation as per feedback

---------

Co-authored-by: Melanie Coslett <50204104+m-coslett@users.noreply.github.com>
  • Loading branch information
cb-cs and m-coslett authored Jan 22, 2024
1 parent af265ac commit 3ed7997
Show file tree
Hide file tree
Showing 27 changed files with 3,200 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/main/java/uk/gov/dvsa/enums/CertificateTemplates.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ public enum CertificateTemplates {
VT29("MOT/VT29"),

VTP20("CommercialVehicles/pass"),
VTP20W("CommercialVehicles/passWelsh"),
VTP30("CommercialVehicles/fail"),

VTG5("CommercialVehicles/passNoSeatbeltFields"),
VTG5W("CommercialVehicles/passNoSeatbeltFieldsWelsh"),
VTG5A("CommercialVehicles/passNoSeatbeltFields"),
VTG5AW("CommercialVehicles/passNoSeatbeltFieldsWelsh"),
VTG30("CommercialVehicles/VTG30"),
ADR_PASS("CommercialVehicles/ADR_PASS"),

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/uk/gov/dvsa/enums/CertificateTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ public enum CertificateTypes {
VT29("MOT/VT29"),

CVS_PASS("CVS/VTP20"),
CVS_PASS_WELSH("CVS/VTP20W"),
CVS_PASS_BILINGUAL("CVS/VTP20_BILINGUAL"),
CVS_FAIL("CVS/VTP30"),
CVS_PSV_PRS("CVS/PSV_PRS"),

CVS_HGV_PASS("CVS/VTG5"),
CVS_HGV_PASS_WELSH("CVS/VTG5W"),
CVS_HGV_PASS_BILINGUAL("CVS/VTG5_BILINGUAL"),
CVS_TRL_PASS("CVS/VTG5A"),
CVS_TRL_PASS_WELSH("CVS/VTG5AW"),
CVS_TRL_PASS_BILINGUAL("CVS/VTG5A_BILINGUAL"),
CVS_HGV_TRL_FAIL("CVS/VTG30"),
CVS_HGV_PRS("CVS/HGV_PRS"),
CVS_TRL_PRS("CVS/TRL_PRS"),
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/uk/gov/dvsa/enums/DocumentsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ public enum DocumentsConfig {
new String[]{CertificateTemplates.VTP20.getCertificateTemplateName(), CertificateTemplates.VTP30.getCertificateTemplateName()}),
VTP20(CertificateTypes.CVS_PASS.getCertificateType(), uk.gov.dvsa.model.cvs.VTP20.class,
new String[]{CertificateTemplates.VTP20.getCertificateTemplateName()}),
VTP20W(CertificateTypes.CVS_PASS_WELSH.getCertificateType(), uk.gov.dvsa.model.cvs.VTP20W.class,
new String[]{CertificateTemplates.VTP20W.getCertificateTemplateName()}),
VTP30(CertificateTypes.CVS_FAIL.getCertificateType(), uk.gov.dvsa.model.cvs.VTP30.class,
new String[]{CertificateTemplates.VTP30.getCertificateTemplateName()}),

VTG5A(CertificateTypes.CVS_TRL_PASS.getCertificateType(), uk.gov.dvsa.model.cvs.VTG5A.class,
new String[]{CertificateTemplates.VTG5A.getCertificateTemplateName()}),
VTG5AW(CertificateTypes.CVS_TRL_PASS_WELSH.getCertificateType(), uk.gov.dvsa.model.cvs.VTG5AW.class,
new String[]{CertificateTemplates.VTG5AW.getCertificateTemplateName()}),
VTG5(CertificateTypes.CVS_HGV_PASS.getCertificateType(), uk.gov.dvsa.model.cvs.VTG5.class,
new String[]{CertificateTemplates.VTG5.getCertificateTemplateName()}),
VTG5W(CertificateTypes.CVS_HGV_PASS_WELSH.getCertificateType(), uk.gov.dvsa.model.cvs.VTG5W.class,
new String[]{CertificateTemplates.VTG5W.getCertificateTemplateName()}),
VTG30(CertificateTypes.CVS_HGV_TRL_FAIL.getCertificateType(), uk.gov.dvsa.model.cvs.VTG30.class,
new String[]{CertificateTemplates.VTG30.getCertificateTemplateName()}),
ADR_PASS(CertificateTypes.ADR_PASS.getCertificateType(), AdrPassCertificate.class,
Expand All @@ -68,6 +74,12 @@ public enum DocumentsConfig {
new String[]{CertificateTemplates.RWT_DATA.getCertificateTemplateName()}),
CVS_HGV_PRS(CertificateTypes.CVS_HGV_PRS.getCertificateType(), uk.gov.dvsa.model.cvs.CvsHgvPRS.class,
new String[]{CertificateTemplates.VTG5.getCertificateTemplateName(), CertificateTemplates.VTG30.getCertificateTemplateName()}),
CVS_PASS_BILINGUAL(CertificateTypes.CVS_PASS_BILINGUAL.getCertificateType(), uk.gov.dvsa.model.cvs.CvsPsvPassBilingual.class,
new String[]{CertificateTemplates.VTP20.getCertificateTemplateName(), CertificateTemplates.VTP20W.getCertificateTemplateName()}),
CVS_HGV_PASS_BILINGUAL(CertificateTypes.CVS_HGV_PASS_BILINGUAL.getCertificateType(), uk.gov.dvsa.model.cvs.CvsHgvPassBilingual.class,
new String[]{CertificateTemplates.VTG5.getCertificateTemplateName(), CertificateTemplates.VTG5W.getCertificateTemplateName()}),
CVS_TRL_PASS_BILINGUAL(CertificateTypes.CVS_TRL_PASS_BILINGUAL.getCertificateType(), uk.gov.dvsa.model.cvs.CvsTrlPassBilingual.class,
new String[]{CertificateTemplates.VTG5A.getCertificateTemplateName(), CertificateTemplates.VTG5AW.getCertificateTemplateName()}),
CVS_TRL_PRS(CertificateTypes.CVS_TRL_PRS.getCertificateType(), uk.gov.dvsa.model.cvs.CvsTrlPRS.class,
new String[]{CertificateTemplates.VTG5A.getCertificateTemplateName(), CertificateTemplates.VTG30.getCertificateTemplateName()}),

Expand Down
28 changes: 28 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/CvsHgvPassBilingual.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.dvsa.model.cvs;

public class CvsHgvPassBilingual extends VTG5W {

public String getTestType() {
return "HGV";
}

public String getPresentedDocumentNamePass() {
return "VTG5";
}

public String getPresentedDocumentNamePassWelsh() {
return "VTG5W";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getVersionNumberPassWelsh() {
return "1.0";
}

public String getRegOrIdHeading() {
return "Registration number";
}
}
28 changes: 28 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/CvsPsvPassBilingual.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.dvsa.model.cvs;

public class CvsPsvPassBilingual extends VTP20W {

public String getTestType() {
return "PSV";
}

public String getPresentedDocumentNamePass() {
return "VTP20";
}

public String getPresentedDocumentNamePassWelsh() {
return "VTP20W";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getVersionNumberPassWelsh() {
return "1.0";
}

public String getRegOrIdHeading() {
return "Registration number";
}
}
28 changes: 28 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/CvsTrlPassBilingual.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.dvsa.model.cvs;

public class CvsTrlPassBilingual extends VTG5AW {

public String getTestType() {
return "Trailer";
}

public String getPresentedDocumentNamePass() {
return "VTG5A";
}

public String getPresentedDocumentNamePassWelsh() {
return "VTG5AW";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getVersionNumberPassWelsh() {
return "1.0";
}

public String getRegOrIdHeading() {
return "Identification number";
}
}
2 changes: 0 additions & 2 deletions src/main/java/uk/gov/dvsa/model/cvs/VTG5A.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ public String getVersionNumberPass() {
}

public String getRegOrIdHeading() { return "Identification number"; }


}
27 changes: 27 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/VTG5AW.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package uk.gov.dvsa.model.cvs;

import uk.gov.dvsa.model.Document;
import uk.gov.dvsa.model.cvs.certificateData.CvsMotCertificateData;
import uk.gov.dvsa.model.cvs.certificateData.CvsMotCertificateDataWelsh;

public class VTG5AW extends CvsMotCertificate {

public Document setData(CvsMotCertificateDataWelsh data) {
this.data = data;
return this;
}

public String getTestType() {
return "Trailer";
}

public String getPresentedDocumentNamePass() {
return "VTG5AW";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getRegOrIdHeadingWelsh() { return "Rhif adnabod"; }
}
28 changes: 28 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/VTG5W.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.dvsa.model.cvs;

import uk.gov.dvsa.model.Document;
import uk.gov.dvsa.model.cvs.certificateData.CvsMotCertificateDataWelsh;

public class VTG5W extends CvsMotCertificate {

public Document setData(CvsMotCertificateDataWelsh data) {
this.data = data;
return this;
}

public String getTestType() {
return "HGV";
}

public String getPresentedDocumentNamePass() {
return "VTG5W";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getRegOrIdHeadingWelsh() {
return "Rhif cofrestru";
}
}
28 changes: 28 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/VTP20W.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.dvsa.model.cvs;

import uk.gov.dvsa.model.Document;
import uk.gov.dvsa.model.cvs.certificateData.CvsMotCertificateDataWelsh;

public class VTP20W extends CvsMotCertificate {

public Document setData(CvsMotCertificateDataWelsh data) {
this.data = data;
return this;
}

public String getTestType() {
return "PSV";
}

public String getPresentedDocumentNamePass() {
return "VTP20W";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getRegOrIdHeadingWelsh() {
return "Rhif cofrestru";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package uk.gov.dvsa.model.cvs.certificateData;

import com.fasterxml.jackson.annotation.JsonProperty;
import uk.gov.dvsa.model.mot.certificateData.FormattedOdometerReading;
import uk.gov.dvsa.model.mot.results.DefectsList;
import uk.gov.dvsa.model.mot.results.Summary;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class CvsMotCertificateDataWelsh extends CvsMotCertificateData {

public static final String EU_NUMBER_FOR_DEFECTS = "6";
public static final String ADVISORIES_HEADER_WELSH = "Monitro a thrwsio os oes angen (cynghorol)";
public static final String MINOR_DEFECTS_HEADER_WELSH = "Atgyweiriwch cyn gynted â phosibl (ddiffygion bach)";
public static final String PASS_SUMMARY_HEADER_WELSH = "Llwyddo";
public static final String PASS_WITH_DEFECTS_HEADER_WELSH = "Llwyddo gyda diffygion";
public static final String TESTING_ORGANISATION_WELSH = "ASIANTAETH SAFONAU GYRWYR A CHERBYDAU";

@JsonProperty("AdvisoryDefectsWelsh")
private List<String> advisoryDefectsWelsh;

@JsonProperty("MinorDefectsWelsh")
private List<String> minorDefectsWelsh;

public Summary getSummaryWelsh() {
return new Summary(buildSummaryTitleWelsh());
}

private String buildSummaryTitleWelsh() {
if (!hasMinorDefects(minorDefectsWelsh)) {
return PASS_SUMMARY_HEADER_WELSH;
} else {
return PASS_WITH_DEFECTS_HEADER_WELSH;
}
}

public List<String> getAdvisoryDefectsWelsh() {
return advisoryDefectsWelsh;
}

public CvsMotCertificateDataWelsh setAdvisoryDefectsWelsh(List<String> advisoryDefectsWelsh) {
this.advisoryDefectsWelsh = advisoryDefectsWelsh;
return this;
}

public List<String> getMinorDefectsWelsh() {
return minorDefectsWelsh;
}

public CvsMotCertificateDataWelsh setMinorDefectsWelsh(List<String> minorDefectsWelsh) {
this.minorDefectsWelsh = minorDefectsWelsh;
return this;
}

public DefectsList getAdvisoryWelsh() {
return new DefectsList(ADVISORIES_HEADER_WELSH, this.advisoryDefectsWelsh);
}

public DefectsList getMinorWelsh() {
return new DefectsList(MINOR_DEFECTS_HEADER_WELSH, this.minorDefectsWelsh, EU_NUMBER_FOR_DEFECTS);
}

public String getTestingOrganisationWelsh() {
return TESTING_ORGANISATION_WELSH;
}

public String getFormattedCurrentOdometerWelsh() {
return ODOMETER_FORMATTER.formatWelshValue(getCurrentOdometer());
}

public List<FormattedOdometerReading> getMileageHistoryWelsh() {
if (null != getOdometerHistoryList()) {
return getOdometerHistoryList().stream()
.map(
entry -> new FormattedOdometerReading(
ODOMETER_FORMATTER.formatWelshValue(entry),
entry.getDate()
)
)
.collect(Collectors.toList());
} else {
return Collections.emptyList();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import org.apache.commons.lang3.StringUtils;
import uk.gov.dvsa.model.cvs.certificateData.CvsOdometerReading;
import uk.gov.dvsa.model.mot.certificateData.OdometerReading;

import java.util.Optional;

public class CvsOdometerReadingFormatter {

public static final String MILES = "miles";

public static final String MILES_WELSH = "milltiroedd";
private static final String MILES_UNIT = "mi";
public static final String KILOMETERS = "kilometres";
public static final String KILOMETERS_WELSH = "cilometrau";
private static final String KILOMETERS_UNIT = "km";
private static final String THOUSANDS_PATTERN = "\\B(?=(?:.{3})+$)";
private static final String THOUSANDS_SEPARATOR = ",";
Expand All @@ -30,12 +31,29 @@ public String formatValue(CvsOdometerReading odometer) {
.orElse("");
}

public String formatWelshValue(CvsOdometerReading odometer) {
if (odometer == null) {
return "";
}

if (isRemark(odometer)) {
return odometer.getValue();
}

return formatNumberValue(odometer.getValue()) +
Optional.ofNullable(odometer.getUnit())
.map(unit -> " " + formatUnit(unit, true))
.orElse("");
}

private String formatUnit(String unit, Boolean unitWelsh) {
switch (unit) {
case MILES:
case MILES_UNIT:
return MILES;
return unitWelsh.equals(Boolean.TRUE) ? MILES_WELSH : MILES;
case KILOMETERS:
case KILOMETERS_UNIT:
return "km";
return unitWelsh.equals(Boolean.TRUE) ? KILOMETERS_WELSH : KILOMETERS;
default:
return unit;
}
Expand Down
Loading

0 comments on commit 3ed7997

Please sign in to comment.