targonca
This commit is contained in:
parent
efebc96394
commit
a085a2c473
|
|
@ -88,6 +88,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
protected readonly IDateTimeHelper _dateTimeHelper;
|
protected readonly IDateTimeHelper _dateTimeHelper;
|
||||||
protected readonly ITaxService _taxService;
|
protected readonly ITaxService _taxService;
|
||||||
protected readonly MeasurementService _measurementService;
|
protected readonly MeasurementService _measurementService;
|
||||||
|
protected readonly IWorkflowMessageService _workflowMessageService;
|
||||||
private static readonly char[] _separator = [','];
|
private static readonly char[] _separator = [','];
|
||||||
// ... other dependencies
|
// ... other dependencies
|
||||||
|
|
||||||
|
|
@ -135,7 +136,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
IImportManager importManager,
|
IImportManager importManager,
|
||||||
IDateTimeHelper dateTimeHelper,
|
IDateTimeHelper dateTimeHelper,
|
||||||
ITaxService taxService,
|
ITaxService taxService,
|
||||||
MeasurementService measurementService)
|
MeasurementService measurementService, IWorkflowMessageService workflowMessageService)
|
||||||
{
|
{
|
||||||
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
||||||
|
|
||||||
|
|
@ -163,6 +164,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
_dateTimeHelper = dateTimeHelper;
|
_dateTimeHelper = dateTimeHelper;
|
||||||
_taxService = taxService;
|
_taxService = taxService;
|
||||||
_measurementService = measurementService;
|
_measurementService = measurementService;
|
||||||
|
_workflowMessageService = workflowMessageService;
|
||||||
// ... initialize other deps
|
// ... initialize other deps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -508,7 +510,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
OrderGuid = Guid.NewGuid(),
|
OrderGuid = Guid.NewGuid(),
|
||||||
CustomOrderNumber = "",
|
CustomOrderNumber = "",
|
||||||
CustomerId = customerId,
|
CustomerId = customerId,
|
||||||
CustomerLanguageId = customer.LanguageId ?? 1,
|
CustomerLanguageId = customer.LanguageId ?? 2,
|
||||||
CustomerTaxDisplayType = TaxDisplayType.IncludingTax,
|
CustomerTaxDisplayType = TaxDisplayType.IncludingTax,
|
||||||
CustomerIp = string.Empty,
|
CustomerIp = string.Empty,
|
||||||
OrderStatus = OrderStatus.Pending,
|
OrderStatus = OrderStatus.Pending,
|
||||||
|
|
@ -519,7 +521,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
ShippingAddressId = customer.ShippingAddressId,
|
ShippingAddressId = customer.ShippingAddressId,
|
||||||
PaymentMethodSystemName = "Payments.CheckMoneyOrder", // Default payment method
|
PaymentMethodSystemName = "Payments.CheckMoneyOrder", // Default payment method
|
||||||
CustomerCurrencyCode = "HUF", // TODO: GET Default currency - A.
|
CustomerCurrencyCode = "HUF", // TODO: GET Default currency - A.
|
||||||
|
CurrencyRate = 1,
|
||||||
OrderTotal = 0,
|
OrderTotal = 0,
|
||||||
OrderSubtotalInclTax = 0,
|
OrderSubtotalInclTax = 0,
|
||||||
OrderSubtotalExclTax = 0,
|
OrderSubtotalExclTax = 0,
|
||||||
|
|
@ -544,7 +546,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
//var orderDto = await _dbContext.OrderDtos.GetByIdAsync(order.Id, true);
|
//var orderDto = await _dbContext.OrderDtos.GetByIdAsync(order.Id, true);
|
||||||
//await _sendToClient.SendMeasuringNotification("Módosult a rendelés, mérjétek újra!", orderDto);
|
//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 });
|
return RedirectToAction("Edit", "Order", new { id = order.Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
|
using Nop.Core.Domain.Customers;
|
||||||
using Nop.Core.Domain.Orders;
|
using Nop.Core.Domain.Orders;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||||
|
|
@ -15,6 +16,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
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" });
|
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 billingCountry = await _countryService.GetCountryByAddressAsync(billingAddress);
|
||||||
var billingCountryCode = billingCountry?.TwoLetterIsoCode ?? "HU";
|
var billingCountryCode = billingCountry?.TwoLetterIsoCode ?? "HU";
|
||||||
|
|
||||||
|
|
@ -107,6 +115,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
|
|
||||||
string megjegyzes = string.Empty;
|
string megjegyzes = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create order request
|
// Create order request
|
||||||
var orderRequest = new OrderCreateRequest
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ using Nop.Plugin.Misc.FruitBankPlugin.Services.FileStorage;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Common;
|
using Nop.Services.Common;
|
||||||
using Nop.Services.Events;
|
using Nop.Services.Events;
|
||||||
|
using Nop.Services.Messages;
|
||||||
using Nop.Web.Areas.Admin.Factories;
|
using Nop.Web.Areas.Admin.Factories;
|
||||||
using Nop.Web.Areas.Admin.Models.Catalog;
|
using Nop.Web.Areas.Admin.Models.Catalog;
|
||||||
using Nop.Web.Areas.Admin.Models.Orders;
|
using Nop.Web.Areas.Admin.Models.Orders;
|
||||||
|
|
@ -118,6 +119,7 @@ public class PluginNopStartup : INopStartup
|
||||||
//services.AddScoped<IAIAPIService, OpenAIApiService>();
|
//services.AddScoped<IAIAPIService, OpenAIApiService>();
|
||||||
services.AddScoped<AICalculationService>();
|
services.AddScoped<AICalculationService>();
|
||||||
services.AddScoped<PdfToImageService>();
|
services.AddScoped<PdfToImageService>();
|
||||||
|
services.AddScoped<IWorkflowMessageService, WorkflowMessageService>();
|
||||||
|
|
||||||
services.AddSingleton<IFileStorageProvider>(sp =>
|
services.AddSingleton<IFileStorageProvider>(sp =>
|
||||||
new LocalFileStorageProvider() // Uses default wwwroot/uploads
|
new LocalFileStorageProvider() // Uses default wwwroot/uploads
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,19 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
|
||||||
|
|
||||||
shippingConfigurationItem.ChildNodes.Insert(4, InvoiceSyncMenuItem);
|
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
|
var invoiceListMenuItem = new AdminMenuItem
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue