Merge branch 'release/FixSearch'
This commit is contained in:
@@ -594,19 +594,20 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
/// <summary>
|
||||
/// Elenco Docs
|
||||
/// </summary>
|
||||
/// <param name="searchVal">Ricerca in descrizione + note</param>
|
||||
/// <param name="anno">Anno da selezionare: 0=tutti / anno specifico</param>
|
||||
/// <param name="basketId">Filtro x Basket</param>
|
||||
/// <param name="negotiationId">Filtro x Negoziazione</param>
|
||||
/// <param name="showAll">Mostra tutti (=true) / solo attivi</param>
|
||||
/// <returns></returns>
|
||||
public List<DbModels.DocsModel> DocGetLastDesc(int anno = 0, int basketId = 0, int negotiationId = 0, bool showAll = false)
|
||||
public List<DbModels.DocsModel> DocGetLastDesc(string searchVal, int anno = 0, int basketId = 0, int negotiationId = 0, bool showAll = false)
|
||||
{
|
||||
List<DbModels.DocsModel> dbResult = new List<DbModels.DocsModel>();
|
||||
using (SHERPABBMContext dbCtx = new SHERPABBMContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetDocs
|
||||
.Where(x => (x.Anno == anno || anno == 0) && (x.IsActive || showAll) && (x.Negotiation.BasketId == basketId || basketId == 1) && (x.NegotiationId == negotiationId || negotiationId == 1))
|
||||
.Where(x => (x.Anno == anno || anno == 0) && (x.IsActive || showAll) && (x.Negotiation.BasketId == basketId || basketId == 1) && (x.NegotiationId == negotiationId || negotiationId == 1) && (x.Descript.Contains(searchVal) || x.Note.Contains(searchVal) || string.IsNullOrEmpty(searchVal)))
|
||||
.Include(d => d.Negotiation)
|
||||
.Include(d => d.FattNav)
|
||||
.Include(d => d.ResNav)
|
||||
@@ -674,7 +675,7 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
|
||||
// altri record da disattivare (vuoto)
|
||||
List<DbModels.DocsModel> otherData = new List<DbModels.DocsModel>();
|
||||
|
||||
|
||||
// se NON fosse licenza --> disattivo altri
|
||||
if (currData.DocType < BbmDocType.Licenza)
|
||||
{
|
||||
@@ -1060,7 +1061,7 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
dbResult = dbCtx
|
||||
.DbSetNegotiations
|
||||
// || x.Basket.Company.RagSoc.Contains(searchVal)
|
||||
.Where(x => (x.Anno == anno || anno == 0) && (x.Basket.CompanyId == companyId || companyId == 1) && (x.CustomerId == customerId || customerId == 1) && (x.BasketId == basketId || basketId == 1) && (x.NegotiationId > 1) && (string.IsNullOrEmpty(searchVal) || x.CodNegotiation.Contains(searchVal) || x.BasePath.Contains(searchVal)))
|
||||
.Where(x => (x.Anno == anno || anno == 0) && (x.Basket.CompanyId == companyId || companyId == 1) && (x.CustomerId == customerId || customerId == 1) && (x.BasketId == basketId || basketId == 1) && (x.NegotiationId > 1) && (string.IsNullOrEmpty(searchVal) || x.CodNegotiation.Contains(searchVal) || x.Descript.Contains(searchVal)))
|
||||
.Include(n => n.Basket)
|
||||
.Include(n => n.DocsNav)
|
||||
.ThenInclude(d => d.FattNav)
|
||||
@@ -1181,17 +1182,29 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetResources
|
||||
.AsNoTracking()
|
||||
.Where(x => x.DocId == DocIdSrc)
|
||||
.ToList();
|
||||
|
||||
// aggiorno doc ed aggiungo...
|
||||
foreach (var item in dbResult)
|
||||
{
|
||||
item.DocId = DocIdTgt;
|
||||
var newItem = new DbModels.ResourcesModel()
|
||||
{
|
||||
Anno = item.Anno,
|
||||
DocId = DocIdTgt,
|
||||
FinalPrice = item.FinalPrice,
|
||||
ItemId = item.ItemId,
|
||||
Note = item.Note,
|
||||
Ordinal = item.Ordinal,
|
||||
QtyOff = item.QtyOff,
|
||||
QtyPrev = item.QtyPrev,
|
||||
UnitPriceOff = item.UnitPriceOff
|
||||
};
|
||||
//item.DocId = DocIdTgt;
|
||||
//dbCtx.Entry(item).State = EntityState.Detached;
|
||||
dbCtx
|
||||
.DbSetResources
|
||||
.Add(item);
|
||||
.Add(newItem);
|
||||
}
|
||||
// salvo!
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
@@ -56,6 +56,8 @@ namespace SHERPA.BBM.CORE.DbModels
|
||||
[Column("Note"), MaxLength(500)]
|
||||
public string Note { get; set; } = "";
|
||||
|
||||
[NotMapped]
|
||||
public int DocIdSource { get; set; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public decimal Importo
|
||||
@@ -63,12 +65,9 @@ namespace SHERPA.BBM.CORE.DbModels
|
||||
get
|
||||
{
|
||||
decimal answ = 0;
|
||||
if (IsActive)
|
||||
if (ResNav != null && ResNav.Count > 0)
|
||||
{
|
||||
if (ResNav != null && ResNav.Count > 0)
|
||||
{
|
||||
answ = (decimal)ResNav.Sum(r => r.FinalPrice);
|
||||
}
|
||||
answ = (decimal)ResNav.Sum(r => r.FinalPrice);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -44,49 +44,6 @@ namespace SHERPA.BBM.UI.Components
|
||||
private CORE.DbModels.DocsModel currItem = null;
|
||||
private List<CORE.DbModels.DocsModel> ListRecords;
|
||||
private List<CORE.DbModels.DocsModel> SearchRecords;
|
||||
#if false
|
||||
protected async Task<decimal> getFatturato(int anno, int docId)
|
||||
{
|
||||
decimal fatturato = 0;
|
||||
try
|
||||
{
|
||||
var currVal = await BBMService.BillsGetTotFatturato(anno, 1, 1, docId);
|
||||
fatturato = currVal != null ? currVal : 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return fatturato;
|
||||
}
|
||||
|
||||
protected async Task<double> getGrandTot(int anno, int docId)
|
||||
{
|
||||
double grandTot = 0;
|
||||
var resourcesList = await BBMService.ResourcesGetAsync(anno, 0, 0, docId, BbmResType.ND);
|
||||
if (resourcesList != null && resourcesList.Count > 0)
|
||||
{
|
||||
grandTot = resourcesList.Select(x => x.FinalPrice).Sum();
|
||||
}
|
||||
|
||||
return grandTot;
|
||||
}
|
||||
|
||||
protected async Task<decimal> getIncassato(int anno, int docId)
|
||||
{
|
||||
decimal incassato = 0;
|
||||
try
|
||||
{
|
||||
var currVal = await BBMService.BillsGetTotIncasso(anno, 1, 1, docId);
|
||||
incassato = currVal != null ? currVal : 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return incassato;
|
||||
}
|
||||
#endif
|
||||
|
||||
public string btnFromState(bool isActive)
|
||||
{
|
||||
@@ -137,6 +94,7 @@ namespace SHERPA.BBM.UI.Components
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MessageService.ShowSearch = true;
|
||||
MessageService.SearchVal = "";
|
||||
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
||||
await ReloadAllData();
|
||||
}
|
||||
@@ -150,7 +108,7 @@ namespace SHERPA.BBM.UI.Components
|
||||
|
||||
protected async Task updateTable()
|
||||
{
|
||||
SearchRecords = await BBMService.DocsGetAsync(AnnoSel, 1, NegotIdSour, ShowAllDoc);
|
||||
SearchRecords = await BBMService.DocsGetAsync(MessageService.SearchVal, AnnoSel, 1, NegotIdSour, ShowAllDoc);
|
||||
totalCount = SearchRecords.Count();
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
|
||||
@@ -119,11 +119,8 @@
|
||||
// aggiorno active
|
||||
BBMService.DocSetActive(_currItem);
|
||||
}
|
||||
|
||||
// clono ANCHE le resources suo NUOVO elemento
|
||||
BBMService.ResourceCloneByDoc(SelectData.DocIdSrc, _currItem.DocId);
|
||||
// reset
|
||||
SelectData.DocIdSrc = 0;
|
||||
BBMService.ResourceCloneByDoc(_currItem.DocIdSource, _currItem.DocId);
|
||||
// evento
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
|
||||
@@ -248,9 +248,9 @@ namespace SHERPA.BBM.UI.Data
|
||||
return Task.FromResult(dbController.DocGetLastDesc(numRec).ToArray());
|
||||
}
|
||||
|
||||
public Task<List<CORE.DbModels.DocsModel>> DocsGetAsync(int anno, int basketId, int negotiationId, bool showAll)
|
||||
public Task<List<CORE.DbModels.DocsModel>> DocsGetAsync(string searchVal, int anno, int basketId, int negotiationId, bool showAll)
|
||||
{
|
||||
return Task.FromResult(dbController.DocGetLastDesc(anno, basketId, negotiationId, showAll));
|
||||
return Task.FromResult(dbController.DocGetLastDesc(searchVal, anno, basketId, negotiationId, showAll));
|
||||
}
|
||||
|
||||
public Task<bool> DocsMoveNegot(int DocId, int NegotiationId)
|
||||
|
||||
@@ -45,11 +45,6 @@ namespace SHERPA.BBM.UI.Data
|
||||
/// </summary>
|
||||
public int DocId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Doc selezionato come SRC per CLONAZIONE (se 0 --> NO clonazione)
|
||||
/// </summary>
|
||||
public int DocIdSrc { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Negoziazione selezionata
|
||||
/// </summary>
|
||||
|
||||
@@ -267,6 +267,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
currPage = 1;
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
@@ -50,4 +50,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using SHERPA.BBM.UI.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -23,9 +22,15 @@ namespace SHERPA.BBM.UI.Pages
|
||||
[Inject]
|
||||
private BBM_EFService BBMService { get; set; }
|
||||
|
||||
private int currPage { get; set; } = 1;
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
[Inject]
|
||||
private IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
@@ -55,6 +60,18 @@ namespace SHERPA.BBM.UI.Pages
|
||||
currItem = currRecord;
|
||||
}
|
||||
|
||||
protected async Task ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MService.ShowSearch = true;
|
||||
@@ -82,7 +99,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
protected async Task updateTable()
|
||||
{
|
||||
SearchRecords = await BBMService.CounterGetFilt(MService.SearchVal);
|
||||
ListRecords = SearchRecords;
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
@@ -113,6 +130,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
currPage = 1;
|
||||
Task task = ReloadAllData();
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
private IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[Inject]
|
||||
private MessageService MessageService { get; set; }
|
||||
private MessageService AppMService { get; set; }
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavManager { get; set; }
|
||||
@@ -173,10 +173,10 @@ namespace SHERPA.BBM.UI.Pages
|
||||
NumDoc = 0,
|
||||
DocType = BbmDocType.Quotazione,
|
||||
Descript = "New Document",
|
||||
IsActive = true
|
||||
IsActive = true,
|
||||
DocIdSource=0
|
||||
};
|
||||
currItem = newRecord;
|
||||
SelectData.DocIdSrc = 0;
|
||||
}
|
||||
|
||||
protected async Task Delete(CORE.DbModels.DocsModel currRecord)
|
||||
@@ -205,32 +205,6 @@ namespace SHERPA.BBM.UI.Pages
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
#if false
|
||||
protected decimal getFatturato(CORE.DbModels.DocsModel currRecord)
|
||||
{
|
||||
decimal fatturato = 0;
|
||||
try
|
||||
{
|
||||
fatturato = currRecord.FattNav.Sum(f => f.Importo);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return fatturato;
|
||||
}
|
||||
|
||||
protected double getImporto(CORE.DbModels.DocsModel currRecord)
|
||||
{
|
||||
double grandTot = 0;
|
||||
try
|
||||
{
|
||||
grandTot = currRecord.ResNav.Sum(r => r.FinalPrice);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return grandTot;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected async Task NewRelease(CORE.DbModels.DocsModel currRecord)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler clonare il documento corrente (e le relative risorse)??"))
|
||||
@@ -247,23 +221,23 @@ namespace SHERPA.BBM.UI.Pages
|
||||
NegotiationId = currRecord.NegotiationId,
|
||||
NumDoc = currRecord.NumDoc + 1,
|
||||
DocType = currRecord.DocType,
|
||||
Descript = "COPIA di " + currRecord.Descript
|
||||
Descript = "COPIA di " + currRecord.Descript,
|
||||
DocIdSource=currRecord.DocId
|
||||
};
|
||||
currItem = newRecord;
|
||||
SelectData.DocIdSrc = currRecord.DocId;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MessageService.ShowSearch = true;
|
||||
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
||||
AppMService.ShowSearch = true;
|
||||
AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
yearsList = await BBMService.DocsYears();
|
||||
basketList = await BBMService.BasketsGetAsync(1, MessageService.SearchVal);
|
||||
basketList = await BBMService.BasketsGetAsync(1, "");
|
||||
negotiationList = await BBMService.NegotiationsGetAllAsync();
|
||||
await updateTable();
|
||||
}
|
||||
@@ -300,20 +274,6 @@ namespace SHERPA.BBM.UI.Pages
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
#if false
|
||||
protected decimal getIncassato(CORE.DbModels.DocsModel currRecord)
|
||||
{
|
||||
decimal fatturato = 0;
|
||||
try
|
||||
{
|
||||
fatturato = currRecord.FattNav.Sum(f => f.Incassato);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return fatturato;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currItem = null;
|
||||
@@ -322,7 +282,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
protected async Task updateTable()
|
||||
{
|
||||
SearchRecords = await BBMService.DocsGetAsync(yearSel, selBasketId, selCodNegotiation, ShowAllDoc);
|
||||
SearchRecords = await BBMService.DocsGetAsync(AppMService.SearchVal, yearSel, selBasketId, selCodNegotiation, ShowAllDoc);
|
||||
// se ho ordinamento riordino...
|
||||
if (!string.IsNullOrEmpty(sortField))
|
||||
{
|
||||
@@ -418,13 +378,14 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
MessageService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
AppMService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
}
|
||||
|
||||
public async void OnSeachUpdated()
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
currPage = 1;
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
@@ -208,6 +208,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
currPage = 1;
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
private IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[Inject]
|
||||
private MessageService MessageService { get; set; }
|
||||
private MessageService AppMService { get; set; }
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavManager { get; set; }
|
||||
@@ -245,10 +245,8 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MessageService.ShowSearch = false;
|
||||
|
||||
|
||||
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
||||
AppMService.ShowSearch = true;
|
||||
AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
@@ -258,8 +256,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
CompanyList = await BBMService.CompanyGetAll();
|
||||
CustomersList = await BBMService.CustomersGetAll("");
|
||||
BasketList = await BBMService.BasketsGetAsync(selCompanyId, "");
|
||||
SearchRecords = await BBMService.NegotiationsGetAsync(yearSel, selCompanyId, selCustomerId, selBasketId, "");
|
||||
//SearchRecords = await BBMService.NegotiationsGetAsync(yearSel, selCompanyId, selCustomerId, selBasketId, MessageService.SearchVal);
|
||||
SearchRecords = await BBMService.NegotiationsGetAsync(yearSel, selCompanyId, selCustomerId, selBasketId, AppMService.SearchVal);
|
||||
// se ho ordinamento riordino...
|
||||
if (!string.IsNullOrEmpty(sortField))
|
||||
{
|
||||
@@ -376,13 +373,14 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
MessageService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
AppMService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
}
|
||||
|
||||
public async void OnSeachUpdated()
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
currPage = 1;
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
@@ -390,43 +388,5 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#if false
|
||||
protected async Task<decimal> getFatturato(int anno, int negotId)
|
||||
{
|
||||
decimal fatturato = 0;
|
||||
try
|
||||
{
|
||||
var currVal = await BBMService.BillsGetTotFatturato(anno, 0, negotId, 0);
|
||||
fatturato = currVal != null ? currVal : 0;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return fatturato;
|
||||
}
|
||||
|
||||
protected async Task<double> getImporto(int anno, int negotId)
|
||||
{
|
||||
double grandTot = 0;
|
||||
var resourcesList = await BBMService.ResourcesGetAsync(anno, 0, negotId, 0, BbmResType.ND);
|
||||
if (resourcesList != null && resourcesList.Count > 0)
|
||||
{
|
||||
grandTot = resourcesList.Select(x => x.FinalPrice).Sum();
|
||||
}
|
||||
return grandTot;
|
||||
}
|
||||
|
||||
protected async Task<decimal> getIncassato(int anno, int negotId)
|
||||
{
|
||||
decimal incassato = 0;
|
||||
try
|
||||
{
|
||||
var currVal = await BBMService.BillsGetTotIncasso(anno, 0, negotId, 0);
|
||||
incassato = currVal != null ? currVal : 0;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return incassato;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
currPage = 1;
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<UserSecretsId>60fcdaab-6c1e-4bec-9d88-f7727ef1c12c</UserSecretsId>
|
||||
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
|
||||
<Version>1.0.2112.1016</Version>
|
||||
<Version>1.0.2112.1411</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user