diff --git a/server/AyaNova/biz/PMBiz.cs b/server/AyaNova/biz/PMBiz.cs index d61ad224..d5cdf4c1 100644 --- a/server/AyaNova/biz/PMBiz.cs +++ b/server/AyaNova/biz/PMBiz.cs @@ -58,7 +58,7 @@ namespace AyaNova.Biz AuthorizationRoles.BizAdmin, UserType.NotService);//picked not service arbitrarily, probably a non-factor } - + private VizCache vc = new VizCache(); private ObjectCache oc = new ObjectCache(); @@ -2118,7 +2118,7 @@ namespace AyaNova.Biz //POTENTIAL CONTRACT ADJUSTMENTS //First check if there is a matching tagged service rate contract discount, that takes precedence - if (c.ContractServiceRateOverrideItems.Count > 0 && Rate!=null) + if (c.ContractServiceRateOverrideItems.Count > 0 && Rate != null) { //Iterate all contract tagged items in order of ones with the most tags first foreach (var csr in c.ContractServiceRateOverrideItems.OrderByDescending(z => z.Tags.Count)) @@ -3925,23 +3925,21 @@ namespace AyaNova.Biz return; } - if (!isNew && UserIsRestrictedType && currentObj.CompletedByUserId != UserId) + if (!isNew && UserIsRestrictedType) { - //restricted users are not allowed to edit any task unless they are the selected User - AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); - return; + //Existing record so just make sure they haven't changed the not changeable fields from the db version + //* Tasks: view and edit existing tasks, set completion type and date only, no add or remove or changing other fields + //note that UI will prevent this, this rule is only backup for 3rd party api users + if (currentObj.Task != proposedObj.Task) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Task"); + if (currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "CompletedByUserId"); + if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); - // //Existing record so just make sure they haven't changed the not changeable fields from the db version - - // //* Tasks: view and edit existing tasks, set completion type and date only, no add or remove or changing other fields - // //note that UI will prevent this, this rule is only backup for 3rd party api users - // if (currentObj.Task != proposedObj.Task) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Task"); - // if (currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "CompletedByUserId"); - // if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); + //they *are* permitted to change the date and status but only if they are the selected user: + //note that UI will prevent this, this rule is only backup for 3rd party api users + if (currentObj.CompletedDate != proposedObj.CompletedDate && currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "CompletedDate"); + if (currentObj.Status != proposedObj.Status && currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Status"); } - - if (string.IsNullOrWhiteSpace(proposedObj.Task)) AddError(ApiErrorCode.VALIDATION_REQUIRED, "Task"); @@ -4224,7 +4222,7 @@ namespace AyaNova.Biz //POTENTIAL CONTRACT ADJUSTMENTS //First check if there is a matching tagged Travel rate contract discount, that takes precedence - if (c.ContractTravelRateOverrideItems.Count > 0 && Rate!=null) + if (c.ContractTravelRateOverrideItems.Count > 0 && Rate != null) { //Iterate all contract tagged items in order of ones with the most tags first foreach (var csr in c.ContractTravelRateOverrideItems.OrderByDescending(z => z.Tags.Count)) diff --git a/server/AyaNova/biz/QuoteBiz.cs b/server/AyaNova/biz/QuoteBiz.cs index 6e36bc60..51be5ebd 100644 --- a/server/AyaNova/biz/QuoteBiz.cs +++ b/server/AyaNova/biz/QuoteBiz.cs @@ -4172,19 +4172,19 @@ namespace AyaNova.Biz return; } - if (!isNew && UserIsRestrictedType && currentObj.CompletedByUserId != UserId) + if (!isNew && UserIsRestrictedType) { - //restricted users are not allowed to edit any task unless they are the selected User - AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); - return; + //Existing record so just make sure they haven't changed the not changeable fields from the db version + //* Tasks: view and edit existing tasks, set completion type and date only, no add or remove or changing other fields + //note that UI will prevent this, this rule is only backup for 3rd party api users + if (currentObj.Task != proposedObj.Task) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Task"); + if (currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "CompletedByUserId"); + if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); - // //Existing record so just make sure they haven't changed the not changeable fields from the db version - - // //* Tasks: view and edit existing tasks, set completion type and date only, no add or remove or changing other fields - // //note that UI will prevent this, this rule is only backup for 3rd party api users - // if (currentObj.Task != proposedObj.Task) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Task"); - // if (currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "CompletedByUserId"); - // if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); + //they *are* permitted to change the date and status but only if they are the selected user: + //note that UI will prevent this, this rule is only backup for 3rd party api users + if (currentObj.CompletedDate != proposedObj.CompletedDate && currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "CompletedDate"); + if (currentObj.Status != proposedObj.Status && currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Status"); } diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index f0018a7f..2cf4707a 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -5769,19 +5769,19 @@ namespace AyaNova.Biz } - if (!isNew && UserIsRestrictedType && currentObj.CompletedByUserId != UserId) + if (!isNew && UserIsRestrictedType) { - //restricted users are not allowed to edit any task unless they are the selected User - AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); - return; + //Existing record so just make sure they haven't changed the not changeable fields from the db version + //* Tasks: view and edit existing tasks, set completion type and date only, no add or remove or changing other fields + //note that UI will prevent this, this rule is only backup for 3rd party api users + if (currentObj.Task != proposedObj.Task) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Task"); + if (currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "CompletedByUserId"); + if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); - // //Existing record so just make sure they haven't changed the not changeable fields from the db version - - // //* Tasks: view and edit existing tasks, set completion type and date only, no add or remove or changing other fields - // //note that UI will prevent this, this rule is only backup for 3rd party api users - // if (currentObj.Task != proposedObj.Task) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Task"); - // if (currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "CompletedByUserId"); - // if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); + //they *are* permitted to change the date and status but only if they are the selected user: + //note that UI will prevent this, this rule is only backup for 3rd party api users + if (currentObj.CompletedDate != proposedObj.CompletedDate && currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "CompletedDate"); + if (currentObj.Status != proposedObj.Status && currentObj.CompletedByUserId != UserId) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Status"); }