From 3441508754d7a8755d6aee169e43e606ae5381db Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 13 Jul 2021 19:26:23 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- server/AyaNova/biz/WorkOrderBiz.cs | 50 ++++++++++++++++++++++++------ server/AyaNova/util/Seeder.cs | 6 ++++ 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 03869ca9..b77f3b95 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -54,7 +54,7 @@ "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", "AYANOVA_SERVER_TEST_MODE": "false", - "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "large", + "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" }, diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index cebbc4a3..99563f15 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -85,7 +85,7 @@ namespace AyaNova.Biz { get { - //the "for sure can not view labor cost" user types + //the "for sure can not view labor/travel cost" user types switch (CurrentUserType) { case UserType.Customer: @@ -101,6 +101,26 @@ namespace AyaNova.Biz } } + internal bool UserCanViewLoanerCosts + { + get + { + //the "for sure can not view loaner cost" user types + switch (CurrentUserType) + { + case UserType.Customer: + case UserType.HeadOffice: + case UserType.ServiceContractor: + return false; + } + //Now check roles (same as rates as accessed via svc area) + return (CurrentUserRoles.HasFlag(AuthorizationRoles.Service) + || CurrentUserRoles.HasFlag(AuthorizationRoles.ServiceRestricted) + || CurrentUserRoles.HasFlag(AuthorizationRoles.BizAdmin) + || CurrentUserRoles.HasFlag(AuthorizationRoles.Accounting)); + } + } + // internal bool IsTechRestricted // { // get @@ -280,17 +300,17 @@ namespace AyaNova.Biz .ThenInclude(wi => wi.OutsideServices) .SingleOrDefaultAsync(z => z.Id == id); + if (ret != null) + { + var stat = await GetCurrentWorkOrderStatusFromRelatedAsync(BizType, ret.Id); + ret.IsLockedAtServer = stat.Locked; - //todo: set isLocked from state - var stat = await GetCurrentWorkOrderStatusFromRelatedAsync(BizType, ret.Id); - ret.IsLockedAtServer = stat.Locked; + if (populateDisplayFields) + await WorkOrderPopulateVizFields(ret, false); - - if (populateDisplayFields) - await WorkOrderPopulateVizFields(ret, false); - - if (logTheGetEvent && ret != null) - await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct); + if (logTheGetEvent && ret != null) + await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct); + } return ret; } @@ -3385,6 +3405,11 @@ namespace AyaNova.Biz } } o.LineTotalViz = o.NetViz + o.TaxAViz + o.TaxBViz; + + //RESTRICTED COST FIELD?? + if (!UserCanViewLoanerCosts) + o.Cost = 0;//cost already used in calcs and will not be updated on any update operation so this ensures the cost isn't sent over the wire + } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -3407,7 +3432,12 @@ namespace AyaNova.Biz { //If it wasn't a complete part change there is no need to set pricing if (newObj.LoanUnitId == oldObj.LoanUnitId && newObj.Rate == oldObj.Rate) + { SnapshotPricing = false; + //maintain old cost as it can come from the client as zero when it shouldn't be or someone using the api and setting it directly + //but we will only allow the price *we* set at the server initially + newObj.Cost = oldObj.Cost; + } } //Pricing diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 4bb772c7..dbdf847c 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -2141,11 +2141,17 @@ namespace AyaNova.Util o.Tags = RandomTags(); o.RateHour = Fake.Random.Decimal(1, 25); + o.RateHourCost=o.RateHour/2; o.RateHalfDay = o.RateHour * 4; + o.RateHalfDayCost=o.RateHalfDay/2; o.RateDay = o.RateHour * 8; + o.RateDayCost=o.RateDay/2; o.RateWeek = o.RateHour * 36.8m; + o.RateWeekCost=o.RateWeek/2; o.RateMonth = o.RateHour * 21 * 8; + o.RateMonthCost=o.RateMonth/2; o.RateYear = o.RateHour * 36.8m * 52; + o.RateYearCost=o.RateYear/2; o.DefaultRate = Fake.Random.Enum();