This commit is contained in:
2021-08-12 17:57:36 +00:00
parent f01ae69b0d
commit fc034e852a

View File

@@ -266,6 +266,9 @@ namespace AyaNova.PlugIn.V8
private long ClosedWorkOrderStatus = 0;
private long ServiceCompletedWorkOrderStatus = 0;
private bool V7UseInventory = false;
private List<long> Allv8WarehouseIds = new List<long>();
//UNKNOWN / MISSING RECORD OBJECT STAND INs
private long UnknownV7PartId = 0;//used when there is no part id on a workorderitempart record
@@ -287,6 +290,7 @@ namespace AyaNova.PlugIn.V8
progress.Op("Preparing to export....");
ResetUniqueUserNames();
ResetUniqueNames();
Allv8WarehouseIds.Clear();
V7ToV8IdMap.Clear();
V7ToV8WorkOrderItemStatusIdMap.Clear();
TagMap.Clear();
@@ -369,6 +373,10 @@ namespace AyaNova.PlugIn.V8
ExportClientNoteTypes(progress);
progress.Op("Exporting Business objects");
//are we using inventory for this?
V7UseInventory = AyaBizUtils.GlobalSettings.UseInventory;
//BIZ objects
await ExportLocales(progress);
await ExportStaffUsers(progress);
@@ -378,10 +386,11 @@ namespace AyaNova.PlugIn.V8
await ExportHeadOffices(progress);
await ExportClients(progress);
await ExportVendors(progress);
await TurnOffInventory(progress);
await ExportWarehouses(progress);
await ExportLoanItems(progress);
await ExportParts(progress);
await InitInventory(progress);
await ExportProjects(progress);
//PURCHASE ORDERS deferred to possibly never if people can live without it
@@ -1505,20 +1514,22 @@ namespace AyaNova.PlugIn.V8
#region TurnOffInventory
private async System.Threading.Tasks.Task TurnOffInventory(ProgressForm progress)
#region InitInventory
private async System.Threading.Tasks.Task InitInventory(ProgressForm progress)
{
ResetUniqueNames();
if (!progress.KeepGoing) return;
progress.Op("Turning off v8 inventory");
var a = await util.GetAsync("global-biz-setting");
dynamic d = a.ObjectResponse["data"];
d.useInventory = false;
await util.PutAsync("global-biz-setting", d.ToString());
if (!V7UseInventory)
{
progress.Append("v7 Use inventory is OFF, not migrating inventory");
var a = await util.GetAsync("global-biz-setting");
dynamic d = a.ObjectResponse["data"];
d.useInventory = false;
await util.PutAsync("global-biz-setting", d.ToString());
return;
}
progress.Append("v7 Use inventory is Active; parts will be exported with initial inventory to allow migration and adjusted to balance v7 at end of migration");
}
#endregion TurnOffInventory
#endregion InitInventory
@@ -1612,6 +1623,20 @@ namespace AyaNova.PlugIn.V8
//Event log fixup
await util.EventLog(util.AyaType.Part, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
//INVENTORY?
if (V7UseInventory)
{
foreach (long l in Allv8WarehouseIds)
{
//create opening initial inventory just so migrate can proceed without v8 balking
dynamic di = new JObject();
di.description = "v8 migrate temporary initial inventory to allow migration";
di.partId = RavenId;
di.partWarehouseId = l;
di.quantity = 1000000000m;//one billion should cover it
await util.PostAsync("part-inventory", di.ToString());
}
}
}
//UntrackedV7PartId
@@ -1650,6 +1675,7 @@ namespace AyaNova.PlugIn.V8
if (!progress.KeepGoing) return;
if (i.ID == PartWarehouse.DefaultWarehouseID)
{
Allv8WarehouseIds.Add(1);
Addv7v8IdMap(i.ID, 1);
continue;
}
@@ -1666,6 +1692,7 @@ namespace AyaNova.PlugIn.V8
var rMainObject = await util.PostAsync("part-warehouse", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(i.ID, RavenId);
Allv8WarehouseIds.Add(RavenId);
await util.EventLog(util.AyaType.PartWarehouse, RavenId, SafeGetUserMap(i.Creator), SafeGetUserMap(i.Modifier), i.Created, i.Modified);
}
}
@@ -2737,10 +2764,38 @@ namespace AyaNova.PlugIn.V8
dwip.workorderItemId = ravenwoitemid;
dwip.quantity = wip.Quantity;
var tryPartId = Getv7v8IdMapNullOk(wip.PartID);
if (tryPartId==null)
if (tryPartId == null)
{
dwip.partId = UnknownV7PartId;
if (wip.Quantity == 0 && string.IsNullOrWhiteSpace(wip.Description))
if (wip.Quantity == 0 && string.IsNullOrWhiteSpace(wip.Description))
continue; //no part record, no quantity, no text at all, just skip it
}
else
dwip.partId = tryPartId;
dwip.partWarehouseId = Getv7v8IdMap(wip.PartWarehouseID, "warehouse");
dwip.taxPartSaleId = Getv7v8IdMapNullOk(wip.TaxPartSaleID);
dwip.priceOverride = wip.Price;
dwip.price = wip.Price;
dwip.cost = wip.Cost;
dwip.description = wip.Description;
if (wip.PartSerialID != Guid.Empty)
dwip.serials = PartSerial.GetSerialNumberFromPartSerialID(wip.PartSerialID);
await util.PostAsync("workorder/items/parts", dwip.ToString());
}
//##### WORKORDER ITEM PART
foreach (WorkorderItemPart wip in wi.Parts)
{
progress.Op("WorkorderItemPart " + wip.ID.ToString());
dynamic dwip = new JObject();
dwip.workOrderId = RavenId;
dwip.workorderItemId = ravenwoitemid;
dwip.quantity = wip.Quantity;
var tryPartId = Getv7v8IdMapNullOk(wip.PartID);
if (tryPartId == null)
{
dwip.partId = UnknownV7PartId;
if (wip.Quantity == 0 && string.IsNullOrWhiteSpace(wip.Description))
continue; //no part record, no quantity, no text at all, just skip it
}
else