public decimal GetLastProductPriceForAccount(int productId, int accountid, InventoryTransactionTypeEnum transactionType)
        {
            var priceDetail = _context.OrderDetail.AsNoTracking().OrderByDescending(m => m.DateCreated)
                              .FirstOrDefault(a => a.ProductId == productId && a.IsDeleted != true && a.Order.AccountID == accountid &&
                                              a.Order.InventoryTransactionTypeId == (int)transactionType);

            if (transactionType == InventoryTransactionTypeEnum.PurchaseOrder)
            {
                return(priceDetail != null
                    ? priceDetail.Price
                    : ConvertBaseRates(accountid, _productService.GetProductMasterById(productId).BuyPrice ?? 0));
            }

            if (transactionType == InventoryTransactionTypeEnum.SalesOrder)
            {
                var sellPrice = GetProductMasterWithSpecialPrice(productId, accountid).SellPrice ?? 0.0m;

                if (CanTheProductBeSoldAtPriceToAccount(productId, accountid, sellPrice).Success)
                {
                    return(sellPrice);
                }
                return(GetProductPriceThresholdByAccountId(productId, accountid).SellPrice);
            }
            return(0.0m);
        }
 public string GenerateNextOrderNumber(InventoryTransactionTypeEnum type)
 {
     return(OrderService.GenerateNextOrderNumber(type, CurrentTenantId));
 }