diff --git a/server/AyaNova/Controllers/CustomerController.cs b/server/AyaNova/Controllers/CustomerController.cs index 295a7d85..b7b1bae2 100644 --- a/server/AyaNova/Controllers/CustomerController.cs +++ b/server/AyaNova/Controllers/CustomerController.cs @@ -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 })); } + + /// + /// Get list for accounting integrations + /// + /// NameIdActive list + [HttpGet("accounting-list")] + public async Task 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)); + } + + // /// // /// Get service (physical) address for this customer // /// diff --git a/server/AyaNova/Controllers/VendorController.cs b/server/AyaNova/Controllers/VendorController.cs index 386c4946..aedcd89e 100644 --- a/server/AyaNova/Controllers/VendorController.cs +++ b/server/AyaNova/Controllers/VendorController.cs @@ -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())); } + /// + /// Get list for accounting integrations + /// + /// NameIdActive list + [HttpGet("accounting-list")] + public async Task 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)); + } + + //------------ diff --git a/server/AyaNova/biz/CustomerBiz.cs b/server/AyaNova/biz/CustomerBiz.cs index 552168cb..a0f00b90 100644 --- a/server/AyaNova/biz/CustomerBiz.cs +++ b/server/AyaNova/biz/CustomerBiz.cs @@ -193,6 +193,15 @@ namespace AyaNova.Biz } } + + //////////////////////////////////////////////////////////////////////////////////////////////// + //GET LIST FOR QBI MAPPING + // + internal async Task> 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 // diff --git a/server/AyaNova/biz/PartBiz.cs b/server/AyaNova/biz/PartBiz.cs index 7143bd6b..7c8102b9 100644 --- a/server/AyaNova/biz/PartBiz.cs +++ b/server/AyaNova/biz/PartBiz.cs @@ -77,17 +77,17 @@ namespace AyaNova.Biz // internal async Task> 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; } diff --git a/server/AyaNova/biz/ServiceRateBiz.cs b/server/AyaNova/biz/ServiceRateBiz.cs index b6fd9aef..e667a60f 100644 --- a/server/AyaNova/biz/ServiceRateBiz.cs +++ b/server/AyaNova/biz/ServiceRateBiz.cs @@ -201,7 +201,7 @@ namespace AyaNova.Biz // internal async Task> 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(); } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/server/AyaNova/biz/TravelRateBiz.cs b/server/AyaNova/biz/TravelRateBiz.cs index ad14cdaf..35f3120e 100644 --- a/server/AyaNova/biz/TravelRateBiz.cs +++ b/server/AyaNova/biz/TravelRateBiz.cs @@ -201,7 +201,7 @@ namespace AyaNova.Biz // internal async Task> 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(); } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/server/AyaNova/biz/VendorBiz.cs b/server/AyaNova/biz/VendorBiz.cs index d37a81e8..e3f33aa5 100644 --- a/server/AyaNova/biz/VendorBiz.cs +++ b/server/AyaNova/biz/VendorBiz.cs @@ -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> 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(); - 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;