From a4af03be3cf410e4baaf70244932eb2b49632c05 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 11 Nov 2025 20:15:07 +0100 Subject: [PATCH] small fixes, cors policy, discounts, innvoice order date fix, innvoice email address fix --- .../Controllers/CustomOrderController.cs | 13 +++++++--- .../Controllers/InnVoiceOrderController.cs | 22 ++++++++++++---- .../Admin/Views/AppDownload/Index.cshtml | 26 ++++++++++--------- .../Services/CustomPriceCalculationService.cs | 9 +++++-- .../Infrastructure/PluginNopStartup.cs | 2 +- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs index c5b8a4a..0b654a0 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomOrderController.cs @@ -1235,9 +1235,16 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers } // Get or calculate price - var unitPrice = productModel.Price > 0 - ? productModel.Price - : (await _priceCalculationService.GetFinalPriceAsync(product, customer, store)).finalPrice; + //var unitPrice = productModel.Price > 0 + // ? productModel.Price + // : (await _priceCalculationService.GetFinalPriceAsync(product, customer, store)).finalPrice; + + + var valami = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: true); + var originalPrice = valami.priceWithoutDiscounts; + var discountAmount = valami.appliedDiscountAmount; + var discountedPrice = valami.appliedDiscounts; + var unitPrice = valami.finalPrice; // Calculate tax var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer); diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/InnVoiceOrderController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/InnVoiceOrderController.cs index 0fb48c7..d69fa4f 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/InnVoiceOrderController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/InnVoiceOrderController.cs @@ -68,13 +68,23 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers { // Validate and get order var order = await _orderService.GetOrderByIdAsync(orderId); + var orderDto = await _dbContext.OrderDtos.GetByIdAsync(orderId, true); if (order == null) { return Json(new { success = false, message = "Order not found" }); } + if (orderDto == null) + { + return Json(new { success = false, message = "OrderDTO not found" }); + } + + if (orderDto.DateOfReceipt == null) + { + return Json(new { success = false, message = "Ki kell tölteni az átvétel idejét." }); + } // Validate and get customer - var customer = await _customerService.GetCustomerByIdAsync(order.CustomerId); + var customer = await _customerService.GetCustomerByIdAsync(orderDto.CustomerId); if (customer == null) { return Json(new { success = false, message = "Customer not found" }); @@ -105,13 +115,15 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers VevoOrszag = billingCountryCode, VevoAdoszam = customer.VatNumber, MegrendelestombID = 1, - MegrendelesKelte = order.CreatedOnUtc.ToLocalTime(), + MegrendelesKelte = ((DateTime)orderDto.DateOfReceipt).ToLocalTime(), Hatarido = DateTime.Now.AddDays(7), Devizanem = "Ft", // TODO: get real default - A. - FizetesiMod = order.PaymentMethodSystemName ?? "átutalás", - Email = customer.Email ?? string.Empty, + //FizetesiMod = order.PaymentMethodSystemName ?? "átutalás", + FizetesiMod = "átutalás", + //Email = customer.Email ?? string.Empty, + Email = billingAddress.Email ?? customer.Email ?? string.Empty, Telefon = billingAddress.PhoneNumber ?? string.Empty, - MegrendelesSzamStr = order.Id.ToString() + MegrendelesSzamStr = orderDto.Id.ToString() }; // Add shipping address details diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/AppDownload/Index.cshtml b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/AppDownload/Index.cshtml index 6f1ba3e..9388d88 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/AppDownload/Index.cshtml +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Views/AppDownload/Index.cshtml @@ -134,19 +134,21 @@ diff --git a/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs b/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs index dc435be..125a6bf 100644 --- a/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs +++ b/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs @@ -152,9 +152,14 @@ public class CustomPriceCalculationService : PriceCalculationService { var productDto = await _dbContext.ProductDtos.GetByIdAsync(product.Id, true); + + var finalPrice = await base.GetFinalPriceAsync(product, customer, store, overriddenProductPrice, additionalCharge, includeDiscounts, quantity, rentalStartDate, rentalEndDate); + if (productDto.IsMeasurable) { - return (0, product.Price, 1000m, []); + //finalPrice.priceWithoutDiscounts = 0; + //return (0, finalPrice.finalPrice, finalPrice.appliedDiscountAmount, []); + return finalPrice; //return (overriddenProductPrice.GetValueOrDefault(0), overriddenProductPrice.GetValueOrDefault(0), 0m, []); } //var productAttributeMappings = await _specificationAttributeService.GetProductSpecificationAttributesAsync(product.Id); @@ -174,6 +179,6 @@ public class CustomPriceCalculationService : PriceCalculationService // } //} - return await base.GetFinalPriceAsync(product, customer, store, overriddenProductPrice, additionalCharge, includeDiscounts, quantity, rentalStartDate, rentalEndDate); + return finalPrice; } } diff --git a/Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs b/Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs index 7930106..25f66ba 100644 --- a/Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs +++ b/Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs @@ -24,7 +24,7 @@ public class PluginNopStartup : INopStartup feature.AddPolicy( "AllowBlazorClient", apiPolicy => apiPolicy - .WithOrigins(["https://localhost:7144", "measuringtest.fruitbank.hu", "https://localhost:60589"]) + .WithOrigins(["https://localhost:7144", "https://measurementtest.fruitbank.hu", "https://localhost:60589", "http://localhost:5000"]) .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials()