From 0ab5c61f0225921dff689084a355e336dfe0c001 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 5 Mar 2021 19:29:29 +0000 Subject: [PATCH] --- server/AyaNova/biz/ContractBiz.cs | 2 ++ server/AyaNova/biz/FormFieldReference.cs | 2 ++ server/AyaNova/models/Unit.cs | 1 + server/AyaNova/util/AySchema.cs | 6 +++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/AyaNova/biz/ContractBiz.cs b/server/AyaNova/biz/ContractBiz.cs index 8bbe9d9f..b2ffab9b 100644 --- a/server/AyaNova/biz/ContractBiz.cs +++ b/server/AyaNova/biz/ContractBiz.cs @@ -408,6 +408,8 @@ namespace AyaNova.Biz AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("Customer")); if (await ct.HeadOffice.AnyAsync(m => m.ContractId == inObj.Id)) AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("HeadOffice")); + if (await ct.Unit.AnyAsync(m => m.ContractId == inObj.Id)) + AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("Unit")); } diff --git a/server/AyaNova/biz/FormFieldReference.cs b/server/AyaNova/biz/FormFieldReference.cs index 54e7cfe3..64c4dcfd 100644 --- a/server/AyaNova/biz/FormFieldReference.cs +++ b/server/AyaNova/biz/FormFieldReference.cs @@ -682,6 +682,8 @@ namespace AyaNova.Biz l.Add(new FormField { TKey = "UnitModel", FieldKey = "UnitModelId" }); l.Add(new FormField { TKey = "UnitReplacedByUnitID", FieldKey = "ReplacedByUnitId" }); l.Add(new FormField { TKey = "UnitParentUnitID", FieldKey = "ParentUnitId" }); + l.Add(new FormField { TKey = "Contract", FieldKey = "ContractId" }); + l.Add(new FormField { TKey = "ContractExpires", FieldKey = "ContractExpires" }); l.Add(new FormField { TKey = "UsesBanking", FieldKey = "UsesBanking" }); l.Add(new FormField { TKey = "UnitMetered", FieldKey = "Metered" }); l.Add(new FormField { TKey = "UnitBoughtHere", FieldKey = "BoughtHere" }); diff --git a/server/AyaNova/models/Unit.cs b/server/AyaNova/models/Unit.cs index 67778dbf..00807cba 100644 --- a/server/AyaNova/models/Unit.cs +++ b/server/AyaNova/models/Unit.cs @@ -48,6 +48,7 @@ namespace AyaNova.Models public int? WarrantyLength { get; set; } public string WarrantyTerms { get; set; } public bool UsesBanking { get; set; } + public long? ContractId { get; set; } public bool Metered { get; set; } public bool LifeTimeWarranty { get; set; } public string Text1 { get; set; } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 99dc2c69..792d0405 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -22,9 +22,9 @@ namespace AyaNova.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! private const int DESIRED_SCHEMA_LEVEL = 15; - internal const long EXPECTED_COLUMN_COUNT = 785; + internal const long EXPECTED_COLUMN_COUNT = 786; internal const long EXPECTED_INDEX_COUNT = 130; - internal const long EXPECTED_CHECK_CONSTRAINTS = 356; + internal const long EXPECTED_CHECK_CONSTRAINTS = 357; internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 77; internal const long EXPECTED_VIEWS = 3; internal const long EXPECTED_ROUTINES = 2; @@ -798,7 +798,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); + "serial TEXT NOT NULL, customerid BIGINT NOT NULL REFERENCES acustomer(id), parentunitid BIGINT NULL REFERENCES aunit(id), " + "unitmodelid BIGINT NULL REFERENCES aunitmodel(id), unithasownaddress BOOL, boughthere BOOL, purchasedfromvendorid BIGINT NULL REFERENCES avendor(id), " + "receipt TEXT NULL, purchaseddate TIMESTAMP NULL, description TEXT NULL, replacedbyunitid BIGINT NULL REFERENCES aunit(id), " - + "overridemodelwarranty BOOL, warrantylength INTEGER NULL, warrantyterms TEXT NULL, usesbanking BOOL, metered BOOL, lifetimewarranty BOOL, " + + "overridemodelwarranty BOOL, warrantylength INTEGER NULL, warrantyterms TEXT NULL, contractid BIGINT NULL REFERENCES acontract, usesbanking BOOL, metered BOOL, lifetimewarranty BOOL, " + "text1 TEXT NULL, text2 TEXT NULL, text3 TEXT NULL, text4 TEXT NULL, address TEXT NULL, city TEXT NULL, region TEXT NULL, country TEXT NULL, latitude DECIMAL(8,6) NULL, longitude DECIMAL(9,6) NULL, " + "CONSTRAINT unq_unitserialmodelid UNIQUE (serial, unitmodelid) " + " )");