using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;

public class CustomerIntegrationRequest
{
    [Required(ErrorMessage = "Customer Number is required")]
    [StringLength(10, MinimumLength = 1, ErrorMessage = "Customer Number must be between 1 and 10 characters")]
    public string CustomerNumber { get; set; } = string.Empty;

    [Required(ErrorMessage = "Customer Name is required")]
    [StringLength(35, MinimumLength = 1, ErrorMessage = "Customer Name must be between 1 and 35 characters")]
    public string CustomerName { get; set; } = string.Empty;

    [Required(ErrorMessage = "Account Group is required")]
    [StringLength(3, MinimumLength = 1, ErrorMessage = "Account Group must be between 1 and 3 characters")]
    public string AccountGroup { get; set; } = string.Empty;

    [Required(ErrorMessage = "Account Group Description is required")]
    [StringLength(30, ErrorMessage = "Account Group Description cannot exceed 30 characters")]
    public string AccountGroupDescription { get; set; } = string.Empty;

    [Required(ErrorMessage = "Company Code is required")]
    [StringLength(4, MinimumLength = 1, ErrorMessage = "Company Code must be between 1 and 4 characters")]
    public string CompanyCode { get; set; } = string.Empty;

    [Required(ErrorMessage = "Company Code Description is required")]
    [StringLength(25, ErrorMessage = "Company Code Description cannot exceed 25 characters")]
    public string CompanyCodeDescription { get; set; } = string.Empty;

    [Required(ErrorMessage = "Sales Organization is required")]
    [StringLength(4, MinimumLength = 1, ErrorMessage = "Sales Organization must be between 1 and 4 characters")]
    public string SalesOrganization { get; set; } = string.Empty;

    [Required(ErrorMessage = "Sales Organization Description is required")]
    [StringLength(40, ErrorMessage = "Sales Organization Description cannot exceed 40 characters")]
    public string SalesOrganizationDescription { get; set; } = string.Empty;

    [Required(ErrorMessage = "Distribution Channel is required")]
    [StringLength(2, MinimumLength = 1, ErrorMessage = "Distribution Channel must be between 1 and 2 characters")]
    public string DistributionChannel { get; set; } = string.Empty;

    [Required(ErrorMessage = "Distribution Channel Description is required")]
    [StringLength(20, ErrorMessage = "Distribution Channel Description cannot exceed 20 characters")]
    public string DistributionChannelDescription { get; set; } = string.Empty;

    [Required(ErrorMessage = "Division is required")]
    [StringLength(2, MinimumLength = 1, ErrorMessage = "Division must be between 1 and 2 characters")]
    public string Division { get; set; } = string.Empty;

    [Required(ErrorMessage = "Division Description is required")]
    [StringLength(20, ErrorMessage = "Division Description cannot exceed 20 characters")]
    public string DivisionDescription { get; set; } = string.Empty;

    [Required(ErrorMessage = "Mobile Number is required")]
    [StringLength(31, ErrorMessage = "Mobile Number cannot exceed 31 characters")]
    [Phone(ErrorMessage = "Invalid mobile number format")]
    public string MobileNumber { get; set; } = string.Empty;

    [Required(ErrorMessage = "Email Address is required")]
    [StringLength(241, ErrorMessage = "Email Address cannot exceed 241 characters")]
    [EmailAddress(ErrorMessage = "Invalid email address format")]
    public string EmailAddress { get; set; } = string.Empty;

    [Required(ErrorMessage = "Business/Tax Number is required")]
    [StringLength(16, ErrorMessage = "Business/Tax Number cannot exceed 16 characters")]
    public string BusinessTaxNumber { get; set; } = string.Empty;

    [Required(ErrorMessage = "Credit Limit is required")]
    [Range(0, 9999999999999, ErrorMessage = "Credit Limit must be a valid number")]
    public decimal CreditLimit { get; set; }

    [Required(ErrorMessage = "Sales Office is required")]
    [StringLength(4, MinimumLength = 1, ErrorMessage = "Sales Office must be between 1 and 4 characters")]
    public string SalesOffice { get; set; } = string.Empty;

