This commit is contained in:
@@ -159,9 +159,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//needs to be fetched internally from several places for rule checking etc
|
||||||
|
|
||||||
//quote needs to be fetched internally from several places for rule checking etc
|
|
||||||
//this just gets it raw and lets others process
|
//this just gets it raw and lets others process
|
||||||
private async Task<PM> PMGetFullAsync(long id)
|
private async Task<PM> PMGetFullAsync(long id)
|
||||||
{
|
{
|
||||||
@@ -686,7 +684,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
//FOREIGN KEY CHECKS
|
//FOREIGN KEY CHECKS
|
||||||
if (await ct.WorkOrder.AnyAsync(m => m.FromPMId == dbObject.Id))
|
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)
|
private async Task PMPopulateVizFields(PM o, bool headerOnly, bool populateForReporting)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
o.UserIsRestrictedType = UserIsRestrictedType;
|
o.UserIsRestrictedType = UserIsRestrictedType;
|
||||||
o.UserIsTechRestricted = UserIsTechRestricted;
|
o.UserIsTechRestricted = UserIsTechRestricted;
|
||||||
o.UserIsSubContractorFull = UserIsSubContractorFull;
|
o.UserIsSubContractorFull = UserIsSubContractorFull;
|
||||||
@@ -987,13 +983,13 @@ namespace AyaNova.Biz
|
|||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
|
|
||||||
PM oProposed = (PM)proposedObj;
|
PM oProposed = (PM)proposedObj;
|
||||||
|
|
||||||
//STANDARD EVENTS FOR ALL OBJECTS
|
//STANDARD EVENTS FOR ALL OBJECTS
|
||||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);//Note: will properly handle all delete events and event removal if deleted
|
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);//Note: will properly handle all delete events and event removal if deleted
|
||||||
|
|
||||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}//end of process notifications
|
}//end of process notifications
|
||||||
|
|
||||||
@@ -1273,20 +1269,11 @@ namespace AyaNova.Biz
|
|||||||
//run validation and biz rules
|
//run validation and biz rules
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
|
|
||||||
//does it have a valid quote id
|
//does it have a valid id
|
||||||
if (proposedObj.PMId == 0)
|
if (proposedObj.PMId == 0)
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "PMId");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "PMId");
|
||||||
else if (!await PMExistsAsync(proposedObj.PMId))
|
else if (!await PMExistsAsync(proposedObj.PMId))
|
||||||
{
|
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "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
|
//Check restricted role preventing create
|
||||||
if (isNew && UserIsRestrictedType)
|
if (isNew && UserIsRestrictedType)
|
||||||
@@ -1295,8 +1282,7 @@ namespace AyaNova.Biz
|
|||||||
return;//this is a completely disqualifying error
|
return;//this is a completely disqualifying error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(proposedObj.Notes))
|
||||||
if (string.IsNullOrWhiteSpace(proposedObj.Notes))//negative quantities are not allowed
|
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Notes");
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Notes");
|
||||||
|
|
||||||
//Any form customizations to validate?
|
//Any form customizations to validate?
|
||||||
@@ -2041,7 +2027,6 @@ namespace AyaNova.Biz
|
|||||||
return;//this is a completely disqualifying error
|
return;//this is a completely disqualifying error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (UserIsRestrictedType && (proposedObj.UserId != UserId || (!isNew && currentObj.UserId != UserId)))
|
if (UserIsRestrictedType && (proposedObj.UserId != UserId || (!isNew && currentObj.UserId != UserId)))
|
||||||
{
|
{
|
||||||
//no edits allowed on other people's records
|
//no edits allowed on other people's records
|
||||||
@@ -2049,7 +2034,6 @@ namespace AyaNova.Biz
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Start date AND end date must both be null or both contain values
|
//Start date AND end date must both be null or both contain values
|
||||||
if (proposedObj.ServiceStartDate == null && proposedObj.ServiceStopDate != null)
|
if (proposedObj.ServiceStartDate == null && proposedObj.ServiceStopDate != null)
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "ServiceStartDate");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "ServiceStartDate");
|
||||||
@@ -3164,8 +3148,6 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
private async Task PartBizActionsAsync(AyaEvent ayaEvent, PMItemPart newObj, PMItemPart oldObj, IDbContextTransaction transaction)
|
private async Task PartBizActionsAsync(AyaEvent ayaEvent, PMItemPart newObj, PMItemPart oldObj, IDbContextTransaction transaction)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//SNAPSHOT PRICING IF NECESSARY
|
//SNAPSHOT PRICING IF NECESSARY
|
||||||
if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified)
|
if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified)
|
||||||
return;
|
return;
|
||||||
@@ -3187,7 +3169,6 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Pricing
|
//Pricing
|
||||||
if (SnapshotPricing)
|
if (SnapshotPricing)
|
||||||
{
|
{
|
||||||
@@ -3195,7 +3176,6 @@ namespace AyaNova.Biz
|
|||||||
newObj.Cost = 0;
|
newObj.Cost = 0;
|
||||||
newObj.ListPrice = 0;
|
newObj.ListPrice = 0;
|
||||||
|
|
||||||
|
|
||||||
var s = await ct.Part.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.PartId);
|
var s = await ct.Part.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.PartId);
|
||||||
if (s != null)
|
if (s != null)
|
||||||
{
|
{
|
||||||
@@ -3502,27 +3482,28 @@ namespace AyaNova.Biz
|
|||||||
if (proposedObj.StartDate > proposedObj.StopDate)
|
if (proposedObj.StartDate > proposedObj.StopDate)
|
||||||
AddError(ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE, "StartDate");
|
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?
|
//Any form customizations to validate?
|
||||||
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.PMItemScheduledUser.ToString());
|
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.PMItemScheduledUser.ToString());
|
||||||
|
|||||||
@@ -1657,18 +1657,9 @@ namespace AyaNova.Biz
|
|||||||
//does it have a valid quote id
|
//does it have a valid quote id
|
||||||
if (proposedObj.QuoteId == 0)
|
if (proposedObj.QuoteId == 0)
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "QuoteId");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "QuoteId");
|
||||||
else if (!await QuoteExistsAsync(proposedObj.QuoteId))
|
else if (!await QuoteExistsAsync(proposedObj.QuoteId))
|
||||||
{
|
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "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
|
//Check restricted role preventing create
|
||||||
if (isNew && UserIsRestrictedType)
|
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");
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Notes");
|
||||||
|
|
||||||
//Any form customizations to validate?
|
//Any form customizations to validate?
|
||||||
|
|||||||
@@ -1267,7 +1267,7 @@ namespace AyaNova.Biz
|
|||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
|
|
||||||
WorkOrder oProposed = (WorkOrder)proposedObj;
|
WorkOrder oProposed = (WorkOrder)proposedObj;
|
||||||
|
|
||||||
|
|
||||||
//STANDARD EVENTS FOR ALL OBJECTS
|
//STANDARD EVENTS FOR ALL OBJECTS
|
||||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);//Note: will properly handle all delete events and event removal if deleted
|
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)
|
if (proposedObj.WorkOrderId == 0)
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "WorkOrderId");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "WorkOrderId");
|
||||||
else if (!await WorkOrderExistsAsync(proposedObj.WorkOrderId))
|
else if (!await WorkOrderExistsAsync(proposedObj.WorkOrderId))
|
||||||
{
|
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "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
|
//Check restricted role preventing create
|
||||||
if (isNew && UserIsRestrictedType)
|
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");
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Notes");
|
||||||
|
|
||||||
//Any form customizations to validate?
|
//Any form customizations to validate?
|
||||||
@@ -4878,7 +4869,7 @@ namespace AyaNova.Biz
|
|||||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
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();
|
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.Tags = WorkorderInfo.Tags;
|
||||||
|
|
||||||
proposedObj.Name = WorkorderInfo.Serial.ToString();
|
proposedObj.Name = WorkorderInfo.Serial.ToString();
|
||||||
|
|
||||||
//STANDARD EVENTS FOR ALL OBJECTS
|
//STANDARD EVENTS FOR ALL OBJECTS
|
||||||
|
|||||||
Reference in New Issue
Block a user