From 7e55a67fc0777d807bac34dd08f10fd9d4713d91 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 30 Jul 2021 22:01:06 +0000 Subject: [PATCH] --- server/AyaNova/biz/PMBiz.cs | 73 +++++++++++------------------- server/AyaNova/biz/QuoteBiz.cs | 15 ++---- server/AyaNova/biz/WorkOrderBiz.cs | 15 ++---- 3 files changed, 33 insertions(+), 70 deletions(-) diff --git a/server/AyaNova/biz/PMBiz.cs b/server/AyaNova/biz/PMBiz.cs index 54f76647..c523767a 100644 --- a/server/AyaNova/biz/PMBiz.cs +++ b/server/AyaNova/biz/PMBiz.cs @@ -159,9 +159,7 @@ namespace AyaNova.Biz } - - - //quote needs to be fetched internally from several places for rule checking etc + //needs to be fetched internally from several places for rule checking etc //this just gets it raw and lets others process private async Task PMGetFullAsync(long id) { @@ -686,7 +684,7 @@ namespace AyaNova.Biz } //FOREIGN KEY CHECKS if (await ct.WorkOrder.AnyAsync(m => m.FromPMId == dbObject.Id)) - AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PM")); + AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PM")); } @@ -833,8 +831,6 @@ namespace AyaNova.Biz // private async Task PMPopulateVizFields(PM o, bool headerOnly, bool populateForReporting) { - - o.UserIsRestrictedType = UserIsRestrictedType; o.UserIsTechRestricted = UserIsTechRestricted; o.UserIsSubContractorFull = UserIsSubContractorFull; @@ -987,13 +983,13 @@ namespace AyaNova.Biz bool isNew = currentObj == null; PM oProposed = (PM)proposedObj; - + //STANDARD EVENTS FOR ALL OBJECTS await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);//Note: will properly handle all delete events and event removal if deleted //SPECIFIC EVENTS FOR THIS OBJECT - + }//end of process notifications @@ -1273,20 +1269,11 @@ namespace AyaNova.Biz //run validation and biz rules bool isNew = currentObj == null; - //does it have a valid quote id + //does it have a valid id if (proposedObj.PMId == 0) AddError(ApiErrorCode.VALIDATION_REQUIRED, "PMId"); else if (!await PMExistsAsync(proposedObj.PMId)) - { AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "PMId"); - } - - //summary is required now, this is a change from v7 - //I did this because it is required in terms of hiding on the form so it also - //is required to have a value. This is really because the form field customization I took away the hideable field - //maybe I should add that feature back? - if (proposedObj.PMId == 0) - AddError(ApiErrorCode.VALIDATION_REQUIRED, "PMId"); //Check restricted role preventing create if (isNew && UserIsRestrictedType) @@ -1295,8 +1282,7 @@ namespace AyaNova.Biz return;//this is a completely disqualifying error } - - if (string.IsNullOrWhiteSpace(proposedObj.Notes))//negative quantities are not allowed + if (string.IsNullOrWhiteSpace(proposedObj.Notes)) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Notes"); //Any form customizations to validate? @@ -2041,7 +2027,6 @@ namespace AyaNova.Biz return;//this is a completely disqualifying error } - if (UserIsRestrictedType && (proposedObj.UserId != UserId || (!isNew && currentObj.UserId != UserId))) { //no edits allowed on other people's records @@ -2049,7 +2034,6 @@ namespace AyaNova.Biz return; } - //Start date AND end date must both be null or both contain values if (proposedObj.ServiceStartDate == null && proposedObj.ServiceStopDate != null) AddError(ApiErrorCode.VALIDATION_REQUIRED, "ServiceStartDate"); @@ -3164,8 +3148,6 @@ namespace AyaNova.Biz // private async Task PartBizActionsAsync(AyaEvent ayaEvent, PMItemPart newObj, PMItemPart oldObj, IDbContextTransaction transaction) { - - //SNAPSHOT PRICING IF NECESSARY if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified) return; @@ -3187,7 +3169,6 @@ namespace AyaNova.Biz } } - //Pricing if (SnapshotPricing) { @@ -3195,7 +3176,6 @@ namespace AyaNova.Biz newObj.Cost = 0; newObj.ListPrice = 0; - var s = await ct.Part.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.PartId); if (s != null) { @@ -3502,27 +3482,28 @@ namespace AyaNova.Biz if (proposedObj.StartDate > proposedObj.StopDate) AddError(ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE, "StartDate"); - //Scheduling conflict? - if (!AyaNova.Util.ServerGlobalBizSettings.Cache.AllowScheduleConflicts - && proposedObj.UserId != null - && proposedObj.StartDate != null - && proposedObj.StopDate != null - && (isNew - || (proposedObj.StartDate != currentObj.StartDate) - || (proposedObj.StopDate != currentObj.StopDate) - || (proposedObj.UserId != currentObj.UserId) - )) - { - if (await ct.PMItemScheduledUser.AnyAsync(x => x.Id != proposedObj.Id - && x.UserId == proposedObj.UserId - && x.StartDate <= proposedObj.StopDate - && proposedObj.StartDate <= x.StopDate)) - { - AddError(ApiErrorCode.VALIDATION_FAILED, "StartDate", await Translate("ScheduleConflict")); - AddError(ApiErrorCode.VALIDATION_FAILED, "StopDate", await Translate("ScheduleConflict")); - } - } + //For now decision is to not check for sched conflicts on pm as it's not a work order yet anyway + // //Scheduling conflict? + // if (!AyaNova.Util.ServerGlobalBizSettings.Cache.AllowScheduleConflicts + // && proposedObj.UserId != null + // && proposedObj.StartDate != null + // && proposedObj.StopDate != null + // && (isNew + // || (proposedObj.StartDate != currentObj.StartDate) + // || (proposedObj.StopDate != currentObj.StopDate) + // || (proposedObj.UserId != currentObj.UserId) + // )) + // { + // if (await ct.PMItemScheduledUser.AnyAsync(x => x.Id != proposedObj.Id + // && x.UserId == proposedObj.UserId + // && x.StartDate <= proposedObj.StopDate + // && proposedObj.StartDate <= x.StopDate)) + // { + // AddError(ApiErrorCode.VALIDATION_FAILED, "StartDate", await Translate("ScheduleConflict")); + // AddError(ApiErrorCode.VALIDATION_FAILED, "StopDate", await Translate("ScheduleConflict")); + // } + // } //Any form customizations to validate? var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.PMItemScheduledUser.ToString()); diff --git a/server/AyaNova/biz/QuoteBiz.cs b/server/AyaNova/biz/QuoteBiz.cs index 4e2f45a9..8b30008e 100644 --- a/server/AyaNova/biz/QuoteBiz.cs +++ b/server/AyaNova/biz/QuoteBiz.cs @@ -1657,18 +1657,9 @@ namespace AyaNova.Biz //does it have a valid quote id if (proposedObj.QuoteId == 0) AddError(ApiErrorCode.VALIDATION_REQUIRED, "QuoteId"); - else if (!await QuoteExistsAsync(proposedObj.QuoteId)) - { + else if (!await QuoteExistsAsync(proposedObj.QuoteId)) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "QuoteId"); - } - - //summary is required now, this is a change from v7 - //I did this because it is required in terms of hiding on the form so it also - //is required to have a value. This is really because the form field customization I took away the hideable field - //maybe I should add that feature back? - if (proposedObj.QuoteId == 0) - AddError(ApiErrorCode.VALIDATION_REQUIRED, "QuoteId"); - + //Check restricted role preventing create if (isNew && UserIsRestrictedType) { @@ -1689,7 +1680,7 @@ namespace AyaNova.Biz } } - if (string.IsNullOrWhiteSpace(proposedObj.Notes))//negative quantities are not allowed + if (string.IsNullOrWhiteSpace(proposedObj.Notes)) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Notes"); //Any form customizations to validate? diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index cc6fdc61..e161c5eb 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -1267,7 +1267,7 @@ namespace AyaNova.Biz bool isNew = currentObj == null; WorkOrder oProposed = (WorkOrder)proposedObj; - + //STANDARD EVENTS FOR ALL OBJECTS await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);//Note: will properly handle all delete events and event removal if deleted @@ -2223,16 +2223,7 @@ namespace AyaNova.Biz if (proposedObj.WorkOrderId == 0) AddError(ApiErrorCode.VALIDATION_REQUIRED, "WorkOrderId"); else if (!await WorkOrderExistsAsync(proposedObj.WorkOrderId)) - { AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "WorkOrderId"); - } - - //summary is required now, this is a change from v7 - //I did this because it is required in terms of hiding on the form so it also - //is required to have a value. This is really because the form field customization I took away the hideable field - //maybe I should add that feature back? - if (proposedObj.WorkOrderId == 0) - AddError(ApiErrorCode.VALIDATION_REQUIRED, "WorkOrderId"); //Check restricted role preventing create if (isNew && UserIsRestrictedType) @@ -2254,7 +2245,7 @@ namespace AyaNova.Biz } } - if (string.IsNullOrWhiteSpace(proposedObj.Notes))//negative quantities are not allowed + if (string.IsNullOrWhiteSpace(proposedObj.Notes)) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Notes"); //Any form customizations to validate? @@ -4878,7 +4869,7 @@ namespace AyaNova.Biz var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct); var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync(); proposedObj.Tags = WorkorderInfo.Tags; - + proposedObj.Name = WorkorderInfo.Serial.ToString(); //STANDARD EVENTS FOR ALL OBJECTS