[fix:] plz/pplz was not normalized during address creation
This commit is contained in:
@@ -104,8 +104,9 @@ public static class AddressCreator
|
|||||||
// Alternative A: pplz valid and city existing
|
// Alternative A: pplz valid and city existing
|
||||||
if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.pplz, address.land))
|
if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.pplz, address.land))
|
||||||
{
|
{
|
||||||
KasPerson.SetUsedPLZ(id, address.pplz);
|
string pplz = NormalizeGermanPLZ(address.pplz);
|
||||||
string_address = address.pplz + " " + address.ort + "\n" + string_address;
|
KasPerson.SetUsedPLZ(id, pplz);
|
||||||
|
string_address = pplz + " " + address.ort + "\n" + string_address;
|
||||||
address_line_count++;
|
address_line_count++;
|
||||||
if (!string.IsNullOrWhiteSpace(address.postfach))
|
if (!string.IsNullOrWhiteSpace(address.postfach))
|
||||||
{
|
{
|
||||||
@@ -151,8 +152,9 @@ public static class AddressCreator
|
|||||||
} // Alternative B: plz valid and city existing
|
} // Alternative B: plz valid and city existing
|
||||||
else if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.plz, address.land))
|
else if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.plz, address.land))
|
||||||
{
|
{
|
||||||
KasPerson.SetUsedPLZ(id, address.plz);
|
string plz = NormalizeGermanPLZ(address.plz);
|
||||||
string_address = address.plz + " " + address.ort + "\n" + string_address;
|
KasPerson.SetUsedPLZ(id, plz);
|
||||||
|
string_address = plz + " " + address.ort + "\n" + string_address;
|
||||||
address_line_count++;
|
address_line_count++;
|
||||||
if (!string.IsNullOrWhiteSpace(address.strasse))
|
if (!string.IsNullOrWhiteSpace(address.strasse))
|
||||||
{
|
{
|
||||||
@@ -251,4 +253,23 @@ public static class AddressCreator
|
|||||||
// For non-German countries, accept any non-empty postal code
|
// For non-German countries, accept any non-empty postal code
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string NormalizeGermanPLZ(string plz)
|
||||||
|
{
|
||||||
|
if(plz.Length == 5) return plz;
|
||||||
|
if(plz.Length > 5)
|
||||||
|
{
|
||||||
|
return plz.Substring(0, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plz.Length < 5)
|
||||||
|
{
|
||||||
|
int toadd = 5 - plz.Length;
|
||||||
|
for (int i = 0; i < toadd; i++)
|
||||||
|
{
|
||||||
|
plz = "0" + plz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return plz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user