This commit is contained in:
2022-07-04 00:12:42 +00:00
parent 5f5f5bb2e4
commit fb358e4533
7 changed files with 75 additions and 18 deletions

View File

@@ -96,7 +96,7 @@ namespace AyaNova.Api.Controllers
CustomerBiz biz = CustomerBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
var o = await biz.PutAsync(updatedObject);
var o = await biz.PutAsync(updatedObject);
if (o == null)
{
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
@@ -177,6 +177,27 @@ namespace AyaNova.Api.Controllers
}));
}
/// <summary>
/// Get list for accounting integrations
/// </summary>
/// <returns>NameIdActive list</returns>
[HttpGet("accounting-list")]
public async Task<IActionResult> GetAccountingList()
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
CustomerBiz biz = CustomerBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var o = await biz.GetNameIdActiveItemsAsync();
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
return Ok(ApiOkResponse.Response(o));
}
// /// <summary>
// /// Get service (physical) address for this customer
// /// </summary>

View File

@@ -168,6 +168,26 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(await ct.Vendor.AsNoTracking().Where(x => x.Id == id).Select(x => x.AlertNotes).FirstOrDefaultAsync()));
}
/// <summary>
/// Get list for accounting integrations
/// </summary>
/// <returns>NameIdActive list</returns>
[HttpGet("accounting-list")]
public async Task<IActionResult> GetAccountingList()
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
VendorBiz biz = VendorBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var o = await biz.GetNameIdActiveItemsAsync();
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
return Ok(ApiOkResponse.Response(o));
}
//------------

View File

@@ -193,6 +193,15 @@ namespace AyaNova.Biz
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
//GET LIST FOR QBI MAPPING
//
internal async Task<List<NameIdActiveItem>> GetNameIdActiveItemsAsync()
{
return await ct.Customer.AsNoTracking().OrderBy(x => x.Name).Select(x => new NameIdActiveItem { Name = x.Name, Id = x.Id, Active = x.Active }).ToListAsync();
}
////////////////////////////////////////////////////////////////////////////////////////////////
//SEARCH
//

View File

@@ -77,17 +77,17 @@ namespace AyaNova.Biz
//
internal async Task<List<NameIdActiveChargeCostItem>> GetNameIdActiveChargeCostItemsAsync()
{
var pList = await ct.Part.AsNoTracking().Select(x => new NameIdActiveChargeCostItem {Name=null, Id = x.Id, Active = x.Active, Cost = x.Cost, Charge = x.Retail }).ToListAsync();
var pList = await ct.Part.AsNoTracking().OrderBy(z=>z.Name).Select(x => new NameIdActiveChargeCostItem {Name=x.Name, Id = x.Id, Active = x.Active, Cost = x.Cost, Charge = x.Retail }).ToListAsync();
long[] partIdList = new long[0];
var PickList = AyaNova.PickList.PickListFactory.GetAyaPickList(AyaType.Part);
var partNames = await AyaNova.PickList.PickListFetcher.GetResponseAsync(PickList, null, null, true, partIdList, null, ct, null, string.Empty);
foreach (var item in pList)
{
item.Name = partNames.Where(z => z.Id == item.Id).First().Name;
}
//sort in place by name
pList.Sort((lhs, rhs) => lhs.Name.CompareTo(rhs.Name));
// long[] partIdList = new long[0];
// var PickList = AyaNova.PickList.PickListFactory.GetAyaPickList(AyaType.Part);
// var partNames = await AyaNova.PickList.PickListFetcher.GetResponseAsync(PickList, null, null, true, partIdList, null, ct, null, string.Empty);
// foreach (var item in pList)
// {
// item.Name = partNames.Where(z => z.Id == item.Id).First().Name;
// }
// //sort in place by name
// pList.Sort((lhs, rhs) => lhs.Name.CompareTo(rhs.Name));
return pList;
}

View File

@@ -201,7 +201,7 @@ namespace AyaNova.Biz
//
internal async Task<List<NameIdActiveChargeCostItem>> GetNameIdActiveChargeCostItemsAsync()
{
return await ct.ServiceRate.AsNoTracking().Select(x => new NameIdActiveChargeCostItem { Name = x.Name, Id = x.Id, Active = x.Active, Cost = x.Cost, Charge = x.Charge }).OrderBy(x => x.Name).ToListAsync();
return await ct.ServiceRate.AsNoTracking().OrderBy(x => x.Name).Select(x => new NameIdActiveChargeCostItem { Name = x.Name, Id = x.Id, Active = x.Active, Cost = x.Cost, Charge = x.Charge }).ToListAsync();
}
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -201,7 +201,7 @@ namespace AyaNova.Biz
//
internal async Task<List<NameIdActiveChargeCostItem>> GetNameIdActiveChargeCostItemsAsync()
{
return await ct.TravelRate.AsNoTracking().Select(x => new NameIdActiveChargeCostItem { Name = x.Name, Id = x.Id, Active = x.Active, Cost = x.Cost, Charge = x.Charge }).OrderBy(x => x.Name).ToListAsync();
return await ct.TravelRate.AsNoTracking().OrderBy(x => x.Name).Select(x => new NameIdActiveChargeCostItem { Name = x.Name, Id = x.Id, Active = x.Active, Cost = x.Cost, Charge = x.Charge }).ToListAsync();
}
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -161,7 +161,7 @@ namespace AyaNova.Biz
await ValidateCanDeleteAsync(dbObject);
if (HasErrors)
return false;
{
{
var IDList = await ct.Review.AsNoTracking().Where(x => x.AType == AyaType.Vendor && x.ObjectId == id).Select(x => x.Id).ToListAsync();
if (IDList.Count() > 0)
{
@@ -186,6 +186,13 @@ namespace AyaNova.Biz
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
//GET LIST FOR QBI MAPPING
//
internal async Task<List<NameIdActiveItem>> GetNameIdActiveItemsAsync()
{
return await ct.Vendor.AsNoTracking().OrderBy(x => x.Name).Select(x => new NameIdActiveItem { Name = x.Name, Id = x.Id, Active = x.Active }).ToListAsync();
}
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -250,7 +257,7 @@ namespace AyaNova.Biz
{
//skip validation if seeding
if(ServerBootConfig.SEEDING) return;
if (ServerBootConfig.SEEDING) return;
bool isNew = currentObj == null;
@@ -327,7 +334,7 @@ namespace AyaNova.Biz
var batchResults = await ct.Vendor.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
//order the results back into original
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
batchResults=null;
batchResults = null;
foreach (Vendor w in orderedList)
{
if (!ReportRenderManager.KeepGoing(jobId)) return null;
@@ -336,7 +343,7 @@ namespace AyaNova.Biz
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
ReportData.Add(jo);
}
orderedList=null;
orderedList = null;
}
return ReportData;
}
@@ -515,7 +522,7 @@ namespace AyaNova.Biz
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
{
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<VendorBiz>();
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
bool isNew = currentObj == null;