
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;

public class IntegrationBillingDocumentRequest
{
    [Required(ErrorMessage = "Invoice/Billing document number is required.")]
    [StringLength(50, ErrorMessage = "Invoice/Billing document number cannot exceed 50 characters.")]
    public string BillingDocumentNumber { get; set; } = string.Empty;

    [Required(ErrorMessage = "Billing date is required.")]
    [DataType(DataType.Date)]
    public DateTime BillingDate { get; set; }

    [Required(ErrorMessage = "Sales order reference number is required.")]
    [StringLength(50, ErrorMessage = "Sales order reference number cannot exceed 50 characters.")]
    public string SalesOrderReferenceNumber { get; set; } = string.Empty;

    [Required(ErrorMessage = "Delivery reference number is required.")]
    [StringLength(50, ErrorMessage = "Delivery reference number cannot exceed 50 characters.")]
    public string DeliveryReferenceNumber { get; set; } = string.Empty;

    public IList<IntegrationBillingDocumentItemRequest> Items { get; set; } = new List<IntegrationBillingDocumentItemRequest>();
}


public class IntegrationBillingDocumentItemRequest
{
    [Required(ErrorMessage = "Item code is required.")]
    [StringLength(100, ErrorMessage = "Item code cannot exceed 100 characters.")]
    public string ItemCode { get; set; } = string.Empty;

    [Required(ErrorMessage = "Quantity is required.")]
    [Range(0.000001, double.MaxValue, ErrorMessage = "Quantity must be greater than zero.")]
    public decimal Quantity { get; set; }

    [Required(ErrorMessage = "Unit of Measure is required.")]
    [StringLength(20, ErrorMessage = "Unit of Measure cannot exceed 20 characters.")]
    public string UnitOfMeasure { get; set; } = string.Empty;

    [Required(ErrorMessage = "Billing amount is required.")]
    [Range(0, double.MaxValue, ErrorMessage = "Billing amount must be greater than zero.")]
    [DataType(DataType.Currency)]
    public decimal BillingAmount { get; set; }
}


public class IntegrationDeliveryDocumentRequest
{
    [Required(ErrorMessage = "Delivery Document number is required.")]
    [StringLength(50, ErrorMessage = "Delivery Document number cannot exceed 50 characters.")]
    public string DeliveryDocumentNo{ get; set; } = string.Empty;

    [Required(ErrorMessage = "Delivery date is required.")]
    [DataType(DataType.Date)]
    public DateTime DeliveryDate { get; set; }

    [Required(ErrorMessage = "Sales order reference number is required.")]
    [StringLength(50, ErrorMessage = "Sales order reference number cannot exceed 50 characters.")]
    public string SalesOrderReferenceNumber { get; set; } = string.Empty;

    [Required(ErrorMessage = "Delivery Status is required.")]
    [StringLength(5, ErrorMessage = "Delivery Status cannot exceed 5 characters.")]
    public string DeliveryStatus { get; set; } = string.Empty;

    public IList<IntegrationDeliveryDocumentItemRequest> Items { get; set; } = new List<IntegrationDeliveryDocumentItemRequest>();
}


public class IntegrationDeliveryDocumentItemRequest
{
    [Required(ErrorMessage = "Item code is required.")]
    [StringLength(100, ErrorMessage = "Item code cannot exceed 100 characters.")]
    public string ItemCode { get; set; } = string.Empty;

    [Required(ErrorMessage = "Quantity is required.")]
    [Range(0.000001, double.MaxValue, ErrorMessage = "Quantity must be greater than zero.")]
    public decimal Quantity { get; set; }

    [Required(ErrorMessage = "Unit of Measure is required.")]
    [StringLength(20, ErrorMessage = "Unit of Measure cannot exceed 20 characters.")]
    public string UnitOfMeasure { get; set; } = string.Empty;
}