Innvoice order fix and note addition

This commit is contained in:
Adam 2025-11-12 17:56:49 +01:00
parent a4af03be3c
commit 22d2436d5f
2 changed files with 15 additions and 2 deletions

View File

@ -105,6 +105,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
var shippingCountry = await _countryService.GetCountryByAddressAsync(shippingAddress); var shippingCountry = await _countryService.GetCountryByAddressAsync(shippingAddress);
var shippingCountryCode = shippingCountry?.TwoLetterIsoCode ?? billingCountryCode; var shippingCountryCode = shippingCountry?.TwoLetterIsoCode ?? billingCountryCode;
string megjegyzes = string.Empty;
// Create order request // Create order request
var orderRequest = new OrderCreateRequest var orderRequest = new OrderCreateRequest
{ {
@ -123,7 +125,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
//Email = customer.Email ?? string.Empty, //Email = customer.Email ?? string.Empty,
Email = billingAddress.Email ?? customer.Email ?? string.Empty, Email = billingAddress.Email ?? customer.Email ?? string.Empty,
Telefon = billingAddress.PhoneNumber ?? string.Empty, Telefon = billingAddress.PhoneNumber ?? string.Empty,
MegrendelesSzamStr = orderDto.Id.ToString() MegrendelesSzamStr = orderDto.Id.ToString(),
Megjegyzes = $""
}; };
// Add shipping address details // Add shipping address details
@ -174,8 +177,16 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
CikkSzam = string.Empty CikkSzam = string.Empty
}); });
} }
if(item.UnitPriceInclTax != product.Price)
{
megjegyzes += $"{productName} egységár módosítva: {Math.Round(product.Price, 2)} Ft -> {Math.Round(item.UnitPriceInclTax, 2)} Ft; \n";
megjegyzes += $"Kedvezmény: { ((1 - (item.UnitPriceInclTax / product.Price)) * 100).ToString() }%; \n";
}
} }
orderRequest.Megjegyzes = megjegyzes;
// Create order via API // Create order via API
var response = await _innVoiceOrderService.CreateOrderAsync(orderRequest); var response = await _innVoiceOrderService.CreateOrderAsync(orderRequest);
@ -370,7 +381,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
FizetesiMod = order.PaymentMethodSystemName, FizetesiMod = order.PaymentMethodSystemName,
Email = billingAddress.Email, Email = billingAddress.Email,
Telefon = billingAddress.PhoneNumber, Telefon = billingAddress.PhoneNumber,
MegrendelesSzamStr = order.Id.ToString() MegrendelesSzamStr = order.Id.ToString(),
Megjegyzes = $""
}; };
// Add order items // Add order items

View File

@ -18,6 +18,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
private readonly string _password; private readonly string _password;
private readonly string _baseUrl; private readonly string _baseUrl;
//public InnVoiceOrderService(string companyName = "apiteszt", string username = "apiteszt", string password = "dsjfluio4324hjhjfdhkjskjh213kjgsd", string baseUrl = "https://api.innvoice.hu")
public InnVoiceOrderService(string companyName = "fruitbank", string username = "fruitbank", string password = "YkKzM1dwJax0HTlPWlMABSqdSA", string baseUrl = "https://api.innvoice.hu") public InnVoiceOrderService(string companyName = "fruitbank", string username = "fruitbank", string password = "YkKzM1dwJax0HTlPWlMABSqdSA", string baseUrl = "https://api.innvoice.hu")
{ {
_companyName = companyName ?? throw new ArgumentNullException(nameof(companyName)); _companyName = companyName ?? throw new ArgumentNullException(nameof(companyName));