using MisIngredientesVue.Core.Attributes; 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; namespace MisIngredientesVue.Core.Models { public class Product : RepositoryEntityWithTenantId { [Unique] [DisplayName("Código")] public string Code { get; set; } [DisplayName("Nombre")] [Required] [MaxLength(255)] public string Name { get; set; } [DisplayName("Categoría")] [Required] [MaxLength(255)] public string Category { get; set; } [DisplayName("Costo (sin impuestos)")] [Required] public decimal SupplierCost { get; set; } [DisplayName("Margen / Utilidad (%)")] public decimal? SalePriceRate { get; set; } //[DisplayName("Precio Mayoreo")] //public decimal? WholesalePrice { get; set; } //[DisplayName("Cantidad de Mayoreo")] //public decimal? WholesaleQty { get; set; } [DisplayName("Comprador")] [MaxLength(255)] public string Buyer { get; set; } //Esta propiedad no se usa en restaurantes [DisplayName("Proveedor")] [MaxLength(255)] public string Supplier { get; set; } [DisplayName("Zona de compra")] [MaxLength(255)] public string PurchaseZone { get; set; } [DisplayName("Ganancia ($)")] public decimal Utility { get { return SupplierCost - SalePrice; } } [Required] public int UnitId { get; set; } [DisplayName("Unidades")] public Unit Unit { get; set; } [DisplayName("Precio venta")] //Sin impuestos [Required] public decimal SalePrice { get; set; } [DisplayName("Precio venta (inc. impuestos)")] [NotMapped] public decimal SalePriceWithTaxes { get { return SalePrice + (SalePrice * ((Iva ?? 0) / 100)) + (SalePrice * ((Ieps ?? 0) / 100)); } } [NotMapped] public decimal? TotalTaxesPc { get; set; } //En los productos creados por los restaurantes no se ocupa esto, cada sucursal tiene su propio inventario, //en su lugar se usa la tabla de BranchInventory [DisplayName("Inventario")] public decimal? Qty { get; set; } //En los productos creados por los restaurantes no se ocupa esto, cada sucursal tiene su propia cantidad mínima de inventario //en su lugar se usa la tabla de BranchInventory [DisplayName("Cant. mín. de inventario")] public decimal? MinQty { get; set; } //En los productos creados por los restaurantes no se ocupa esto, cada sucursal tiene su propia cantidad mínima de inventario //en su lugar se usa la tabla de BranchInventory //No se guarda en la base de datos, se agregó para poder pasar el valor del cliente al servidor (y viceversa) [NotMapped] [DisplayName("Cant. max. de inventario")] public decimal? MaxQty { get; set; } [DisplayName("Pedido mínimo")] public decimal? MinOrder { get; set; } [MaxLength(10)] [DisplayName("Clave Producto SAT")] public string ClaveProductoSat { get; set; } [MaxLength(3)] [DisplayName("Clave Unidad SAT")] public string ClaveUnidadSat { get; set; } [DisplayName("IEPS (%)")] public decimal? Ieps { get; set; } [DisplayName("Continuar vendiendo")] public bool ContinueStockMode { get; set; } [DisplayName("IVA (%)")] public decimal? Iva { get; set; } public int? CostModifiedById { get; set; } [DisplayName("Costo modificado por")] public UserData CostModifiedBy { get; set; } [DisplayName("Costo modificado")] [IncludeTime] public DateTime? CostModified { get; set; } [DisplayName("Estatus Vigencia Precio")] [NotMapped] public string PriceExpirationStatus { get; set; } [DisplayName("Cambio de precio")] [NotMapped] public string PriceChange { get; set; } //{ // get // { // return DateTime.UtcNow - CostModified > TimeSpan.FromDays(30) ? "No vigente" : "Vigente"; // } //} //public List Taxes { get; set; } [NotMapped] public Order OrderInfo { get; set; } //Para los productos de los restaurantes [NoJoin] public int? ClientSupplierId { get; set; } [NoJoin] public Supplier ClientSupplier { get; set; } [NotMapped] public string ExternalSupplier { get; set; } //true significa que este producto proviene de un proveedor //false significa que el producto lo agregó el mismo restaurante [NotMapped] public bool IsVerified { get { if (!string.IsNullOrEmpty(ExternalSupplier)) return true; return ClientSupplier?.IsVerified ?? false; } } [NotMapped] public string ClientSupplierTenantId { get; set; } public override string ToString() { return Name; } } public class ClientProduct : RepositoryEntityWithTenantId { [Unique] [DisplayName("Código")] public string Code { get; set; } [DisplayName("Nombre")] [Required] [MaxLength(255)] public string Name { get; set; } [DisplayName("Categoría")] [Required] [MaxLength(255)] public string Category { get; set; } [DisplayName("Costo (sin impuestos)")] [Required] public decimal SalePrice { get; set; } [Required] public int UnitId { get; set; } [DisplayName("Unidades")] public Unit Unit { get; set; } //Esta propiedad no se usa en restaurantes [DisplayName("Proveedor")] [MaxLength(255)] public string Supplier { get; set; } [DisplayName("Pedido mínimo")] public decimal? MinOrder { get; set; } [MaxLength(10)] [DisplayName("Clave Producto SAT")] public string ClaveProductoSat { get; set; } [MaxLength(3)] [DisplayName("Clave Unidad SAT")] public string ClaveUnidadSat { get; set; } [DisplayName("IEPS (%)")] public decimal? Ieps { get; set; } [DisplayName("IVA (%)")] public decimal? Iva { get; set; } [DisplayName("Inventario total sucursales")] public decimal? Qty { get; set; } } public class BulkUploadProduct { public string Code { get; set; } [Required] public string Name { get; set; } [Required] public string Category { get; set; } [Required] public decimal SupplierCost { get; set; } public decimal? SalePriceRate { get; set; } public string Buyer { get; set; } public string Supplier { get; set; } public string PurchaseZone { get; set; } [Required] public int UnitId { get; set; } public Unit Unit { get; set; } [Required] public decimal SalePrice { get; set; } public decimal? Qty { get; set; } public decimal? MinQty { get; set; } public decimal? MinOrder { get; set; } public string ClaveProductoSat { get; set; } public string ClaveUnidadSat { get; set; } public decimal? Ieps { get; set; } public decimal? Iva { get; set; } public bool ContinueStockMode { get; set; } } [DisplayColumn("Name")] public class Unit : RepositoryEntity { public string Name { get; set; } public string Key { get; set; } public bool UsesDecimalPlaces { get; set; } } //Se usa para almacenar los inventarios de las sucursales (en los restaurantes) public class BranchInventory : RepositoryEntity { [DoNotUpdate] [IgnoreRelationship] public string TenantId { get; set; } [Unique] public int ProductId { get; set; } public Product Product { get; set; } [Unique] public int BranchId { get; set; } public ClientBranch Branch { get; set; } public decimal Qty { get; set; } public decimal MinQty { get; set; } public decimal MaxQty { get; set; } } public class UserOrderProduct : RepositoryEntity { public int OrderId { get; set; } public int ProductId { get; set; } [DisplayName("Artículo")] public string Name { get; set; } [DisplayName("Especificación")] public string Specification { get; set; } [DisplayName("Cantidad")] public decimal Qty { get; set; } public int UnitId { get; set; } [DisplayName("Unidades")] public Unit Unit { get; set; } [DisplayName("Precio con impuestos")] public decimal? FixedPrice { get; set; } [DisplayName("Subtotal con impuestos")] public decimal Subtotal { get; set; } public decimal? SupplierCost { get; set; } public decimal? SalePrice { get; set; } public decimal? Iva { get; set; } public decimal? Ieps { get; set; } } //public class ProductTax : RepositoryEntityWithTenantId //{ // public int ProductId { get; set; } // public string Name { get; set; } // public decimal Pc { get; set; } //} }