diff --git a/devdocs/specs/core-workorder.txt b/devdocs/specs/core-workorder.txt index a20bb604..863ace3f 100644 --- a/devdocs/specs/core-workorder.txt +++ b/devdocs/specs/core-workorder.txt @@ -13,11 +13,16 @@ CONCURRENCY decision / research - updating, in bits seperately, entirely at once Things that might require an entire workorder graph be updated at once: Major header changes? Customer, Contract because pricing and policies might change? + Anything that affects balances and totals (are there new features happening showing dollar amounts billable right on workorder?) in v7 not an issue because need to preview report to see totals in v8 some talk of seeing totals, so need to determine if that's still a thing, if not then this whole class of concurrency issues dissappears This would be entirely resolved with a "view" showing a type of "invoice" summary kind of thing where you open that tab and it fetches and calcs and displays however this would be little difference from a report and a little worse because the end user can't edit it to calculate how they would like it to so... + + ENTIRE GRAPH AFFECTING CHANGES + One idea to support this is if a change is made at header that affects all children then change their concurrency values so updates will fail + This is a good idea, need a clean way to support it but this makes sense Dirty tracking at every level and object would save having to send entire workorder, just dirty bits i.e. have non-mapped dirty fields for every woitemrecord @@ -36,6 +41,21 @@ CONCURRENCY decision / research - updating, in bits seperately, entirely at once if locked then bumps back with error that wo is now locked (of course they could just change teh status in the header and resave I guess) + + + + + + + + + + + + + + + ########### PLANNING BELOW HERE, OUTDATED NOW ######################################## Lot's to go in here but for now this is holding my planning and thoughts until can set in stone: diff --git a/server/AyaNova/Controllers/SearchController.cs b/server/AyaNova/Controllers/SearchController.cs index 8f0d437d..f9ef7972 100644 --- a/server/AyaNova/Controllers/SearchController.cs +++ b/server/AyaNova/Controllers/SearchController.cs @@ -141,7 +141,7 @@ namespace AyaNova.Api.Controllers case AyaType.WorkOrderItemTravel: case AyaType.WorkOrderItemOutsideService: case AyaType.WorkOrderItemUnit: - AyaTypeId TypeId = new AyaTypeId(AyaType.WorkOrder, await WorkOrderBiz.GetWorkOrderIdFromDescendant(ayaType, id, ct)); + AyaTypeId TypeId = new AyaTypeId(AyaType.WorkOrder, await WorkOrderBiz.GetWorkOrderIdFromRelativeAsync(ayaType, id, ct)); return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ATypeAsInt, Id = TypeId.ObjectId })); default: return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Only types with ancestors are valid")); diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index e036cc07..fd557228 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -253,11 +253,13 @@ namespace AyaNova.Biz //////////////////////////////////////////////////////////////////////////////////////////////// //GET WORKORDER ID FROM DESCENDANT TYPE AND ID // - internal static async Task GetWorkOrderIdFromDescendant(AyaType ayaType, long id, AyContext ct) + internal static async Task GetWorkOrderIdFromRelativeAsync(AyaType ayaType, long id, AyContext ct) { long woitemid = 0; switch (ayaType) { + case AyaType.WorkOrder: + return id; case AyaType.WorkOrderItem: woitemid = id; break; @@ -346,6 +348,9 @@ namespace AyaNova.Biz //run validation and biz rules bool isNew = currentObj == null; + + //Check state if updatable right now + /* todo: workorder status list first, it's a table of created items, keep properties from v7 but add the following properties: @@ -3597,6 +3602,25 @@ namespace AyaNova.Biz throw new System.ArgumentOutOfRangeException($"WorkOrder::GetWorkOrderGraphItem -> Invalid ayaType{ayaType}"); } } + + + + //////////////////////////////////////////////////////////////////////////////////////////////// + //GET UPDATEABLE STATUS FOR WORKORDER FROM DESCENDANT + // + internal static async Task GetCurrentWorkOrderStatusFromRelatedAsync(AyaType ayaType, long id, AyContext ct) + { + long WoId = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct); + + return await ct.WorkOrderState.AsNoTracking() + .Include(z => z.WorkOrderStatus) + .Where(z => z.WorkOrderId == WoId) + .OrderBy(z => z.Created) + .Select(z => z.WorkOrderStatus) + .Take(1) + .FirstOrDefaultAsync(); + + } #endregion utility diff --git a/server/AyaNova/models/WorkOrder.cs b/server/AyaNova/models/WorkOrder.cs index cf21dc12..01b27178 100644 --- a/server/AyaNova/models/WorkOrder.cs +++ b/server/AyaNova/models/WorkOrder.cs @@ -64,6 +64,11 @@ namespace AyaNova.Models public List States { get; set; } = new List(); + //UTILITY FIELDS + + + + [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.WorkOrder; } }//eoc diff --git a/server/AyaNova/models/WorkOrderState.cs b/server/AyaNova/models/WorkOrderState.cs index c570127b..857bc5a3 100644 --- a/server/AyaNova/models/WorkOrderState.cs +++ b/server/AyaNova/models/WorkOrderState.cs @@ -19,7 +19,10 @@ namespace AyaNova.Models [Required] public long UserId { get; set; } - [NotMapped, JsonIgnore] +//related + public WorkOrderStatus WorkOrderStatus { get; set; } + + [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.WorkOrderStatus; } }//eoc