From 47e5bad23df789eac5a4d6dfb9bbd7929fe1bf09 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 12 Oct 2021 00:37:11 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 74 +++++++++++++++++++++----- 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 908133f..ffa1955 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -35,7 +35,7 @@ namespace AyaNova.PlugIn.V8 public string PluginVersion { - get { return "7.6.1-alpha.132"; } + get { return "7.6.1-alpha.133"; } } public string About @@ -814,13 +814,13 @@ namespace AyaNova.PlugIn.V8 var rOptions = await util.GetAsync("user-option/" + RavenId.ToString()); d = rOptions.ObjectResponse["data"]; - // d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor)); + // d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor)); d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress; d.phone1 = c.Phone1; d.phone2 = c.Phone2; d.phone3 = c.PageAddress; - + if (LocaleMap.ContainsKey(c.DefaultLanguage)) d.translationId = LocaleMap[c.DefaultLanguage]; else @@ -1945,7 +1945,6 @@ namespace AyaNova.PlugIn.V8 #endregion Parts - #region Part assemblies private async System.Threading.Tasks.Task ExportPartAssemblies(ProgressForm progress) { @@ -1995,8 +1994,6 @@ namespace AyaNova.PlugIn.V8 } #endregion part assemblies - - #region Warehouses private async System.Threading.Tasks.Task ExportWarehouses(ProgressForm progress) { @@ -2043,7 +2040,6 @@ namespace AyaNova.PlugIn.V8 } #endregion warehouses - #region Projects private async System.Threading.Tasks.Task ExportProjects(ProgressForm progress) { @@ -2296,6 +2292,62 @@ namespace AyaNova.PlugIn.V8 #endregion PurchaseOrders + #region Inventory adjustment serials + + + private async System.Threading.Tasks.Task ExportAdjustmentSerials(ProgressForm progress) + { + if (!progress.KeepGoing) return; + + + progress.Op("Start part inventory adjustment serial numbers export"); + progress.SubOp(""); + + //Step 2: export the objects + PartInventoryAdjustmentListDetailed pl = PartInventoryAdjustmentListDetailed.GetList( + " "); + + foreach (PartInventoryAdjustmentListDetailed.PartInventoryAdjustmentListDetailedInfo i in pl) + { + if (!progress.KeepGoing) return; + + //if no serial then continue to the next one until there is + if (string.IsNullOrWhiteSpace(i.LT_Common_Label_SerialNumber)) continue; + + long partNumber = await Getv7v8IdMap(i.LT_O_Part.Value, RootObjectTypes.Part, false, false); + if (partNumber == 0) + { + //log here or skip it as old adjustments could have invalid parts or not exported + //maybe append just to be safe + progress.Append("Part inventory adjustment part missing; skipping serial number '" + i.LT_Common_Label_SerialNumber + "' export: PartID " + i.LT_O_Part.Value.ToString()); + continue; + } + //get the part serial record + + + var a = await util.GetAsync("part/serials/" + partNumber.ToString()); + + + dynamic d = a.ObjectResponse["data"]; + dynamic dItem = new JObject(); + dItem = i.LT_Common_Label_SerialNumber; + d.Add(dItem); + + //list should only have a serial number in it if it's staying, removed ones are removed entirely from the list as well due to quirk + //so the list should only have one serial per part per adjustment item in the list in theory and no negative removed ones + //get new part number + //get existing serials because the same part may be adjusted multiple times + //PUT at route /part/serials/v8partid array of strings which are *all* serial numbers for that part (warehouse no longer relevant) + + await util.PutAsync("part/serials/" + partNumber, d); + + }//end of adjustmentitem loop + + + } + #endregion Inventory adjustment serials + + #region Task groups private async System.Threading.Tasks.Task ExportTaskGroups(ProgressForm progress) { @@ -2343,8 +2395,6 @@ namespace AyaNova.PlugIn.V8 } #endregion Task groups - - #region Units private async System.Threading.Tasks.Task ExportUnits(ProgressForm progress) { @@ -2804,7 +2854,7 @@ namespace AyaNova.PlugIn.V8 if (i.ContractRate) { - d.contractOnly = true; + d.contractOnly = true; } else { @@ -4862,7 +4912,7 @@ namespace AyaNova.PlugIn.V8 } //Clear out inventory for special unknown missing part created in v8 for potentially missing parts - if(mSubstitutePartId!=0) + if (mSubstitutePartId != 0) { JObject v8inv = (await util.GetAsync("part/latest-inventory/" + mSubstitutePartId)).ObjectResponse; @@ -4993,7 +5043,7 @@ namespace AyaNova.PlugIn.V8 //MAKE A DUPLICATE (probable source locale here in v7 that matches Raven is duped in Raven as basis for updating with custom v7 translations) //i.e. if we guess german is the v7 source of the customized locale then migrate it to the Raven german translation ensuring the best language for the user var exportName = GetUniqueName(i.Locale + " (" + ProbableSourceLocale + ")"); - progress.Append("ACTION REQUIRED: migrating a custom locale '" + i.Locale + "' to v8 as '"+exportName+"'. We do not recommend using migrated locales, see the Migration guide 'Localized Text' section for guidance."); + progress.Append("ACTION REQUIRED: migrating a custom locale '" + i.Locale + "' to v8 as '" + exportName + "'. We do not recommend using migrated locales, see the Migration guide 'Localized Text' section for guidance."); progress.SubOp("Is custom and closest match to " + ProbableSourceLocale); progress.Op("Exporting " + i.Locale + " to " + exportName);