This commit is contained in:
@@ -53,6 +53,9 @@ namespace AyaNova.DataList
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string SqlColorColumnName { get; set; }//column to fetch the color if applicable to this field
|
public string SqlColorColumnName { get; set; }//column to fetch the color if applicable to this field
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string SqlColumnExpression { get; set; }//column is based on this expression, not directly on the source tables
|
||||||
|
|
||||||
public DataListFieldDefinition()
|
public DataListFieldDefinition()
|
||||||
{
|
{
|
||||||
//most common defaults
|
//most common defaults
|
||||||
@@ -65,6 +68,7 @@ namespace AyaNova.DataList
|
|||||||
AType = (int)AyaType.NoType;
|
AType = (int)AyaType.NoType;
|
||||||
SqlATypeColumnName = null;//must be null as that is checked against specifically
|
SqlATypeColumnName = null;//must be null as that is checked against specifically
|
||||||
SqlColorColumnName = null;//must be null to be ignored properly
|
SqlColorColumnName = null;//must be null to be ignored properly
|
||||||
|
SqlColumnExpression = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get column to query for display name or use FieldName if there is no difference
|
//Get column to query for display name or use FieldName if there is no difference
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ namespace AyaNova.DataList
|
|||||||
{
|
{
|
||||||
if (firstColumnAdded)
|
if (firstColumnAdded)
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
sb.Append(valueColumnName);
|
|
||||||
|
if (o.SqlColumnExpression != null)//if there is an expression defined then add it into the select statement, the valuecolumnname will be the AS alias of it
|
||||||
|
sb.Append(o.SqlColumnExpression);
|
||||||
|
else
|
||||||
|
sb.Append(valueColumnName);
|
||||||
firstColumnAdded = true;
|
firstColumnAdded = true;
|
||||||
map.Add(valueColumnName, nOrdinal++);
|
map.Add(valueColumnName, nOrdinal++);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ namespace AyaNova.DataList
|
|||||||
{
|
{
|
||||||
DefaultListAType = AyaType.WorkOrder;
|
DefaultListAType = AyaType.WorkOrder;
|
||||||
SQLFrom = "from aworkorder "
|
SQLFrom = "from aworkorder "
|
||||||
// + "left join lateral (select id, workorderstatusid, workorderid from aworkorderstate st where workorderid = aworkorder.id order by st.id DESC limit 1) st on aworkorder.id=st.workorderid "
|
|
||||||
+ "left join aworkorderstatus on (aworkorder.laststatusid = aworkorderstatus.id) "
|
+ "left join aworkorderstatus on (aworkorder.laststatusid = aworkorderstatus.id) "
|
||||||
+ "left join acustomer on (aworkorder.customerid=acustomer.id) "
|
+ "left join acustomer on (aworkorder.customerid=acustomer.id) "
|
||||||
+ "left join aheadoffice on (acustomer.headofficeid=aheadoffice.id) "
|
+ "left join aheadoffice on (acustomer.headofficeid=aheadoffice.id) "
|
||||||
@@ -19,7 +18,7 @@ namespace AyaNova.DataList
|
|||||||
+ "left join acontract on (aworkorder.contractid=acontract.id)";
|
+ "left join acontract on (aworkorder.contractid=acontract.id)";
|
||||||
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
||||||
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
||||||
DefaultColumns = new List<string>() { "WorkOrderSerialNumber", "Customer", "WorkOrderServiceDate", "WorkOrderCloseByDate", "WorkOrderStatus", "Project" };
|
DefaultColumns = new List<string>() { "WorkOrderSerialNumber", "Customer", "WorkOrderServiceDate", "WorkOrderCloseByDate", "WorkOrderStatus", "Project", "WorkOrderAge" };
|
||||||
DefaultSortBy = new Dictionary<string, string>() { { "WorkOrderSerialNumber", "-" } };
|
DefaultSortBy = new Dictionary<string, string>() { { "WorkOrderSerialNumber", "-" } };
|
||||||
FieldDefinitions = new List<DataListFieldDefinition>();
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
||||||
|
|
||||||
@@ -247,6 +246,15 @@ namespace AyaNova.DataList
|
|||||||
SqlValueColumnName = "aworkorder.longitude"
|
SqlValueColumnName = "aworkorder.longitude"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new DataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "WorkOrderAge",
|
||||||
|
FieldKey = "WorkOrderAge",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.TimeSpan,
|
||||||
|
SqlColumnExpression="AGE(timezone('UTC', now()), aworkorder.createddate) as expwoage",
|
||||||
|
SqlValueColumnName = "expwoage"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|||||||
@@ -416,14 +416,9 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
//CREATED OR MODIFIED
|
//CREATED OR MODIFIED
|
||||||
if(ayaEvent==AyaEvent.Created || ayaEvent==AyaEvent.Modified)
|
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||||
{
|
{
|
||||||
//Set duration to completed
|
|
||||||
//Clear it if set and not completed state
|
|
||||||
//or
|
|
||||||
//Set it if not set and completed state
|
|
||||||
|
|
||||||
todo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -448,6 +443,22 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
if (newObj.ContractId != oldObj.ContractId)
|
if (newObj.ContractId != oldObj.ContractId)
|
||||||
await AutoSetCloseByDateAsync(newObj);
|
await AutoSetCloseByDateAsync(newObj);
|
||||||
|
|
||||||
|
//Set duration to completed
|
||||||
|
//Note that it's not practical to set this in the Created path because the header is saved *before* the state from the client for new work orders
|
||||||
|
//by necessity so if a user creates and closes a work order in one go then duration will not be set (or at least it will remain at zero which is actually accurate)
|
||||||
|
//Clear it if set and not completed state
|
||||||
|
//or
|
||||||
|
//Set it if not set and completed state
|
||||||
|
WorkOrderStatus currentStatus = await GetCurrentWorkOrderStatusFromRelatedAsync(AyaType.WorkOrder, newObj.Id);
|
||||||
|
if (currentStatus.Completed && newObj.DurationToCompleted == TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
newObj.DurationToCompleted = DateTime.UtcNow - newObj.CreatedDate;
|
||||||
|
}
|
||||||
|
else if (newObj.DurationToCompleted != TimeSpan.Zero && !currentStatus.Completed)
|
||||||
|
{
|
||||||
|
newObj.DurationToCompleted = TimeSpan.Zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,10 +782,11 @@ namespace AyaNova.Biz
|
|||||||
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "generalerror", await Translate("WorkOrderErrorLocked"));
|
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "generalerror", await Translate("WorkOrderErrorLocked"));
|
||||||
return;//this is a completely disqualifying error
|
return;//this is a completely disqualifying error
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
todo: workorder status list first, it's a table of created items, keep properties from v7 but add the following properties:
|
todo: workorder status list first, it's a table of created items, keep properties from v7 but add the following properties:
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace AyaNova.Models
|
|||||||
public long? FromQuoteId { get; set; }
|
public long? FromQuoteId { get; set; }
|
||||||
public long? FromPMId { get; set; }
|
public long? FromPMId { get; set; }
|
||||||
public long? FromCSRId { get; set; }
|
public long? FromCSRId { get; set; }
|
||||||
|
public DateTime CreatedDate { get; set; } = DateTime.UtcNow;
|
||||||
public DateTime? ServiceDate { get; set; }
|
public DateTime? ServiceDate { get; set; }
|
||||||
public DateTime? CompleteByDate { get; set; }
|
public DateTime? CompleteByDate { get; set; }
|
||||||
public TimeSpan DurationToCompleted { get; set; } = TimeSpan.Zero;
|
public TimeSpan DurationToCompleted { get; set; } = TimeSpan.Zero;
|
||||||
@@ -119,6 +120,8 @@ namespace AyaNova.Models
|
|||||||
//workaround for notification
|
//workaround for notification
|
||||||
[NotMapped, JsonIgnore]
|
[NotMapped, JsonIgnore]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
}//eons
|
}//eons
|
||||||
|
|||||||
@@ -22,16 +22,16 @@ namespace AyaNova.Util
|
|||||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||||
private const int DESIRED_SCHEMA_LEVEL = 1;
|
private const int DESIRED_SCHEMA_LEVEL = 1;
|
||||||
|
|
||||||
internal const long EXPECTED_COLUMN_COUNT = 962;
|
internal const long EXPECTED_COLUMN_COUNT = 963;
|
||||||
internal const long EXPECTED_INDEX_COUNT = 138;
|
internal const long EXPECTED_INDEX_COUNT = 138;
|
||||||
internal const long EXPECTED_CHECK_CONSTRAINTS = 415;
|
internal const long EXPECTED_CHECK_CONSTRAINTS = 416;
|
||||||
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 118;
|
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 118;
|
||||||
internal const long EXPECTED_VIEWS = 6;
|
internal const long EXPECTED_VIEWS = 6;
|
||||||
internal const long EXPECTED_ROUTINES = 2;
|
internal const long EXPECTED_ROUTINES = 2;
|
||||||
|
|
||||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////// (C961:I137:CC415:FC118:V6:R2)
|
///////////////////////////////////////////////////////////////// C963:I138:CC416:FC118:V6:R2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -776,7 +776,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
//WORKORDER
|
//WORKORDER
|
||||||
await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, "
|
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), "
|
+ "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, "
|
+ "projectid BIGINT REFERENCES aproject, laststatusid BIGINT REFERENCES aworkorderstatus(id), contractid BIGINT NULL, internalreferencenumber text, "
|
||||||
|
+" customerreferencenumber text, customercontactname text, createddate TIMESTAMP NOT NULL, "
|
||||||
+ "servicedate TIMESTAMP, completebydate TIMESTAMP, invoicenumber TEXT, customersignature TEXT, customersignaturename TEXT, customersignaturecaptured TIMESTAMP, "
|
+ "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, "
|
+ "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) "
|
+ "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) "
|
||||||
|
|||||||
Reference in New Issue
Block a user