Compare commits

..

2 Commits

Author SHA1 Message Date
Adam 000f1de2dd Merge branch '4.80' of https://git.aycode.com/Adam/Mango.Nop.Plugins into 4.80 2026-03-10 18:11:18 +01:00
Adam a085a2c473 targonca 2026-03-10 18:10:04 +01:00
4 changed files with 65 additions and 4 deletions

View File

@ -88,6 +88,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
protected readonly IDateTimeHelper _dateTimeHelper;
protected readonly ITaxService _taxService;
protected readonly MeasurementService _measurementService;
protected readonly IWorkflowMessageService _workflowMessageService;
private static readonly char[] _separator = [','];
// ... other dependencies
@ -135,7 +136,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
IImportManager importManager,
IDateTimeHelper dateTimeHelper,
ITaxService taxService,
MeasurementService measurementService)
MeasurementService measurementService, IWorkflowMessageService workflowMessageService)
{
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
@ -163,6 +164,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
_dateTimeHelper = dateTimeHelper;
_taxService = taxService;
_measurementService = measurementService;
_workflowMessageService = workflowMessageService;
// ... initialize other deps
}
@ -508,7 +510,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
OrderGuid = Guid.NewGuid(),
CustomOrderNumber = "",
CustomerId = customerId,
CustomerLanguageId = customer.LanguageId ?? 1,
CustomerLanguageId = customer.LanguageId ?? 2,
CustomerTaxDisplayType = TaxDisplayType.IncludingTax,
CustomerIp = string.Empty,
OrderStatus = OrderStatus.Pending,
@ -519,7 +521,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
ShippingAddressId = customer.ShippingAddressId,
PaymentMethodSystemName = "Payments.CheckMoneyOrder", // Default payment method
CustomerCurrencyCode = "HUF", // TODO: GET Default currency - A.
CurrencyRate = 1,
OrderTotal = 0,
OrderSubtotalInclTax = 0,
OrderSubtotalExclTax = 0,
@ -544,7 +546,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
{
//var orderDto = await _dbContext.OrderDtos.GetByIdAsync(order.Id, true);
//await _sendToClient.SendMeasuringNotification("Módosult a rendelés, mérjétek újra!", orderDto);
//var updatedOrder = await _orderService.GetOrderByIdAsync(order.Id);
await _workflowMessageService.SendOrderPlacedCustomerNotificationAsync(order, order.CustomerLanguageId);
return RedirectToAction("Edit", "Order", new { id = order.Id });
}

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Nop.Core;
using Nop.Core.Domain.Customers;
using Nop.Core.Domain.Orders;
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
using Nop.Plugin.Misc.FruitBankPlugin.Services;
@ -15,6 +16,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
{
@ -97,6 +99,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
return Json(new { success = false, message = "Billing address not found" });
}
//get tax info from attributes and sync with VatNumber
if(customer.VatNumber == null || customer.VatNumber == "")
{
await SynchronizeTaxInformationAsync(customer);
}
var billingCountry = await _countryService.GetCountryByAddressAsync(billingAddress);
var billingCountryCode = billingCountry?.TwoLetterIsoCode ?? "HU";
@ -107,6 +115,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
string megjegyzes = string.Empty;
// Create order request
var orderRequest = new OrderCreateRequest
{
@ -476,5 +486,38 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
});
}
}
private async Task SynchronizeTaxInformationAsync(Customer customer)
{
string attributesXml = customer.CustomCustomerAttributesXML;
string taxId = null;
if (!string.IsNullOrWhiteSpace(attributesXml))
{
var doc = XDocument.Parse(attributesXml);
taxId = doc.Descendants("CustomerAttribute")
.FirstOrDefault(el => (int?)el.Attribute("ID") == 1) // your TaxId attribute ID
?.Descendants("Value")
.FirstOrDefault()
?.Value;
}
if (!string.IsNullOrWhiteSpace(taxId) && string.IsNullOrWhiteSpace(customer.VatNumber))
{
customer.VatNumber = taxId;
}
else if (string.IsNullOrWhiteSpace(taxId) && !string.IsNullOrWhiteSpace(customer.VatNumber))
{
await _fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Customer, string>(
customer.Id,
"TaxId",
customer.VatNumber);
}
_dbContext.Customers.Update(customer, false);
}
}
}

View File

@ -29,6 +29,7 @@ using Nop.Plugin.Misc.FruitBankPlugin.Services.FileStorage;
using Nop.Services.Catalog;
using Nop.Services.Common;
using Nop.Services.Events;
using Nop.Services.Messages;
using Nop.Web.Areas.Admin.Factories;
using Nop.Web.Areas.Admin.Models.Catalog;
using Nop.Web.Areas.Admin.Models.Orders;
@ -118,6 +119,7 @@ public class PluginNopStartup : INopStartup
//services.AddScoped<IAIAPIService, OpenAIApiService>();
services.AddScoped<AICalculationService>();
services.AddScoped<PdfToImageService>();
services.AddScoped<IWorkflowMessageService, WorkflowMessageService>();
services.AddSingleton<IFileStorageProvider>(sp =>
new LocalFileStorageProvider() // Uses default wwwroot/uploads

View File

@ -204,6 +204,19 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
shippingConfigurationItem.ChildNodes.Insert(4, InvoiceSyncMenuItem);
// Create a new top-level menu item
var AppDownloadMenuItem = new AdminMenuItem
{
Visible = true,
SystemName = "FruitBank",
Title = await _localizationService.GetResourceAsync("Plugins.Misc.FruitBankPlugin.Menu.AppDownload"), // You can localize this with await _localizationService.GetResourceAsync("...")
IconClass = "fas fa-mobile",
Url = _adminMenu.GetMenuItemUrl("AppDownload", "Index")
//ChildNodes = [shippingsListMenuItem, createShippingMenuItem, editShippingMenuItem]
};
shippingConfigurationItem.ChildNodes.Insert(4, AppDownloadMenuItem);
var invoiceListMenuItem = new AdminMenuItem
{