public void ReserveProduct(SaleViewModel model) //Chamado quando colocar no carrinho // Criar objeto carrinho (ViewModel) SaleViewModel { var productTransaction = new ProductTransaction { ProductId = model.ProductId, ProductTransactionId = 0, Quantity = model.Quantity, StockId = model.StockId, TransactionTypeId = transactionService.GetTransactionTypeByDescription("Reserva").TransactionTypeId, UnityValue = model.AverageCost, UserId = model.UserId }; productTransaction = transactionService.CreateProductTransaction(productTransaction); var sale = new Sale { CreateDate = DateTime.Now, ExpirationDate = DateTime.Now.AddDays(1), Quantity = model.Quantity, SaleId = 0, Status = "Reservado", TotalPrice = model.AverageCost * model.Quantity, ProductTransactionId = productTransaction.ProductTransactionId }; CreateSale(sale); }
public void sell(List <ProductTransactionItem> pti, DateTime date, string not = null, bool isPaid = true, Contact con = null, Check chk = null) { DateTime?paydate = null; if (isPaid) { paydate = DateTime.Now; } ProductTransaction pt = new ProductTransaction() { CreationDate = date, PaymentDate = paydate, Check = chk, Contact = con, Note = not, }; DBContext myDBContext = new DBContext(); foreach (ProductTransactionItem item in pti) { pt.items.Add(item); myDBContext.products.Attach(item.Product); //association with product and dbcontext } myDBContext.save(pt); }
public static productTransaction Map(this productTransaction uiTransaction, ProductTransaction dbTransaction) { uiTransaction.productTransactionID = dbTransaction.ProductTransactionID; uiTransaction.subProductID = dbTransaction.SubProductID; uiTransaction.wareHouseID = dbTransaction.WarehouseID; uiTransaction.balanceTransactionID = dbTransaction.BalanceTransactionID; uiTransaction.transactionDate = dbTransaction.TransactionDate.ToString(); uiTransaction.buyQuantity = dbTransaction.BuyQuantity; uiTransaction.sellQuantity = dbTransaction.SellQuantity; uiTransaction.isSellFromWarehouse = dbTransaction.IsSellFromWarehouse; uiTransaction.sellingPrice = dbTransaction.SellingPrice; uiTransaction.totalPrice = dbTransaction.TotalPrice; uiTransaction.taxPrice = dbTransaction.TaxPrice; uiTransaction.totalPriceIncludingTax = dbTransaction.TotalPriceIncludingTax; uiTransaction.miscellaneousPrice = dbTransaction.MiscellaneousPrice; uiTransaction.description = dbTransaction.Description; uiTransaction.quantityRemaining = dbTransaction.QuantityRemaining; uiTransaction.supplierName = dbTransaction.SupplierName; uiTransaction.supplierID = dbTransaction.SupplierID; uiTransaction.buyingAmount = dbTransaction.BuyingAmount; if (dbTransaction.BalanceTransaction != null) { uiTransaction.balanceTransaction = new balanceTransaction(); uiTransaction.balanceTransaction.Map(dbTransaction.BalanceTransaction); } if (dbTransaction.SubProduct != null) { uiTransaction.subProduct = new subProduct(); uiTransaction.subProduct.Map(dbTransaction.SubProduct); } return(uiTransaction); }
public void Calculate_rate_and_price_campaign_tests(decimal applePrice, decimal quantity, decimal discountRate, decimal discountPrice, decimal expectedValue) { IProductWithCampaignPriceAggregate productWithCampaignPriceAggregate = Resolve <IProductWithCampaignPriceAggregate>(); ProductTransaction productTransaction = new ProductTransaction { Product = new Product { Price = applePrice, Title = "Apple", Campaigns = new List <Campaign> { new Campaign { Discount = discountRate, Type = CampaignType.Rate, }, new Campaign { Discount = discountPrice, Type = CampaignType.Price, }, }, }, Quantity = quantity, }; var actualPrice = productWithCampaignPriceAggregate.Calculate(productTransaction); Assert.Equal(expectedValue, actualPrice); }
public ProductTransaction GetByProductTransactionId(int productTransactionId) { var productTransaction = productTransactionRepository.GetById(productTransactionId); if (productTransaction == null) { productTransaction = new ProductTransaction(); } return(productTransaction); }
/// <summary> /// cycle through the list of products and sell items /// </summary> /// <param name="inventory">list of Items</param> private static void DisplayPerformTransactions(IList <Item> inventory) { // // declare delegate object // ProductTransaction productTransaction = null; // // sell products // foreach (var item in inventory) { int unitsSold = 0; Console.Clear(); Console.WriteLine(); Console.WriteLine("Sell Products"); Console.WriteLine(); // // get number of units to sell and process based on item class // if (item is NonPerishable) { NonPerishable nonPerishableItem = new NonPerishable(); nonPerishableItem = item as NonPerishable; Console.Write($"Enter the number of {nonPerishableItem.ItemName} sold: "); if (int.TryParse(Console.ReadLine(), out unitsSold)) { productTransaction = ProcessNonPerishableSale; } } else if (item is Perishable) { Perishable perishableItem = new Perishable(); perishableItem = item as Perishable; Console.Write($"Enter the number of {perishableItem.ItemName} sold: "); if (int.TryParse(Console.ReadLine(), out unitsSold)) { productTransaction = ProcessPerishableSale; } } // // process the transaction // ProcessTransaction(productTransaction, item, unitsSold); } Console.WriteLine(); Console.WriteLine("Inventory Complete"); Console.WriteLine("Press any key to continue."); Console.ReadKey(); }
public ActionResult CreateProductTransaction(int stockId) { var productTransaction = new ProductTransaction { StockId = stockId }; ViewBag.TransactionTypes = new SelectList(transactionService.GetTransactionTypeList(), "TransactionTypeId", "Description"); ViewBag.Products = new SelectList(productService.GetProducts(), "ProductId", "Name"); return(View("ProductTransactionForm", productTransaction)); }
/// <summary> /// ürünün indirimli fiyatını hesaplar /// </summary> private decimal CalculateReducedPrice(ProductTransaction productTransaction, decimal productPrice) { productPrice = CalculateCategoryCampaign(productTransaction, productPrice); var campaigns = productTransaction.Product.Campaigns; productPrice = campaigns.GetRateReducedPrice(productPrice); productPrice = campaigns.GetReducedPrice(productPrice); return(productPrice); }
public ActionResult Edit(int id) //id = ProductTransactionID { int ProductTransactionID = id; ProductTransactions_Edit viewProductTransactions_Edit = new ProductTransactions_Edit(); ProductTransaction productTransaction = ProductTransactions.GetProductTransaction(ProductTransactionID); viewProductTransactions_Edit.productTransaction = productTransaction; return(View("EditPartial", viewProductTransactions_Edit)); }
public void UpdateByTransactionAmount(int SearchByID, ProductTransaction anObject, SqlTransaction atrans) { int returnValue = -1; SqlParameter[] SP_Parameters = { new SqlParameter("@ID", SearchByID) , new SqlParameter("@TransactionAmount", anObject.TransactionAmount) , new SqlParameter("@ProductTransactionType", anObject.TransactionType.ToString()) }; returnValue = QueryExecute.StoredProcedure(UPDATEBYTRANSACTIONAMOUNT, atrans, SP_Parameters); }
public void ProductOperationsCreate(int?productId, int transactionsType, string title, int userId) { ProductTransaction productTransaction = new ProductTransaction(); productTransaction.TransactionsType = transactionsType; productId = productId == null ? 0 : productId; productTransaction.ProductId = (int)productId; productTransaction.Actions = title; productTransaction.CreateDateTime = DateTime.Now; productTransaction.CreateUserId = userId; db.ProductTransactions.Add(productTransaction); db.SaveChanges(); }
public async Task <CommonResponse> DecideTheDeal(MakeDealRequest values) { using (var uow = this.unitOfWorkFactory.GetUnitOfWork()) { var transactionEntity = new ProductTransaction { ProductAnalyzerId = values.productAnalyzeId, Deal = values.DealStatus }; uow.Repository <ProductTransaction>().Add(transactionEntity); uow.SaveChanges(); return(CommonResponse.CreateSuccess("success", "Suc01", transactionEntity)); } }
public JsonResult CreateProductTransaction(int _ClientID, DateTime _TransactionDate, DateTime _DateOrdered, int _ProductID, string _ProductType, string _ProductDescription, decimal _ProductPrice, string _FName, string _MName, string _LName, string _Reference, string _OrderedBy, string _FileNum, int _VendorID, string _SSN, decimal _BasePrice) { ProductTransaction productTransaction = new ProductTransaction(0, _ClientID, "", _TransactionDate, _DateOrdered, _ProductID, _ProductType, "", _ProductDescription, _ProductPrice, 0, 0, _FName, _MName, _LName, _Reference, _OrderedBy, _FileNum, _VendorID, "", _SSN, _BasePrice, true, 0); ProductTransactions.CreateProductTransaction(productTransaction); return(new JsonResult { Data = new { success = true } }); }
/// <summary> /// kategoriye uygulanan indirimi ürüne uygular /// </summary> /// <param name="productTransaction">ürün hareketi</param> /// <param name="productPrice">ürün fiyatı</param> /// <returns>ürünün kategorisine yapılmış indirimin çıkartılmış fiyatı</returns> private decimal CalculateCategoryCampaign(ProductTransaction productTransaction, decimal productPrice) { List <Campaign> campaigns = new List <Campaign>(); //yüzdeli indirim campaigns.GetCategoryCampaigns(productTransaction.Product.Category, CampaignType.Rate); productPrice = campaigns.GetRateReducedPrice(productPrice); //fiyat üzerinden indirim campaigns.GetCategoryCampaigns(productTransaction.Product.Category, CampaignType.Price); productPrice = campaigns.GetReducedPrice(productPrice); return(productPrice); }
public ReportDataRow(ProductTransaction transaction, Lot lot) { this.Transaction = transaction; this.ProductName = transaction.Instance.InventoryItem.Name; this.Vendor = lot.Cost.DistributorName; this.LotNumber = lot.LotNumber; this.SupplierPoNumber = lot.SupplierPoNumber; this.UnitCost = (transaction.UnitCost != null) ? transaction.UnitCost.Value : 0; if (transaction.InventoryAction == InventoryAction.OUTGOING) { this.Transaction.Quantity *= -1; } this.Cost = this.UnitCost * this.Transaction.Quantity; //this.Cost = (transaction.TotalCost != null) ? transaction.TotalCost.Value : 0; }
public int addProductTransactions(int newTransactionId) { ProductTransactionManager productTransactionManager = new ProductTransactionManager(); List <ProductTransaction> productTransactionList = new List <ProductTransaction>(); foreach (var item in shoppingListProductsIds) { ProductTransaction productTransaction = new ProductTransaction { ProductId = item, TransactionId = newTransactionId }; productTransactionList.Add(productTransaction); } int rowsAffected = productTransactionManager.addProductTransaction(productTransactionList); return(rowsAffected); }
public ProductTransaction CreateProductTransaction(ProductTransaction productTransaction) { try { var transactionType = GetTransactionTypeById(productTransaction.TransactionTypeId); var productInStock = stockService.GetProductInStockById(productTransaction.StockId, productTransaction.ProductId); if (!transactionType.IsIncoming && productInStock.StockQuantity < productTransaction.Quantity) { throw new LesserStockException(); } productTransaction = productTransactionRepository.Create(productTransaction); return(productTransactionRepository.GetById(productTransaction.ProductTransactionId)); } catch (LesserStockException ex) { throw new LesserStockException(ex.Message); } }
public void Calculate_tests(decimal applePrice, decimal quantity, decimal expectedValue) { IProductTotalPriceAggregate productTotalPriceAggregate = Resolve <IProductTotalPriceAggregate>(); ProductTransaction productTransaction = new ProductTransaction { Product = new Product { Price = applePrice, Title = "Apple", }, Quantity = quantity, }; var actualPrice = productTotalPriceAggregate.Calculate(productTransaction); Assert.Equal(expectedValue, actualPrice); }
public ActionResult CreateProductTransaction(ProductTransaction productTransaction) { try { if (this.ModelState.IsValid) { productTransaction = transactionService.CreateProductTransaction(productTransaction); return(RedirectToAction("Details", new { stockId = productTransaction.StockId })); } ViewBag.TransactionTypes = new SelectList(transactionService.GetTransactionTypeList(), "TransactionTypeId", "Description"); ViewBag.Products = new SelectList(productService.GetProducts(), "ProductId", "Name"); return(View("ProductTransactionForm", productTransaction)); } catch (System.Exception) { return(BadRequest()); } }
public static ProductTransaction Map(this ProductTransaction dbTransaction, productTransaction uiTransaction, bool isEdit) { DateTime transactionDate; if (DateTime.TryParse(uiTransaction.transactionDate, out transactionDate)) { dbTransaction.TransactionDate = transactionDate; } else { dbTransaction.TransactionDate = DateTime.Now; } dbTransaction.SupplierID = uiTransaction.supplierID; dbTransaction.IsSellFromWarehouse = uiTransaction.isSellFromWarehouse; dbTransaction.SupplierName = uiTransaction.supplierName; dbTransaction.WarehouseID = uiTransaction.wareHouseID; dbTransaction.Description = uiTransaction.description; dbTransaction.BuyQuantity = uiTransaction.buyQuantity; dbTransaction.SellQuantity = uiTransaction.sellQuantity; dbTransaction.SellingPrice = uiTransaction.sellingPrice; dbTransaction.TotalPrice = uiTransaction.totalPrice; dbTransaction.TaxPrice = uiTransaction.taxPrice; dbTransaction.TotalPriceIncludingTax = uiTransaction.totalPriceIncludingTax; dbTransaction.BuyingAmount = uiTransaction.buyingAmount; dbTransaction.MiscellaneousPrice = uiTransaction.miscellaneousPrice; if (isEdit) { dbTransaction.LastUpdatedDateTime = DateTime.Now; } else { dbTransaction.CreatedDateTime = DateTime.Now; dbTransaction.SubProductID = uiTransaction.subProductID; dbTransaction.BalanceTransactionID = uiTransaction.balanceTransactionID; } return(dbTransaction); }
public void SetUp() { _stockRepository = new Mock <IStockRepository>(); _productTransactionRepository = new Mock <IProductTransactionRepository>(); _materialTransactionRepository = new Mock <IMaterialTransactionRepository>(); _toolsTransactionRepository = new Mock <IToolsTransactionRepository>(); _transactionTypeRepository = new Mock <ITransactionTypeRepository>(); _stockService = new Mock <IStockService>(); _transactionService = new TransactionService( _stockRepository.Object, _productTransactionRepository.Object, _materialTransactionRepository.Object, _toolsTransactionRepository.Object, _transactionTypeRepository.Object, _stockService.Object); _product = new Product { ProductId = 1, SKU = "sku", Description = "description", Name = "Coca", DueDate = DateTime.Now, Unity = 10, UnityTypeId = 1, PriceList = 10, Active = true }; _stock = new Stock { StockId = 1, BranchId = 1 }; _transactionType = new TransactionType { TransactionTypeId = 1, Description = "Description", IsIncoming = true }; _productTransaction = new ProductTransaction { ProductTransactionId = 1, ProductId = 1, Quantity = 10, UnityValue = 10, TransactionTypeId = 1, StockId = 1, Product = _product, Stock = _stock, TransactionType = _transactionType }; }
public void CancelReservedSale(int productTransactionId) { var productTransactionReserved = transactionService.GetProductTransaction(productTransactionId); var productTransactionreservedCanceled = new ProductTransaction { ProductId = productTransactionReserved.ProductId, ProductTransactionId = 0, Quantity = productTransactionReserved.Quantity, StockId = productTransactionReserved.StockId, TransactionTypeId = transactionService.GetTransactionTypeByDescription("Reserva Cancelada").TransactionTypeId, UnityValue = productTransactionReserved.UnityValue, UserId = productTransactionReserved.UserId }; transactionService.CreateProductTransaction(productTransactionreservedCanceled); var sale = saleRepository.GetByProductTransactionId(productTransactionId); sale.ExpirationDate = null; sale.Status = "Reserva Cancelada"; UpdateSale(sale); }
public void AddStock(/*out ErrorDto error*/) { Stock newStock = new Stock(); if (CheckAddStockFields()) { newStock.StockName = addStockForm.mtxtStockName.Text; newStock.CurrentUnitPrice = Convert.ToDouble(addStockForm.mtxtUnitPrice.Text); newStock.Description = addStockForm.mtxtStockDescription.Text; newStock.UserCompanyId = mainForm.userCompanyId; if (addStockForm.mtxtStockStartingCount.Text != "0") { ProductTransaction newProductTransaction = new ProductTransaction(); newProductTransaction.ProductNumber = int.Parse(addStockForm.mtxtStockStartingCount.Text); newProductTransaction.Date = DateTime.Now; newProductTransaction.UnitPrice = int.Parse(addStockForm.mtxtUnitPrice.Text); newProductTransaction.Description = addStockForm.mtxtStockDescription.Text; newStock.ProductTransactions.Add(newProductTransaction); } bStock.Add(newStock, out ErrorDto error); if (error.ProcessResult) { addStockForm.Close(); MessageBox.Show("Stok Ekleme Başarılı.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); FillProductsToDataGrid(mainForm.userCompanyId); } else { Error.Show(error); } } }
/// <summary> /// ürünün gerçek fiyatına indirim uygular /// </summary> public override decimal Calculate(ProductTransaction productTransaction) { var productPrice = base.Calculate(productTransaction); return(CalculateReducedPrice(productTransaction, productPrice)); }
public void delete(ProductTransaction pt) { SaveChanges(); }
/// <summary> /// process all item transactions /// </summary> /// <param name="transaction"></param> /// <param name="item"></param> /// <param name="units"></param> public static void ProcessTransaction(ProductTransaction transaction, Item item, int units) { transaction(item, units); }
public void pardakhteNesie(ProductTransaction pt) { DBContext myDB = new DBContext();////We need this to use function - association }
public void save(ProductTransaction pt) { ProductTransactions.Add(pt); SaveChanges(); }
public List <Product> Products() { return(ProductTransaction.GetProducts()); }
public void update(ProductTransaction pt) { }