Compare commits
4 Commits
eb265e9a5c
...
4081bddfcc
| Author | SHA1 | Date |
|---|---|---|
|
|
4081bddfcc | |
|
|
9f6aa1b903 | |
|
|
36f22aa2cc | |
|
|
95b7fbd561 |
|
|
@ -35,8 +35,10 @@ public class CustomerCreditWidgetViewComponent : NopViewComponent
|
||||||
var credit = await _customerCreditService.GetByCustomerIdAsync(customerId);
|
var credit = await _customerCreditService.GetByCustomerIdAsync(customerId);
|
||||||
var outstanding = await _customerCreditService.GetOutstandingBalanceAsync(customerId);
|
var outstanding = await _customerCreditService.GetOutstandingBalanceAsync(customerId);
|
||||||
|
|
||||||
|
// Hiányzó attribútum (null) = köteles — a kapu is így dönt (CreateMissingEkaerHistories: csak az explicit
|
||||||
|
// false mentesít); a checkbox pipáltat mutat, amíg explicit ki nem veszik.
|
||||||
var isEkaer = await _attributeService
|
var isEkaer = await _attributeService
|
||||||
.GetGenericAttributeValueAsync<Customer, bool>(customerId, FruitBankPluginConst.IsEkaerAttribute, storeId: 0);
|
.GetGenericAttributeValueAsync<Customer, bool?>(customerId, FruitBankPluginConst.IsEkaerAttribute, storeId: 0) ?? true;
|
||||||
|
|
||||||
var model = new CustomerCreditWidgetModel
|
var model = new CustomerCreditWidgetModel
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
using FruitBank.Common.Dtos;
|
using FruitBank.Common.Dtos;
|
||||||
using FruitBank.Common.Entities;
|
using FruitBank.Common.Entities;
|
||||||
using FruitBank.Common.Interfaces;
|
using FruitBank.Common.Interfaces;
|
||||||
//using FruitBank.Common.Loggers;
|
|
||||||
using FruitBank.Common.Models;
|
using FruitBank.Common.Models;
|
||||||
using FruitBank.Common.Server;
|
using FruitBank.Common.Server;
|
||||||
using FruitBank.Common.Server.Interfaces;
|
using FruitBank.Common.Server.Interfaces;
|
||||||
|
|
@ -50,6 +49,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
: BasePluginController, IFruitBankDataControllerServer
|
: BasePluginController, IFruitBankDataControllerServer
|
||||||
{
|
{
|
||||||
private const int LastShippingDays = 15;
|
private const int LastShippingDays = 15;
|
||||||
|
private const string GridLayoutKeyGroup = "GridLayout";
|
||||||
private readonly ILogger _logger = new Logger<FruitBankDataController>(logWriters.ToArray());
|
private readonly ILogger _logger = new Logger<FruitBankDataController>(logWriters.ToArray());
|
||||||
|
|
||||||
[SignalR(SignalRTags.ProcessAndSaveFullShippingJson)]
|
[SignalR(SignalRTags.ProcessAndSaveFullShippingJson)]
|
||||||
|
|
@ -78,6 +78,53 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
return await ctx.GenericAttributeDtos.GetByIdAsync(genericAttributeDto.Id);
|
return await ctx.GenericAttributeDtos.GetByIdAsync(genericAttributeDto.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<GenericAttributeDto?> GetGridLayoutAttributeAsync(string key, int userId)
|
||||||
|
=> (await ctx.GetGenericAttributeDtosByEntityIdAndKeyGroup(userId, GridLayoutKeyGroup, 0))
|
||||||
|
.FirstOrDefault(x => x.Key == key);
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetGridLayoutTag)]
|
||||||
|
public async Task<string?> GetGridLayout(string key, int userId)
|
||||||
|
{
|
||||||
|
return (await GetGridLayoutAttributeAsync(key, userId))?.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.SaveGridLayoutTag)]
|
||||||
|
public async Task<bool> SaveGridLayout(string key, string layoutJson, int userId)
|
||||||
|
{
|
||||||
|
var attribute = await GetGridLayoutAttributeAsync(key, userId);
|
||||||
|
|
||||||
|
if (attribute == null)
|
||||||
|
{
|
||||||
|
await ctx.GenericAttributeDtos.InsertAsync(new GenericAttributeDto
|
||||||
|
{
|
||||||
|
EntityId = userId,
|
||||||
|
KeyGroup = GridLayoutKeyGroup,
|
||||||
|
Key = key,
|
||||||
|
Value = layoutJson,
|
||||||
|
StoreId = 0,
|
||||||
|
CreatedOrUpdatedDateUTC = DateTime.UtcNow
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attribute.Value = layoutJson;
|
||||||
|
attribute.CreatedOrUpdatedDateUTC = DateTime.UtcNow;
|
||||||
|
await ctx.GenericAttributeDtos.UpdateAsync(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.DeleteGridLayoutTag)]
|
||||||
|
public async Task<bool> DeleteGridLayout(string key, int userId)
|
||||||
|
{
|
||||||
|
var attribute = await GetGridLayoutAttributeAsync(key, userId);
|
||||||
|
if (attribute == null) return false;
|
||||||
|
|
||||||
|
await ctx.GenericAttributeDtos.DeleteAsync(attribute);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.GetStockQuantityHistoryDtos)]
|
[SignalR(SignalRTags.GetStockQuantityHistoryDtos)]
|
||||||
public async Task<List<StockQuantityHistoryDto>> GetStockQuantityHistoryDtos()
|
public async Task<List<StockQuantityHistoryDto>> GetStockQuantityHistoryDtos()
|
||||||
{
|
{
|
||||||
|
|
@ -341,7 +388,10 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
if (!ekaerHistory.IsOutgoing)
|
if (!ekaerHistory.IsOutgoing)
|
||||||
{
|
{
|
||||||
// Bejövő: a csoport ÖSSZES szállítólevele EGY tradeCard-dá (összevont tömeg/érték); GetAll(true) = teljes gráf.
|
// Bejövő: a csoport ÖSSZES szállítólevele EGY tradeCard-dá (összevont tömeg/érték); GetAll(true) = teljes gráf.
|
||||||
var documents = await ctx.ShippingDocuments.GetAll(true).Where(sd => foreignKeys.Contains(sd.Id)).ToListAsync();
|
// A PartnerDepot szándékosan NINCS a default loadRelations-ben — csak itt kell (felrakodási hely = depot címe).
|
||||||
|
var documents = await ctx.ShippingDocuments.GetAll(true)
|
||||||
|
.LoadWith(sd => sd.PartnerDepot)
|
||||||
|
.Where(sd => foreignKeys.Contains(sd.Id)).ToListAsync();
|
||||||
if (documents.Count == 0) throw new InvalidOperationException($"EkaerHistory #{ekaerHistoryId}: no ShippingDocuments found for the mapped ids.");
|
if (documents.Count == 0) throw new InvalidOperationException($"EkaerHistory #{ekaerHistoryId}: no ShippingDocuments found for the mapped ids.");
|
||||||
ekaerHistory = fruitBankEkaerService.GenerateEkaerXmlDocument(documents, ekaerHistory);
|
ekaerHistory = fruitBankEkaerService.GenerateEkaerXmlDocument(documents, ekaerHistory);
|
||||||
|
|
||||||
|
|
@ -434,6 +484,15 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
if (result.Obligation == EkaerObligation.DataError) { messages.UnionWith(result.Errors); continue; }
|
if (result.Obligation == EkaerObligation.DataError) { messages.UnionWith(result.Errors); continue; }
|
||||||
if (result.Obligation == EkaerObligation.NotRequired) continue;
|
if (result.Obligation == EkaerObligation.NotRequired) continue;
|
||||||
|
|
||||||
|
// Kötelező, de nincs telephely → NEM jön létre sor, üzenet a popupba (T-D8R4: a PartnerDepot az
|
||||||
|
// EKÁER-hez kötelező — a felrakodási hely a depot címe); pótlás után a következő futás felveszi.
|
||||||
|
// A depot-check a kötelezettség-döntés UTÁN: küszöb alatti belföldi csoportra nem szólunk feleslegesen.
|
||||||
|
if (group.Key.PartnerDepotId is null)
|
||||||
|
{
|
||||||
|
messages.Add($"{docs[0].Partner?.Name} (Szállítás #{group.Key.ShippingId}): nincs telephely (PartnerDepot) — EKÁER-bejelentéshez kötelező, a sor nem jött létre.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Kötelező → EGY EkaerHistory a csoportra (összegző: ShippingDate + Partner — invariáns) + a dokumentumok mapping-foreignKey-ként.
|
// Kötelező → EGY EkaerHistory a csoportra (összegző: ShippingDate + Partner — invariáns) + a dokumentumok mapping-foreignKey-ként.
|
||||||
var history = new EkaerHistory { IsOutgoing = false, StatusId = (int)EkaerStatus.Pending };
|
var history = new EkaerHistory { IsOutgoing = false, StatusId = (int)EkaerStatus.Pending };
|
||||||
fruitBankEkaerService.SetSummary(history, docs[0].ShippingDate, docs[0].Partner?.Name);
|
fruitBankEkaerService.SetSummary(history, docs[0].ShippingDate, docs[0].Partner?.Name);
|
||||||
|
|
@ -456,10 +515,22 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
|
|
||||||
var missingOrders = missingOrderIds.Count == 0 ? [] : await ctx.OrderDtos.GetAllByIds(missingOrderIds, true).ToListAsync();
|
var missingOrders = missingOrderIds.Count == 0 ? [] : await ctx.OrderDtos.GetAllByIds(missingOrderIds, true).ToListAsync();
|
||||||
|
|
||||||
|
// Vevő-szintű mentesség (isEkaer GenericAttribute — mint a Partner.IsEkaer) EGY batch-queryvel a ciklus előtt:
|
||||||
|
// ami nincs a dictionary-ben = nincs beállítva = köteles (fail-safe; a widget-checkbox is pipáltat mutat rá),
|
||||||
|
// CSAK az explicit false mentesít.
|
||||||
|
var customerIds = missingOrders.Select(o => o.CustomerId).Distinct().ToList();
|
||||||
|
Dictionary<int, bool> isEkaerByCustomer = customerIds.Count == 0 ? new() : (await ctx.GenericAttributes.Table
|
||||||
|
.Where(ga => ga.KeyGroup == nameof(Customer) && ga.Key == FruitBankPluginConst.IsEkaerAttribute
|
||||||
|
&& ga.StoreId == 0 && customerIds.Contains(ga.EntityId))
|
||||||
|
.ToListAsync())
|
||||||
|
.ToDictionary(ga => ga.EntityId, ga => CommonHelper.To<bool>(ga.Value));
|
||||||
|
|
||||||
foreach (var order in missingOrders)
|
foreach (var order in missingOrders)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (isEkaerByCustomer.TryGetValue(order.CustomerId, out var isEkaer) && !isEkaer) continue;
|
||||||
|
|
||||||
var result = fruitBankEkaerService.EvaluateObligation(order);
|
var result = fruitBankEkaerService.EvaluateObligation(order);
|
||||||
if (result.Obligation == EkaerObligation.DataError) { messages.UnionWith(result.Errors); continue; }
|
if (result.Obligation == EkaerObligation.DataError) { messages.UnionWith(result.Errors); continue; }
|
||||||
if (result.Obligation == EkaerObligation.NotRequired) continue;
|
if (result.Obligation == EkaerObligation.NotRequired) continue;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue