This commit is contained in:
2021-08-13 23:42:47 +00:00
parent 0a49c6c737
commit 33a72d6c46

View File

@@ -277,7 +277,7 @@ namespace AyaNova.PlugIn.V8
/// export
/// </summary>
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<string> tags = new List<string>();
AddImportTag(tags);
PurchaseOrder c = PurchaseOrder.GetItem(i.LT_PurchaseOrder_Label_PONumber.Value);
//get receipts for this PO
PurchaseOrderReceiptListDetailed prl = PurchaseOrderReceiptListDetailed.GetList(
"<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?><GRIDCRITERIA><COLUMNITEM CM=\"aPurchaseOrderReceipt.aReceivedDate\" UI=\"LT_PurchaseOrderReceipt_Label_ReceivedDate\" PIN=\"0\" WIDTH=\"121\" SORT=\"ASC\" /><COLUMNITEM CM=\"aPurchaseOrder.aPONumber\" UI=\"LT_PurchaseOrder_Label_PONumber\" PIN=\"0\" WIDTH=\"105\" /><COLUMNITEM CM=\"grid\" UI=\"LT_O_PurchaseOrderReceipt\" PIN=\"0\" WIDTH=\"155\" /><WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_PurchaseOrder_Label_PONumber\"><WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aPurchaseOrder.aID\" UICOMPAREVALUE=\"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" +
c.ID.ToString().ToUpper()
+ "}\" /></WHEREITEMGROUP></GRIDCRITERIA>");
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(
"<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?><GRIDCRITERIA><COLUMNITEM CM=\"aPurchaseOrderReceipt.aReceivedDate\" UI=\"LT_PurchaseOrderReceipt_Label_ReceivedDate\" PIN=\"0\" WIDTH=\"121\" SORT=\"ASC\" /><COLUMNITEM CM=\"aPurchaseOrder.aPONumber\" UI=\"LT_PurchaseOrder_Label_PONumber\" PIN=\"0\" WIDTH=\"105\" /><COLUMNITEM CM=\"grid\" UI=\"LT_O_PurchaseOrderReceipt\" PIN=\"0\" WIDTH=\"155\" /><WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_PurchaseOrder_Label_PONumber\"><WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aPurchaseOrder.aID\" UICOMPAREVALUE=\"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" +
c.ID.ToString().ToUpper()
+ "}\" /></WHEREITEMGROUP></GRIDCRITERIA>");
//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<PurchaseOrderReceipt> receipts = new List<PurchaseOrderReceipt>();
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);
}
}