This commit is contained in:
@@ -225,18 +225,39 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//VALIDATION
|
||||
//
|
||||
|
||||
private async Task ValidateAsync(TaxCode proposedObj, TaxCode currentObj)
|
||||
{
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
bool isGlobalDefault = (!isNew
|
||||
&& ServerGlobalBizSettings.TaxPartPurchaseId == proposedObj.Id
|
||||
|| ServerGlobalBizSettings.TaxPartSaleId == proposedObj.Id
|
||||
|| ServerGlobalBizSettings.TaxRateSaleId == proposedObj.Id);
|
||||
|
||||
|
||||
if (!isNew
|
||||
&& proposedObj.Name != currentObj.Name
|
||||
|| proposedObj.TaxA != currentObj.TaxA
|
||||
|| proposedObj.TaxB != currentObj.TaxB
|
||||
|| proposedObj.TaxOnTax != currentObj.TaxOnTax)
|
||||
{
|
||||
//MIGRATE_OUTSTANDING - check workorder records once wo is coded here for this tax code in use
|
||||
|
||||
if (await ct.PurchaseOrderItem.AnyAsync(x => x.PurchaseTaxCodeId == proposedObj.Id))
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PurchaseOrder"));
|
||||
|
||||
if (isGlobalDefault)
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("AdministrationGlobalSettings"));
|
||||
}
|
||||
|
||||
//Active not changeable for global default
|
||||
if (isGlobalDefault && proposedObj.Active == false)
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Active", await Translate("TaxCodeDefault"));
|
||||
|
||||
//Name required
|
||||
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
||||
|
||||
|
||||
|
||||
//If name is otherwise OK, check that name is unique
|
||||
if (!PropertyHasErrors("Name"))
|
||||
{
|
||||
@@ -247,10 +268,6 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
//MIGRATE_OUTSTANDING - Biz rule needs porting
|
||||
//BrokenRules.Assert("DefaultMustBeActive", "TaxCode.Error.Default","Active",value==false && AyaBizUtils.GlobalSettings.TaxCodeIsADefault(this.mID));
|
||||
|
||||
|
||||
//Any form customizations to validate?
|
||||
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(x => x.FormKey == AyaType.TaxCode.ToString());
|
||||
if (FormCustomization != null)
|
||||
@@ -263,7 +280,6 @@ namespace AyaNova.Biz
|
||||
//validate custom fields
|
||||
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task ValidateCanDeleteAsync(TaxCode inObj)
|
||||
@@ -272,6 +288,11 @@ namespace AyaNova.Biz
|
||||
//FOREIGN KEY CHECKS
|
||||
if (await ct.PurchaseOrderItem.AnyAsync(m => m.PurchaseTaxCodeId == inObj.Id))
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PurchaseOrder"));
|
||||
|
||||
if (ServerGlobalBizSettings.TaxPartPurchaseId == inObj.Id
|
||||
|| ServerGlobalBizSettings.TaxPartSaleId == inObj.Id
|
||||
|| ServerGlobalBizSettings.TaxRateSaleId == inObj.Id)
|
||||
AddError(ApiErrorCode.INVALID_OPERATION, "generalerror", await Translate("TaxCodeDefault"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user