This commit is contained in:
2021-07-29 20:23:27 +00:00
parent c76e1cad3b
commit b22769a585
5 changed files with 137 additions and 56 deletions

2
.vscode/launch.json vendored
View File

@@ -53,7 +53,7 @@
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
"AYANOVA_SERVER_TEST_MODE": "true",
"AYANOVA_SERVER_TEST_MODE": "false",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"

View File

@@ -4,7 +4,11 @@
Notes for docs:
All selectable dates are advanced relatively based on the next service date calculation:
Next service date is calcualted as the repeat interval selected on PM then if exclude days are set the next service date is checked to ensure it doesn't fall on an excluded day of week. If it does fall on an excluded day then 1 day is added and it's checked against excluded days and this continues until it hits a non excluded day of week.
This Next service date calculated has the previous service date subtracted giving the total time span difference between the current generate date and the next generate date.
PM Scheduled user dates are set to empty in generated work order regardless of setting in PM to prevent blocking due to "Allow schedule conflicts" set to false, and also AyaNova can't guess what the scheduled date should be so this way a PM scheduled users collection is useful to have a crew of workers established but exact dates still need to be set after generation.
That time span is then added to all the current dates (such as scheduled user start date etc) in the PM as well as the Next service date and the PM is saved ready for the next time it will go through the process again.
If an date is left empty it will not be affected by this process so for example if you do not want a scheduled user date to be set or modified leave it blank in the PM.

View File