    [StringLength(255, ErrorMessage = "Sales Office Description cannot exceed 255 characters")]
    public string? SalesOfficeDescription { get; set; }

    [Required(ErrorMessage = "Sales Group is required")]
    [StringLength(3, MinimumLength = 1, ErrorMessage = "Sales Group must be between 1 and 3 characters")]
    public string SalesGroup { get; set; } = string.Empty;

    [Required(ErrorMessage = "Customer Group is required")]
    [StringLength(2, MinimumLength = 1, ErrorMessage = "Customer Group must be between 1 and 2 characters")]
    public string CustomerGroup { get; set; } = string.Empty;

    [Required(ErrorMessage = "Status is required")]
    [StringLength(1, MinimumLength = 1, ErrorMessage = "Status must be exactly 1 character")]
    public string Status { get; set; } = string.Empty;

    [Required(ErrorMessage = "Payment Terms are required")]
    [StringLength(4, MinimumLength = 1, ErrorMessage = "Payment Terms must be between 1 and 4 characters")]
    public string PaymentTerms { get; set; } = string.Empty;

    [Required(ErrorMessage = "Search Term is required")]
    [StringLength(20, ErrorMessage = "Search Term cannot exceed 20 characters")]
    public string SearchTerm { get; set; } = string.Empty;

    [Required(ErrorMessage = "Region is required")]
    [StringLength(3, MinimumLength = 1, ErrorMessage = "Region must be between 1 and 3 characters")]
    public string Region { get; set; } = string.Empty;

    [Required(ErrorMessage = "Region Name is required")]
    [StringLength(40, ErrorMessage = "Region Name cannot exceed 40 characters")]
    public string RegionName { get; set; } = string.Empty;

    [Required(ErrorMessage = "Area is required")]
    [StringLength(10, MinimumLength = 1, ErrorMessage = "Area must be between 1 and 10 characters")]
    public string Area { get; set; } = string.Empty;

    [Required(ErrorMessage = "Area Name is required")]
    [StringLength(40, ErrorMessage = "Area Name cannot exceed 40 characters")]
    public string AreaName { get; set; } = string.Empty;

    [Required(ErrorMessage = "Sales Unit is required")]
    [StringLength(3, MinimumLength = 1, ErrorMessage = "Sales Unit must be between 1 and 3 characters")]
    public string SalesUnit { get; set; } = string.Empty;

    [Required(ErrorMessage = "Sales Unit Name is required")]
    [StringLength(30, ErrorMessage = "Sales Unit Name cannot exceed 30 characters")]
    public string SalesUnitName { get; set; } = string.Empty;

    [Required(ErrorMessage = "Territory is required")]
    [StringLength(3, MinimumLength = 1, ErrorMessage = "Territory must be between 1 and 3 characters")]
    public string Territory { get; set; } = string.Empty;

    [Required(ErrorMessage = "Territory Name is required")]
    [StringLength(20, ErrorMessage = "Territory Name cannot exceed 20 characters")]
    public string TerritoryName { get; set; } = string.Empty;

    [Required(ErrorMessage = "Plant is required")]
    [StringLength(4, MinimumLength = 1, ErrorMessage = "Plant must be between 1 and 4 characters")]
    public string Plant { get; set; } = string.Empty;

    [Required(ErrorMessage = "Plant Name is required")]
    [StringLength(30, ErrorMessage = "Plant Name cannot exceed 30 characters")]
    public string PlantName { get; set; } = string.Empty;
}


public class CustomerByCompanyCodeRequest
{
    [Required(ErrorMessage = "Customer Number is required")]
    [StringLength(10, MinimumLength = 1, ErrorMessage = "Customer Number must be between 1 and 10 characters")]
    public string CustomerNumber { get; set; } = string.Empty;


    [Required(ErrorMessage = "Company Code is required")]
    [StringLength(4, MinimumLength = 1, ErrorMessage = "Company Code must be between 1 and 4 characters")]
    public string CompanyCode { get; set; } = string.Empty;
}