This commit is contained in:
@@ -318,7 +318,7 @@ MULTIPLE discount / markup ITEMS
|
||||
|
||||
|
||||
//VALIDATE TAGGED ITEMS
|
||||
|
||||
//PARTS
|
||||
if (proposedObj.ContractPartOverrideItems.Count > 1)
|
||||
{
|
||||
List<string> allTags = new List<string>();
|
||||
@@ -350,7 +350,7 @@ MULTIPLE discount / markup ITEMS
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].OverrideType");
|
||||
}
|
||||
}
|
||||
|
||||
//SERVICE RATES
|
||||
if (proposedObj.ContractServiceRateOverrideItems.Count > 1)
|
||||
{
|
||||
List<string> allTags = new List<string>();
|
||||
@@ -377,12 +377,13 @@ MULTIPLE discount / markup ITEMS
|
||||
}
|
||||
}
|
||||
if (item.OverridePct == 0)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].OverridePct");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractServiceRateOverrideItems[{i}].OverridePct");
|
||||
if (item.OverrideType == ContractOverrideType.NotSet)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].OverrideType");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractServiceRateOverrideItems[{i}].OverrideType");
|
||||
}
|
||||
}
|
||||
|
||||
//TRAVEL RATES
|
||||
if (proposedObj.ContractTravelRateOverrideItems.Count > 1)
|
||||
{
|
||||
List<string> allTags = new List<string>();
|
||||
@@ -409,52 +410,37 @@ MULTIPLE discount / markup ITEMS
|
||||
}
|
||||
}
|
||||
if (item.OverridePct == 0)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].OverridePct");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractTravelRateOverrideItems[{i}].OverridePct");
|
||||
if (item.OverrideType == ContractOverrideType.NotSet)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].OverrideType");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractTravelRateOverrideItems[{i}].OverrideType");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//VALIDATE CONTRACT RATE / PART ITEMS
|
||||
//VALIDATE CONTRACT SERVICE AND TRAVEL RATE ITEMS
|
||||
|
||||
//Limit to list requires some to be set
|
||||
if (proposedObj.ServiceRateItems.Count == 0)
|
||||
{
|
||||
if (proposedObj.ContractServiceRatesOnly)
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, $"ContractRatesOnly");
|
||||
}
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ContractServiceRatesOnly");
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> allTags = new List<string>();
|
||||
//No duplicate rates
|
||||
//just filter them out rather than setting an error
|
||||
proposedObj.ServiceRateItems = proposedObj.ServiceRateItems.GroupBy(x => x.ServiceRateId).Select(y => y.First()).ToList();
|
||||
|
||||
for (int i = 0; i < proposedObj.ContractPartOverrideItems.Count; i++)
|
||||
{
|
||||
var item = proposedObj.ContractPartOverrideItems[i];
|
||||
if (item.Tags.Count < 1)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].Tags");
|
||||
else
|
||||
{
|
||||
//add to list, check for dupes
|
||||
foreach (string s in item.Tags)
|
||||
{
|
||||
if (allTags.Contains(s))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, $"ContractPartOverrideItems[{i}].Tags");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
allTags.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.OverridePct == 0)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].OverridePct");
|
||||
if (item.OverrideType == ContractOverrideType.NotSet)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"ContractPartOverrideItems[{i}].OverrideType");
|
||||
}
|
||||
|
||||
//Limit to list requires some to be set
|
||||
if (proposedObj.TravelRateItems.Count == 0)
|
||||
{
|
||||
if (proposedObj.ContractTravelRatesOnly)
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ContractTravelRatesOnly");
|
||||
}
|
||||
//No duplicate rates
|
||||
//just filter them out rather than setting an error
|
||||
proposedObj.TravelRateItems = proposedObj.TravelRateItems.GroupBy(x => x.TravelRateId).Select(y => y.First()).ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user