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

namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;

public class IntegrationMaterialFreeGoodsRequest
{
    public IntegrationMaterialFreeGoodsRequest()
    {
        Slabs = new List<IntegrationMaterialFreeGoodItemRequest>();
    }

    [Required(ErrorMessage = "Condition Record No is Required")]
    public int ConditionRecNo { get; set; }

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

    [StringLength(5, MinimumLength = 1, ErrorMessage = "DistributionChannel must be between 1 and 5 characters.")]
    public string DistributionChannel { get; set; }

    [StringLength(13, MinimumLength = 1, ErrorMessage = "CustomerNumber must be between 1 and 13 characters.")]
    public string? CustomerNumber { get; set; }   // nullable

    [StringLength(2, MinimumLength = 1, ErrorMessage = "CustomerPriceGroup must be between 1 and 2 characters.")]
    public string? CustomerPriceGroup { get; set; }

    [StringLength(18, MinimumLength = 1, ErrorMessage = "MaterialCode must be between 1 and 18 characters.")]
    public string? MaterialCode { get; set; } 
    public IList<IntegrationMaterialFreeGoodItemRequest> Slabs { get; set; }
}

public class IntegrationMaterialFreeGoodItemRequest
{
    [Range(0.001, 9999999999999.999, ErrorMessage = "MinOrderQuantity must be greater than 0.")]
    public decimal? MinOrderQuantity { get; set; }

    [Range(0.001, 9999999999999.999, ErrorMessage = "ForQuantity must be greater than 0.")]
    public decimal? ForQuantity { get; set; }

    [StringLength(3, MinimumLength = 1, ErrorMessage = "UnitOfMeasure must be between 1 and 3 characters.")]
    public string? UnitOfMeasure { get; set; }

    [Range(0.001, 9999999999999.999, ErrorMessage = "FreeQuantity must be greater than 0.")]
    public decimal? FreeQuantity { get; set; }

    [StringLength(3, MinimumLength = 1, ErrorMessage = "FocUnitOfMeasure must be between 1 and 3 characters.")]
    public string? FocUnitOfMeasure { get; set; }

    [Required(ErrorMessage = "ValidFrom is required.")]
    public DateTime ValidFrom { get; set; }

    [Required(ErrorMessage = "ValidTo is required.")]
    public DateTime ValidTo { get; set; }

    [StringLength(1, MinimumLength = 1, ErrorMessage = "Status must be 1 character.")]
    public string? Status { get; set; }   // NULL = Active, X = Inactive
}

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

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

    [StringLength(13, MinimumLength = 1, ErrorMessage = "CustomerNumber must be between 1 and 13 characters.")]
    public string? CustomerNumber { get; set; }   // nullable

    [StringLength(2, MinimumLength = 1, ErrorMessage = "CustomerPriceGroup must be between 1 and 2 characters.")]
    public string? CustomerPriceGroup { get; set; }

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

    public DateTime? ValidFrom { get; set; }
    public DateTime? ValidTo { get; set; }
}