This commit is contained in:
2021-09-08 15:37:53 +00:00
parent 3cc64146dc
commit 77aff9e8cf
3 changed files with 88 additions and 134 deletions

View File

@@ -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

View File

@@ -59,29 +59,7 @@ namespace AyaNova.Api.Controllers
return CreatedAtAction(nameof(CustomerServiceRequestController.GetCustomerServiceRequest), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
}
// /// <summary>
// /// Duplicate CustomerServiceRequest
// /// (Wiki and Attachments are not duplicated)
// /// </summary>
// /// <param name="id">Source object id</param>
// /// <param name="apiVersion">From route path</param>
// /// <returns>CustomerServiceRequest</returns>
// [HttpPost("duplicate/{id}")]
// public async Task<IActionResult> 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));
// }
/// <summary>
/// Get CustomerServiceRequest
@@ -150,52 +128,53 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Reject CustomerServiceRequest
/// </summary>
/// <param name="id">Source object id</param>
/// <param name="apiVersion">From route path</param>
/// <returns>CustomerServiceRequest</returns>
[HttpPost("reject/{id}")]
public async Task<IActionResult> 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));
}
// /// <summary>
// /// Reject CustomerServiceRequest
// /// </summary>
// /// <param name="id">Source object id</param>
// /// <param name="apiVersion">From route path</param>
// /// <returns>CustomerServiceRequest</returns>
// [HttpPost("reject/{id}")]
// public async Task<IActionResult> 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));
// }
/// <summary>
/// Accept CustomerServiceRequest
/// </summary>
/// <param name="id">Source object id</param>
/// <param name="workorderid">Existing WorkOrder to accept to, 0 creates new workorder</param>
/// <param name="apiVersion">From route path</param>
/// <returns>CustomerServiceRequest with WorkOrderItemId set</returns>
[HttpPost("accept/{id}/{workorderid}")]
public async Task<IActionResult> 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));
}
// /// <summary>
// /// Accept CustomerServiceRequest to new WorkOrder
// /// </summary>
// /// <param name="id">Source CSR id</param>
// /// <param name="apiVersion">From route path</param>
// /// <returns>CustomerServiceRequest with WorkOrderItemId set</returns>
// [HttpPost("accept/{id}/{workorderid}")]
// public async Task<IActionResult> 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));
// }

View File

@@ -60,39 +60,6 @@ namespace AyaNova.Biz
}
}
// ////////////////////////////////////////////////////////////////////////////////////////////////
// //DUPLICATE
// //
// internal async Task<CustomerServiceRequest> 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<CustomerServiceRequest> 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<CustomerServiceRequest> 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<CustomerServiceRequest> RejectAsync(long csrId)
{
var dbObject = await GetAsync(csrId, false);
if (dbObject == null)
{
AddError(ApiErrorCode.NOT_FOUND, "id");
return null;
}
// ////////////////////////////////////////////////////////////////////////////////////////////////
// //REJECT
// //
// internal async Task<CustomerServiceRequest> 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<CustomerServiceRequestBiz>();
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;