public BillToModel(ProductQuote quote, Dictionary <string, byte[]> imageByImageName) { var contactMechanism = quote.FullfillContactMechanism; if (contactMechanism is PostalAddress postalAddress) { this.Address = postalAddress.Address1; if (!string.IsNullOrWhiteSpace(postalAddress.Address2)) { this.Address = $"\n{postalAddress.Address2}"; } if (!string.IsNullOrWhiteSpace(postalAddress.Address3)) { this.Address = $"\n{postalAddress.Address3}"; } this.City = postalAddress.Locality; this.State = postalAddress.Region; this.PostalCode = postalAddress.PostalCode; this.Country = postalAddress.Country?.Name; } if (contactMechanism is ElectronicAddress electronicAddress) { this.Address = electronicAddress.ElectronicAddressString; } }
public ReceiverModel(ProductQuote quote, Dictionary <string, byte[]> imageByImageName) { var session = quote.Strategy.Session; var receiver = quote.Receiver; var organisationReceiver = quote.Receiver as Organisation; if (receiver != null) { this.Name = receiver.PartyName; this.TaxId = organisationReceiver?.TaxNumber; } this.Contact = quote.ContactPerson?.PartyName; this.ContactFirstName = quote.ContactPerson?.FirstName; this.Salutation = quote.ContactPerson?.Salutation?.Name; this.ContactFunction = quote.ContactPerson?.Function; if (quote.ContactPerson?.CurrentPartyContactMechanisms.FirstOrDefault(v => v.ContactMechanism.GetType().Name == typeof(EmailAddress).Name)?.ContactMechanism is EmailAddress emailAddress) { this.ContactEmail = emailAddress.ElectronicAddressString; } if (quote.ContactPerson?.CurrentPartyContactMechanisms.FirstOrDefault(v => v.ContactMechanism.GetType().Name == typeof(TelecommunicationsNumber).Name)?.ContactMechanism is TelecommunicationsNumber phone) { this.ContactPhone = phone.ToString(); } }
public IHttpActionResult CreateProductQuoteExpress(ProductQuote productQuote) { if (ModelState.IsValid) { Boolean sendNotifications = globalVariableRepository.FindGlobalVariables().EnvioCotizacionPorMail; Boolean sendUserCreatorNotifications = globalVariableRepository.FindGlobalVariables().EnvioCotizacionUsuarioCreadorPorMail; Boolean sendClientNotifications = customerRepository.FindCustomersByID(productQuote.CustomerID).SendNotifications; if (User.IsInRole("SellerUser") && !(User.IsInRole("AdminUser"))) { sendClientNotifications = true; } if (User.IsInRole("AdminUser")) { sendClientNotifications = false; } productQuote.ProductQuotePDFFooter = System.Configuration.ConfigurationManager.AppSettings["ProductQuotePDFFooter"].ToString(); productQuote.ProductQuoteSmallPDFFooter = System.Configuration.ConfigurationManager.AppSettings["ProductQuoteSmallPDFFooter"].ToString(); productQuoteService.CreateQuote(productQuote.CustomerContactMail, productQuote, sendNotifications, sendClientNotifications, sendUserCreatorNotifications); var res = new { ok = true, data = productQuote, returnUrl = "../ProductQuote/DetailsExpress/" + productQuote.ProductQuoteID.ToString() + "?pq=1&customerID=0" }; return(Json(res)); } else { return(BadRequest(ModelState)); } }
public void GetMargenNetoPorcentual_PORC_USD_Cliente_NULL_Producto() { // Arrange MarginServices marginServices = new MarginServices(); ProductQuote productQuote = new ProductQuote(); Product product = new Product(); Customer customer = new Customer(); SaleModalityCreditRating saleModalityCreditRating = new SaleModalityCreditRating(); saleModalityCreditRating.MinimumMarginPercentage = 5; saleModalityCreditRating.MinimumMarginUSD = 50; customer.MinimumMarginPercentage = 10; customer.MinimumMarginUSD = 100; // Act MininumMarginSale mininumMarginSale = marginServices.GetMargenNetoPorcentual(productQuote, product, customer, saleModalityCreditRating); // Assert Assert.AreEqual(10, mininumMarginSale.MinimumMarginPercentage); Assert.AreEqual(100, mininumMarginSale.MinimumMarginUSD); Assert.AreEqual(mininumMarginSale.MininumMarginSourcePercentage, MarginTypes.MarginCustomer); Assert.AreEqual(mininumMarginSale.MininumMarginSourceUSD, MarginTypes.MarginCustomer); }
private void SetCustomerToProductQuote(ProductQuote productQuote, Customer customer) { productQuote.CustomerID = customer.CustomerID; //Agrofacil S.A. productQuote.CustomerName = ""; productQuote.CustomerContactMail = customer.ContactEmail; productQuote.CustomerCompany = customer.Company; productQuote.CustomerDelayAverageDays = customer.DelayAverageDays; }
public void DeleteProductQuoteSmallPdf(ProductQuote productQuote) { string pathFile = Path.Combine(CommonHelper.MapPath("~/Documents/Export"), productQuote.ProductQuoteSmallPDF == null ? "" : productQuote.ProductQuoteSmallPDF); if (File.Exists(pathFile)) { File.Delete(pathFile); } }
public MininumMarginSale GetMargenNetoPorcentual(ProductQuote productQuoteToAdd, Product product, Customer customer, SaleModalityCreditRating saleModalityCreditRating) { MaxMinimunMarginSale maxMarginPercentage = GetMaxMarginPercentage(productQuoteToAdd, product, customer, saleModalityCreditRating); MaxMinimunMarginSale maxMarginUSD = GetMaxMarginUSD(productQuoteToAdd, product, customer, saleModalityCreditRating); MininumMarginSale result = new MininumMarginSale(maxMarginPercentage.MarginValue, maxMarginUSD.MarginValue, maxMarginPercentage.MarginSource, maxMarginUSD.MarginSource); return(result); }
public ProductQuoteReasonsForClosureViewModel(ProductQuote pq) { this.ProductQuoteID = pq.ProductQuoteID; this.ProductQuoteCode = pq.ProductQuoteCode; this.ReasonsForClosureID = pq.ReasonsForClosureID; this.ReasonsForClosure = pq.ReasonsForClosure; this.ClosureDate = pq.ClosureDate; this.ClosureObservations = pq.ClosureObservations; }
public ProductQuote CalculateProductQuote(ProductQuote productQuote) { LogProductQuoteCalc(productQuote, "Calculo Cotizacion - PRE"); productQuoteService.CalculateQuote(productQuote); LogProductQuoteCalc(productQuote, "Calculo Cotizacion - POST"); return(productQuote); }
private bool IsValidProductQuote(int productQuoteID) { ProductQuote pq = productQuoteRepository.FindProductQuotesByID(productQuoteID); if (pq.ProductValidityOfPrice < DateTime.Now.Date) { return(false); } return(true); }
public Model(ProductQuote quote) { this.Quote = new QuoteModel(quote); this.Request = new RequestModel(quote.Request); this.Issuer = new IssuerModel((Organisation)quote.Issuer); this.BillTo = new BillToModel(quote); this.Receiver = new ReceiverModel(quote); this.QuoteItems = quote.QuoteItems.Select(v => new QuoteItemModel(v)).ToArray(); }
public Model(ProductQuote quote, Dictionary <string, byte[]> images) { this.Quote = new QuoteModel(quote, images); this.Request = new RequestModel(quote, images); this.Issuer = new IssuerModel(quote, images); this.BillTo = new BillToModel(quote, images); this.Receiver = new ReceiverModel(quote, images); this.QuoteItems = quote.QuoteItems.Select(v => new QuoteItemModel(v, images)).ToArray(); }
private string CreateBody(ProductQuote productQuote) { string result = ""; result = result + "<b>Usuario: </b>" + productQuote.UserFullName + "<br>"; result = result + "<b>Cliente: </b>" + productQuote.CustomerCompany + "<br>"; result = result + "<b>Fecha y Hora: </b>" + productQuote.DateQuote + "<br>"; result = result + "<b>Producto: </b>" + productQuote.ProductName + "<br>"; return(result); }
public ReceiverModel(ProductQuote quote) { var receiver = quote.Receiver; var organisationReceiver = quote.Receiver as Organisation; if (receiver != null) { this.Name = receiver.PartyName; this.TaxId = organisationReceiver?.TaxNumber; } this.Contact = quote.ContactPerson?.PartyName; }
public void Cuando_CalculamosCon_ProductoNull_DeberiaRetornarMensaje() { // Arrange IProductQuoteService productQuoteService = new ProductQuoteServiceBuilder().Build(); // Act ProductQuote productQuote = new ProductQuote(); productQuoteService.CalculateQuote(productQuote); // Assert Assert.AreEqual("Debe ingresar un Producto", productQuote.Message); }
public HttpResponseMessage CreateCustomerOrder(ProductQuote productQuote) { if (ModelState.IsValid) { //Si el usuario es un Vendedor Interno, entonces se crea la Cotizacion APROBADA productQuoteService.CreateCustomerOrder(null, productQuote, User.IsInRole("SellerUser")); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
private void LogProductQuoteCalc(ProductQuote productQuote, string messageTitle) { var jsonProductQuote = Newtonsoft.Json.JsonConvert.SerializeObject(productQuote); var log = new LogRecord { LogLevel = LogLevel.Information, ShortMessage = messageTitle + " - (Cliente: " + productQuote.CustomerName + " - Producto: " + productQuote.ProductName + ")", FullMessage = jsonProductQuote, CreatedOnUtc = DateTime.Now }; logRecordRepository.Create(log); }
private void SetProductToProductQuote(ProductQuote productQuote, Product product) { //Producto productQuote.ProductID = product.ProductID; //5: Agua Amoniacal 28% productQuote.ProductName = product.FullName; productQuote.ProductProviderName = product.Provider.ProviderName; productQuote.ProductBrandName = product.Brand; productQuote.ProductFCLKilogram = product.FCLKilogram.ToString(); productQuote.ProductBuyAndSellDirect = product.BuyAndSellDirect; productQuote.ProductSingleName = product.Name; productQuote.ProductPackagingID = product.PackagingID; productQuote.ProductPackagingName = product.Packaging.Description; productQuote.ProductValidityOfPrice = product.ValidityOfPrice; productQuote.ProductInOutStorage = product.InOutStorage; }
//[HttpPost] public ActionResult CreateWhitDefault(ProductQuote productQuote) { ViewBag.CustomerID = new SelectList(customerRepository.FindCustomers(), "CustomerID", "Company"); ViewBag.ProductID = new SelectList(productRepository.Products(), "ProductID", "FullName"); ViewBag.SaleModalityID = new SelectList(saleModalityRepository.SaleModalitys(), "SaleModalityID", "Description"); ViewBag.GeographicAreaID = new SelectList(geographicAreaRepository.GeographicAreas(), "GeographicAreaID", "Name"); ViewBag.PaymentDeadlineID = new SelectList(paymentDeadlineRepository.PaymentDeadlines(), "PaymentDeadlineID", "Description"); ViewBag.ExchangeTypeID = new SelectList(exchangeTypeRepository.ExchangeTypes(), "ExchangeTypeID", "Description"); ViewBag.DeliveryAmount = new SelectList(deliveryAmountRepository.DeliveryAmounts(), "DeliveryAmountID", "Description"); ViewBag.MaximumMonthsStock = new SelectList(stockTimeRepository.StockTimes(), "StockTimeID", "Description"); HttpContext.RewritePath("/WayOfException/CreateWhitDefault"); return(View()); }
public BillToModel(ProductQuote quote) { var contactMechanisam = quote.FullfillContactMechanism; if (contactMechanisam is PostalAddress postalAddress) { this.Address = postalAddress.Address1; if (!string.IsNullOrWhiteSpace(postalAddress.Address2)) { this.Address = $"\n{postalAddress.Address2}"; } if (!string.IsNullOrWhiteSpace(postalAddress.Address3)) { this.Address = $"\n{postalAddress.Address3}"; } if (postalAddress.ExistCity) { this.City = postalAddress.City.Name; this.State = postalAddress.City.State?.Name; } else if (postalAddress.ExistPostalBoundary) { var postalBoundary = postalAddress.PostalBoundary; this.City = postalBoundary.Locality; this.State = postalBoundary.Region; this.PostalCode = postalBoundary.PostalCode; this.Country = postalBoundary.Country.Name; } if (this.PostalCode == null) { this.PostalCode = postalAddress.PostalCode?.Code; } if (this.Country == null) { this.Country = postalAddress.Country?.Name; } } if (contactMechanisam is ElectronicAddress electronicAddress) { this.Address = electronicAddress.ElectronicAddressString; } }
public void Cuando_CalculamosCon_QuantityOpenPurchaseOrderEqualOrLessThanZero_And_SaleModalityIsLocal_DeberiaRetornarMensaje() { // Arrange IProductQuoteService productQuoteService = new ProductQuoteServiceBuilder().Build(); // Act ProductQuote productQuote = new ProductQuote(); productQuote.ProductID = 1; productQuote.SaleModalityID = (int)EnumSaleModality.Local; productQuoteService.CalculateQuote(productQuote); // Assert Assert.AreEqual("Debe ingresar Cantidad Total Orden de Compra (Kg)", productQuote.Message); }
public async Task <ActionResult> ReasonsForClosure(int pq, int customerID, int id) { ProductQuote productQuote = await productQuoteRepository.FindProductQuotesByIDAsync(id); ViewBag.Pq = pq; ViewBag.CustomerID = customerID; if (productQuote == null) { return(HttpNotFound()); } ViewBag.ReasonsForClosureID = new SelectList(reasonsForClosureRepository.GetAll(), "ReasonsForClosureID", "Description", productQuote.ReasonsForClosureID); return(View(new ProductQuoteReasonsForClosureViewModel(productQuote))); }
public async Task <ActionResult> DueDateReason(int pq, int customerID, int id) { ProductQuote productQuote = await productQuoteRepository.FindProductQuotesByIDAsync(id); ViewBag.Pq = pq; ViewBag.CustomerID = customerID; if (productQuote == null) { return(HttpNotFound()); } ViewBag.DueDateReasonID = new SelectList(dueDateReasonRepository.DueDateReasons(), "DueDateReasonID", "Description", productQuote.DueDateReasonID); return(View(new ProductQuoteViewModel(productQuote))); }
public void Cuando_CalculamosCon_MinimumQuantityDeliveryNull_DeberiaRetornarMensaje() { // Arrange IProductQuoteService productQuoteService = new ProductQuoteServiceBuilder().Build(); // Act ProductQuote productQuote = new ProductQuote(); productQuote.ProductID = 1; productQuote.SaleModalityID = (int)EnumSaleModality.LocalProgramada; productQuoteService.CalculateQuote(productQuote); // Assert Assert.AreEqual("Debe seleccionar la Cantidad de Entregas.", productQuote.Message); }
public void Cuando_CalculamosCon_MinimumQuantityDelivery_MayorQue_QuantityOpenPurchaseOrder_DeberiaRetornarMensaje() { // Arrange IProductQuoteService productQuoteService = new ProductQuoteServiceBuilder().Build(); // Act ProductQuote productQuote = new ProductQuote(); productQuote.ProductID = 1; productQuote.SaleModalityID = (int)EnumSaleModality.LocalProgramada; productQuote.MinimumQuantityDelivery = 10; productQuoteService.CalculateQuote(productQuote); // Assert Assert.AreEqual("La Cantidad Minima por Entrega (Kg) no puede ser mayor a la Cantidad Total Orden de Compra (Kg)", productQuote.Message); }
public void GetMargenNetoPorcentual_PORC_USD_NULL() { // Arrange MarginServices marginServices = new MarginServices(); ProductQuote productQuote = new ProductQuote(); Product product = new Product(); Customer customer = new Customer(); // Act MininumMarginSale mininumMarginSale = marginServices.GetMargenNetoPorcentual(productQuote, product, customer, null); // Assert Assert.AreEqual(0, mininumMarginSale.MinimumMarginPercentage); Assert.AreEqual(mininumMarginSale.MininumMarginSourcePercentage, MarginTypes.MarginUndefined); }
public void Cuando_CalculamosCon_ModalidadVentaIndentSL_Entonces_CantidadMinimaPorEntrega_DebeSer_Menor_CantidadTotalOrdenCompra() { // Arrange IProductQuoteService productQuoteService = new ProductQuoteServiceBuilder().Build(); // Act ProductQuote productQuote = new ProductQuote(); productQuote.ProductID = 1; productQuote.SaleModalityID = (int)EnumSaleModality.IndentSL; productQuote.MinimumQuantityDelivery = 10; productQuote.MaximumMonthsStock = 0; productQuoteService.CalculateQuote(productQuote); // Assert Assert.AreEqual("La Cantidad Minima por Entrega (Kg) no puede ser mayor a la Cantidad Total Orden de Compra (Kg)", productQuote.Message); }
public string ProductQuoteToSmallPdf(ProductQuote productQuote, string productQuoteSmallPdfTemplate) { string fileTemplate = Path.Combine(CommonHelper.MapPath("~/Documents/Templates"), productQuoteSmallPdfTemplate); string fileNameExport = string.Format("{0}_{1}_{2}.pdf", productQuote.ProductQuoteCode, "Rev08", Guid.NewGuid().ToString().Substring(0, 8)); string fileExport = Path.Combine(CommonHelper.MapPath("~/Documents/Export"), fileNameExport); PdfReader reader = new PdfReader(fileTemplate); FileStream fs = new FileStream(fileExport, FileMode.Create, FileAccess.Write); iTextSharp.text.Rectangle size = reader.GetPageSizeWithRotation(1); Document document = new Document(size); PdfCopy copy = new PdfCopy(document, fs); document.Open(); PdfImportedPage page = null; for (int i = 1; i <= reader.NumberOfPages; i++) { page = copy.GetImportedPage(reader, i); //En la primer pagina ponemos los datos if (i == 1) { PdfCopy.PageStamp pageStamp = copy.CreatePageStamp(page); StampDataIntoSmallPdf(pageStamp, productQuote); pageStamp.AlterContents(); } PdfCopy.PageStamp pageStampFooter = copy.CreatePageStamp(page); StampFooterDataIntoPdf(pageStampFooter, productQuote.ProductQuoteSmallPDFFooter); pageStampFooter.AlterContents(); copy.AddPage(page); } copy.FreeReader(reader); document.Close(); reader.Close(); return(fileNameExport); }
public void SendCustomerProductQuote(string customerEmail, ProductQuote productQuote) { if (productQuote == null) { throw new ArgumentNullException("productQuote"); } string productQuotePDF = productQuote.ExpressCalc ? productQuote.ProductQuoteSmallPDF : productQuote.ProductQuotePDF; EmailAccount emailAccount = emailAccountRepository.FindEmailAccountsDefaultAsync(); Thread senderMail = new Thread(delegate() { emailManager.SendEmail(emailAccount, emailAccount.Email, emailAccount.DisplayName, customerEmail, customerEmail, "", "Cotización On-Line de Producto -" + productQuote.ProductQuoteCode, CreateBody(productQuote), CommonHelper.MapPath("~/Documents/Export"), productQuotePDF); }); senderMail.IsBackground = true; senderMail.Start(); }
//[ValidateAntiForgeryToken] public async Task <ActionResult> Sent(int pq, int customerID, int id) { ViewBag.Pq = pq; ViewBag.CustomerID = customerID; if (ModelState.IsValid) { ProductQuote productQuote = null; productQuote = new ProductQuote { ProductQuoteID = id, DateSent = DateTime.Now }; await productQuoteRepository.UpdateDateSentAsync(productQuote); return(RedirectToAction("Index", new { pq = ViewBag.Pq, customerID = ViewBag.CustomerID })); } return(View()); }