This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -141,8 +141,24 @@ namespace AyaNova.Api.Controllers
|
||||
case AyaType.WorkOrderItemTravel:
|
||||
case AyaType.WorkOrderItemOutsideService:
|
||||
case AyaType.WorkOrderItemUnit:
|
||||
AyaTypeId TypeId = new AyaTypeId(AyaType.WorkOrder, (await WorkOrderBiz.GetWorkOrderIdFromRelativeAsync(ayaType, id, ct)).WorkOrderId);
|
||||
return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ATypeAsInt, Id = TypeId.ObjectId }));
|
||||
{
|
||||
AyaTypeId TypeId = new AyaTypeId(AyaType.WorkOrder, (await WorkOrderBiz.GetWorkOrderIdFromRelativeAsync(ayaType, id, ct)).ParentId);
|
||||
return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ATypeAsInt, Id = TypeId.ObjectId }));
|
||||
}
|
||||
case AyaType.QuoteItem:
|
||||
case AyaType.QuoteItemExpense:
|
||||
case AyaType.QuoteItemLabor:
|
||||
case AyaType.QuoteItemLoan:
|
||||
case AyaType.QuoteItemPart:
|
||||
case AyaType.QuoteItemScheduledUser:
|
||||
case AyaType.QuoteItemTask:
|
||||
case AyaType.QuoteItemTravel:
|
||||
case AyaType.QuoteItemOutsideService:
|
||||
case AyaType.QuoteItemUnit:
|
||||
{
|
||||
AyaTypeId TypeId = new AyaTypeId(AyaType.Quote, (await QuoteBiz.GetQuoteIdFromRelativeAsync(ayaType, id, ct)).ParentId);
|
||||
return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ATypeAsInt, Id = TypeId.ObjectId }));
|
||||
}
|
||||
default:
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Only types with ancestors are valid"));
|
||||
|
||||
|
||||
@@ -38,11 +38,7 @@ namespace AyaNova.Api.Controllers
|
||||
serverState = apiServerState;
|
||||
}
|
||||
|
||||
//todo: finish this off, it's missing some shit, and also check it's modernized
|
||||
//will also likely need a seperate fetch route for just the header and just an item
|
||||
//prefer named routes for each rather than some kind of parameter for existing routes, i.e. get{id} for whole graph and get headeronly/{id}
|
||||
|
||||
//STATES OUTSIDE SERVICE
|
||||
|
||||
|
||||
/*
|
||||
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗
|
||||
|
||||
359
server/AyaNova/DataList/QuoteDataList.cs
Normal file
359
server/AyaNova/DataList/QuoteDataList.cs
Normal file
@@ -0,0 +1,359 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AyaNova.Biz;
|
||||
using AyaNova.Models;
|
||||
|
||||
namespace AyaNova.DataList
|
||||
{
|
||||
internal class QuoteDataList : DataListProcessingBase, IDataListInternalCriteria
|
||||
{
|
||||
public QuoteDataList()
|
||||
{
|
||||
DefaultListAType = AyaType.Quote;
|
||||
SQLFrom = "from aquote "
|
||||
+ "left join aquotestatus on (aquote.laststatusid = aquotestatus.id) "
|
||||
+ "left join acustomer on (aquote.customerid=acustomer.id) "
|
||||
+ "left join aheadoffice on (acustomer.headofficeid=aheadoffice.id) "
|
||||
+ "left join aproject on (aquote.projectid=aproject.id) "
|
||||
+ "left join acontract on (aquote.contractid=acontract.id)";
|
||||
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
||||
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
||||
DefaultColumns = new List<string>() { "QuoteSerialNumber", "Customer", "QuoteStatus", "Project" };
|
||||
DefaultSortBy = new Dictionary<string, string>() { { "QuoteSerialNumber", "-" } };
|
||||
FieldDefinitions = new List<DataListFieldDefinition>();
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "QuoteSerialNumber",
|
||||
FieldKey = "QuoteSerialNumber",
|
||||
AType = (int)AyaType.Quote,
|
||||
UiFieldDataType = (int)UiFieldDataType.Integer,
|
||||
SqlIdColumnName = "aquote.id",
|
||||
SqlValueColumnName = "aquote.serial",
|
||||
IsRowId = true
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
FieldKey = "Customer",
|
||||
TKey = "Customer",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
AType = (int)AyaType.Customer,
|
||||
SqlIdColumnName = "acustomer.id",
|
||||
SqlValueColumnName = "acustomer.name"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "HeadOffice",
|
||||
FieldKey = "quoteheadoffice",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
AType = (int)AyaType.HeadOffice,
|
||||
SqlIdColumnName = "aheadoffice.id",
|
||||
SqlValueColumnName = "aheadoffice.name"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "QuoteStatus",
|
||||
FieldKey = "QuoteStatus",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
AType = (int)AyaType.QuoteStatus,
|
||||
SqlIdColumnName = "aquote.laststatusid",
|
||||
SqlColorColumnName = "aquotestatus.color",
|
||||
SqlValueColumnName = "aquotestatus.name"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "QuoteSummary",
|
||||
FieldKey = "quotenotes",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.notes"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "Tags",
|
||||
FieldKey = "quotetags",
|
||||
UiFieldDataType = (int)UiFieldDataType.Tags,
|
||||
SqlValueColumnName = "aquote.tags"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
FieldKey = "Project",
|
||||
TKey = "Project",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
AType = (int)AyaType.Project,
|
||||
SqlIdColumnName = "aproject.id",
|
||||
SqlValueColumnName = "aproject.name"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "Contract",
|
||||
FieldKey = "Contract",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
AType = (int)AyaType.Contract,
|
||||
SqlIdColumnName = "acontract.id",
|
||||
SqlValueColumnName = "acontract.name"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "QuoteInternalReferenceNumber",
|
||||
FieldKey = "QuoteInternalReferenceNumber",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.internalreferencenumber"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "QuoteCustomerReferenceNumber",
|
||||
FieldKey = "QuoteCustomerReferenceNumber",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.customerreferencenumber"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "QuoteCustomerContactName",
|
||||
FieldKey = "QuoteCustomerContactName",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.customercontactname"
|
||||
});
|
||||
|
||||
// FieldDefinitions.Add(new DataListFieldDefinition
|
||||
// {
|
||||
// TKey = "QuoteServiceDate",
|
||||
// FieldKey = "QuoteServiceDate",
|
||||
// UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||
// SqlValueColumnName = "aquote.servicedate"
|
||||
// });
|
||||
|
||||
// FieldDefinitions.Add(new DataListFieldDefinition
|
||||
// {
|
||||
// TKey = "QuoteCloseByDate",
|
||||
// FieldKey = "QuoteCloseByDate",
|
||||
// UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||
// SqlValueColumnName = "aquote.completebydate"
|
||||
// });
|
||||
|
||||
// FieldDefinitions.Add(new DataListFieldDefinition
|
||||
// {
|
||||
// TKey = "QuoteInvoiceNumber",
|
||||
// FieldKey = "QuoteInvoiceNumber",
|
||||
// UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
// SqlValueColumnName = "aquote.invoicenumber"
|
||||
// });
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "QuoteOnsite",
|
||||
FieldKey = "QuoteOnsite",
|
||||
UiFieldDataType = (int)UiFieldDataType.Bool,
|
||||
SqlValueColumnName = "aquote.onsite"
|
||||
});
|
||||
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressPostalDeliveryAddress",
|
||||
FieldKey = "quotepostaddress",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.postaddress"
|
||||
});
|
||||
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressPostalCity",
|
||||
FieldKey = "quotepostcity",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.postcity"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressPostalStateProv",
|
||||
FieldKey = "quotepostregion",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.postregion"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressPostalCountry",
|
||||
FieldKey = "quotepostcountry",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.postcountry"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressPostalPostal",
|
||||
FieldKey = "quotepostcode",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.postcode"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressDeliveryAddress",
|
||||
FieldKey = "quoteaddress",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.address"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressCity",
|
||||
FieldKey = "quotecity",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.city"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressStateProv",
|
||||
FieldKey = "quoteregion",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.region"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressCountry",
|
||||
FieldKey = "quotecountry",
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlValueColumnName = "aquote.country"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressLatitude",
|
||||
FieldKey = "quotelatitude",
|
||||
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
||||
SqlValueColumnName = "aquote.latitude"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "AddressLongitude",
|
||||
FieldKey = "quotelongitude",
|
||||
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
||||
SqlValueColumnName = "aquote.longitude"
|
||||
});
|
||||
|
||||
|
||||
// FieldDefinitions.Add(new DataListFieldDefinition
|
||||
// {
|
||||
// TKey = "QuoteCloseByDate",
|
||||
// FieldKey = "QuoteCloseByDate",
|
||||
// UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||
// SqlValueColumnName = "aquote.closebydate"
|
||||
// });
|
||||
|
||||
|
||||
// FieldDefinitions.Add(new DataListFieldDefinition
|
||||
// {
|
||||
// TKey = "QuoteAge",
|
||||
// FieldKey = "QuoteAge",
|
||||
// UiFieldDataType = (int)UiFieldDataType.TimeSpan,
|
||||
// SqlValueColumnName = "expwoage"
|
||||
// });
|
||||
|
||||
// FieldDefinitions.Add(new DataListFieldDefinition
|
||||
// {
|
||||
// TKey = "TimeToCompletion",
|
||||
// FieldKey = "TimeToCompletion",
|
||||
// UiFieldDataType = (int)UiFieldDataType.TimeSpan,
|
||||
// SqlValueColumnName = "durationtocompleted"
|
||||
// });
|
||||
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom1", FieldKey = "quotecustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom2", FieldKey = "quotecustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom3", FieldKey = "quotecustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom4", FieldKey = "quotecustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom5", FieldKey = "quotecustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom6", FieldKey = "quotecustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom7", FieldKey = "quotecustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom8", FieldKey = "quotecustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom9", FieldKey = "quotecustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom10", FieldKey = "quotecustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom11", FieldKey = "quotecustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom12", FieldKey = "quotecustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom13", FieldKey = "quotecustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom14", FieldKey = "quotecustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom15", FieldKey = "quotecustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom16", FieldKey = "quotecustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
||||
|
||||
|
||||
//META COLUMNS
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
FieldKey = "metacustomer",
|
||||
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
||||
SqlIdColumnName = "acustomer.id",
|
||||
SqlValueColumnName = "acustomer.id",
|
||||
IsMeta = true
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
FieldKey = "metaproject",
|
||||
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
||||
SqlIdColumnName = "aproject.id",
|
||||
SqlValueColumnName = "aproject.id",
|
||||
IsMeta = true
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
||||
{
|
||||
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
||||
|
||||
//ClientCriteria format for this list is "OBJECTID,AYATYPE"
|
||||
var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray();
|
||||
if (crit.Length > 1)
|
||||
{
|
||||
//will be filtered from different types, show all quotes from Customer, Project and nothing else at this time (others but for sub lists like quoteitemunits etc)
|
||||
int nType = 0;
|
||||
if (!int.TryParse(crit[1], out nType)) return ret;
|
||||
AyaType forType = (AyaType)nType;
|
||||
if (forType != AyaType.Customer && forType != AyaType.Project) return ret;//only supports customer and project for now
|
||||
|
||||
long lId = 0;
|
||||
if (!long.TryParse(crit[0], out lId)) return ret;
|
||||
if (lId == 0) return ret;
|
||||
|
||||
//Have valid type, have an id, so filter away
|
||||
switch (forType)
|
||||
{
|
||||
case AyaType.Customer:
|
||||
{
|
||||
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" };
|
||||
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
||||
ret.Add(FilterOption);
|
||||
}
|
||||
break;
|
||||
case AyaType.Project:
|
||||
{
|
||||
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metaproject" };
|
||||
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
||||
ret.Add(FilterOption);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}//eoc
|
||||
}//eons
|
||||
@@ -64,15 +64,14 @@ namespace AyaNova.Biz
|
||||
|
||||
case AyaType.PM:
|
||||
return new PMBiz(ct, userId, translationId, roles);
|
||||
|
||||
|
||||
case AyaType.Project:
|
||||
return new ProjectBiz(ct, userId, translationId, roles);
|
||||
case AyaType.PurchaseOrder:
|
||||
return new PurchaseOrderBiz(ct, userId, translationId, roles);
|
||||
case AyaType.Quote:
|
||||
return new QuoteBiz(ct, userId, translationId, roles);
|
||||
|
||||
|
||||
|
||||
|
||||
case AyaType.Unit:
|
||||
return new UnitBiz(ct, userId, translationId, roles);
|
||||
case AyaType.UnitModel:
|
||||
@@ -93,8 +92,24 @@ namespace AyaNova.Biz
|
||||
case AyaType.WorkOrderItemUnit:
|
||||
case AyaType.WorkOrderItemOutsideService:
|
||||
return new WorkOrderBiz(ct, userId, translationId, roles, UserType.NotService);//default to not service for now arbitrarily on the principle of least access
|
||||
//---
|
||||
|
||||
|
||||
//--- Quote
|
||||
case AyaType.Quote:
|
||||
case AyaType.QuoteItem:
|
||||
case AyaType.QuoteItemExpense:
|
||||
case AyaType.QuoteItemLabor:
|
||||
case AyaType.QuoteItemLoan:
|
||||
case AyaType.QuoteItemPart:
|
||||
case AyaType.QuoteItemScheduledUser:
|
||||
case AyaType.QuoteItemTask:
|
||||
case AyaType.QuoteItemTravel:
|
||||
case AyaType.QuoteItemUnit:
|
||||
case AyaType.QuoteItemOutsideService:
|
||||
return new QuoteBiz(ct, userId, translationId, roles, UserType.NotService);//default to not service for now arbitrarily on the principle of least access
|
||||
//---
|
||||
|
||||
|
||||
case AyaType.Reminder:
|
||||
return new ReminderBiz(ct, userId, translationId, roles);
|
||||
case AyaType.Review:
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace AyaNova.Biz
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//Project
|
||||
@@ -382,7 +382,7 @@ namespace AyaNova.Biz
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//Unit
|
||||
//
|
||||
@@ -561,6 +561,31 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//Quote
|
||||
//
|
||||
|
||||
var quoteBizRoleSet = new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Sales | AuthorizationRoles.Accounting,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.SalesRestricted,
|
||||
Select = AuthorizationRoles.All
|
||||
};
|
||||
roles.Add(AyaType.Quote, quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItem, quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemExpense,quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemLabor,quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemLoan, quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemPart,quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemScheduledUser, quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemTask, quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemTravel, quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemUnit, quoteBizRoleSet);
|
||||
roles.Add(AyaType.QuoteItemOutsideService,quoteBizRoleSet);
|
||||
//---
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//GLOBAL BIZ SETTINGS
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -563,15 +563,15 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GET WORKORDER ID FROM DESCENDANT TYPE AND ID
|
||||
//
|
||||
internal static async Task<WorkorderAndItemId> GetWorkOrderIdFromRelativeAsync(AyaType ayaType, long id, AyContext ct)
|
||||
internal static async Task<ParentAndChildItemId> GetWorkOrderIdFromRelativeAsync(AyaType ayaType, long id, AyContext ct)
|
||||
{
|
||||
WorkorderAndItemId w = new WorkorderAndItemId();
|
||||
ParentAndChildItemId w = new ParentAndChildItemId();
|
||||
long woitemid = 0;
|
||||
switch (ayaType)
|
||||
{
|
||||
case AyaType.WorkOrder:
|
||||
w.WorkOrderId = id;
|
||||
w.WorkOrderItemId = 0;
|
||||
w.ParentId = id;
|
||||
w.ChildItemId = 0;
|
||||
return w;
|
||||
case AyaType.WorkOrderItem:
|
||||
woitemid = id;
|
||||
@@ -604,8 +604,8 @@ namespace AyaNova.Biz
|
||||
woitemid = await ct.WorkOrderItemOutsideService.AsNoTracking().Where(z => z.Id == id).Select(z => z.WorkOrderItemId).SingleOrDefaultAsync();
|
||||
break;
|
||||
case AyaType.WorkOrderStatus:
|
||||
w.WorkOrderId = await ct.WorkOrderState.AsNoTracking().Where(z => z.Id == id).Select(z => z.WorkOrderId).SingleOrDefaultAsync();
|
||||
w.WorkOrderItemId = 0;
|
||||
w.ParentId = await ct.WorkOrderState.AsNoTracking().Where(z => z.Id == id).Select(z => z.WorkOrderId).SingleOrDefaultAsync();
|
||||
w.ChildItemId = 0;
|
||||
return w;
|
||||
case AyaType.WorkOrderItemUnit:
|
||||
woitemid = await ct.WorkOrderItemUnit.AsNoTracking().Where(z => z.Id == id).Select(z => z.WorkOrderItemId).SingleOrDefaultAsync();
|
||||
@@ -614,11 +614,11 @@ namespace AyaNova.Biz
|
||||
throw new System.NotSupportedException($"WorkOrderBiz::GetWorkOrderIdFromRelativeAsync -> AyaType {ayaType.ToString()} is not supported");
|
||||
}
|
||||
|
||||
w.WorkOrderId = await ct.WorkOrderItem.AsNoTracking()
|
||||
w.ParentId = await ct.WorkOrderItem.AsNoTracking()
|
||||
.Where(z => z.Id == woitemid)
|
||||
.Select(z => z.WorkOrderId)
|
||||
.SingleOrDefaultAsync();
|
||||
w.WorkOrderItemId = woitemid;
|
||||
w.ChildItemId = woitemid;
|
||||
return w;
|
||||
|
||||
|
||||
@@ -881,7 +881,7 @@ namespace AyaNova.Biz
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct);
|
||||
|
||||
//get header only
|
||||
var ret = await ct.WorkOrder.AsNoTracking().SingleOrDefaultAsync(x => x.Id == wid.WorkOrderId);
|
||||
var ret = await ct.WorkOrder.AsNoTracking().SingleOrDefaultAsync(x => x.Id == wid.ParentId);
|
||||
|
||||
//not found don't bomb, just return null
|
||||
if (ret == null) return ret;
|
||||
@@ -907,13 +907,13 @@ namespace AyaNova.Biz
|
||||
.Include(wi => wi.Travels)
|
||||
.Include(wi => wi.Units)
|
||||
.Include(wi => wi.OutsideServices)
|
||||
.SingleOrDefaultAsync(z => z.Id == wid.WorkOrderItemId);
|
||||
.SingleOrDefaultAsync(z => z.Id == wid.ChildItemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//get the single workorder item required
|
||||
woitem = await ct.WorkOrderItem.AsNoTracking().SingleOrDefaultAsync(x => x.Id == wid.WorkOrderItemId);
|
||||
woitem = await ct.WorkOrderItem.AsNoTracking().SingleOrDefaultAsync(x => x.Id == wid.ChildItemId);
|
||||
|
||||
switch (ayaType)
|
||||
{
|
||||
@@ -2301,7 +2301,7 @@ namespace AyaNova.Biz
|
||||
WorkOrderItem oProposed = (WorkOrderItem)proposedObj;
|
||||
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
//for notification purposes because has no name field itself
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString();
|
||||
|
||||
@@ -2687,7 +2687,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemExpense oProposed = (WorkOrderItemExpense)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
oProposed.Tags = WorkorderInfo.Tags;
|
||||
|
||||
//STANDARD EVENTS FOR ALL OBJECTS
|
||||
@@ -3089,7 +3089,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemLabor oProposed = (WorkOrderItemLabor)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
//for notification purposes because has no name or tags field itself
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString();
|
||||
oProposed.Tags = WorkorderInfo.Tags;
|
||||
@@ -3493,7 +3493,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemLoan oProposed = (WorkOrderItemLoan)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
//for notification purposes because has no name / tags field itself
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString();
|
||||
oProposed.Tags = WorkorderInfo.Tags;
|
||||
@@ -3826,7 +3826,7 @@ namespace AyaNova.Biz
|
||||
|
||||
WorkOrderItemOutsideService oProposed = (WorkOrderItemOutsideService)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
//for notification purposes because has no name / tags field itself
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString();
|
||||
oProposed.Tags = WorkorderInfo.Tags;
|
||||
@@ -4585,7 +4585,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemPart oProposed = (WorkOrderItemPart)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString(); //for notification purposes because has no name / tags field itself
|
||||
oProposed.Tags = WorkorderInfo.Tags;
|
||||
|
||||
@@ -4863,7 +4863,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemPartRequest oProposed = (WorkOrderItemPartRequest)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
proposedObj.Tags = WorkorderInfo.Tags;
|
||||
proposedObj.Name = WorkorderInfo.Serial.ToString();
|
||||
|
||||
@@ -5148,7 +5148,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemScheduledUser oProposed = (WorkOrderItemScheduledUser)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString(); //for notification purposes because has no name field itself
|
||||
oProposed.Tags = WorkorderInfo.Tags; //for notification purposes because has no tag field itself
|
||||
|
||||
@@ -5555,7 +5555,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemTask oProposed = (WorkOrderItemTask)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString(); //for notification purposes because has no name / tags field itself
|
||||
oProposed.Tags = WorkorderInfo.Tags;
|
||||
|
||||
@@ -5937,7 +5937,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemTravel oProposed = (WorkOrderItemTravel)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString();//for notification purposes because has no name / tags field itself
|
||||
oProposed.Tags = WorkorderInfo.Tags;
|
||||
|
||||
@@ -6341,7 +6341,7 @@ namespace AyaNova.Biz
|
||||
bool isNew = currentObj == null;
|
||||
WorkOrderItemUnit oProposed = (WorkOrderItemUnit)proposedObj;
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItem, oProposed.WorkOrderItemId, ct);
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.WorkOrderId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
var WorkorderInfo = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid.ParentId).Select(x => new { Serial = x.Serial, Tags = x.Tags }).FirstOrDefaultAsync();
|
||||
oProposed.Name = WorkorderInfo.Serial.ToString();//for notification purposes because has no name field itself
|
||||
|
||||
//STANDARD EVENTS FOR ALL OBJECTS
|
||||
@@ -6486,7 +6486,7 @@ namespace AyaNova.Biz
|
||||
if (mFetchedContractAlready == false)
|
||||
{
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct);
|
||||
var WoContractId = await ct.WorkOrder.AsNoTracking().Where(z => z.Id == wid.WorkOrderId).Select(z => z.ContractId).FirstOrDefaultAsync();
|
||||
var WoContractId = await ct.WorkOrder.AsNoTracking().Where(z => z.Id == wid.ParentId).Select(z => z.ContractId).FirstOrDefaultAsync();
|
||||
await GetCurrentContractFromContractIdAsync(WoContractId);
|
||||
}
|
||||
return mContractInEffect;
|
||||
@@ -6530,7 +6530,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
var wid = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct);
|
||||
var stat = await ct.WorkOrderState.AsNoTracking()
|
||||
.Where(z => z.WorkOrderId == wid.WorkOrderId)
|
||||
.Where(z => z.WorkOrderId == wid.ParentId)
|
||||
.OrderByDescending(z => z.Created)
|
||||
.Take(1)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace AyaNova.Models
|
||||
[Required]
|
||||
public long QuoteId { get; set; }
|
||||
public string TechNotes { get; set; }
|
||||
public long? QuoteItemStatusId { get; set; }
|
||||
public long? QuoteItemPriorityId { get; set; }
|
||||
public long? WorkOrderItemStatusId { get; set; }
|
||||
public long? WorkOrderItemPriorityId { get; set; }
|
||||
public DateTime? RequestDate { get; set; }
|
||||
public bool WarrantyService { get; set; } = false;
|
||||
public int Sequence { get; set; }
|
||||
|
||||
8
server/AyaNova/models/dto/ParentAndChildItemId.cs
Normal file
8
server/AyaNova/models/dto/ParentAndChildItemId.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
public class ParentAndChildItemId
|
||||
{
|
||||
public long ParentId { get; set; }
|
||||
public long ChildItemId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
public class WorkorderAndItemId
|
||||
{
|
||||
public long WorkOrderId { get; set; }
|
||||
public long WorkOrderItemId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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, "
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user