using MisIngredientesVue.Core.Services; using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; using System.Linq; using MisIngredientesVue.Core.Attributes; namespace MisIngredientesVue.Core.Models { //public class TestEntity : RepositoryEntityWithTenantId //{ // public int? Qty { get; set; } // public DeliveryStatus? DeliveryStatus { get; set; } //} [DisplayColumn("Name")] public class OrderTemplate : RepositoryEntityWithTenantId { [DisplayName("Nombre")] public string Name { get; set; } [DoNotUpdate] [MaxLength(50)] public string PublicId { get; set; } public int ClientId { get; set; } public Client Client { get; set; } public List Brands { get; set; } //-> OrderTemplateBrand //Usado por las plantillas de los restaurantes public List Branches { get; set; } //-> OrderTemplateBranch public List Suppliers { get; set; } //Usado para mostrar el distinct de los proveedores de los productos que se usaron en la plantilla public decimal? Discount { get; set; } public DiscountType? DiscountType { get; set; } public bool HasFixedDiscount { get; set; } //Este no se guarda en la base de datos, aquí se coloca el pedido mínimo configurado en el cliente [NotMapped] public decimal? MinTotal { get; set; } //Pedido mínimo (para overridear el valor global en la configuración) public List Products { get; set; } //-> OrderTemplateProduct [NotMapped] public bool HasFixedPrices { get { return Products?.Any(x => x.FixedPrice != null) ?? false; } } [NotMapped] public string SuppliersDisplay { get; set; } [NotMapped] public bool IsVerified { get; set; } [NotMapped] public OrderAllowedDates AllowedDates { get; set; } } public class OrderTemplateProduct : RepositoryEntityWithTenantId { public OrderTemplate OrderTemplate { get; set; } public int OrderTemplateId { get; set; } public int ProductId { get; set; } public Product Product { get; set; } public decimal Qty { get; set; } public decimal? FixedPrice { get; set; } [NotMapped] public decimal Subtotal { get; set; } [MaxLength(300)] public string Specification { get; set; } [NotMapped] public string SuppliersDisplay { get; set; } //Usado en las plantillas generales para poder guardar productos adicionales [NotMapped] public bool PreventDelete { get; set; } public static decimal GetActualSalePrice(OrderTemplateProduct product) { if (product.FixedPrice.HasValue && product.FixedPrice > 0) return product.FixedPrice.Value; return product.Product.SalePrice; } } public class OrderTemplateBranch : RepositoryEntityWithTenantId { public OrderTemplate OrderTemplate { get; set; } public ClientBranch ClientBranch { get; set; } public int OrderTemplateId { get; set; } public int ClientBranchId { get; set; } } public class OrderTemplateBrand : RepositoryEntityWithTenantId { public OrderTemplate OrderTemplate { get; set; } public ClientBrand ClientBrand { get; set; } public int OrderTemplateId { get; set; } public int ClientBrandId { get; set; } } public class GeneralOrderTemplateProduct : RepositoryEntityWithTenantId { public int ProductId { get; set; } public Product Product { get; set; } public decimal Qty { get; set; } public decimal? FixedPrice { get; set; } [NotMapped] public decimal Subtotal { get; set; } [MaxLength(300)] public string Specification { get; set; } [NotMapped] public string SuppliersDisplay { get; set; } //Usado en las plantillas generales para poder guardar productos adicionales [NotMapped] public bool PreventDelete { get; set; } public static decimal GetActualSalePrice(GeneralOrderTemplateProduct product) { if (product.FixedPrice.HasValue && product.FixedPrice > 0) return product.FixedPrice.Value; return product.Product.SalePrice; } } public enum DiscountType { [Display(Name = "Porcentaje")] Percentage = 0, [Display(Name = "Monto")] Amount = 1 } }