This commit is contained in:
@@ -69,7 +69,7 @@ namespace AyaNovaQBI
|
||||
var a = await util.GetAsync($"workorder/{mm.WorkOrderId}");
|
||||
WorkOrder w = a.ObjectResponse["data"].ToObject<WorkOrder>();
|
||||
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);
|
||||
wip.PriceOverride = mm.QBPrice;
|
||||
@@ -82,30 +82,24 @@ namespace AyaNovaQBI
|
||||
//Change this workorder item parts price 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;
|
||||
Workorder w = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPart, WorkorderItemPartID);
|
||||
Guid PartID = Guid.Empty;
|
||||
foreach (WorkorderItem wi in w.WorkorderItems)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
var a = await util.GetAsync($"workorder/{mm.WorkOrderId}");
|
||||
WorkOrder w = a.ObjectResponse["data"].ToObject<WorkOrder>();
|
||||
if (w == null)
|
||||
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 (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);
|
||||
p.Retail = (decimal)e.Cell.Row.Cells["QBPrice"].Value;
|
||||
p.Save();
|
||||
var partResponse = await util.GetAsync($"part/{PartId}");
|
||||
Part p = partResponse.ObjectResponse["data"].ToObject<Part>();
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user