@@ -5269,42 +5269,47 @@ namespace AyaNova.Biz
internal static async Task<bool> NewServiceWorkOrderFromPMAsync(PM p, AyContext ct, ILogger log)
{
WorkOrder o = new WorkOrder();
//todo: copy dates over after all, the pm will have it's dates moved forward so we should definitely
//copy dates over as they should be refreshed and ready to accept
//need to pick through this and find those dates and possibly other items
//if user doesn't want dates set then they can leave them blank
o.Address = p.Address;
o.City = p.City;
WorkOrder wo = new WorkOrder();
wo.Address = p.Address;
wo.City = p.City;
//o.CompleteByDate=??
o.ContractId = p.ContractId;
o.Country = p.Country;
o.CreatedDate = DateTime.UtcNow;
o.CustomerContactName = p.CustomerContactName;
o.CustomerId = p.CustomerId;
o.CustomerReferenceNumber = p.CustomerReferenceNumber;
o.CustomFields = p.CustomFields;
o.FromPMId = p.Id;
o.InternalReferenceNumber = p.InternalReferenceNumber;
o.Latitude = p.Latitude;
o.Longitude = p.Longitude;
o.Notes = p.Notes;
o.Onsite = p.Onsite;
o.PostAddress = p.PostAddress;
o.PostCity = p.PostCity;
o.PostCode = p.PostCode;
o.PostCountry = p.PostCountry;
o.PostRegion = p.PostRegion;
o.ProjectId = p.ProjectId;
o.Region = p.Region;
o.ServiceDate = p.NextServiceDate;
o.Tags = p.Tags;
wo.ContractId = p.ContractId;
wo.Country = p.Country;
wo.CreatedDate = DateTime.UtcNow;
wo.CustomerContactName = p.CustomerContactName;
wo.CustomerId = p.CustomerId;
wo.CustomerReferenceNumber = p.CustomerReferenceNumber;
wo.CustomFields = p.CustomFields;
wo.FromPMId = p.Id;
wo.InternalReferenceNumber = p.InternalReferenceNumber;
wo.Latitude = p.Latitude;
wo.Longitude = p.Longitude;
wo.Notes = p.Notes;
wo.Onsite = p.Onsite;
wo.PostAddress = p.PostAddress;
wo.PostCity = p.PostCity;
wo.PostCode = p.PostCode;
wo.PostCountry = p.PostCountry;
wo.PostRegion = p.PostRegion;
wo.ProjectId = p.ProjectId;
wo.Region = p.Region;
wo.ServiceDate = p.NextServiceDate;//DATE ADJUST
wo.Tags = p.Tags;
if (p.CopyWiki)
o.Wiki = p.Wiki;
wo.Wiki = p.Wiki;
if (p.CopyAttachments)
o.GenCopyAttachmentsFrom = new AyaTypeId(AyaType.PM, p.Id);
wo.GenCopyAttachmentsFrom = new AyaTypeId(AyaType.PM, p.Id);
foreach (PMItem pmi in p.Items)
{
var woi = new WorkOrderItem();
woi.Notes = pmi.Notes;
woi.RequestDate = pmi.RequestDate;
woi.RequestDate = pmi.RequestDate;//DATE ADJUST
woi.Sequence = pmi.Sequence;
woi.Tags = pmi.Tags;
woi.TechNotes = pmi.TechNotes;
@@ -5330,15 +5335,9 @@ namespace AyaNova.Biz
foreach (PMItemScheduledUser pmsu in pmi.ScheduledUsers)
{
var wois = new WorkOrderItemScheduledUser();
wois.ServiceRateId = pmsu.ServiceRateId;
//Note: sched users were not in v7 pm's but adding "ALL THE THINGS"
//so the dates would be screwed up and could conflict if allow sched conflicts is
//set to false.
//We can't really guess what to schedule as so the sane choice seems to be to
//not set a date but keep them so user can schedule to wherever they want
//as null dates for sched user are supported
wois.StartDate = null;//pmischeduser.StartDate;
wois.StopDate = null;//pmischeduser.StopDate;
wois.ServiceRateId = pmsu.ServiceRateId;
wois.StartDate = pmsu.StartDate;//DATE ADJUST
wois.StopDate = pmsu.StopDate;//DATE ADJUST
wois.Tags = pmsu.Tags;
wois.UserId = pmsu.UserId;
@@ -5369,29 +5368,107 @@ namespace AyaNova.Biz
wil.Rate = pml.Rate;
wil.Tags = pml.Tags;
wil.TaxCodeId = pml.TaxCodeId;
wil.DueDate=pml.DueDate;//DATE ADJUST
wil.OutDate=pml.OutDate;//DATE ADJUST
wil.ReturnDate=pml.ReturnDate;//DATE ADJUST
woi.Loans.Add(wil);
}
foreach(PMItemLabor pmlab in pmi.Labors){
foreach (PMItemLabor pmlab in pmi.Labors)
{
var wilab = new WorkOrderItemLabor();
wilab.NoChargeQuantity=pmlab.NoChargeQuantity;
wilab.PriceOverride=pmlab.PriceOverride;
wilab.ServiceDetails=pmlab.ServiceDetails;
wilab.ServiceRateId=pmlab.ServiceRateId;
wilab.ServiceRateQuantity=pmlab.ServiceRateQuantity;
wilab.Tags=pmlab.Tags;
wilab.TaxCodeSaleId=pmlab.TaxCodeSaleId;
wilab.UserId=pmlab.UserId;
woi.Labors.Add(wilab);
wilab.NoChargeQuantity = pmlab.NoChargeQuantity;
wilab.PriceOverride = pmlab.PriceOverride;
wilab.ServiceDetails = pmlab.ServiceDetails;
wilab.ServiceRateId = pmlab.ServiceRateId;
wilab.ServiceRateQuantity = pmlab.ServiceRateQuantity;
wilab.Tags = pmlab.Tags;
wilab.TaxCodeSaleId = pmlab.TaxCodeSaleId;
wilab.UserId = pmlab.UserId;
wilab.ServiceStartDate=pmlab.ServiceStartDate;//DATE ADJUST
wilab.ServiceStopDate=pmlab.ServiceStopDate;//DATE ADJUST
woi.Labors.Add(wilab);
}
foreach (PMItemTravel pmtrav in pmi.Travels)
{
var witrav = new WorkOrderItemTravel();
witrav.Distance = pmtrav.Distance;
witrav.NoChargeQuantity = pmtrav.NoChargeQuantity;
witrav.PriceOverride = pmtrav.PriceOverride;
witrav.TravelDetails = pmtrav.TravelDetails;
witrav.TravelRateId = pmtrav.TravelRateId;
witrav.TravelRateQuantity = pmtrav.TravelRateQuantity;
witrav.TaxCodeSaleId = pmtrav.TaxCodeSaleId;
witrav.UserId = pmtrav.UserId;
witrav.TravelStartDate=pmtrav.TravelStartDate;//DATE ADJUST
witrav.TravelStopDate=pmtrav.TravelStopDate;//DATE ADJUST
woi.Travels.Add(witrav);
}
//------------
foreach (PMItemTask pmt in pmi.Tasks)
{
var wit = new WorkOrderItemTask();
wit.CompletedByUserId = pmt.CompletedByUserId;
wit.Sequence = pmt.Sequence;
wit.Status = pmt.Status;
wit.Task = pmt.Task;
wit.CompletedDate=pmt.CompletedDate;//DATE ADJUST
woi.Tasks.Add(wit);
}
foreach (PMItemExpense pme in pmi.Expenses)
{
var wie = new WorkOrderItemExpense();
wie.ChargeAmount = pme.ChargeAmount;
wie.ChargeTaxCodeId = pme.ChargeTaxCodeId;
wie.ChargeToCustomer = pme.ChargeToCustomer;
wie.Description = pme.Description;
wie.ReimburseUser = pme.ReimburseUser;
wie.TaxPaid = pme.TaxPaid;
wie.TotalCost = pme.TotalCost;
wie.UserId = pme.UserId;
woi.Expenses.Add(wie);
}
foreach (PMItemOutsideService pmo in pmi.OutsideServices)
{
var wio = new WorkOrderItemOutsideService();
wio.Notes = pmo.Notes;
wio.RepairCost = pmo.RepairCost;
wio.RepairPrice = pmo.RepairPrice;
wio.RMANumber = pmo.RMANumber;
wio.ShippingCost = pmo.ShippingCost;
wio.ShippingPrice = pmo.ShippingPrice;
wio.TaxCodeId = pmo.TaxCodeId;
wio.TrackingNumber = pmo.TrackingNumber;
wio.UnitId = pmo.UnitId;
wio.VendorSentToId = pmo.VendorSentToId;
wio.VendorSentViaId = pmo.VendorSentViaId;
wio.SentDate=pmo.SentDate;//DATE ADJUST
wio.ReturnDate=pmo.ReturnDate;//DATE ADJUST
wio.ETADate=pmo.ETADate;//DATE ADJUST
woi.OutsideServices.Add(wio);
}
wo.Items.Add(woi);
}
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct);
var NewObject = await biz.WorkOrderCreateAsync(wo, false);
if (NewObject == null)
{
var err = $"PMBiz::NewServiceWorkOrderFromPMAsync error creating from PM {p.Serial}\r\n{biz.GetErrorsAsString()}";
log.LogError(err);
return false;
}
return true;
}
#endregion

View File

@@ -23,7 +23,7 @@ namespace AyaNova.Biz
#if (DEBUG)
private static TimeSpan RUN_EVERY_INTERVAL = new TimeSpan(0, 0, 20);//no more frequently than once every 20 seconds
private static TimeSpan RUN_EVERY_INTERVAL = new TimeSpan(0, 0, 60);//no more frequently than once every 60 seconds
#else
private static TimeSpan RUN_EVERY_INTERVAL = new TimeSpan(0, 5, 0);//no more frequently than once every 5 minutes
#endif

View File

@@ -22,16 +22,16 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 1;
internal const long EXPECTED_COLUMN_COUNT = 1221;
internal const long EXPECTED_COLUMN_COUNT = 1223;
internal const long EXPECTED_INDEX_COUNT = 145;
internal const long EXPECTED_CHECK_CONSTRAINTS = 517;
internal const long EXPECTED_CHECK_CONSTRAINTS = 519;
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 190;
internal const long EXPECTED_VIEWS = 7;
internal const long EXPECTED_ROUTINES = 2;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
///////////////////////////////////////////////////////////////// C1220:I145:CC515:FC190:V7:R2
///////////////////////////////////////////////////////////////// C1223:I145:CC519:FC190:V7:R2
/*