small fixes, cors policy, discounts, innvoice order date fix, innvoice email address fix

This commit is contained in:
Adam 2025-11-11 20:15:07 +01:00
parent 5c950c6ae4
commit a4af03be3c
5 changed files with 49 additions and 23 deletions

View File

@ -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);

View File

@ -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

View File

@ -134,19 +134,21 @@
<script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
<script>
$(function() {
@if (!string.IsNullOrEmpty(Model.DownloadUrl))
@if (!string.IsNullOrEmpty(Model.CurrentVersion) && !string.IsNullOrEmpty(Model.FileName))
{
<text>
var downloadUrl = window.location.origin + '@Model.DownloadUrl';
new QRCode(document.getElementById("qrcode"), {
text: downloadUrl,
width: 200,
height: 200,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H
});
</text>
<text>
var downloadUrl = '@Url.Action("Download", "AppDownload", new { version = Model.CurrentVersion, fileName = Model.FileName }, Context.Request.Scheme)';
console.log('QR Code URL:', downloadUrl); // Debug log
new QRCode(document.getElementById("qrcode"), {
text: downloadUrl,
width: 200,
height: 200,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H
});
</text>
}
});
</script>

View File

@ -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;
}
}

View File

@ -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()