Ejemplo n.º 1
0
        public JsonResult _SaveDetail(OrderDetail model, ProductDetailRequest productRequest)
        {
            if (productRequest != null && productRequest.IsNewProduct && productRequest.ProductName != null)
            {
                var product = StockTakeApiService.CreateProductOnStockTake(productRequest);
                model.ProductId = product.Result.ProductId;
            }

            model = _commonDbServices.SetDetails(model, productRequest.AccountId, Request.UrlReferrer.AbsolutePath, productRequest.ProcessByType);

            if (Request.UrlReferrer.AbsolutePath.Contains("SalesOrder") && model.ProductId > 0 && model.OrderDetailID < 1)
            {
                var minPrice = _productPriceService.GetProductPriceThresholdByAccountId(model.ProductId, productRequest != null ? productRequest.AccountId : 0);
                if (model.Price < minPrice.MinimumThresholdPrice)
                {
                    minPrice.Success          = false;
                    model.OrderDetailStatusId = (int)OrderStatusEnum.AwaitingAuthorisation;
                    if (productRequest.ThresholdAcknowledged)
                    {
                        UpdatedOrderDetails(model, productRequest.CaseQuantity, productRequest.PageSessionToken);
                        return(Json(new { error = "" }, JsonRequestBehavior.AllowGet));
                    }
                    return(Json(new { error = minPrice.FailureMessage, Threshold = minPrice }, JsonRequestBehavior.AllowGet));
                }
            }

            UpdatedOrderDetails(model, productRequest.CaseQuantity, productRequest.PageSessionToken, productRequest.IsTransferAdd);
            return(Json(new { error = "" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult CreateProduct(BSDto product)
        {
            if ((product.IsNewProduct == true) && (product.ProductName != null))
            {
                ProductDetailRequest productDetailRequest = new ProductDetailRequest();
                productDetailRequest.IsNewProduct        = product?.IsNewProduct ?? false;
                productDetailRequest.ProductName         = product?.ProductName;
                productDetailRequest.TenantId            = CurrentTenantId;
                productDetailRequest.TaxIds              = product?.TaxId ?? 3;
                productDetailRequest.ProductDesc         = product.ProductDesc;
                productDetailRequest.ProductDepartmentId = product.ProductDepartmentId;
                productDetailRequest.ProductGroupId      = product.ProductGroupId;

                var products = StockTakeApiService.CreateProductOnStockTake(productDetailRequest);
                if (!string.IsNullOrEmpty(products?.Result?.FailureMessage))
                {
                    return(Json(products.Result.FailureMessage));
                }
                product.ProductId    = products.Result.ProductId;
                product.ProductName  = product.ProductName;
                product.SKU          = products.Result.ProductCode;
                product.GroupProduct = products.Result.ProductGroup;
            }
            product.Quantity = product.Quantity ?? 1;
            product.Price    = product.Price ?? 0;
            var lst = Session["bsList"] as List <BSDto>;

            product.Id++;
            lst.Add(product);
            return(null);
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> CreateProductOnStockTake(ProductDetailRequest request)
        {
            var result = await StockTakeApiService.CreateProductOnStockTake(request);

            return(Ok(result));
        }