2022-03-14 17:59:22 +01:00
|
|
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
2022-05-31 19:07:39 +02:00
|
|
|
// it under the terms of the GNU Affero General Public License as
|
2022-03-14 17:59:22 +01:00
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2022-05-31 19:07:39 +02:00
|
|
|
// GNU Affero General Public License for more details.
|
2022-03-14 17:59:22 +01:00
|
|
|
//
|
2022-05-31 19:07:39 +02:00
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
2022-03-14 17:59:22 +01:00
|
|
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
|
|
|
//
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
namespace Wonky.Entity.DTO;
|
|
|
|
|
2022-05-31 19:07:39 +02:00
|
|
|
public class CompanyDto
|
2022-03-14 17:59:22 +01:00
|
|
|
{
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Name
|
|
|
|
/// </summary>
|
|
|
|
[Required(ErrorMessage = "Navn skal udfyldes")]
|
|
|
|
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")]
|
|
|
|
public string Name { get; set; } = "";
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Postal code
|
|
|
|
/// </summary>
|
|
|
|
[Required(ErrorMessage = "Postnummer skal udfyldes")]
|
|
|
|
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
|
|
|
|
public string ZipCode { get; set; } = "";
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// City name
|
|
|
|
/// </summary>
|
|
|
|
[Required(ErrorMessage = "Bynavn skal udfyldes")]
|
|
|
|
[MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")]
|
|
|
|
public string City { get; set; } = "";
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// VAT number
|
|
|
|
/// </summary>
|
2022-06-28 10:07:38 +02:00
|
|
|
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
|
2022-06-08 18:52:00 +02:00
|
|
|
public string VatNumber { get; set; } = "";
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Company Id
|
|
|
|
/// </summary>
|
2022-03-14 17:59:22 +01:00
|
|
|
public string CompanyId { get; set; } = "";
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Sales representative entity Id
|
|
|
|
/// </summary>
|
2022-03-14 17:59:22 +01:00
|
|
|
public string SalesRepId { get; set; } = "";
|
2022-09-14 13:45:55 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// SalesRep ERP identifier
|
|
|
|
/// </summary>
|
|
|
|
public string SalesRep { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Business Central entity Id
|
|
|
|
/// </summary>
|
2022-03-15 18:11:01 +01:00
|
|
|
public string BcId { get; set; } = "";
|
2022-06-28 10:07:38 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Office address 1
|
|
|
|
/// </summary>
|
2022-06-19 13:55:29 +02:00
|
|
|
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")]
|
|
|
|
public string Address1 { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Office address 2
|
|
|
|
/// </summary>
|
2022-06-19 13:55:29 +02:00
|
|
|
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")]
|
|
|
|
public string Address2 { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Account number
|
|
|
|
/// </summary>
|
2022-06-19 13:55:29 +02:00
|
|
|
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
|
|
|
|
public string Account { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Phone number
|
|
|
|
/// </summary>
|
2022-06-19 13:55:29 +02:00
|
|
|
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
|
|
|
|
public string Phone { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Mobile phone number
|
|
|
|
/// </summary>
|
2022-06-19 13:55:29 +02:00
|
|
|
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")]
|
|
|
|
public string Mobile { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Office email
|
|
|
|
/// </summary>
|
2022-06-19 13:55:29 +02:00
|
|
|
[MaxLength(80, ErrorMessage = "Du kan højst bruge 80 tegn")]
|
|
|
|
public string Email { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Attention
|
|
|
|
/// </summary>
|
2022-06-19 13:55:29 +02:00
|
|
|
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")]
|
|
|
|
public string Attention { get; set; } = "";
|
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Country code ISO
|
|
|
|
/// </summary>
|
2022-06-08 18:52:00 +02:00
|
|
|
public string CountryCode { get; set; } = "";
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Last visit
|
|
|
|
/// </summary>
|
|
|
|
public string LastVisit { get; set; } = "2010-01-01";
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Next visit
|
|
|
|
/// </summary>
|
|
|
|
public string NextVisit { get; set; } = "2010-01-01";
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Interval between visits
|
|
|
|
/// </summary>
|
|
|
|
/// <value>between 1 and 52 (inclusive) default value is 8</value>
|
2022-06-08 18:52:00 +02:00
|
|
|
[Range(1, 52, ErrorMessage = "Angiv interval mellem 1 og 52 uger")]
|
2022-03-18 15:06:23 +01:00
|
|
|
public int Interval { get; set; } = 8;
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Value indication if company has shutdown
|
|
|
|
/// </summary>
|
|
|
|
/// <value>0 or 1</value>
|
2022-04-03 11:50:33 +02:00
|
|
|
public int HasFolded { get; set; }
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// User value for hiding the company is out of business
|
|
|
|
/// </summary>
|
|
|
|
/// <value>0 or 1</value>
|
2022-06-08 18:52:00 +02:00
|
|
|
public int IsHidden { get; set; }
|
2022-07-01 10:02:29 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Value indicating the VAT number is valid
|
|
|
|
/// </summary>
|
|
|
|
/// <value>0 or 1</value>
|
2022-05-31 19:07:39 +02:00
|
|
|
public int ValidVat { get; set; }
|
2022-06-19 13:55:29 +02:00
|
|
|
|
2022-07-01 10:02:29 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Value indicating if VAT number has changed and should be written to ERP record
|
|
|
|
/// </summary>
|
|
|
|
/// <value>0 or 1</value>
|
|
|
|
public int UpdateErpVat { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Date for last sync of product history
|
|
|
|
/// </summary>
|
|
|
|
public string HistorySync { get; set; } = "";
|
2022-08-30 15:21:39 +02:00
|
|
|
|
|
|
|
public int IsDirty { get; set; } = 0;
|
2022-07-01 10:02:29 +02:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Virtual property indicating if timespan is within the defined interval
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>true/false</returns>
|
2022-06-19 13:55:29 +02:00
|
|
|
public virtual bool ValidDateSpan()
|
2022-06-08 18:52:00 +02:00
|
|
|
{
|
2022-07-01 10:02:29 +02:00
|
|
|
var notAllowed = new List<string> {"2010-01-01", "1970-01-01", "0001-01-01"};
|
2022-06-08 18:52:00 +02:00
|
|
|
if (notAllowed.Contains(LastVisit) || notAllowed.Contains(NextVisit))
|
|
|
|
return false;
|
|
|
|
return DateTime.Parse(LastVisit) < DateTime.Parse(NextVisit);
|
|
|
|
}
|
2022-03-14 17:59:22 +01:00
|
|
|
}
|