diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 18130fc..c2f33a0 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -277,7 +277,7 @@ namespace AyaNova.PlugIn.V8 /// export /// private async void DoExport() - { + { //Show progress form ProgressForm progress = new ProgressForm(); progress.Show(); @@ -300,7 +300,7 @@ namespace AyaNova.PlugIn.V8 LocaleMap.Add("Français", 3); LocaleMap.Add("Deutsch", 4); //admin user (not exported but is there already) - V7ToV8IdMap.Add(User.AdministratorID, 1); + V7ToV8IdMap.Add(User.AdministratorID, 1); //ERASE DB @@ -357,9 +357,9 @@ namespace AyaNova.PlugIn.V8 await ExportWarehouses(progress); await ExportParts(progress); await ExportProjects(progress); - - if(V7UseInventory) - await ExportPurchaseOrders(progress); + + if (V7UseInventory) + await ExportPurchaseOrders(progress); await ExportUnitModels(progress); await ExportUnits(progress); await ExportExternalUsers(progress);//needs vendors, clients and headoffices already exported so needs to be here late @@ -383,7 +383,7 @@ namespace AyaNova.PlugIn.V8 await ExportClientServiceRequests(progress); - + if (progress.KeepGoing) { progress.Append("Export completed"); @@ -1748,6 +1748,7 @@ namespace AyaNova.PlugIn.V8 #endregion Projects #region PurchaseOrders + private async System.Threading.Tasks.Task ExportPurchaseOrders(ProgressForm progress) { if (!progress.KeepGoing) return; @@ -1770,22 +1771,52 @@ namespace AyaNova.PlugIn.V8 if (!progress.KeepGoing) return; List tags = new List(); AddImportTag(tags); - PurchaseOrder c = PurchaseOrder.GetItem(i.LT_PurchaseOrder_Label_PONumber.Value); - - //get receipts for this PO - PurchaseOrderReceiptListDetailed prl = PurchaseOrderReceiptListDetailed.GetList( - ""); + PurchaseOrder c = PurchaseOrder.GetItem(i.LT_PurchaseOrder_Label_PONumber.Value); var ObjectTID = new TypeAndID(RootObjectTypes.PurchaseOrder, c.ID); dynamic d = new JObject(); - d.serial = c.PONumber; if (IsDuplicatev7v8IdMapItem(c.ID, i.LT_PurchaseOrder_Label_PONumber.Display, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.notes = c.Notes; - d.vendorMemo + d.vendorMemo = c.VendorMemo; + d.dropShipToCustomerId =Getv7v8IdMapNullOk(c.DropShipToClientID); + d.referenceNumber = c.ReferenceNumber; + d.vendorId = Getv7v8IdMap(c.VendorID, "Vendor for PO"); + d.orderedDate = util.DateToV8(c.OrderedDate); + d.expectedReceiveDate = util.DateToV8(c.ExpectedReceiveDate); + d.status = (int)c.Status;//same enum id's so this is kosher + d.projectId = Getv7v8IdMapNullOk(c.ProjectID); + + StringBuilder sbText1 = new StringBuilder(); + StringBuilder sbText2 = new StringBuilder(); + //get receipts for this PO + PurchaseOrderReceiptListDetailed prl = PurchaseOrderReceiptListDetailed.GetList( + ""); + + //compile all actual receipts into collection for later recombination + //above list is missing crucial bit which is which exact poitemid they are received against so need actual full record + //even though list has almost everything else needed + List receipts = new List(); + foreach (PurchaseOrderReceiptListDetailed.PurchaseOrderReceiptListDetailedInfo prli in prl) + { + receipts.Add(PurchaseOrderReceipt.GetItem(prli.LT_O_PurchaseOrderReceipt.Value)); + } + + + foreach (PurchaseOrderItem pi in c.OrderItems) + { + //here combine potiem and poreceipts into singular items for v8 + //also compile all text1,text2 to put into header for v8 later + + //iterate receipt list find id's fetch actual receipts which contain exactly which poitem they were received against + //also, keep track of required woitempartrequestid's for later so can fixup when the time comes + + + + } @@ -1837,17 +1868,17 @@ namespace AyaNova.PlugIn.V8 progress.Op("Start Task Groups export"); progress.SubOp(""); var ObjectTypeName = "TaskGroup"; - + //Step 2: export the objects PickListAutoComplete pl = PickListAutoComplete.GetList("**", "taskgroup"); progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); - //task picklist used over and over + //task picklist used over and over var AllTasks = TaskPickList.GetList(); foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl) { if (!progress.KeepGoing) return; - + TaskGroup c = TaskGroup.GetItem(i.ID); var ObjectTID = new TypeAndID(RootObjectTypes.TaskGroup, c.ID); dynamic d = new JObject(); @@ -1870,7 +1901,7 @@ namespace AyaNova.PlugIn.V8 d.items = dTasks; var rMainObject = await util.PostAsync("task-group", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - Addv7v8IdMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); await util.EventLog(util.AyaType.Project, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); } }