public ProductOrderDtlDTO GetProductOrderDtlById(int productOrderDtlId) { var productOrderDtl = unitOfWork.ProductOrderDtlRepository.GetById(productOrderDtlId); ProductOrderDtlDTO productOrderDtlDTO = ProductOrderDtlDTOConvertor.ConvertToProductOrderDtlDto(productOrderDtl); return(productOrderDtlDTO); }
public static ProductOrderDtlDTO ConvertToProductOrderDtlDto(ProductOrderDetail productOrderDetail) { ProductOrderDtlDTO productOrderDtlDTO = new ProductOrderDtlDTO(); productOrderDtlDTO.ProductOrderDetailId = productOrderDetail.ProductOrderDetailId; productOrderDtlDTO.OrderId = productOrderDetail.OrderId.GetValueOrDefault(); productOrderDtlDTO.ProductMappingId = productOrderDetail.ProductMappingId.GetValueOrDefault(); productOrderDtlDTO.Quantity = productOrderDetail.Quantity.GetValueOrDefault(); productOrderDtlDTO.TotalPrice = productOrderDetail.TotalPrice.GetValueOrDefault(); productOrderDtlDTO.OrderStatus = productOrderDetail.OrderStatus.ToString(); productOrderDtlDTO.DeliveryExpectedDate = productOrderDetail.DeliveryExpectedDate; productOrderDtlDTO.DeliveredDate = productOrderDetail.DeliveredDate.GetValueOrDefault(); productOrderDtlDTO.DeliveredBy = productOrderDetail.DeliveredBy; productOrderDtlDTO.VehicleNumber = productOrderDetail.VehicleNumber; productOrderDtlDTO.DriverName = productOrderDetail.DriverName; productOrderDtlDTO.DriverNumber = productOrderDetail.DriverNumber; productOrderDtlDTO.JCBDriverNumber = productOrderDetail.JCBDriverNumber; productOrderDtlDTO.RoyaltyNumber = productOrderDetail.RoyaltyNumber; productOrderDtlDTO.OrderAddress = productOrderDetail.OrderAddress; productOrderDtlDTO.Ref1 = productOrderDtlDTO.Ref1; productOrderDtlDTO.Ref2 = productOrderDtlDTO.Ref2; return(productOrderDtlDTO); }
public IHttpActionResult Post([FromBody] ProductOrderDtlDTO productOrderDtlDTO) { if (_productOrderDtlService == null) { return(BadRequest("Argument Null")); } _productOrderDtlService.AddProductOrderDtl(productOrderDtlDTO); return(Ok()); }
private void CalculateOrderAmount(ProductOrderDtlDTO productOrderDtlDTO) { if (productOrderDtlDTO.Quantity > 0 && productOrderDtlDTO.ProductMappingId > 0) { decimal productUnitPrice = unitOfWork.ProductSiteMappingRepository.GetById(productOrderDtlDTO.ProductMappingId).Product.ProductPrice.GetValueOrDefault(); productOrderDtlDTO.OrderPrice = productUnitPrice * productOrderDtlDTO.Quantity; } else { productOrderDtlDTO.OrderPrice = 0; } }
public IHttpActionResult Put(int id, [FromBody] ProductOrderDtlDTO productOrderDtlDTO) { if (productOrderDtlDTO == null) { return(BadRequest("Argument Null")); } productOrderDtlDTO.ProductOrderDetailId = id; _productOrderDtlService.UpdateProductOrderDtl(productOrderDtlDTO); return(Ok()); }
public void AddCustomerPayment(ProductOrderDtlDTO productOrderDtlDTO) { CustomerPaymentTransaction customerPaymentTransaction = new CustomerPaymentTransaction(); customerPaymentTransaction.CustomerPaymentId = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerPaymentTransaction"); customerPaymentTransaction.CustomerId = productOrderDtlDTO.CustomerId; customerPaymentTransaction.OrderId = productOrderDtlDTO.OrderId; customerPaymentTransaction.PaymentCrAmount = productOrderDtlDTO.OrderAmountPaid; customerPaymentTransaction.PaymentDrAmount = productOrderDtlDTO.TotalPrice; customerPaymentTransaction.PaymentReceivedBy = "Order Placed"; customerPaymentTransaction.PaymentDate = DateTime.Now.Date; unitOfWork.CustomerPaymentRepository.Add(customerPaymentTransaction); }
private void CalcualteOrderTax(ProductOrderDtlDTO productOrderDtlDTO) { bool isTaxEnable = Convert.ToBoolean(unitOfWork.SiteConfigurationRepository.GetSiteConfigurationByKeyTypeAndKeyName("OrderTax", "IsEnable", "False")); if (isTaxEnable) { decimal taxPrecentage = Convert.ToDecimal(unitOfWork.SiteConfigurationRepository.GetSiteConfigurationByKeyTypeAndKeyName("OrderTax", "Percentage", "7")); productOrderDtlDTO.OrderTax = ((productOrderDtlDTO.OrderPrice * taxPrecentage) / (decimal)100.00); } else { productOrderDtlDTO.OrderTax = 0; } productOrderDtlDTO.TotalPrice = productOrderDtlDTO.OrderPrice + productOrderDtlDTO.OrderTax; }
private void AddOrUpdateCustomerWallet(ProductOrderDtlDTO productOrderDtlDTO) { var customerWallet = unitOfWork.CustomerWalletRepository.GetByCustomerId(productOrderDtlDTO.CustomerId); if (customerWallet != null) { customerWallet.WalletBalance += productOrderDtlDTO.TotalPrice; unitOfWork.CustomerWalletRepository.Update(customerWallet); } else { customerWallet = new CustomerWallet(); customerWallet.WalletId = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerWallet"); customerWallet.CustomerId = productOrderDtlDTO.CustomerId; customerWallet.WalletBalance = productOrderDtlDTO.TotalPrice; customerWallet.AmountDueDate = DateTime.Now.AddDays(10); unitOfWork.CustomerWalletRepository.Add(customerWallet); } }
public static ProductOrderDtlDTO ConvertToProductOrderDtlDto(ProductOrderDetail productOrderDetail) { ProductOrderDtlDTO productOrderDtlDTO = new ProductOrderDtlDTO(); productOrderDtlDTO.ProductOrderDetailId = productOrderDetail.ProductOrderDetailId; productOrderDtlDTO.CustomerId = productOrderDetail.ProductOrder.OrderCustomerId.GetValueOrDefault(); productOrderDtlDTO.CustomerName = productOrderDetail.ProductOrder.Customer.Name; productOrderDtlDTO.OrderId = productOrderDetail.ProductOrder.OrderId; productOrderDtlDTO.OrderNumber = productOrderDetail.ProductOrder.OrderNumber; productOrderDtlDTO.ProductMappingId = productOrderDetail.ProductMappingId.GetValueOrDefault(); productOrderDtlDTO.ProductName = productOrderDetail.ProductSiteMapping.Product.ProductName; productOrderDtlDTO.UnitPrice = productOrderDetail.ProductSiteMapping.Product.ProductPrice.HasValue ? productOrderDetail.ProductSiteMapping.Product.ProductPrice.Value : 0; productOrderDtlDTO.Quantity = productOrderDetail.Quantity.GetValueOrDefault(); productOrderDtlDTO.OrderPrice = productOrderDetail.ProductOrder.OrderPrice; productOrderDtlDTO.OrderTax = productOrderDetail.ProductOrder.OrderTax.GetValueOrDefault(); productOrderDtlDTO.CGSTTax = productOrderDetail.ProductOrder.CGSTTax.GetValueOrDefault(); productOrderDtlDTO.SGSTTax = productOrderDetail.ProductOrder.SGSTTax.GetValueOrDefault(); productOrderDtlDTO.OrderDiscount = productOrderDetail.ProductOrder.OrderDiscount.GetValueOrDefault(); productOrderDtlDTO.OrderAmountPaid = productOrderDetail.ProductOrder.OrderPaidAmount.GetValueOrDefault(); productOrderDtlDTO.TotalPrice = productOrderDetail.ProductOrder.OrderTotalPrice.GetValueOrDefault(); productOrderDtlDTO.OrderStatus = productOrderDetail.OrderStatus.ToString(); productOrderDtlDTO.DeliveryExpectedDate = productOrderDetail.DeliveryExpectedDate; productOrderDtlDTO.DeliveredDate = productOrderDetail.DeliveredDate.GetValueOrDefault(); productOrderDtlDTO.DeliveredBy = productOrderDetail.DeliveredBy; productOrderDtlDTO.VehicleNumber = productOrderDetail.VehicleNumber; productOrderDtlDTO.DriverName = productOrderDetail.DriverName; productOrderDtlDTO.DriverNumber = productOrderDetail.DriverNumber; productOrderDtlDTO.JCBDriverName = productOrderDetail.JCBDriverName; productOrderDtlDTO.RoyaltyNumber = productOrderDetail.RoyaltyNumber; productOrderDtlDTO.ChallanNumber = productOrderDetail.ChalanNumber; productOrderDtlDTO.OrderAddress = productOrderDetail.OrderAddress; productOrderDtlDTO.Ref1 = productOrderDetail.Ref1; productOrderDtlDTO.Ref2 = productOrderDetail.Ref2; return(productOrderDtlDTO); }
private void AddOrUpdateProductSales(ProductOrderDtlDTO productOrderDtlDTO) { var sales = unitOfWork.ProductSalesRepository.GetByProductAndSalesDate(productOrderDtlDTO.ProductMappingId, DateTime.Now.Date); if (sales == null) { ProductSale productSale = new ProductSale(); productSale.SalesId = unitOfWork.DashboardRepository.NextNumberGenerator("ProductSales"); productSale.SalesDate = DateTime.Now.Date; productSale.TotalPrice = productOrderDtlDTO.TotalPrice; productSale.ProductMappingId = productOrderDtlDTO.ProductMappingId; productSale.Quantity = productOrderDtlDTO.Quantity; unitOfWork.ProductSalesRepository.Add(productSale); } else { sales.Quantity += productOrderDtlDTO.Quantity; sales.TotalPrice += productOrderDtlDTO.TotalPrice; unitOfWork.ProductSalesRepository.Update(sales); } }
public void AddProductOrderDtl(ProductOrderDtlDTO productOrderDtlDTO) { this.CalculateOrderAmount(productOrderDtlDTO); this.CalcualteOrderTax(productOrderDtlDTO); ProductOrderDetail productOrderDetail = unitOfWork.ProductOrderDtlRepository.GetById(productOrderDtlDTO.ProductOrderDetailId); if (productOrderDetail != null) { productOrderDetail.ProductMappingId = productOrderDtlDTO.ProductMappingId; if (productOrderDtlDTO.Quantity > 0) { productOrderDetail.Quantity = productOrderDtlDTO.Quantity; } if (productOrderDtlDTO.OrderPrice > 0) { productOrderDetail.TotalPrice = productOrderDtlDTO.OrderPrice; } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.OrderStatus) == false) { productOrderDetail.OrderStatus = (int)((OrderStatus)Enum.Parse(typeof(OrderStatus), productOrderDtlDTO.OrderStatus)); } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.VehicleNumber) == false) { productOrderDetail.VehicleNumber = productOrderDtlDTO.VehicleNumber; } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.DriverName) == false) { productOrderDetail.DriverName = productOrderDtlDTO.DriverName; } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.DriverNumber) == false) { productOrderDetail.DriverNumber = productOrderDtlDTO.DriverNumber; } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.JCBDriverName) == false) { productOrderDetail.JCBDriverName = productOrderDtlDTO.JCBDriverName; } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.RoyaltyNumber) == false) { productOrderDetail.RoyaltyNumber = productOrderDtlDTO.RoyaltyNumber; } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.ChallanNumber) == false) { productOrderDetail.ChalanNumber = productOrderDtlDTO.ChallanNumber; } if (string.IsNullOrWhiteSpace(productOrderDtlDTO.DeliveredBy) == false) { productOrderDetail.DeliveredBy = productOrderDtlDTO.DeliveredBy; } if (productOrderDetail.DeliveredDate != DateTime.MinValue) { productOrderDetail.DeliveredDate = productOrderDtlDTO.DeliveredDate; } unitOfWork.ProductOrderDtlRepository.Update(productOrderDetail); //Update product Order for tax and total price ProductOrder productOrder = unitOfWork.ProductOrderRepository.GetById(productOrderDtlDTO.OrderId); productOrder.OrderPrice = productOrderDtlDTO.OrderPrice; productOrder.OrderTax = productOrderDtlDTO.OrderTax; productOrder.CGSTTax = productOrderDtlDTO.CGSTTax; productOrder.SGSTTax = productOrderDtlDTO.SGSTTax; productOrder.OrderDiscount = productOrderDtlDTO.OrderDiscount; productOrder.OrderPaidAmount = productOrderDtlDTO.OrderAmountPaid; productOrder.OrderTotalPrice = productOrderDtlDTO.TotalPrice - productOrderDtlDTO.OrderDiscount; unitOfWork.ProductOrderRepository.Update(productOrder); this.AddOrUpdateProductSales(productOrderDtlDTO); this.AddCustomerPayment(productOrderDtlDTO); this.AddOrUpdateCustomerWallet(productOrderDtlDTO); unitOfWork.SaveChanges(); } }
public void AddProductOrderDtl(ProductOrderDtlDTO customerDto) { throw new NotImplementedException(); }
public static void ConvertToProductOrderDetailEntity(ref ProductOrderDetail productOrderDetail, ProductOrderDtlDTO productOrderDtlDTO, bool isUpdate) { if (isUpdate) { productOrderDetail.DeliveredDate = productOrderDtlDTO.DeliveredDate; productOrderDetail.DeliveredBy = productOrderDtlDTO.DeliveredBy; productOrderDetail.VehicleNumber = productOrderDtlDTO.VehicleNumber; productOrderDetail.DriverName = productOrderDtlDTO.DriverName; productOrderDetail.DriverNumber = productOrderDtlDTO.DriverNumber; productOrderDetail.JCBDriverName = productOrderDtlDTO.JCBDriverName; productOrderDetail.RoyaltyNumber = productOrderDtlDTO.RoyaltyNumber; productOrderDetail.ChalanNumber = productOrderDtlDTO.ChallanNumber; productOrderDetail.OrderAddress = productOrderDtlDTO.OrderAddress; } else { productOrderDetail.OrderId = productOrderDtlDTO.OrderId; productOrderDetail.ProductMappingId = productOrderDtlDTO.ProductMappingId; productOrderDetail.Quantity = productOrderDtlDTO.Quantity; productOrderDetail.TotalPrice = productOrderDtlDTO.TotalPrice; productOrderDetail.DeliveryExpectedDate = productOrderDtlDTO.DeliveryExpectedDate; } productOrderDetail.OrderStatus = (int)((OrderStatus)Enum.Parse(typeof(OrderStatus), productOrderDtlDTO.OrderStatus)); productOrderDetail.Ref1 = productOrderDtlDTO.Ref1; productOrderDetail.Ref2 = productOrderDtlDTO.Ref2; }