public static SaleInventory MakeInventory(RegisterSaleRequest request)
        {
            try
            {
                var config        = request.TotalValueCalculationConfig;
                var saleInventory = new SaleInventory()
                {
                    ProductId        = request.ProductId,
                    QuantitySold     = request.QuantitySold,
                    Taxes            = request.IncludedTaxes,
                    IncludedServices = request.IncludedServices
                };

                if (config.OverrideUnitaryPrice)
                {
                    saleInventory.UnitaryPrice = request.TotalValueCalculationConfig.UnitaryPrice;
                }
                SetSaleInventoryStates(request, saleInventory);

                return(saleInventory);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 private static void SetSaleInventoryStates(RegisterSaleRequest request, SaleInventory inventory)
 {
     try
     {
         if (request.TotalValueCalculationConfig.OverrideUnitaryPrice)
         {
             inventory.States.UnitaryPriceWasOverridden = true;
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public static void Validate(SaleInventory inventory)
        {
            try
            {
                var quantitySoldIsGreaterThanZero   = inventory.QuantitySold > 0;
                var saleTotalValueIsGreaterThanZero = inventory.TotalValue > 0;

                if (!quantitySoldIsGreaterThanZero)
                {
                    throw new ValidationException("Quantidade vendida mão pode ser zero", "");
                }
                if (!saleTotalValueIsGreaterThanZero)
                {
                    //throw new Exception("Nao foi possivel determinar o valor total da venda");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #4
0
 private void detach_SaleInventories(SaleInventory entity)
 {
     this.SendPropertyChanging("SaleInventories");
     entity.Item = null;
 }