Ejemplo n.º 1
0
        public void Insert(SaleOrderItem item, Guid UpdatedId)
        {
            var inventory = dbStock.ExistsProduct(item.Product_Id, item.SaleOrder.Id, item.Unit);

            Check.IsEquals(inventory, false, "No existe inventario disponible para este producto");
            var Query             = dbProduct.GetProductByTaxeWhere(item.Product_Id).ToList();
            List <TaxeOrder> taxe = new List <TaxeOrder>();

            if (Query != null)
            {
                taxe = Query
                       .Select(t => new TaxeOrder
                {
                    Id            = Guid.NewGuid(),
                    Code          = t.Code,
                    Name          = t.Name,
                    Parent        = t.Parent,
                    SaleOrderItem = item,
                    ServiceType   = t.ServiceType,
                    State         = ObjectState.Added,
                    Status        = true,
                    Type          = t.Type,
                    UpdatedId     = UpdatedId,
                    Creation      = DateTime.UtcNow,
                    Value         = t.Value,
                    PriceTax      = CalculateTax(item.Unit, item.PriceSalebyUnit, t.Value, t.Type)
                })
                       .ToList();
            }
            item.TaxeOrder = taxe;
            item.UpdatedId = UpdatedId;
            item.State     = ObjectState.Added;
            var id = db.Save(item);

            ChangePriceTotal(item);
        }