This commit is contained in:
2021-02-19 18:29:06 +00:00
parent b8a35b1eb2
commit 7a76b2e361
9 changed files with 56 additions and 20 deletions

View File

@@ -110,6 +110,9 @@ namespace AyaNova.Api.Controllers
//Actual global settings:
SearchCaseSensitiveOnly = AyaNova.Util.ServerGlobalBizSettings.SearchCaseSensitiveOnly,
UseInventory = AyaNova.Util.ServerGlobalBizSettings.UseInventory,
DefaultTaxPartSaleId = AyaNova.Util.ServerGlobalBizSettings.TaxPartSaleId,
DefaultTaxPartPurchaseId = AyaNova.Util.ServerGlobalBizSettings.TaxPartPurchaseId,
DefaultTaxRateSaleId = AyaNova.Util.ServerGlobalBizSettings.TaxRateSaleId,
//used to drive UI in case of unlicensed or attention required
LicenseStatus = AyaNova.Core.License.ActiveKey.Status,
MaintenanceExpired = AyaNova.Core.License.ActiveKey.MaintenanceExpired,

View File

@@ -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"));
}

View File

@@ -23,6 +23,11 @@ namespace AyaNova.Models
public bool SearchCaseSensitiveOnly { get; set; }
public bool UseInventory { get; set; }
//TAX CODE DEFAULTS
public long? TaxPartPurchaseId {get;set;}
public long? TaxPartSaleId {get;set;}
public long? TaxRateSaleId {get;set;}
public GlobalBizSettings()

View File

@@ -760,7 +760,7 @@
"PurchaseOrderReceiptItemPurchaseOrderReceiptID": "Einkaufsauftragseingang",
"PurchaseOrderReceiptItemQuantityReceived": "Empfangene Menge",
"PurchaseOrderReceiptItemQuantityReceivedErrorInvalid": "Der Eintrag muss gleich oder kleiner dem ausstehenden Betrag vom Einkaufsauftrag oder positiv sein",
"PurchaseOrderReceiptItemReceiptCost": "Ist-Kosten",
"PurchaseOrderReceiptItemReceiptCost": "Erhaltene Kosten",
"PurchaseOrderReceiptItemReferenceNumber": "Referenz",
"PurchaseOrderReceiptItemWarehouseID": "Teilelager",
"PurchaseOrderReceiptItemWorkOrderNumber": "Arbeitsauftragsnummer",

View File

@@ -760,7 +760,7 @@
"PurchaseOrderReceiptItemPurchaseOrderReceiptID": "Purchase Order Receipt",
"PurchaseOrderReceiptItemQuantityReceived": "Quantity Received",
"PurchaseOrderReceiptItemQuantityReceivedErrorInvalid": "Entry must be equal or less than outstanding amount from purchase order and non-negative",
"PurchaseOrderReceiptItemReceiptCost": "Actual Cost",
"PurchaseOrderReceiptItemReceiptCost": "Received Cost",
"PurchaseOrderReceiptItemReferenceNumber": "Reference",
"PurchaseOrderReceiptItemWarehouseID": "Part Warehouse",
"PurchaseOrderReceiptItemWorkOrderNumber": "WorkOrder #",

View File

@@ -759,7 +759,7 @@
"PurchaseOrderReceiptItemPurchaseOrderReceiptID": "Recibo orden de compra",
"PurchaseOrderReceiptItemQuantityReceived": "Cantidad recibida",
"PurchaseOrderReceiptItemQuantityReceivedErrorInvalid": "La entrada debe ser igual o inferior a la cantidad restante de la orden de compra y no negativa",
"PurchaseOrderReceiptItemReceiptCost": "Coste real",
"PurchaseOrderReceiptItemReceiptCost": "Costo recibido",
"PurchaseOrderReceiptItemReferenceNumber": "Referencia",
"PurchaseOrderReceiptItemWarehouseID": "Almacén de la pieza",
"PurchaseOrderReceiptItemWorkOrderNumber": "Núm. pedido",

View File

@@ -760,7 +760,7 @@
"PurchaseOrderReceiptItemPurchaseOrderReceiptID": "Reçu de bon de commande",
"PurchaseOrderReceiptItemQuantityReceived": "Quantité réceptionnée",
"PurchaseOrderReceiptItemQuantityReceivedErrorInvalid": "Cette entrée doit être positive et égale ou inférieure à l'encours du bon de commande",
"PurchaseOrderReceiptItemReceiptCost": "Coût réel",
"PurchaseOrderReceiptItemReceiptCost": "Coût reçu",
"PurchaseOrderReceiptItemReferenceNumber": "Référence",
"PurchaseOrderReceiptItemWarehouseID": "Magasin de pièces",
"PurchaseOrderReceiptItemWorkOrderNumber": "Bon de travail n° ",

View File

@@ -236,8 +236,11 @@ namespace AyaNova.Util
//create global biz settings table
await ExecQueryAsync("CREATE TABLE aglobalbizsettings (id INTEGER NOT NULL PRIMARY KEY, "
+ "searchcasesensitiveonly BOOL default false, "
+ "useinventory BOOL default true "
+ "searchcasesensitiveonly BOOL DEFAULT FALSE, "
+ "useinventory BOOL DEFAULT TRUE, "
+ "taxpartpurchaseid BIGINT, "
+ "taxpartsaleid BIGINT, "
+ "taxratesaleid BIGINT "
+ ")");
//create global ops BACKUP settings table

View File

@@ -1,7 +1,3 @@
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using AyaNova.Models;
@@ -18,9 +14,14 @@ namespace AyaNova.Util
{
internal static bool SearchCaseSensitiveOnly { get; set; }
internal static bool UseInventory {get;set;}
internal static bool UseInventory { get; set; }
//TAX CODE DEFAULTS
internal static long? TaxPartPurchaseId { get; set; }
internal static long? TaxPartSaleId { get; set; }
internal static long? TaxRateSaleId { get; set; }
/// <summary>
/// Populate and / or create the settings
@@ -43,6 +44,9 @@ namespace AyaNova.Util
//We have the object, now copy the static values here
SearchCaseSensitiveOnly = global.SearchCaseSensitiveOnly;
UseInventory = global.UseInventory;
TaxPartPurchaseId = global.TaxPartPurchaseId;
TaxPartSaleId = global.TaxPartSaleId;
TaxRateSaleId = global.TaxRateSaleId;
}