small fixes
This commit is contained in:
parent
236e2c6a03
commit
16dbfb18e2
|
|
@ -1,6 +1,8 @@
|
||||||
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;
|
||||||
|
|
@ -29,6 +31,7 @@ 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,
|
||||||
|
|
@ -38,7 +41,8 @@ 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;
|
||||||
|
|
@ -48,6 +52,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
_innVoiceOrderService = innVoiceOrderService;
|
_innVoiceOrderService = innVoiceOrderService;
|
||||||
_genericAttributeService = genericAttributeService;
|
_genericAttributeService = genericAttributeService;
|
||||||
|
_dbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -75,10 +80,16 @@ 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;
|
||||||
var shippingCountryCode = shippingCountry?.TwoLetterIsoCode ?? billingCountryCode;
|
var shippingCountryCode = shippingCountry?.TwoLetterIsoCode ?? billingCountryCode;
|
||||||
|
|
||||||
// Create order request
|
// Create order request
|
||||||
var orderRequest = new OrderCreateRequest
|
var orderRequest = new OrderCreateRequest
|
||||||
|
|
@ -92,8 +103,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 = order.CustomerCurrencyCode,
|
Devizanem = "HUF", //TODO get real deault - A.
|
||||||
FizetesiMod = order.PaymentMethodSystemName,
|
FizetesiMod = order.PaymentMethodSystemName ?? "átutalás",
|
||||||
Email = billingAddress.Email,
|
Email = billingAddress.Email,
|
||||||
Telefon = billingAddress.PhoneNumber,
|
Telefon = billingAddress.PhoneNumber,
|
||||||
MegrendelesSzamStr = order.Id.ToString()
|
MegrendelesSzamStr = order.Id.ToString()
|
||||||
|
|
@ -113,8 +124,10 @@ 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 product = await _productService.GetProductByIdAsync(item.ProductId);
|
//var productDTO = 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
|
||||||
{
|
{
|
||||||
TetelNev = product?.Name ?? "Product",
|
TetelNev = product?.Name ?? "Product",
|
||||||
|
|
@ -122,8 +135,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 = "db",
|
MennyisegEgyseg = "kt",
|
||||||
CikkSzam = product?.Sku
|
CikkSzam = ""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue