Skip to content

Commit

Permalink
Merge pull request #906 from uktrade/strip-territory-codes-for-hmrc
Browse files Browse the repository at this point in the history
Strip territory code for HMRC.
  • Loading branch information
alixedi authored Jan 25, 2022
2 parents 1a95567 + 873e1b3 commit 4bf08b9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/licences/serializers/hmrc_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ class HMRCIntegrationCountrySerializer(serializers.Serializer):
id = serializers.CharField()
name = serializers.CharField()

def strip_territory_code(self, country_code):
"""Does nothing for "GB" but transforms "AE-DU" to "AE".
"""
return country_code.split("-")[0]

def to_representation(self, data):
data = super().to_representation(data)
data["id"] = self.strip_territory_code(data["id"])
return data


class HMRCIntegrationAddressSerializer(serializers.Serializer):
line_1 = serializers.SerializerMethodField()
Expand Down

0 comments on commit 4bf08b9

Please sign in to comment.