Compare commits
No commits in common. "16dbfb18e23ec407661b2b120b9783f632eb524f" and "705d43061d01851f6f815ca6bdbd839ec7dbf824" have entirely different histories.
16dbfb18e2
...
705d43061d
|
|
@ -9,7 +9,6 @@ using Mango.Nop.Core.Extensions;
|
||||||
using Mango.Nop.Core.Loggers;
|
using Mango.Nop.Core.Loggers;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Nop.Core;
|
|
||||||
using Nop.Core.Domain.Customers;
|
using Nop.Core.Domain.Customers;
|
||||||
using Nop.Core.Domain.Orders;
|
using Nop.Core.Domain.Orders;
|
||||||
using Nop.Core.Domain.Payments;
|
using Nop.Core.Domain.Payments;
|
||||||
|
|
@ -50,13 +49,11 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
private readonly INotificationService _notificationService;
|
private readonly INotificationService _notificationService;
|
||||||
private readonly ICustomerService _customerService;
|
private readonly ICustomerService _customerService;
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
private readonly IStoreContext _storeContext;
|
|
||||||
private readonly IWorkContext _workContext;
|
|
||||||
// ... other dependencies
|
// ... other dependencies
|
||||||
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public CustomOrderController(FruitBankDbContext fruitBankDbContext, IOrderService orderService, IOrderModelFactory orderModelFactory, ICustomOrderSignalREndpointServer customOrderSignalREndpoint, IPermissionService permissionService, IGenericAttributeService genericAttributeService, INotificationService notificationService, ICustomerService customerService, IProductService productService, IEnumerable<IAcLogWriterBase> logWriters, IStoreContext storeContext, IWorkContext workContext)
|
public CustomOrderController(FruitBankDbContext fruitBankDbContext, IOrderService orderService, IOrderModelFactory orderModelFactory, ICustomOrderSignalREndpointServer customOrderSignalREndpoint, IPermissionService permissionService, IGenericAttributeService genericAttributeService, INotificationService notificationService, ICustomerService customerService, IProductService productService, IEnumerable<IAcLogWriterBase> logWriters)
|
||||||
{
|
{
|
||||||
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
||||||
|
|
||||||
|
|
@ -69,8 +66,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
_notificationService = notificationService;
|
_notificationService = notificationService;
|
||||||
_customerService = customerService;
|
_customerService = customerService;
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
_storeContext = storeContext;
|
|
||||||
_workContext = workContext;
|
|
||||||
// ... initialize other deps
|
// ... initialize other deps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,8 +152,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
return RedirectToAction("List", "Order");
|
return RedirectToAction("List", "Order");
|
||||||
|
|
||||||
// store attributes in GenericAttribute table
|
// store attributes in GenericAttribute table
|
||||||
await _genericAttributeService.SaveAttributeAsync(order, nameof(IMeasurable.IsMeasurable), model.IsMeasurable, _storeContext.GetCurrentStore().Id);
|
await _genericAttributeService.SaveAttributeAsync(order, nameof(IMeasurable.IsMeasurable), model.IsMeasurable);
|
||||||
await _genericAttributeService.SaveAttributeAsync(order, nameof(IOrderDto.DateOfReceipt), model.DateOfReceipt, _storeContext.GetCurrentStore().Id);
|
await _genericAttributeService.SaveAttributeAsync(order, nameof(IOrderDto.DateOfReceipt), model.DateOfReceipt);
|
||||||
|
|
||||||
_notificationService.SuccessNotification("Custom attributes saved successfully.");
|
_notificationService.SuccessNotification("Custom attributes saved successfully.");
|
||||||
|
|
||||||
|
|
@ -176,29 +171,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
var customer = await _customerService.GetCustomerByIdAsync(customerId);
|
var customer = await _customerService.GetCustomerByIdAsync(customerId);
|
||||||
if (customer == null) return RedirectToAction("List");
|
if (customer == null) return RedirectToAction("List");
|
||||||
|
|
||||||
var billingAddress = await _customerService.GetCustomerBillingAddressAsync(customer);
|
|
||||||
if(billingAddress == null)
|
|
||||||
{
|
|
||||||
//let's see if he has any address at all
|
|
||||||
var addresses = await _customerService.GetAddressesByCustomerIdAsync(customer.Id);
|
|
||||||
if(addresses != null && addresses.Count > 0)
|
|
||||||
{
|
|
||||||
//set the first one as billing
|
|
||||||
billingAddress = addresses[0];
|
|
||||||
customer.BillingAddressId = billingAddress.Id;
|
|
||||||
await _customerService.UpdateCustomerAsync(customer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//no address at all, cannot create order
|
|
||||||
_logger.Error($"Cannot create order for customer {customer.Id}, no billing address found.");
|
|
||||||
return RedirectToAction("List");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//var currency = await _workContext.GetWorkingCurrencyAsync();
|
|
||||||
//customer.CurrencyId = currency.Id;
|
|
||||||
|
|
||||||
// Parse products
|
// Parse products
|
||||||
var orderProducts = string.IsNullOrEmpty(orderProductsJson) ? [] : JsonConvert.DeserializeObject<List<OrderProductItem>>(orderProductsJson);
|
var orderProducts = string.IsNullOrEmpty(orderProductsJson) ? [] : JsonConvert.DeserializeObject<List<OrderProductItem>>(orderProductsJson);
|
||||||
|
|
||||||
|
|
@ -216,9 +188,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
ShippingStatus = ShippingStatus.ShippingNotRequired,
|
ShippingStatus = ShippingStatus.ShippingNotRequired,
|
||||||
CreatedOnUtc = DateTime.UtcNow,
|
CreatedOnUtc = DateTime.UtcNow,
|
||||||
BillingAddressId = customer.BillingAddressId ?? 0,
|
BillingAddressId = customer.BillingAddressId ?? 0,
|
||||||
ShippingAddressId = customer.ShippingAddressId,
|
ShippingAddressId = customer.ShippingAddressId
|
||||||
PaymentMethodSystemName = "Payments.CheckMoneyOrder", // Default payment method
|
|
||||||
CustomerCurrencyCode = "HUF", // TODO: GET Default currency - A.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var productDtosById = await _dbContext.ProductDtos.GetAllByIds(orderProducts.Select(op => op.Id)).ToDictionaryAsync(p => p.Id, prodDto => prodDto);
|
var productDtosById = await _dbContext.ProductDtos.GetAllByIds(orderProducts.Select(op => op.Id)).ToDictionaryAsync(p => p.Id, prodDto => prodDto);
|
||||||
|
|
@ -380,16 +350,10 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
pageIndex: 0,
|
pageIndex: 0,
|
||||||
pageSize: maxResults);
|
pageSize: maxResults);
|
||||||
|
|
||||||
var customersByCompanyName = await _customerService.GetAllCustomersAsync(
|
|
||||||
company: term,
|
|
||||||
pageIndex: 0,
|
|
||||||
pageSize: maxResults);
|
|
||||||
|
|
||||||
// Combine and deduplicate results
|
// Combine and deduplicate results
|
||||||
var allCustomers = customersByEmail
|
var allCustomers = customersByEmail
|
||||||
.Union(customersByFirstName)
|
.Union(customersByFirstName)
|
||||||
.Union(customersByLastName)
|
.Union(customersByLastName)
|
||||||
.Union(customersByCompanyName)
|
|
||||||
.DistinctBy(c => c.Id)
|
.DistinctBy(c => c.Id)
|
||||||
.Take(maxResults)
|
.Take(maxResults)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
@ -398,22 +362,13 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
foreach (var customer in allCustomers)
|
foreach (var customer in allCustomers)
|
||||||
{
|
{
|
||||||
var fullName = await _customerService.GetCustomerFullNameAsync(customer);
|
var fullName = await _customerService.GetCustomerFullNameAsync(customer);
|
||||||
var company = customer.Company;
|
var displayText = !string.IsNullOrEmpty(customer.Email)
|
||||||
|
? $"{customer.Email} ({fullName})"
|
||||||
if (string.IsNullOrEmpty(fullName))
|
: fullName;
|
||||||
fullName = "[No name]";
|
|
||||||
if(string.IsNullOrEmpty(company))
|
|
||||||
company = "[No company]";
|
|
||||||
|
|
||||||
string fullText = $"{company} ({fullName}), {customer.Email}";
|
|
||||||
|
|
||||||
//var displayText = !string.IsNullOrEmpty(customer.Email)
|
|
||||||
// ? $"{customer.Email}, {customer.Company} ({fullName})"
|
|
||||||
// : fullName;
|
|
||||||
|
|
||||||
result.Add(new
|
result.Add(new
|
||||||
{
|
{
|
||||||
label = fullText,
|
label = displayText,
|
||||||
value = customer.Id
|
value = customer.Id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Core.Domain.Orders;
|
using Nop.Core.Domain.Orders;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Common;
|
using Nop.Services.Common;
|
||||||
|
|
@ -31,7 +29,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
private readonly InnVoiceOrderService _innVoiceOrderService;
|
private readonly InnVoiceOrderService _innVoiceOrderService;
|
||||||
private readonly IGenericAttributeService _genericAttributeService;
|
private readonly IGenericAttributeService _genericAttributeService;
|
||||||
private readonly FruitBankDbContext _dbContext;
|
|
||||||
|
|
||||||
public InnVoiceOrderController(
|
public InnVoiceOrderController(
|
||||||
IOrderService orderService,
|
IOrderService orderService,
|
||||||
|
|
@ -41,8 +38,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
ICountryService countryService,
|
ICountryService countryService,
|
||||||
IProductService productService,
|
IProductService productService,
|
||||||
InnVoiceOrderService innVoiceOrderService,
|
InnVoiceOrderService innVoiceOrderService,
|
||||||
IGenericAttributeService genericAttributeService,
|
IGenericAttributeService genericAttributeService)
|
||||||
FruitBankDbContext dbContext)
|
|
||||||
{
|
{
|
||||||
_orderService = orderService;
|
_orderService = orderService;
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
|
|
@ -52,7 +48,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
_innVoiceOrderService = innVoiceOrderService;
|
_innVoiceOrderService = innVoiceOrderService;
|
||||||
_genericAttributeService = genericAttributeService;
|
_genericAttributeService = genericAttributeService;
|
||||||
_dbContext = dbContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -80,12 +75,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
|
|
||||||
// Get shipping address
|
// Get shipping address
|
||||||
var shippingAddress = await _customerService.GetCustomerShippingAddressAsync(customer);
|
var shippingAddress = await _customerService.GetCustomerShippingAddressAsync(customer);
|
||||||
|
|
||||||
if (shippingAddress == null)
|
|
||||||
{
|
|
||||||
shippingAddress = billingAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
var shippingCountry = shippingAddress != null
|
var shippingCountry = shippingAddress != null
|
||||||
? await _countryService.GetCountryByAddressAsync(shippingAddress)
|
? await _countryService.GetCountryByAddressAsync(shippingAddress)
|
||||||
: null;
|
: null;
|
||||||
|
|
@ -103,8 +92,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
MegrendelestombID = 1, // Configure this based on your setup
|
MegrendelestombID = 1, // Configure this based on your setup
|
||||||
MegrendelesKelte = order.CreatedOnUtc.ToLocalTime(),
|
MegrendelesKelte = order.CreatedOnUtc.ToLocalTime(),
|
||||||
Hatarido = DateTime.Now.AddDays(7), // 7 days delivery time
|
Hatarido = DateTime.Now.AddDays(7), // 7 days delivery time
|
||||||
Devizanem = "HUF", //TODO get real deault - A.
|
Devizanem = order.CustomerCurrencyCode,
|
||||||
FizetesiMod = order.PaymentMethodSystemName ?? "átutalás",
|
FizetesiMod = order.PaymentMethodSystemName,
|
||||||
Email = billingAddress.Email,
|
Email = billingAddress.Email,
|
||||||
Telefon = billingAddress.PhoneNumber,
|
Telefon = billingAddress.PhoneNumber,
|
||||||
MegrendelesSzamStr = order.Id.ToString()
|
MegrendelesSzamStr = order.Id.ToString()
|
||||||
|
|
@ -124,9 +113,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
var orderItems = await _orderService.GetOrderItemsAsync(order.Id);
|
var orderItems = await _orderService.GetOrderItemsAsync(order.Id);
|
||||||
foreach (var item in orderItems)
|
foreach (var item in orderItems)
|
||||||
{
|
{
|
||||||
//var productDTO = await _productService.GetProductByIdAsync(item.ProductId);
|
var product = await _productService.GetProductByIdAsync(item.ProductId);
|
||||||
var product = _dbContext.ProductDtos.GetById(item.ProductId);
|
|
||||||
//string unit = product != null && product.IsMeasurable ? "kg" : "kt";
|
|
||||||
|
|
||||||
orderRequest.AddItem(new InnVoiceOrderItem
|
orderRequest.AddItem(new InnVoiceOrderItem
|
||||||
{
|
{
|
||||||
|
|
@ -135,8 +122,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
Brutto = true,
|
Brutto = true,
|
||||||
EgysegAr = item.UnitPriceInclTax,
|
EgysegAr = item.UnitPriceInclTax,
|
||||||
Mennyiseg = item.Quantity,
|
Mennyiseg = item.Quantity,
|
||||||
MennyisegEgyseg = "kt",
|
MennyisegEgyseg = "db",
|
||||||
CikkSzam = ""
|
CikkSzam = product?.Sku
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
// save partner information to partners table { Id, Name, TaxId, CertificationNumber, PostalCode, Country, State, County, City, Street }
|
// save partner information to partners table { Id, Name, TaxId, CertificationNumber, PostalCode, Country, State, County, City, Street }
|
||||||
if (partnerId != null)
|
if (partnerId != null)
|
||||||
{
|
{
|
||||||
string partnerAnalysisPrompt = "Extract the partner information from this document, and return them as JSON: name, taxId, certificationNumber, postalCode, country, state, county, city, street. " +
|
string partnerAnalysisPrompt = "Extract the sender information from this document, and return them as JSON: name, taxId, certificationNumber, postalCode, country, state, county, city, street. " +
|
||||||
"If you can't find information of any of these, return null value for that field.";
|
"If you can't find information of any of these, return null value for that field.";
|
||||||
|
|
||||||
//here I can start preparing the file entity
|
//here I can start preparing the file entity
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<!-- Order Subsection -->
|
<!-- Order Subsection -->
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-12 col-md-3">
|
<div class="col-12 col-md-3">
|
||||||
<h5><i class="fas fa-shopping-cart"></i> Order</h5>
|
<h5><i class="fas fa-shopping-cart"></i> Order</h5>
|
||||||
|
|
@ -60,33 +62,31 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
<!-- Attributes Section (NO FORM TAG - just a div) -->
|
<div class="col-12">
|
||||||
<div id="orderAttributesSection">
|
<div class="form-group row">
|
||||||
<div class="form-group row">
|
<div class="col-md-3">
|
||||||
<div class="col-12">
|
<nop-label asp-for="IsMeasurable" />
|
||||||
<div class="form-group row">
|
|
||||||
<div class="col-md-3">
|
|
||||||
<nop-label asp-for="IsMeasurable" />
|
|
||||||
</div>
|
|
||||||
<div class="col-md-9">
|
|
||||||
<nop-editor asp-for="IsMeasurable" asp-template="" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="col-md-9">
|
||||||
<div class="col-md-3">
|
<nop-editor asp-for="IsMeasurable" />
|
||||||
<nop-label asp-for="DateOfReceipt" />
|
<span asp-validation-for="IsMeasurable"></span>
|
||||||
</div>
|
|
||||||
<div class="col-md-9">
|
|
||||||
<nop-editor asp-for="DateOfReceipt" asp-template="" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
</div>
|
||||||
<div class="col-md-12 text-right">
|
<div class="form-group row">
|
||||||
<button type="button" id="saveAttributesBtn" class="btn btn-primary">
|
<div class="col-md-3">
|
||||||
<i class="fa fa-save"></i> Save Attributes
|
<nop-label asp-for="DateOfReceipt" />
|
||||||
</button>
|
</div>
|
||||||
</div>
|
<div class="col-md-9">
|
||||||
|
<nop-editor asp-for="DateOfReceipt" />
|
||||||
|
<span asp-validation-for="DateOfReceipt"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-md-12 text-right">
|
||||||
|
<button type="button" id="saveAttributesBtn" class="btn btn-primary">
|
||||||
|
<i class="fa fa-save"></i> Save Attributes
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -94,6 +94,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var createOrderUrl = '/Admin/InnVoiceOrder/CreateOrder';
|
var createOrderUrl = '/Admin/InnVoiceOrder/CreateOrder';
|
||||||
|
|
@ -104,19 +107,8 @@
|
||||||
var orderExists = false;
|
var orderExists = false;
|
||||||
var invoiceExists = false;
|
var invoiceExists = false;
|
||||||
|
|
||||||
// Remove validation from these specific fields
|
|
||||||
$('#@Html.IdFor(m => m.IsMeasurable)').rules('remove');
|
|
||||||
$('#@Html.IdFor(m => m.DateOfReceipt)').rules('remove');
|
|
||||||
|
|
||||||
// Also set data-val to false
|
|
||||||
$('#@Html.IdFor(m => m.IsMeasurable)').attr('data-val', 'false');
|
|
||||||
$('#@Html.IdFor(m => m.DateOfReceipt)').attr('data-val', 'false');
|
|
||||||
|
|
||||||
// Save Order Attributes
|
// Save Order Attributes
|
||||||
$("#saveAttributesBtn").click(function (e) {
|
$("#saveAttributesBtn").click(function () {
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "@Url.Action("SaveOrderAttributes", "CustomOrder")",
|
url: "@Url.Action("SaveOrderAttributes", "CustomOrder")",
|
||||||
|
|
@ -133,8 +125,6 @@
|
||||||
alert("Error saving attributes");
|
alert("Error saving attributes");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ========== ORDER MANAGEMENT ==========
|
// ========== ORDER MANAGEMENT ==========
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class PluginNopStartup : INopStartup
|
||||||
feature.AddPolicy(
|
feature.AddPolicy(
|
||||||
"AllowBlazorClient",
|
"AllowBlazorClient",
|
||||||
apiPolicy => apiPolicy
|
apiPolicy => apiPolicy
|
||||||
.WithOrigins(["https://localhost:7144", "measuringtest.fruitbank.hu", "https://localhost:60589"])
|
.WithOrigins("https://localhost:7144")
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowCredentials()
|
.AllowCredentials()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue