diff --git a/docs/8.0/ayanova/docs/ay-start-changes-from-v7.md b/docs/8.0/ayanova/docs/ay-start-changes-from-v7.md index d6f98a4a..a7326e58 100644 --- a/docs/8.0/ayanova/docs/ay-start-changes-from-v7.md +++ b/docs/8.0/ayanova/docs/ay-start-changes-from-v7.md @@ -140,7 +140,6 @@ PMs now provide all the same sections as a service Work order with the sole exce ### Contracts Service contracts have been expanded with new features and more flexibility when applying (or not) to work orders. You can now select a discount off list price or a markup on cost for special contract pricing. In addition to the v7 general discount in a contract you can now select specific tags for parts or rates that, if those items have the tags selected, will be discounted / marked up the value selected. This gives a lot of flexibility in cases where a certain class or type of part for example should be included in discounts but not others. There are now also features for maximum response time that tie into notification and close by date features of work order automatically for contracts that include a response time commitment. - ### Localized text is now Translation Localized text has been renamed to Translation diff --git a/server/AyaNova/Controllers/CustomerServiceRequestController.cs b/server/AyaNova/Controllers/CustomerServiceRequestController.cs index 4a2e187d..a7a8c70f 100644 --- a/server/AyaNova/Controllers/CustomerServiceRequestController.cs +++ b/server/AyaNova/Controllers/CustomerServiceRequestController.cs @@ -59,29 +59,7 @@ namespace AyaNova.Api.Controllers return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); } - // /// - // /// Duplicate CustomerServiceRequest - // /// (Wiki and Attachments are not duplicated) - // /// - // /// Source object id - // /// From route path - // /// CustomerServiceRequest - // [HttpPost("duplicate/{id}")] - // public async Task DuplicateCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion) - // { - // if (!serverState.IsOpen) - // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); - // CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext); - // if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) - // return StatusCode(403, new ApiNotAuthorizedResponse()); - // if (!ModelState.IsValid) - // return BadRequest(new ApiErrorResponse(ModelState)); - // CustomerServiceRequest o = await biz.DuplicateAsync(id); - // if (o == null) - // return BadRequest(new ApiErrorResponse(biz.Errors)); - // else - // return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); - // } + /// /// Get CustomerServiceRequest @@ -150,52 +128,53 @@ namespace AyaNova.Api.Controllers } - /// - /// Reject CustomerServiceRequest - /// - /// Source object id - /// From route path - /// CustomerServiceRequest - [HttpPost("reject/{id}")] - public async Task RejectCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion) - { - if (!serverState.IsOpen) - return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); - CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext); - if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) - return StatusCode(403, new ApiNotAuthorizedResponse()); - if (!ModelState.IsValid) - return BadRequest(new ApiErrorResponse(ModelState)); - CustomerServiceRequest o = await biz.RejectAsync(id); - if (o == null) - return BadRequest(new ApiErrorResponse(biz.Errors)); - else - return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); - } + // /// + // /// Reject CustomerServiceRequest + // /// + // /// Source object id + // /// From route path + // /// CustomerServiceRequest + // [HttpPost("reject/{id}")] + // public async Task RejectCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion) + // { + // if (!serverState.IsOpen) + // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + // CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext); + // if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) + // return StatusCode(403, new ApiNotAuthorizedResponse()); + // if (!ModelState.IsValid) + // return BadRequest(new ApiErrorResponse(ModelState)); + // CustomerServiceRequest o = await biz.RejectAsync(id); + // if (o == null) + // return BadRequest(new ApiErrorResponse(biz.Errors)); + // else + // return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); + // } - /// - /// Accept CustomerServiceRequest - /// - /// Source object id - /// Existing WorkOrder to accept to, 0 creates new workorder - /// From route path - /// CustomerServiceRequest with WorkOrderItemId set - [HttpPost("accept/{id}/{workorderid}")] - public async Task AcceptCustomerServiceRequest([FromRoute] long id, [FromRoute] long workorderid, ApiVersion apiVersion) - { - if (!serverState.IsOpen) - return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); - CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext); - if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) - return StatusCode(403, new ApiNotAuthorizedResponse()); - if (!ModelState.IsValid) - return BadRequest(new ApiErrorResponse(ModelState)); - CustomerServiceRequest o = await biz.AcceptAsync(id, workorderid); - if (o == null) - return BadRequest(new ApiErrorResponse(biz.Errors)); - else - return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); - } + // /// + // /// Accept CustomerServiceRequest to new WorkOrder + // /// + // /// Source CSR id + // /// From route path + // /// CustomerServiceRequest with WorkOrderItemId set + // [HttpPost("accept/{id}/{workorderid}")] + // public async Task AcceptCustomerServiceRequest([FromRoute] long id, ApiVersion apiVersion) + // { + // if (!serverState.IsOpen) + // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + // CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct, HttpContext); + // if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) + // return StatusCode(403, new ApiNotAuthorizedResponse()); + // if (!ModelState.IsValid) + // return BadRequest(new ApiErrorResponse(ModelState)); + // CustomerServiceRequest o = await biz.AcceptAsync(id); + // if (o == null) + // return BadRequest(new ApiErrorResponse(biz.Errors)); + // else + // return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); + // } + + diff --git a/server/AyaNova/biz/CustomerServiceRequestBiz.cs b/server/AyaNova/biz/CustomerServiceRequestBiz.cs index 652f47a5..09b0fc79 100644 --- a/server/AyaNova/biz/CustomerServiceRequestBiz.cs +++ b/server/AyaNova/biz/CustomerServiceRequestBiz.cs @@ -60,39 +60,6 @@ namespace AyaNova.Biz } } - // //////////////////////////////////////////////////////////////////////////////////////////////// - // //DUPLICATE - // // - // internal async Task DuplicateAsync(long id) - // { - // CustomerServiceRequest dbObject = await GetAsync(id, false); - // if (dbObject == null) - // { - // AddError(ApiErrorCode.NOT_FOUND, "id"); - // return null; - // } - // CustomerServiceRequest newObject = new CustomerServiceRequest(); - // CopyObject.Copy(dbObject, newObject, "Wiki"); - // string newUniqueName = string.Empty; - // bool NotUnique = true; - // long l = 1; - // do - // { - // newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObject.Name, l++, 255); - // NotUnique = await ct.CustomerServiceRequest.AnyAsync(m => m.Name == newUniqueName); - // } while (NotUnique); - // newObject.Name = newUniqueName; - // newObject.Id = 0; - // newObject.Concurrency = 0; - // await ct.CustomerServiceRequest.AddAsync(newObject); - // await ct.SaveChangesAsync(); - // await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); - // await SearchIndexAsync(newObject, true); - // await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - // await HandlePotentialNotificationEvent(AyaEvent.Created, newObject); - // return newObject; - // } - //////////////////////////////////////////////////////////////////////////////////////////////// //GET // @@ -175,43 +142,43 @@ namespace AyaNova.Biz - //////////////////////////////////////////////////////////////////////////////////////////////// - //ACCEPT - // - internal async Task AcceptAsync(long csrId, long workorderId) //MIGRATE_OUTSTANDING waiting for workorder to be completed or at least have a customerid which it currently doesn't - { - var dbObject = await GetAsync(csrId, false); - if (dbObject == null) - { - AddError(ApiErrorCode.NOT_FOUND, "id"); - return null; - } + // //////////////////////////////////////////////////////////////////////////////////////////////// + // //ACCEPT + // // + // internal async Task AcceptAsync(long csrId, long workorderId) //MIGRATE_OUTSTANDING waiting for workorder to be completed or at least have a customerid which it currently doesn't + // { + // var dbObject = await GetAsync(csrId, false); + // if (dbObject == null) + // { + // AddError(ApiErrorCode.NOT_FOUND, "id"); + // return null; + // } - throw new System.NotImplementedException("//MIGRATE_OUTSTANDING CustomerServiceRequestBiz::AcceptAsync - awaiting workorder completion "); - // WorkOrder w=null; - //if (workorderId==0){WorkOrderBiz.GenerateWorkOrder()} //this is how it would work in theory + // throw new System.NotImplementedException("//MIGRATE_OUTSTANDING CustomerServiceRequestBiz::AcceptAsync - awaiting workorder completion "); + // // WorkOrder w=null; + // //if (workorderId==0){WorkOrderBiz.GenerateWorkOrder()} //this is how it would work in theory - } + // } - //////////////////////////////////////////////////////////////////////////////////////////////// - //REJECT - // - internal async Task RejectAsync(long csrId) - { - var dbObject = await GetAsync(csrId, false); - if (dbObject == null) - { - AddError(ApiErrorCode.NOT_FOUND, "id"); - return null; - } + // //////////////////////////////////////////////////////////////////////////////////////////////// + // //REJECT + // // + // internal async Task RejectAsync(long csrId) + // { + // var dbObject = await GetAsync(csrId, false); + // if (dbObject == null) + // { + // AddError(ApiErrorCode.NOT_FOUND, "id"); + // return null; + // } - //Nothing to validate as it just came from the db and rejecting doesn't require validation - dbObject.Status = CustomerServiceRequestStatus.Declined; - await PutAsync(dbObject); - return dbObject; - } + // //Nothing to validate as it just came from the db and rejecting doesn't require validation + // dbObject.Status = CustomerServiceRequestStatus.Declined; + // await PutAsync(dbObject); + // return dbObject; + // } @@ -495,7 +462,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; @@ -507,8 +474,16 @@ namespace AyaNova.Biz //SPECIFIC EVENTS FOR THIS OBJECT var o = (CustomerServiceRequest)proposedObj; + bool WasAccepted = false; + bool WasDeclined = false; + if (!isNew) + { + WasAccepted = ((CustomerServiceRequest)currentObj).Status == CustomerServiceRequestStatus.Accepted; + WasDeclined = ((CustomerServiceRequest)currentObj).Status == CustomerServiceRequestStatus.Declined; + } //CSR ACCEPTED + if (!WasAccepted && o.Status == CustomerServiceRequestStatus.Accepted)//TAGS NOT RELEVANT { var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.CSRAccepted).ToListAsync(); string SourceName = string.Empty; @@ -535,6 +510,7 @@ namespace AyaNova.Biz } //CSR REJECTED + if (!WasDeclined && o.Status == CustomerServiceRequestStatus.Declined)//TAGS NOT RELEVANT { var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.CSRRejected).ToListAsync(); string SourceName = string.Empty;