This commit is contained in:
@@ -69,7 +69,7 @@ namespace AyaNovaQBI
|
|||||||
var a = await util.GetAsync($"workorder/{mm.WorkOrderId}");
|
var a = await util.GetAsync($"workorder/{mm.WorkOrderId}");
|
||||||
WorkOrder w = a.ObjectResponse["data"].ToObject<WorkOrder>();
|
WorkOrder w = a.ObjectResponse["data"].ToObject<WorkOrder>();
|
||||||
if (w == null)
|
if (w == null)
|
||||||
throw new Exception($"FixInvoiceProblems:QBONCE:PRICE: WorkOrder with id {mm.WorkOrderId} was not found in AyaNova and may have just been deleted.\r\nUnable to proceed.");
|
throw new Exception($"FixInvoiceProblems:QBONCE:PRICE: WorkOrder with id {mm.WorkOrderId} was not found in AyaNova and may have just been deleted.\r\nUnable to update wo.");
|
||||||
|
|
||||||
var wip = w.Items.First(z => z.Id == mm.WorkOrderItemId).Parts.First(z => z.Id == mm.WorkOrderItemPartId);
|
var wip = w.Items.First(z => z.Id == mm.WorkOrderItemId).Parts.First(z => z.Id == mm.WorkOrderItemPartId);
|
||||||
wip.PriceOverride = mm.QBPrice;
|
wip.PriceOverride = mm.QBPrice;
|
||||||
@@ -82,30 +82,24 @@ namespace AyaNovaQBI
|
|||||||
//Change this workorder item parts price to the qb price
|
//Change this workorder item parts price to the qb price
|
||||||
//and change ayanova's default price for this part to the qb price
|
//and change ayanova's default price for this part to the qb price
|
||||||
|
|
||||||
Guid WorkorderItemPartID = (Guid)e.Cell.Row.Cells["WorkorderItemPartID"].Value;
|
var a = await util.GetAsync($"workorder/{mm.WorkOrderId}");
|
||||||
Workorder w = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPart, WorkorderItemPartID);
|
WorkOrder w = a.ObjectResponse["data"].ToObject<WorkOrder>();
|
||||||
Guid PartID = Guid.Empty;
|
if (w == null)
|
||||||
foreach (WorkorderItem wi in w.WorkorderItems)
|
throw new Exception($"FixInvoiceProblems:CHANGEAYA:PRICE: WorkOrder with id {mm.WorkOrderId} was not found in AyaNova and may have just been deleted.\r\nUnable to update wo.");
|
||||||
{
|
|
||||||
if (w == null) break;
|
|
||||||
foreach (WorkorderItemPart wp in wi.Parts)
|
|
||||||
{
|
|
||||||
if (wp.ID == WorkorderItemPartID)
|
|
||||||
{
|
|
||||||
PartID = wp.PartID;
|
|
||||||
wp.PriceOverride = (decimal)e.Cell.Row.Cells["QBPrice"].Value;
|
|
||||||
w.Save();
|
|
||||||
w = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PartID != Guid.Empty)
|
var wip = w.Items.First(z => z.Id == mm.WorkOrderItemId).Parts.First(z => z.Id == mm.WorkOrderItemPartId);
|
||||||
|
long PartId = wip.PartId;
|
||||||
|
wip.PriceOverride = mm.QBPrice;
|
||||||
|
await util.PostAsync("workorder", Newtonsoft.Json.JsonConvert.SerializeObject(w));
|
||||||
|
|
||||||
|
if (PartId != 0)
|
||||||
{
|
{
|
||||||
Part p = Part.GetItem(PartID);
|
var partResponse = await util.GetAsync($"part/{PartId}");
|
||||||
p.Retail = (decimal)e.Cell.Row.Cells["QBPrice"].Value;
|
Part p = partResponse.ObjectResponse["data"].ToObject<Part>();
|
||||||
p.Save();
|
if (w == null)
|
||||||
|
throw new Exception($"FixInvoiceProblems:CHANGEAYA:PRICE: Part with id {PartId} was not found in AyaNova and may have just been deleted.\r\nUnable to update Part.");
|
||||||
|
p.Retail = mm.QBPrice;
|
||||||
|
await util.PostAsync("part", Newtonsoft.Json.JsonConvert.SerializeObject(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user