Add legal entity
This commit is contained in:
parent
7b322ef7fb
commit
b9c218111a
5 changed files with 61 additions and 5 deletions
7
src/Nyanlabs.Umogen.Core/Models/IEntity.cs
Normal file
7
src/Nyanlabs.Umogen.Core/Models/IEntity.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace Nyanlabs.Umogen.Core.Models;
|
||||||
|
|
||||||
|
public interface IEntity : INLSerializable
|
||||||
|
{
|
||||||
|
public string GetName();
|
||||||
|
public string? IdCode();
|
||||||
|
}
|
24
src/Nyanlabs.Umogen.Core/Models/LegalEntity.cs
Normal file
24
src/Nyanlabs.Umogen.Core/Models/LegalEntity.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
namespace Nyanlabs.Umogen.Core.Models;
|
||||||
|
|
||||||
|
public class LegalEntity(string Name, string? Nip = null, string? Headquarters = null, Person? Representative = null) : IEntity, INLSerializable
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = Name;
|
||||||
|
public string? Nip { get; set; } = Nip;
|
||||||
|
public string? Headquarters { get; set; } = Headquarters;
|
||||||
|
public Person? Representative { get; set; } = Representative;
|
||||||
|
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? IdCode()
|
||||||
|
{
|
||||||
|
return Nip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NLSerialize()
|
||||||
|
{
|
||||||
|
return $"{Name}; with NIP {Nip ?? "unknown"}{(Headquarters != null ? $"; located in {Headquarters}" : "")}{(Representative != null ? $"; represented by {Representative.GetName()}" : "")}";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Nyanlabs.Umogen.Core.Models;
|
namespace Nyanlabs.Umogen.Core.Models;
|
||||||
|
|
||||||
public record Person(string Name, string Surname, string? Id = null, string? Pesel = null, DateTime? DoB = null) : INLSerializable
|
public record Person(string Name, string Surname, string? Id = null, string? Pesel = null, DateTime? DoB = null) : IEntity, INLSerializable
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = Name;
|
public string Name { get; set; } = Name;
|
||||||
public string Surname { get; set; } = Surname;
|
public string Surname { get; set; } = Surname;
|
||||||
|
@ -8,6 +8,16 @@ public record Person(string Name, string Surname, string? Id = null, string? Pes
|
||||||
public string? Pesel { get; set; } = Pesel;
|
public string? Pesel { get; set; } = Pesel;
|
||||||
public DateTime? DoB { get; set; } = DoB;
|
public DateTime? DoB { get; set; } = DoB;
|
||||||
|
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return $"{Name} {Surname}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? IdCode()
|
||||||
|
{
|
||||||
|
return IDCode!;
|
||||||
|
}
|
||||||
|
|
||||||
public string NLSerialize()
|
public string NLSerialize()
|
||||||
{
|
{
|
||||||
return $"{Name} {Surname}; {(Pesel != null ? $"PESEL {Pesel}" : "unknown PESEL")}; {(IDCode != null ? $"ID series {IDCode}" : "unknown ID series")}; {(DoB != null ? $"born {DoB.Value:dd MMM yyyy}" : "unknown date of birth")}";
|
return $"{Name} {Surname}; {(Pesel != null ? $"PESEL {Pesel}" : "unknown PESEL")}; {(IDCode != null ? $"ID series {IDCode}" : "unknown ID series")}; {(DoB != null ? $"born {DoB.Value:dd MMM yyyy}" : "unknown date of birth")}";
|
||||||
|
|
|
@ -30,7 +30,7 @@ public static class UmoDoctypeBindings
|
||||||
|
|
||||||
public class UmoDocument : INLSerializable
|
public class UmoDocument : INLSerializable
|
||||||
{
|
{
|
||||||
public UmoDocument(UmoDoctype type, Person employer, Person employee, ValidTime? validTime = null)
|
public UmoDocument(UmoDoctype type, IEntity employer, Person employee, ValidTime? validTime = null)
|
||||||
{
|
{
|
||||||
Doctype = type;
|
Doctype = type;
|
||||||
Employer = employer;
|
Employer = employer;
|
||||||
|
@ -39,7 +39,7 @@ public class UmoDocument : INLSerializable
|
||||||
}
|
}
|
||||||
|
|
||||||
public UmoDoctype Doctype { get; set; }
|
public UmoDoctype Doctype { get; set; }
|
||||||
public Person Employer { get; set; }
|
public IEntity Employer { get; set; }
|
||||||
public Person Employee { get; set; }
|
public Person Employee { get; set; }
|
||||||
//Null is 'unspecified time'
|
//Null is 'unspecified time'
|
||||||
public ValidTime? ValidTime { get; set; }
|
public ValidTime? ValidTime { get; set; }
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class NLSerializationTests
|
||||||
var query = doc.NLSerialize();
|
var query = doc.NLSerialize();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
Assert.Equal($"Contract of Employment for {ModelEmployee.NLSerialize()} working for {ModelEmployer.NLSerialize()}; valid for unspecified time.", query);
|
Assert.Equal($"Umowa o Pracę for {ModelEmployee.NLSerialize()} working for {ModelEmployer.NLSerialize()}; valid for unspecified time.", query);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -31,7 +31,7 @@ public class NLSerializationTests
|
||||||
var query = doc.NLSerialize();
|
var query = doc.NLSerialize();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
Assert.Equal($"Contract of Employment for {ModelEmployee.NLSerialize()} working for {ModelEmployer.NLSerialize()}; valid from 17 Nov 2023 until 18 Nov 2023.", query);
|
Assert.Equal($"Umowa o Pracę for {ModelEmployee.NLSerialize()} working for {ModelEmployer.NLSerialize()}; valid from 17 Nov 2023 until 18 Nov 2023.", query);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -64,4 +64,19 @@ public class NLSerializationTests
|
||||||
// Then
|
// Then
|
||||||
Assert.Equal("Kotek Miauczyński; unknown PESEL; unknown ID series; unknown date of birth", query);
|
Assert.Equal("Kotek Miauczyński; unknown PESEL; unknown ID series; unknown date of birth", query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LegalEntity ModelCompany => new("Nyanbyte P.S.A.", "1313131313", "Miaumiaśna 13, Miauczki", ModelEmployer);
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CompanySerializationTest()
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
LegalEntity company = ModelCompany;
|
||||||
|
|
||||||
|
// When
|
||||||
|
var query = company.NLSerialize();
|
||||||
|
|
||||||
|
// Then
|
||||||
|
Assert.Equal("Nyanbyte P.S.A.; with NIP 1313131313; located in Miaumiaśna 13, Miauczki; represented by Kotek Miauczyński", query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue