This commit is contained in:
2021-07-27 23:09:15 +00:00
parent 1bda0620c6
commit 4aa5ebb6fc
3 changed files with 177 additions and 30 deletions

View File

@@ -233,4 +233,4 @@ https://en.wikipedia.org/wiki/Non-functional_requirement
## ASCII ART
//http://www.patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=quote
//http://www.patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=PM

View File

@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using AyaNova.Biz;
namespace AyaNova.Models
{
//NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal,
//otherwise the server will call it an invalid record if the field isn't sent from client
public class PM : ICoreBizObjectModel
{
@@ -17,38 +15,99 @@ namespace AyaNova.Models
[Required]
public long Serial { get; set; }
public bool Active { get; set; }
public string Notes { get; set; }
public string Notes { get; set; }//WAS "SUMMARY"
public string Wiki { get; set; }
public string CustomFields { get; set; }
public List<string> Tags { get; set; }
public List<string> Tags { get; set; } = new List<string>();
//----
public DateTime? StopGeneratingDate { get; set; }
public bool[] ExcludeDaysOfWeek { get; set; }//Monday to Sunday (0-6 index)
public bool Active { get; set; }
public DateTime NextServiceDate { get; set; }
public TimeSpan Repeat { get; set; }//was generate span
public TimeSpan GenerateBefore { get; set; }//was threshold span
public DateTime? GenerateDate { get; set; }
//----
[Required]
public long CustomerId { get; set; }
[NotMapped]
public string CustomerViz { get; set; }
[NotMapped]
public string CustomerTechNotesViz { get; set; }
public long? ProjectId { get; set; }
[NotMapped]
public string ProjectViz { get; set; }
public string InternalReferenceNumber { get; set; }
public string CustomerReferenceNumber { get; set; }
public string CustomerContactName { get; set; }
public DateTime CreatedDate { get; set; } = DateTime.UtcNow;
public bool Onsite { get; set; }
public long? ContractId { get; set; }
[NotMapped]
public string ContractViz { get; set; }
//POSTAL ADDRESS / "BILLING ADDRESS"
public string PostAddress { get; set; }
public string PostCity { get; set; }
public string PostRegion { get; set; }
public string PostCountry { get; set; }
public string PostCode { get; set; }
//workaround for notification
[NotMapped, JsonIgnore]
public string Name { get; set; }
//PHYSICAL ADDRESS / "SERVICE ADDRESS"
public string Address { get; set; }
public string City { get; set; }
public string Region { get; set; }
public string Country { get; set; }
public decimal? Latitude { get; set; }
public decimal? Longitude { get; set; }
public List<PMItem> Items { get; set; } = new List<PMItem>();
/*
//UTILITY FIELDS
[NotMapped]
public bool IsLockedAtServer { get; set; } = false;//signal to client that it came from the server in a locked state
[NotMapped]
public string AlertViz { get; set; } = null;
todo: Consider adding latitude / longitude to wo, quote, pm objects
can copy over from the unit or customer or set themselves
and can always hide
means wo could be scheduled for ad-hoc locations and serviced that way, i.e. a truck parked on the side of the highway etc
*/
//dependents
public List<PMItem> PMItems { get; set; }
public PM()
{
Tags = new List<string>();
PMItems = new List<PMItem>();
}
[NotMapped]
public bool IsCompleteRecord { get; set; } = true;//indicates if some items were removed due to user role / type restrictions (i.e. woitems they are not scheduled on)
[NotMapped]
public bool UserIsRestrictedType { get; set; }
[NotMapped]
public bool UserIsTechRestricted { get; set; }
[NotMapped]
public bool UserIsSubContractorFull { get; set; }
[NotMapped]
public bool UserIsSubContractorRestricted { get; set; }
[NotMapped]
public bool UserCanViewPartCosts { get; set; }
[NotMapped]
public bool UserCanViewLaborOrTravelRateCosts { get; set; }
[NotMapped]
public bool UserCanViewLoanerCosts { get; set; }
[NotMapped, JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public AyaTypeId GenCopyAttachmentsFrom { get; set; }//INTERNAL, USED TO SIGNIFY ATTACHMENTS NEED TO BE COPIED ON SAVE
[NotMapped, JsonIgnore]
public AyaType AyaType { get => AyaType.PM; }
//workaround for notification
[NotMapped, JsonIgnore]
public string Name { get; set; }
}//eoc
}//eons
@@ -64,7 +123,7 @@ CREATE TABLE [dbo].[AWORKORDERPREVENTIVEMAINTENANCE](
[AMODIFIED] [datetime] NOT NULL,
[AWORKORDERSTATUSID] [uniqueidentifier] NULL,
[ASTOPGENERATINGDATE] [datetime] NULL,
[ADAYOFTHEWEEK] [smallint] NULL, <---- NO LONGER, now a collection of days of the week to NOT generate on, ISO8601 standard weekday number, from 1 through 7, beginning with Monday and ending with Sunday.
[ADAYOFTHEWEEK] [smallint] NULL, <---- NO LONGER, now a collection of days of the week to NOT generate on, ISO8601 standard weekday number, from 1 through 7, beginning with Monday and ending with Sunday. make it an array of bools 7 wide for Monday to Sunday
[AACTIVE] [bit] NOT NULL,
[APREVENTIVEMAINTENANCENUMBER] [int] IDENTITY(1,1) NOT NULL,
[ANEXTSERVICEDATE] [datetime] NOT NULL,

View File

@@ -1000,13 +1000,101 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
///////////////////////////////////////////////////////////////////////////////////////
//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, "
+ "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, "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, customerid BIGINT NOT NULL REFERENCES acustomer (id), "
+ "projectid BIGINT REFERENCES aproject, laststatusid BIGINT REFERENCES apmstatus(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, 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) "
+ ")");
//PMITEM
await ExecQueryAsync("CREATE TABLE apmitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmid BIGINT NOT NULL REFERENCES apm (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"
+ ")");
//PMITEM EXPENSE
await ExecQueryAsync("CREATE TABLE apmitemexpense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (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 "
+ ")");
//PMITEM LABOR
await ExecQueryAsync("CREATE TABLE apmitemlabor (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (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) "
+ ")");
//PMITEM LOAN
await ExecQueryAsync("CREATE TABLE apmitemloan (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (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"
+ ")");
//PMITEM PART
await ExecQueryAsync("CREATE TABLE apmitempart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (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) "
+ ")");
//PMITEM SCHEDULED USER
await ExecQueryAsync("CREATE TABLE apmitemscheduleduser (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (id), "
+ "userid BIGINT REFERENCES auser, startdate TIMESTAMP, stopdate TIMESTAMP, servicerateid BIGINT REFERENCES aservicerate, "
+ "estimatedquantity DECIMAL(19,5) NOT NULL default 0"
+ ")");
//PMITEM TASK
await ExecQueryAsync("CREATE TABLE apmitemtask (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (id), "
+ "sequence INTEGER NOT NULL DEFAULT 0, task text NOT NULL, status INTEGER NOT NULL DEFAULT 1, completedbyuserid BIGINT REFERENCES auser, completeddate TIMESTAMP"
+ ")");
//PMITEM TRAVEL
await ExecQueryAsync("CREATE TABLE apmitemtravel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (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) "
+ ")");
//PMITEM UNIT
await ExecQueryAsync("CREATE TABLE apmitemunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (id), "
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, unitid BIGINT NOT NULL REFERENCES aunit"
+ ")");
//PMITEM OUTSIDE SERVICE
await ExecQueryAsync("CREATE TABLE apmitemoutsideservice (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmitemid BIGINT NOT NULL REFERENCES apmitem (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"
+ ")");
//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, "