Invoice fixes
This commit is contained in:
parent
16dbfb18e2
commit
41422340c8
|
|
@ -1,5 +1,4 @@
|
||||||
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.Domains.DataLayer;
|
||||||
|
|
@ -103,7 +102,7 @@ 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 = "Ft", //TODO get real deault - A.
|
||||||
FizetesiMod = order.PaymentMethodSystemName ?? "átutalás",
|
FizetesiMod = order.PaymentMethodSystemName ?? "átutalás",
|
||||||
Email = billingAddress.Email,
|
Email = billingAddress.Email,
|
||||||
Telefon = billingAddress.PhoneNumber,
|
Telefon = billingAddress.PhoneNumber,
|
||||||
|
|
@ -315,7 +314,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
MegrendelestombID = 1,
|
MegrendelestombID = 1,
|
||||||
MegrendelesKelte = order.CreatedOnUtc.ToLocalTime(),
|
MegrendelesKelte = order.CreatedOnUtc.ToLocalTime(),
|
||||||
Hatarido = DateTime.Now.AddDays(7),
|
Hatarido = DateTime.Now.AddDays(7),
|
||||||
Devizanem = order.CustomerCurrencyCode,
|
Devizanem = "Ft",
|
||||||
FizetesiMod = order.PaymentMethodSystemName,
|
FizetesiMod = order.PaymentMethodSystemName,
|
||||||
Email = billingAddress.Email,
|
Email = billingAddress.Email,
|
||||||
Telefon = billingAddress.PhoneNumber,
|
Telefon = billingAddress.PhoneNumber,
|
||||||
|
|
@ -349,6 +348,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
// Create orders via API
|
// Create orders via API
|
||||||
var responses = await _innVoiceOrderService.CreateOrdersAsync(orderRequests);
|
var responses = await _innVoiceOrderService.CreateOrdersAsync(orderRequests);
|
||||||
|
|
||||||
|
if (responses != null)
|
||||||
|
{
|
||||||
var successCount = responses.Count(r => r.IsSuccess);
|
var successCount = responses.Count(r => r.IsSuccess);
|
||||||
var failureCount = responses.Count - successCount;
|
var failureCount = responses.Count - successCount;
|
||||||
|
|
||||||
|
|
@ -397,6 +398,11 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"InvoiceOrderAPi invalid response");
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return Json(new
|
return Json(new
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
using AyCode.Utils.Extensions;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Core.Domain.Orders;
|
using Nop.Core.Domain.Orders;
|
||||||
|
|
@ -82,8 +83,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
SzamlaKelte = DateTime.Now,
|
SzamlaKelte = DateTime.Now,
|
||||||
TeljesitesKelte = DateTime.Now,
|
TeljesitesKelte = DateTime.Now,
|
||||||
Hatarido = DateTime.Now.AddDays(15), // 15 days payment term
|
Hatarido = DateTime.Now.AddDays(15), // 15 days payment term
|
||||||
Devizanem = order.CustomerCurrencyCode,
|
Devizanem = "Ft",
|
||||||
FizetesiMod = order.PaymentMethodSystemName,
|
FizetesiMod = order.PaymentMethodSystemName.IsNullOrWhiteSpace() ? "Átutalás" : order.PaymentMethodSystemName,
|
||||||
Felretett = false,
|
Felretett = false,
|
||||||
Proforma = true,
|
Proforma = true,
|
||||||
Email = billingAddress.Email,
|
Email = billingAddress.Email,
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create one or more orders
|
/// Create one or more orders
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<List<OrderCreateResponse>> CreateOrdersAsync(List<OrderCreateRequest> orders)
|
public async Task<List<OrderCreateResponse>?> CreateOrdersAsync(List<OrderCreateRequest> orders)
|
||||||
{
|
{
|
||||||
var url = $"{_baseUrl}/{_companyName}/order";
|
var url = $"{_baseUrl}/{_companyName}/order";
|
||||||
|
|
||||||
|
|
@ -71,7 +71,9 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
|
||||||
public async Task<OrderCreateResponse> CreateOrderAsync(OrderCreateRequest order)
|
public async Task<OrderCreateResponse> CreateOrderAsync(OrderCreateRequest order)
|
||||||
{
|
{
|
||||||
var responses = await CreateOrdersAsync(new List<OrderCreateRequest> { order });
|
var responses = await CreateOrdersAsync(new List<OrderCreateRequest> { order });
|
||||||
return responses.FirstOrDefault();
|
if (responses != null && responses.Count != 1) throw new Exception($"InvoiceOrderApi responses.Count != 1!");
|
||||||
|
|
||||||
|
return responses?.FirstOrDefault() ?? new OrderCreateResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BuildOrdersXml(List<OrderCreateRequest> orders)
|
private string BuildOrdersXml(List<OrderCreateRequest> orders)
|
||||||
|
|
@ -143,7 +145,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
|
||||||
return new XDeclaration("1.0", "UTF-8", null).ToString() + "\n" + ordersElement.ToString();
|
return new XDeclaration("1.0", "UTF-8", null).ToString() + "\n" + ordersElement.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OrderCreateResponse> ParseOrderResponses(string xml)
|
private List<OrderCreateResponse>? ParseOrderResponses(string xml)
|
||||||
{
|
{
|
||||||
var responses = new List<OrderCreateResponse>();
|
var responses = new List<OrderCreateResponse>();
|
||||||
|
|
||||||
|
|
@ -171,7 +173,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
|
||||||
throw new InnVoiceApiException($"Error parsing order response XML: {ex.Message}", ex);
|
throw new InnVoiceApiException($"Error parsing order response XML: {ex.Message}", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return responses;
|
return responses.Count == 0 ? null : responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -66,11 +66,11 @@
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3 text-right">
|
||||||
<nop-label asp-for="IsMeasurable" />
|
<strong>Mérés információ</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<nop-editor asp-for="IsMeasurable" asp-template="" />
|
@(Model.IsMeasurable ? "Mérendő" : "Nem mérendő")
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue