This commit is contained in:
@@ -398,8 +398,7 @@ namespace AyaNova.Biz
|
||||
//first set it to the customer one if available in case the ho one has expired then set the ho if applicable
|
||||
if (cust.contractId != null && cust.contractExpires > DateTime.UtcNow)
|
||||
newObj.ContractId = cust.contractId;
|
||||
|
||||
if (cust.contractId == null && cust.headofficeId != null)
|
||||
else if (cust.headofficeId != null)
|
||||
{
|
||||
var head = await ct.HeadOffice.AsNoTracking().Where(z => z.Id == cust.headofficeId).Select(z => new { contractId = z.ContractId, contractExpires = z.ContractExpires }).FirstOrDefaultAsync();
|
||||
if (head.contractId != null && head.contractExpires > DateTime.UtcNow)
|
||||
|
||||
@@ -570,7 +570,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
+ "webaddress TEXT, popupnotes TEXT, billheadoffice BOOL, technotes TEXT, accountnumber TEXT, usesbanking BOOL, contractexpires TIMESTAMP NULL, contractid BIGINT NULL REFERENCES acontract(id), "
|
||||
+ "phone1 TEXT, phone2 TEXT, phone3 TEXT, phone4 TEXT, phone5 TEXT, emailaddress TEXT, "
|
||||
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6), "
|
||||
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL AND contractexpires IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
|
||||
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
|
||||
+ ")");
|
||||
await ExecQueryAsync("ALTER TABLE auser ADD FOREIGN KEY (customerid) REFERENCES acustomer(id)");
|
||||
|
||||
@@ -607,7 +607,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
+ "webaddress TEXT, accountnumber TEXT, usesbanking BOOL, contractexpires TIMESTAMP NULL, contractid BIGINT NULL REFERENCES acontract(id), "
|
||||
+ "phone1 TEXT, phone2 TEXT, phone3 TEXT, phone4 TEXT, phone5 TEXT, emailaddress TEXT, "
|
||||
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6), "
|
||||
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL AND contractexpires IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
|
||||
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
|
||||
+ " )");
|
||||
await ExecQueryAsync("ALTER TABLE acustomer ADD column headofficeid BIGINT NULL REFERENCES aheadoffice");
|
||||
await ExecQueryAsync("ALTER TABLE auser ADD FOREIGN KEY (headofficeid) REFERENCES aheadoffice(id)");
|
||||
@@ -716,7 +716,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
+ "contractexpires TIMESTAMP NULL, 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(9,6) NULL, longitude DECIMAL(9,6) NULL, "
|
||||
+ "CONSTRAINT unq_unitserialmodelid UNIQUE (serial, unitmodelid), "
|
||||
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL AND contractexpires IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
|
||||
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
|
||||
+ " )");
|
||||
|
||||
//LOANUNIT
|
||||
|
||||
Reference in New Issue
Block a user