コード例 #1
0
        private IEnumerable <PuntosPendientes> GenerarPuntosPendientes(FAR.Venta venta)
        {
            if (!venta.HasCliente() && venta.Tipo != "1")
            {
                return(new PuntosPendientes[0]);
            }

            if (!venta.HasDetalle())
            {
                return(new PuntosPendientes[0]);
            }

            var puntosPendientes = new List <PuntosPendientes>();

            foreach (var item in venta.Detalle)
            {
                var familia        = item.Farmaco.Familia?.Nombre ?? FAMILIA_DEFAULT;
                var puntoPendiente = new PuntosPendientes
                {
                    VentaId        = $"{venta.FechaHora.Year}{venta.Id}".ToLongOrDefault(),
                    LineaNumero    = item.Linea,
                    CodigoBarra    = item.Farmaco.CodigoBarras ?? "847000" + item.Farmaco.Codigo.PadLeft(6, '0'),
                    CodigoNacional = item.Farmaco.Codigo,
                    Descripcion    = item.Farmaco.Denominacion,

                    Familia = _clasificacion == TIPO_CLASIFICACION_CATEGORIA
                        ? item.Farmaco.Subcategoria?.Nombre ?? FAMILIA_DEFAULT
                        : familia,
                    SuperFamilia = _clasificacion == TIPO_CLASIFICACION_CATEGORIA
                        ? item.Farmaco.Categoria?.Nombre ?? FAMILIA_DEFAULT
                        : string.Empty,
                    SuperFamiliaAux     = string.Empty,
                    FamiliaAux          = _clasificacion == TIPO_CLASIFICACION_CATEGORIA ? familia : string.Empty,
                    CambioClasificacion = _clasificacion == TIPO_CLASIFICACION_CATEGORIA ? 1 : 0,

                    Cantidad          = item.Cantidad,
                    Precio            = item.Importe,
                    Pago              = item.Equals(venta.Detalle.First()) ? venta.TotalBruto : 0,
                    TipoPago          = venta.Tipo,
                    Fecha             = venta.FechaHora.Date.ToDateInteger(),
                    DNI               = venta.Cliente?.Id.ToString() ?? "0",
                    Cargado           = _cargarPuntos.ToLower().Equals("si") ? "no" : "si",
                    Puesto            = $"{venta.Puesto}",
                    Trabajador        = venta.VendedorNombre,
                    LaboratorioCodigo = item.Farmaco.Laboratorio?.Codigo ?? string.Empty,
                    Laboratorio       = item.Farmaco.Laboratorio?.Nombre ?? LABORATORIO_DEFAULT,
                    Proveedor         = item.Farmaco.Proveedor?.Nombre ?? string.Empty,
                    Receta            = item.Receta,
                    FechaVenta        = venta.FechaHora,
                    PVP               = item.PVP,
                    PUC               = item.Farmaco?.PrecioCoste ?? 0,
                    Categoria         = item.Farmaco.Categoria?.Nombre ?? string.Empty,
                    Subcategoria      = item.Farmaco.Subcategoria?.Nombre ?? string.Empty,
                    VentaDescuento    = item.Equals(venta.Detalle.First()) ? venta.TotalDescuento : 0,
                    LineaDescuento    = item.Descuento,
                    TicketNumero      = venta.Ticket?.Numero,
                    Serie             = venta.Ticket?.Serie ?? string.Empty,
                    Sistema           = SISTEMA_UNYCOP
                };

                puntosPendientes.Add(puntoPendiente);
            }

            return(puntosPendientes);
        }