Пример #1
0
        public void Delete(Guid item, bool Status, Guid UpdatedId)
        {
            var Q        = db.Get(item, t => t.SaleOrder);
            int quantity = Q.Unit;

            Check.IsNotNull(Q, $"No Existen Registro para este Item {item}.");
            Q.Status    = Status;
            Q.State     = ObjectState.Modified;
            Q.UpdatedId = UpdatedId;
            Q.Unit      = 0;
            foreach (var k in Q.TaxeOrder)
            {
                k.PriceTax = CalculateTax(0, 0, k.Value, k.Type);
                k.State    = ObjectState.Modified;
            }
            db.Delete(Q);
            var Order = dbSaleOrder.Get(Q.SaleOrder.Id);

            if (Status)
            {
                Order.PriceTotal = Order.PriceTotal + (Q.PriceSalebyUnit * quantity);
            }
            if (!Status)
            {
                Order.PriceTotal = Order.PriceTotal - (Q.PriceSalebyUnit * quantity);
            }
            //dbSaleOrder.Update(Q.SaleOrder_Id, Order, Q.UpdatedId);
            dbSaleOrder.Update(Q.SaleOrder.Id, Order, Q.UpdatedId);
        }
        public Guid Insert(PaymentOrder item, Guid UpdatedId)
        {
            var number = Guid.NewGuid();

            item.State     = ObjectState.Added;
            item.UpdatedId = UpdatedId;
            var id = db.Save(item);
            var Q  = dbSaleOrder.Get(item.SaleOrder.Id);
            var QO = db.GetQuery(e => e.SaleOrder.Id == item.SaleOrder.Id);

            Q.PricePending = Q.PriceTotal - QO.Sum(t => t.PricePayment);
            if (Q.PricePending <= 0)
            {
                Q.StatusTransaction = Transaction.Ok;
            }
            dbSaleOrder.Update(item.SaleOrder.Id, Q, UpdatedId);
            return(id);
        }