diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/ClientResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/ClientResponse.cs index 9dd9546..b2511b7 100644 --- a/DoliMiddlewareApi/Dtos/Dolibarr/ClientResponse.cs +++ b/DoliMiddlewareApi/Dtos/Dolibarr/ClientResponse.cs @@ -3,21 +3,19 @@ namespace DoliMiddlewareApi.Dtos.Dolibarr; public class ClientResponse { public string? id { get; set; } - - // Nombre comercial / razón social public string? name { get; set; } - - // Código cliente (CUxxxx) public string? code_client { get; set; } - - // Tipo de entidad public string? typent_code { get; set; } - - // Estado public string? status { get; set; } - - // Contacto public string? email { get; set; } public string? phone { get; set; } - + public string? address { get; set; } + public string? zip { get; set; } + public string? town { get; set; } + public string? country_code { get; set; } + public string? tva_intra { get; set; } + public string? url { get; set; } + public string? note_public { get; set; } + public string? note_private { get; set; } + public string? client { get; set; } } \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/ContactResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/ContactResponse.cs index 851de43..eb21369 100644 --- a/DoliMiddlewareApi/Dtos/Dolibarr/ContactResponse.cs +++ b/DoliMiddlewareApi/Dtos/Dolibarr/ContactResponse.cs @@ -3,18 +3,16 @@ namespace DoliMiddlewareApi.Dtos.Dolibarr; public class ContactResponse { public string? id { get; set; } - public string? lastname { get; set; } - public string? firstname { get; set; } - public string? email { get; set; } - public string? phone_pro { get; set; } - public string? phone_perso { get; set; } - public string? phone_mobile { get; set; } - public string? fk_soc { get; set; } + public string? address { get; set; } + public string? zip { get; set; } + public string? town { get; set; } + public string? civility_code { get; set; } + public string? statut { get; set; } } diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CivilityResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CivilityResponse.cs new file mode 100644 index 0000000..40fb855 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CivilityResponse.cs @@ -0,0 +1,8 @@ +namespace DoliMiddlewareApi.Dtos.Dolibarr.Setup; + +public class CivilityResponse +{ + public string? id { get; set; } + public string? code { get; set; } + public string? label { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CompanyResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CompanyResponse.cs new file mode 100644 index 0000000..859bfc1 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CompanyResponse.cs @@ -0,0 +1,14 @@ +namespace DoliMiddlewareApi.Dtos.Dolibarr.Setup; + +public class CompanyResponse +{ + public string? name { get; set; } + public string? address { get; set; } + public string? town { get; set; } + public string? zip { get; set; } + public string? country { get; set; } + public string? phone { get; set; } + public string? email { get; set; } + public string? idprof1 { get; set; } + public string? tva_intra { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/Setup/ContactTypeResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/ContactTypeResponse.cs new file mode 100644 index 0000000..63e7db5 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/ContactTypeResponse.cs @@ -0,0 +1,9 @@ +namespace DoliMiddlewareApi.Dtos.Dolibarr.Setup; + +public class ContactTypeResponse +{ + public string? id { get; set; } + public string? code { get; set; } + public string? label { get; set; } + public string? module { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CountryResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CountryResponse.cs new file mode 100644 index 0000000..9287ba6 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/CountryResponse.cs @@ -0,0 +1,13 @@ +namespace DoliMiddlewareApi.Dtos.Dolibarr.Setup; + +public class CountryResponse +{ + public string? id { get; set; } + public string? code { get; set; } + public string? label { get; set; } + public string? code_iso { get; set; } + public string? numeric_code { get; set; } + public string? active { get; set; } + public string? eec { get; set; } + public string? favorite { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/Setup/PaymentTermResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/PaymentTermResponse.cs new file mode 100644 index 0000000..33c1144 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/PaymentTermResponse.cs @@ -0,0 +1,12 @@ +namespace DoliMiddlewareApi.Dtos.Dolibarr.Setup; + +public class PaymentTermResponse +{ + public string? id { get; set; } + public string? code { get; set; } + public string? label { get; set; } + public string? descr { get; set; } + public string? nbjour { get; set; } + public string? type_cdr { get; set; } + public string? module { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/Dolibarr/Setup/PaymentTypeResponse.cs b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/PaymentTypeResponse.cs new file mode 100644 index 0000000..22a5c60 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/Dolibarr/Setup/PaymentTypeResponse.cs @@ -0,0 +1,10 @@ +namespace DoliMiddlewareApi.Dtos.Dolibarr.Setup; + +public class PaymentTypeResponse +{ + public string? id { get; set; } + public string? code { get; set; } + public string? type { get; set; } + public string? label { get; set; } + public string? module { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/command/CreateClientDto.cs b/DoliMiddlewareApi/Dtos/command/CreateClientDto.cs new file mode 100644 index 0000000..904b5bb --- /dev/null +++ b/DoliMiddlewareApi/Dtos/command/CreateClientDto.cs @@ -0,0 +1,42 @@ +using System.ComponentModel.DataAnnotations; + +namespace DoliMiddlewareApi.Dtos.command; + +public class CreateClientDto +{ + [Required] + [StringLength(200)] + public string Name { get; set; } = ""; + + [StringLength(50)] + public string? Address { get; set; } + + [StringLength(50)] + public string? Zip { get; set; } + + [StringLength(50)] + public string? Town { get; set; } + + [StringLength(20)] + public string? Phone { get; set; } + + [EmailAddress] + [StringLength(200)] + public string? Email { get; set; } + + [StringLength(50)] + public string? CountryCode { get; set; } + + [StringLength(50)] + public string? VatNumber { get; set; } + + [Url] + [StringLength(255)] + public string? Url { get; set; } + + [StringLength(500)] + public string? NotePublic { get; set; } + + [StringLength(500)] + public string? NotePrivate { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/command/CreateContactDto.cs b/DoliMiddlewareApi/Dtos/command/CreateContactDto.cs new file mode 100644 index 0000000..bee5c61 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/command/CreateContactDto.cs @@ -0,0 +1,38 @@ +using System.ComponentModel.DataAnnotations; + +namespace DoliMiddlewareApi.Dtos.command; + +public class CreateContactDto +{ + [Required] + [StringLength(100)] + public string Lastname { get; set; } = ""; + + [StringLength(100)] + public string? Firstname { get; set; } + + [Range(1, int.MaxValue)] + public int ClientId { get; set; } + + [EmailAddress] + [StringLength(200)] + public string? Email { get; set; } + + [StringLength(50)] + public string? PhonePro { get; set; } + + [StringLength(50)] + public string? PhonePerso { get; set; } + + [StringLength(50)] + public string? PhoneMobile { get; set; } + + [StringLength(255)] + public string? Address { get; set; } + + [StringLength(50)] + public string? Zip { get; set; } + + [StringLength(50)] + public string? Town { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/command/UpdateClientDto.cs b/DoliMiddlewareApi/Dtos/command/UpdateClientDto.cs new file mode 100644 index 0000000..85ac22d --- /dev/null +++ b/DoliMiddlewareApi/Dtos/command/UpdateClientDto.cs @@ -0,0 +1,41 @@ +using System.ComponentModel.DataAnnotations; + +namespace DoliMiddlewareApi.Dtos.command; + +public class UpdateClientDto +{ + [StringLength(200)] + public string? Name { get; set; } + + [StringLength(50)] + public string? Address { get; set; } + + [StringLength(50)] + public string? Zip { get; set; } + + [StringLength(50)] + public string? Town { get; set; } + + [StringLength(20)] + public string? Phone { get; set; } + + [EmailAddress] + [StringLength(200)] + public string? Email { get; set; } + + [StringLength(50)] + public string? CountryCode { get; set; } + + [StringLength(50)] + public string? VatNumber { get; set; } + + [Url] + [StringLength(255)] + public string? Url { get; set; } + + [StringLength(500)] + public string? NotePublic { get; set; } + + [StringLength(500)] + public string? NotePrivate { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/command/UpdateContactDto.cs b/DoliMiddlewareApi/Dtos/command/UpdateContactDto.cs new file mode 100644 index 0000000..94ae66d --- /dev/null +++ b/DoliMiddlewareApi/Dtos/command/UpdateContactDto.cs @@ -0,0 +1,34 @@ +using System.ComponentModel.DataAnnotations; + +namespace DoliMiddlewareApi.Dtos.command; + +public class UpdateContactDto +{ + [StringLength(100)] + public string? Lastname { get; set; } + + [StringLength(100)] + public string? Firstname { get; set; } + + [EmailAddress] + [StringLength(200)] + public string? Email { get; set; } + + [StringLength(50)] + public string? PhonePro { get; set; } + + [StringLength(50)] + public string? PhonePerso { get; set; } + + [StringLength(50)] + public string? PhoneMobile { get; set; } + + [StringLength(255)] + public string? Address { get; set; } + + [StringLength(50)] + public string? Zip { get; set; } + + [StringLength(50)] + public string? Town { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/command/UpdateInvoiceLineDto.cs b/DoliMiddlewareApi/Dtos/command/UpdateInvoiceLineDto.cs new file mode 100644 index 0000000..dc742b7 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/command/UpdateInvoiceLineDto.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; +using System.Globalization; + +namespace DoliMiddlewareApi.Dtos.command; + +public class UpdateInvoiceLineDto +{ + [StringLength(500)] + public string? Description { get; set; } + + [Range(0.01, double.MaxValue)] + public decimal? Quantity { get; set; } + + [Range(0, double.MaxValue)] + public decimal? UnitPrice { get; set; } + + [Range(0, 100)] + public decimal? TaxRate { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/ClientDetailDto.cs b/DoliMiddlewareApi/Dtos/query/ClientDetailDto.cs new file mode 100644 index 0000000..d442b48 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/ClientDetailDto.cs @@ -0,0 +1,21 @@ +namespace DoliMiddlewareApi.Dtos.query; + +public class ClientDetailDto +{ + public int Id { get; set; } + public required string Name { get; set; } + public string? CodeClient { get; set; } + public string? TypentCode { get; set; } + public string? Status { get; set; } + public string? Email { get; set; } + public string? Phone { get; set; } + public string? Address { get; set; } + public string? Town { get; set; } + public string? Zip { get; set; } + public string? CountryCode { get; set; } + public string? VatNumber { get; set; } + public string? Url { get; set; } + public string? NotePublic { get; set; } + public string? NotePrivate { get; set; } + public List Contacts { get; set; } = new(); +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/ContactDetailDto.cs b/DoliMiddlewareApi/Dtos/query/ContactDetailDto.cs new file mode 100644 index 0000000..5498c4d --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/ContactDetailDto.cs @@ -0,0 +1,18 @@ +namespace DoliMiddlewareApi.Dtos.query; + +public class ContactDetailDto +{ + public int Id { get; set; } + public string? Lastname { get; set; } + public string? Firstname { get; set; } + public string? Email { set; get; } + public string? PhonePro { get; set; } + public string? PhonePerso { get; set; } + public string? PhoneMobile { get; set; } + public int ClientId { get; set; } + public string? Address { get; set; } + public string? Town { get; set; } + public string? Zip { get; set; } + public string? CivilityCode { get; set; } + public string? Status { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/Setup/CivilityDto.cs b/DoliMiddlewareApi/Dtos/query/Setup/CivilityDto.cs new file mode 100644 index 0000000..a0d40ff --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/Setup/CivilityDto.cs @@ -0,0 +1,8 @@ +namespace DoliMiddlewareApi.Dtos.query.Setup; + +public class CivilityDto +{ + public string? Id { get; set; } + public string? Code { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/Setup/CompanyDto.cs b/DoliMiddlewareApi/Dtos/query/Setup/CompanyDto.cs new file mode 100644 index 0000000..1fe78b5 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/Setup/CompanyDto.cs @@ -0,0 +1,14 @@ +namespace DoliMiddlewareApi.Dtos.query.Setup; + +public class CompanyDto +{ + public string? Name { get; set; } + public string? Address { get; set; } + public string? Town { get; set; } + public string? Zip { get; set; } + public string? Country { get; set; } + public string? Phone { get; set; } + public string? Email { get; set; } + public string? VatNumber { get; set; } + public string? Siren { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/Setup/ContactTypeDto.cs b/DoliMiddlewareApi/Dtos/query/Setup/ContactTypeDto.cs new file mode 100644 index 0000000..95ad80e --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/Setup/ContactTypeDto.cs @@ -0,0 +1,8 @@ +namespace DoliMiddlewareApi.Dtos.query.Setup; + +public class ContactTypeDto +{ + public string? Id { get; set; } + public string? Code { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/Setup/CountryDto.cs b/DoliMiddlewareApi/Dtos/query/Setup/CountryDto.cs new file mode 100644 index 0000000..48b61b3 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/Setup/CountryDto.cs @@ -0,0 +1,11 @@ +namespace DoliMiddlewareApi.Dtos.query.Setup; + +public class CountryDto +{ + public string? Id { get; set; } + public string? Code { get; set; } + public string? Label { get; set; } + public string? CodeIso { get; set; } + public string? NumericCode { get; set; } + public bool Active { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/Setup/PaymentTermDto.cs b/DoliMiddlewareApi/Dtos/query/Setup/PaymentTermDto.cs new file mode 100644 index 0000000..6ec1c34 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/Setup/PaymentTermDto.cs @@ -0,0 +1,10 @@ +namespace DoliMiddlewareApi.Dtos.query.Setup; + +public class PaymentTermDto +{ + public string? Id { get; set; } + public string? Code { get; set; } + public string? Label { get; set; } + public string? Description { get; set; } + public string? Nbjour { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Dtos/query/Setup/PaymentTypeDto.cs b/DoliMiddlewareApi/Dtos/query/Setup/PaymentTypeDto.cs new file mode 100644 index 0000000..e00cf96 --- /dev/null +++ b/DoliMiddlewareApi/Dtos/query/Setup/PaymentTypeDto.cs @@ -0,0 +1,9 @@ +namespace DoliMiddlewareApi.Dtos.query.Setup; + +public class PaymentTypeDto +{ + public string? Id { get; set; } + public string? Code { get; set; } + public string? Label { get; set; } + public string? Type { get; set; } +} \ No newline at end of file diff --git a/DoliMiddlewareApi/Mappers/ClientMapper.cs b/DoliMiddlewareApi/Mappers/ClientMapper.cs index ffb0d97..febb44e 100644 --- a/DoliMiddlewareApi/Mappers/ClientMapper.cs +++ b/DoliMiddlewareApi/Mappers/ClientMapper.cs @@ -3,9 +3,8 @@ using DoliMiddlewareApi.Dtos.query; namespace DoliMiddlewareApi.Mappers; -public class ClientMapper +public static class ClientMapper { - public static ClientDto MapToClientDto(ClientResponse clientResponse, List contacts) { var clientId = int.TryParse(clientResponse.id, out int id) ? id : 0; @@ -37,4 +36,28 @@ public class ClientMapper }; } + public static ClientDetailDto MapToClientDetailDto(ClientResponse r, List contacts) + { + var clientId = int.TryParse(r.id, out int id) ? id : 0; + + return new ClientDetailDto + { + Id = clientId, + Name = r.name ?? "", + CodeClient = r.code_client, + TypentCode = r.typent_code, + Status = r.status, + Email = r.email, + Phone = r.phone, + Address = r.address, + Town = r.town, + Zip = r.zip, + CountryCode = r.country_code, + VatNumber = r.tva_intra, + Url = r.url, + NotePublic = r.note_public, + NotePrivate = r.note_private, + Contacts = contacts.Where(c => c.ClientId == clientId).ToList() + }; + } } \ No newline at end of file diff --git a/DoliMiddlewareApi/Mappers/ContactMapper.cs b/DoliMiddlewareApi/Mappers/ContactMapper.cs index 896b364..83fdaab 100644 --- a/DoliMiddlewareApi/Mappers/ContactMapper.cs +++ b/DoliMiddlewareApi/Mappers/ContactMapper.cs @@ -3,7 +3,7 @@ using DoliMiddlewareApi.Dtos.query; namespace DoliMiddlewareApi.Mappers; -public class ContactMapper +public static class ContactMapper { public static ContactDto MapToContactDto(ContactResponse contactResponse) { @@ -19,4 +19,29 @@ public class ContactMapper ClientId = int.TryParse(contactResponse.fk_soc, out int clientId) ? clientId : 0 }; } + + public static ContactDetailDto MapToContactDetailDto(ContactResponse r) + { + return new ContactDetailDto + { + Id = int.TryParse(r.id, out int id) ? id : 0, + Lastname = r.lastname, + Firstname = r.firstname, + Email = r.email, + PhonePro = r.phone_pro, + PhonePerso = r.phone_perso, + PhoneMobile = r.phone_mobile, + ClientId = int.TryParse(r.fk_soc, out int clientId) ? clientId : 0, + Address = r.address, + Town = r.town, + Zip = r.zip, + CivilityCode = r.civility_code, + Status = r.statut switch + { + "0" => "inactive", + "1" => "active", + _ => r.statut + } + }; + } } diff --git a/DoliMiddlewareApi/Mappers/InvoiceMapper.cs b/DoliMiddlewareApi/Mappers/InvoiceMapper.cs index 3197dd9..1305621 100644 --- a/DoliMiddlewareApi/Mappers/InvoiceMapper.cs +++ b/DoliMiddlewareApi/Mappers/InvoiceMapper.cs @@ -96,6 +96,7 @@ public static class InvoiceMapper "0" => "draft", "1" => "unpaid", "2" => "paid", + "3" => "cancelled", _ => "unknown" }; } diff --git a/DoliMiddlewareApi/Mappers/SetupMapper.cs b/DoliMiddlewareApi/Mappers/SetupMapper.cs new file mode 100644 index 0000000..348c493 --- /dev/null +++ b/DoliMiddlewareApi/Mappers/SetupMapper.cs @@ -0,0 +1,79 @@ +using DoliMiddlewareApi.Dtos.Dolibarr.Setup; +using DoliMiddlewareApi.Dtos.query.Setup; + +namespace DoliMiddlewareApi.Mappers; + +public static class SetupMapper +{ + public static PaymentTypeDto MapToPaymentTypeDto(PaymentTypeResponse r) + { + return new PaymentTypeDto + { + Id = r.id, + Code = r.code, + Label = r.label, + Type = r.type + }; + } + + public static CountryDto MapToCountryDto(CountryResponse r) + { + return new CountryDto + { + Id = r.id, + Code = r.code, + Label = r.label, + CodeIso = r.code_iso, + NumericCode = r.numeric_code, + Active = r.active == "1" + }; + } + + public static CivilityDto MapToCivilityDto(CivilityResponse r) + { + return new CivilityDto + { + Id = r.id, + Code = r.code, + Label = r.label + }; + } + + public static ContactTypeDto MapToContactTypeDto(ContactTypeResponse r) + { + return new ContactTypeDto + { + Id = r.id, + Code = r.code, + Label = r.label + }; + } + + public static PaymentTermDto MapToPaymentTermDto(PaymentTermResponse r) + { + return new PaymentTermDto + { + Id = r.id, + Code = r.code, + Label = r.label, + Description = r.descr, + Nbjour = r.nbjour + }; + } + + public static CompanyDto MapToCompanyDto(CompanyResponse r) + { + return new CompanyDto + { + Name = r.name, + Address = r.address, + Town = r.town, + Zip = r.zip, + Country = r.country, + Phone = r.phone, + Email = r.email, + VatNumber = r.tva_intra, + Siren = r.idprof1 + }; + } +} \ No newline at end of file