This commit is contained in:
2021-07-23 23:31:43 +00:00
parent b7e06c1b13
commit 2756b2578e
13 changed files with 7631 additions and 373 deletions

View File

@@ -777,7 +777,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, customerid BIGINT NOT NULL REFERENCES acustomer (id), "
+ "projectid BIGINT REFERENCES aproject, laststatusid BIGINT REFERENCES aworkorderstatus(id), contractid BIGINT NULL, internalreferencenumber text, "
+" customerreferencenumber text, customercontactname text, createddate TIMESTAMP NOT NULL, "
+ " customerreferencenumber text, customercontactname text, createddate TIMESTAMP NOT NULL, "
+ "servicedate TIMESTAMP, completebydate TIMESTAMP, invoicenumber TEXT, customersignature TEXT, customersignaturename TEXT, customersignaturecaptured TIMESTAMP, "
+ "techsignature TEXT, techsignaturename TEXT, techsignaturecaptured TIMESTAMP, durationtocompleted INTERVAL NOT NULL, onsite BOOL NOT NULL, "
+ "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) "
@@ -891,12 +891,12 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
+ "left outer join vpartsonorder on (vpartinventorynow.partid = vpartsonorder.partid and vpartinventorynow.partwarehouseid = vpartsonorder.partwarehouseid)");
//VIEWWORKORDER - adds AGE expression column for datalist queries
//VIEWWORKORDER - adds AGE expression column for datalist queries
await ExecQueryAsync("CREATE VIEW viewworkorder AS select aworkorder.*, AGE(timezone('UTC', now()), aworkorder.createddate) as expwoage from aworkorder");
//----------
/*
██████╗ ██╗ ██╗ ██████╗ ████████╗███████╗
@@ -905,19 +905,88 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
██║▄▄ ██║██║ ██║██║ ██║ ██║ ██╔══╝
╚██████╔╝╚██████╔╝╚██████╔╝ ██║ ███████╗
╚══▀▀═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
*/
*/
//QUOTE
await ExecQueryAsync("CREATE TABLE aquote (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, customerid BIGINT NOT NULL REFERENCES acustomer (id), "
+ "projectid BIGINT REFERENCES aproject, laststatusid BIGINT REFERENCES aquotestatus(id), contractid BIGINT NULL, internalreferencenumber text, "
+ "customerreferencenumber text, customercontactname text, createddate TIMESTAMP NOT NULL, "
+ "preparedbyid BIGINT REFERENCES auser(id), introduction TEXT, requested TIMESTAMP, validuntil TIMESTAMP, submitted TIMESTAMP, approved TIMESTAMP, "
+ "copywiki BOOL NOT NULL, copyattachments BOOL NOT NULL, onsite BOOL NOT NULL, "
+ "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) "
+ ")");
await ExecQueryAsync("CREATE TABLE aquotestate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteid BIGINT NOT NULL REFERENCES aquote (id), "
+ "quotestatusid BIGINT NOT NULL REFERENCES aquotestatus (id), created TIMESTAMP NOT NULL, userid BIGINT NOT NULL REFERENCES auser (id)"
+ ")");
//QUOTEITEM
await ExecQueryAsync("CREATE TABLE aquoteitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteid BIGINT NOT NULL REFERENCES aquote (id), "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, technotes TEXT, workorderitemstatusid BIGINT REFERENCES aworkorderitemstatus (id), "
+ " workorderitempriorityid BIGINT REFERENCES aworkorderitempriority (id), requestdate TIMESTAMP, warrantyservice BOOL NOT NULL, sequence INTEGER"
+ ")");
//QUOTEITEM EXPENSE
await ExecQueryAsync("CREATE TABLE aquoteitemexpense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "description TEXT, name TEXT, totalcost DECIMAL(38,18) NOT NULL default 0, chargeamount DECIMAL(38,18) NOT NULL default 0, taxpaid DECIMAL(38,18) NOT NULL default 0, "
+ "chargetaxcodeid BIGINT REFERENCES ataxcode, reimburseuser BOOL NOT NULL, userid BIGINT REFERENCES auser, chargetocustomer BOOL NOT NULL "
+ ")");
//QUOTEITEM LABOR
await ExecQueryAsync("CREATE TABLE aquoteitemlabor (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "userid BIGINT REFERENCES auser, servicestartdate TIMESTAMP, servicestopdate TIMESTAMP, servicerateid BIGINT REFERENCES aservicerate, servicedetails text, "
+ "serviceratequantity DECIMAL(19,5) NOT NULL default 0, nochargequantity DECIMAL(19,5) NOT NULL default 0, "
+ "taxcodesaleid BIGINT REFERENCES ataxcode, priceoverride DECIMAL(38,18) "
+ ")");
//QUOTEITEM LOAN
await ExecQueryAsync("CREATE TABLE aquoteitemloan (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "notes TEXT, outdate TIMESTAMP, duedate TIMESTAMP, returndate TIMESTAMP,cost DECIMAL(38,18) NOT NULL default 0, listprice DECIMAL(38,18) NOT NULL default 0, priceoverride DECIMAL(38,18), "
+ "taxcodeid BIGINT REFERENCES ataxcode, loanunitid BIGINT NOT NULL REFERENCES aloanunit, quantity DECIMAL(19,5) NOT NULL default 0, rate INTEGER NOT NULL"
+ ")");
//QUOTEITEM PART
await ExecQueryAsync("CREATE TABLE aquoteitempart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "description TEXT, serials TEXT, partid BIGINT NOT NULL REFERENCES apart, partwarehouseid BIGINT NOT NULL REFERENCES apartwarehouse, quantity DECIMAL(19,5) NOT NULL default 0, "
+ "cost DECIMAL(38,18) NOT NULL default 0, listprice DECIMAL(38,18) NOT NULL default 0, taxpartsaleid BIGINT REFERENCES ataxcode, priceoverride DECIMAL(38,18) "
+ ")");
//QUOTEITEM SCHEDULED USER
await ExecQueryAsync("CREATE TABLE aquoteitemscheduleduser (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "userid BIGINT REFERENCES auser, startdate TIMESTAMP, stopdate TIMESTAMP, servicerateid BIGINT REFERENCES aservicerate, "
+ "estimatedquantity DECIMAL(19,5) NOT NULL default 0"
+ ")");
//QUOTEITEM TASK
await ExecQueryAsync("CREATE TABLE aquoteitemtask (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "sequence INTEGER NOT NULL DEFAULT 0, task text NOT NULL, status INTEGER NOT NULL DEFAULT 1, completedbyuserid BIGINT REFERENCES auser, completeddate TIMESTAMP"
+ ")");
//QUOTEITEM TRAVEL
await ExecQueryAsync("CREATE TABLE aquoteitemtravel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "userid BIGINT REFERENCES auser, travelstartdate TIMESTAMP, travelstopdate TIMESTAMP, travelrateid BIGINT REFERENCES atravelrate, traveldetails text, "
+ "travelratequantity DECIMAL(19,5) NOT NULL default 0, nochargequantity DECIMAL(19,5) NOT NULL default 0, "
+ "taxcodesaleid BIGINT REFERENCES ataxcode, distance DECIMAL(19,5) NOT NULL default 0, priceoverride DECIMAL(38,18) "
+ ")");
//QUOTEITEM UNIT
await ExecQueryAsync("CREATE TABLE aquoteitemunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, unitid BIGINT NOT NULL REFERENCES aunit"
+ ")");
//QUOTEITEM OUTSIDE SERVICE
await ExecQueryAsync("CREATE TABLE aquoteitemoutsideservice (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteitemid BIGINT NOT NULL REFERENCES aquoteitem (id), "
+ "notes TEXT, unitid BIGINT NOT NULL REFERENCES aunit, vendorsenttoid BIGINT REFERENCES avendor, vendorsentviaid BIGINT REFERENCES avendor, rmanumber text, trackingnumber text, "
+ "taxcodeid BIGINT REFERENCES ataxcode, repaircost DECIMAL(38,18) NOT NULL default 0, repairprice DECIMAL(38,18) NOT NULL default 0, shippingcost DECIMAL(38,18) NOT NULL default 0, shippingprice DECIMAL(38,18) NOT NULL default 0, "
+ "SentDate TIMESTAMP, etadate TIMESTAMP, returndate TIMESTAMP"
+ ")");
// //QUOTE
// await ExecQueryAsync("CREATE TABLE aquote (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, active BOOL NOT NULL, "
// + "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY )");
// //QUOTEITEM
// await ExecQueryAsync("CREATE TABLE aquoteitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteid BIGINT NOT NULL REFERENCES aquote (id), name TEXT NOT NULL UNIQUE, active BOOL NOT NULL, "
// + "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY )");
///////////////////////////////////////////////////////////////////////////////////////
//PM
await ExecQueryAsync("CREATE TABLE apm (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, active BOOL NOT NULL, "
@@ -926,7 +995,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//PMITEM
await ExecQueryAsync("CREATE TABLE apmitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmid BIGINT NOT NULL REFERENCES apm (id), name TEXT NOT NULL UNIQUE, active BOOL NOT NULL, "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY )");
//CUSTOMERSERVICEREQUEST
await ExecQueryAsync("CREATE TABLE acustomerservicerequest (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, "

View File

@@ -361,8 +361,6 @@ namespace AyaNova.Util
await EraseTableAsync("aworkorderitem", conn);
await EraseTableAsync("aworkorderstate", conn);
await EraseTableAsync("aworkorder", conn);
await EraseTableAsync("aworkordertemplateitem", conn);
await EraseTableAsync("aworkordertemplate", conn);
//---
@@ -387,16 +385,31 @@ namespace AyaNova.Util
await EraseTableAsync("apartassembly", conn);
await EraseTableAsync("apartinventory", conn);
await EraseTableAsync("apart", conn);
//--- QUOTE
await EraseTableAsync("aquoteitemexpense", conn);
await EraseTableAsync("aquoteitemlabor", conn);
await EraseTableAsync("aquoteitemloan", conn);
await EraseTableAsync("aquoteitempart", conn);
await EraseTableAsync("aquoteitemscheduleduser", conn);
await EraseTableAsync("aquoteitemtask", conn);
await EraseTableAsync("aquoteitemtravel", conn);
await EraseTableAsync("aquoteitemunit", conn);
await EraseTableAsync("aquoteitemoutsideservice", conn);
await EraseTableAsync("aquoteitem", conn);
await EraseTableAsync("aquotestate", conn);
await EraseTableAsync("aquote", conn);
//---
await EraseTableAsync("apmitem", conn);
await EraseTableAsync("apm", conn);
await EraseTableAsync("apmtemplateitem", conn);
await EraseTableAsync("apmtemplate", conn);
await EraseTableAsync("aquoteitem", conn);
await EraseTableAsync("aquote", conn);
await EraseTableAsync("aquotetemplateitem", conn);
await EraseTableAsync("aquotetemplate", conn);
await EraseTableAsync("aunitmodel", conn);
await EraseTableAsync("avendor", conn);
@@ -433,12 +446,12 @@ namespace AyaNova.Util
//after cleanup
using (var cmd = new Npgsql.NpgsqlCommand())
{
{
cmd.Connection = conn;
cmd.CommandText = "delete from \"auseroptions\" where UserId <> 1;";
await cmd.ExecuteNonQueryAsync();
cmd.CommandText = "ALTER SEQUENCE auseroptions_id_seq RESTART WITH 2;";
await cmd.ExecuteNonQueryAsync();
await cmd.ExecuteNonQueryAsync();
cmd.CommandText = "delete from \"auser\" where id <> 1;";
await cmd.ExecuteNonQueryAsync();
cmd.CommandText = "ALTER SEQUENCE auser_id_seq RESTART WITH 2;";
@@ -460,8 +473,8 @@ namespace AyaNova.Util
cmd.CommandText = "ALTER SEQUENCE apm_serial_seq RESTART WITH 1;";
await cmd.ExecuteNonQueryAsync();
}