Exemple #1
0
        private void CalcularCostoPromedio(Entradas entrada, SaraContext db)
        {
            var resumen = db.AreaExistencias
                          .FirstOrDefault(x => x.AreaId == entrada.AreaId && x.InventarioId == this.InventarioId);

            if (resumen != null)
            {
                this.CostoPromedio = (
                    (resumen.CostoPromedio * Convert.ToDecimal(resumen.Existencias)) +
                    (this.Costo * Convert.ToDecimal(this.Cantidad))
                    ) /
                                     Convert.ToDecimal(this.Cantidad + resumen.Existencias);


                this.Existencias = this.Cantidad + resumen.Existencias;
            }
        }
Exemple #2
0
        internal void InitFromComprasDetalle(Entradas entrada, ComprasDetalle comprasDetalle, SaraContext db)
        {
            this.InventarioId     = comprasDetalle.InventarioId;
            this.Cantidad         = comprasDetalle.CantidadRecibida;
            this.Costo            = comprasDetalle.Costo;
            this.CostoPromedio    = comprasDetalle.Costo;
            this.Existencias      = comprasDetalle.CantidadRecibida;
            this.Precio           = comprasDetalle.NuevoPrecio;
            this.SubTotal         = comprasDetalle.SubTotal;
            this.DescuentoAverage = comprasDetalle.DescuentoAverage;
            this.DescuentoMonto   = comprasDetalle.DescuentoMonto;
            this.Importe          = comprasDetalle.Importe;
            this.IvaAverage       = comprasDetalle.IvaAverage;
            this.IvaMonto         = comprasDetalle.IvaMonto;
            this.Total            = comprasDetalle.Total;

            this.CalcularCostoPromedio(entrada, db);
        }