This commit is contained in:
@@ -37,6 +37,7 @@ namespace AyaNovaQBI
|
|||||||
var senderGrid = (DataGridView)sender;
|
var senderGrid = (DataGridView)sender;
|
||||||
if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
|
if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
|
||||||
{
|
{
|
||||||
|
|
||||||
var mm = MisMatches[e.RowIndex];//grid event index is same row as collection index so this saves hassles with rows and accessors
|
var mm = MisMatches[e.RowIndex];//grid event index is same row as collection index so this saves hassles with rows and accessors
|
||||||
|
|
||||||
switch (mm.Reason)
|
switch (mm.Reason)
|
||||||
@@ -45,6 +46,8 @@ namespace AyaNovaQBI
|
|||||||
MessageBox.Show("Nothing to invoice");
|
MessageBox.Show("Nothing to invoice");
|
||||||
break;
|
break;
|
||||||
case util.MisMatchReason.PriceDifferent:
|
case util.MisMatchReason.PriceDifferent:
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
#region price problem
|
#region price problem
|
||||||
FixPriceDifference d = new FixPriceDifference();
|
FixPriceDifference d = new FixPriceDifference();
|
||||||
@@ -63,22 +66,14 @@ namespace AyaNovaQBI
|
|||||||
{
|
{
|
||||||
//Change the workorder item part price only
|
//Change the workorder item part price only
|
||||||
//to the quickbooks price, don't touch the default aya part price
|
//to the quickbooks price, don't touch the default aya part 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>();
|
||||||
foreach (WorkorderItem wi in w.WorkorderItems)
|
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.");
|
||||||
if (w == null) break;
|
|
||||||
foreach (WorkorderItemPart wp in wi.Parts)
|
var wip = w.Items.First(z => z.Id == mm.WorkOrderItemId).Parts.First(z => z.Id == mm.WorkOrderItemPartId);
|
||||||
{
|
wip.PriceOverride = mm.QBPrice;
|
||||||
if (wp.ID == WorkorderItemPartID)
|
await util.PostAsync("workorder", Newtonsoft.Json.JsonConvert.SerializeObject(w));
|
||||||
{
|
|
||||||
wp.PriceOverride = (decimal)e.Cell.Row.Cells["QBPrice"].Value;
|
|
||||||
w.Save();
|
|
||||||
w = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -126,6 +121,11 @@ namespace AyaNovaQBI
|
|||||||
//If all done then close up
|
//If all done then close up
|
||||||
if (grid.Rows.Count == 0)
|
if (grid.Rows.Count == 0)
|
||||||
this.Close();
|
this.Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await util.CrackDisplayAndIntegrationLogException(ex, "FixInvoiceProblems:PRICE");
|
||||||
|
}
|
||||||
|
|
||||||
#endregion price prob.
|
#endregion price prob.
|
||||||
}
|
}
|
||||||
@@ -283,8 +283,10 @@ namespace AyaNovaQBI
|
|||||||
if (grid.Rows.Count == 0)
|
if (grid.Rows.Count == 0)
|
||||||
this.Close();
|
this.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await util.CrackDisplayAndIntegrationLogException(ex, "FixInvoiceProblems:NOTLINKED");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3603,12 +3603,18 @@ namespace AyaNovaQBI
|
|||||||
#region Exception helper
|
#region Exception helper
|
||||||
|
|
||||||
public static string CrackException(Exception ex)
|
public static string CrackException(Exception ex)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendLine($"Exception {ex.Message}");
|
||||||
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
while (ex.InnerException != null)
|
while (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
ex = ex.InnerException;
|
ex = ex.InnerException;
|
||||||
|
sb.AppendLine($"Inner Exception: {ex.Message}");
|
||||||
}
|
}
|
||||||
return ex.Message + "\r\n-------TRACE------\r\n" + ex.StackTrace;
|
}
|
||||||
|
return $"{sb.ToString()}\r\n-------TRACE------\r\n{ex.StackTrace}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3616,7 +3622,7 @@ namespace AyaNovaQBI
|
|||||||
public static async Task CrackDisplayAndIntegrationLogException(Exception ex, string methodText = "n/a", string extraText = "n/a")
|
public static async Task CrackDisplayAndIntegrationLogException(Exception ex, string methodText = "n/a", string extraText = "n/a")
|
||||||
{
|
{
|
||||||
|
|
||||||
string message = "Exception error\r\nMethod: " + methodText + "\r\nExtra: " + extraText + "\r\n Error:" + CrackException(ex);
|
string message = $"Exception error\r\nMethod: {methodText}\r\nExtra: {extraText}\r\n Error:{CrackException(ex)}";
|
||||||
//Log it so we have it forever in the log
|
//Log it so we have it forever in the log
|
||||||
await IntegrationLog(message);
|
await IntegrationLog(message);
|
||||||
//display it to the user
|
//display it to the user
|
||||||
@@ -5679,6 +5685,8 @@ namespace AyaNovaQBI
|
|||||||
public decimal AyaPrice { get; set; }
|
public decimal AyaPrice { get; set; }
|
||||||
public decimal QBPrice { get; set; }
|
public decimal QBPrice { get; set; }
|
||||||
public long WorkOrderItemPartId { get; set; }
|
public long WorkOrderItemPartId { get; set; }
|
||||||
|
public long WorkOrderItemId { get; set; }
|
||||||
|
public long WorkOrderId { get; set; }
|
||||||
public string QBListID { get; set; }
|
public string QBListID { get; set; }
|
||||||
public string Fix { get; set; }
|
public string Fix { get; set; }
|
||||||
|
|
||||||
@@ -5716,6 +5724,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch(AyaClientList.FirstOrDefault(z => z.Id == w.CustomerId).Name,
|
AddMisMatch(AyaClientList.FirstOrDefault(z => z.Id == w.CustomerId).Name,
|
||||||
w.CustomerId,
|
w.CustomerId,
|
||||||
AyaType.Customer,
|
AyaType.Customer,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
MisMatchReason.NotLinkedToQB,
|
MisMatchReason.NotLinkedToQB,
|
||||||
MisMatches);
|
MisMatches);
|
||||||
}
|
}
|
||||||
@@ -5741,6 +5751,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch(AyaServiceRateList.FirstOrDefault(z => z.Id == wl.ServiceRateId).Name,
|
AddMisMatch(AyaServiceRateList.FirstOrDefault(z => z.Id == wl.ServiceRateId).Name,
|
||||||
(long)wl.ServiceRateId,
|
(long)wl.ServiceRateId,
|
||||||
AyaType.ServiceRate,
|
AyaType.ServiceRate,
|
||||||
|
wi.WorkOrderId,
|
||||||
|
wi.Id,
|
||||||
MisMatchReason.NotLinkedToQB,
|
MisMatchReason.NotLinkedToQB,
|
||||||
MisMatches);
|
MisMatches);
|
||||||
}
|
}
|
||||||
@@ -5765,6 +5777,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch(AyaTravelRateList.FirstOrDefault(z => z.Id == wt.TravelRateId).Name,
|
AddMisMatch(AyaTravelRateList.FirstOrDefault(z => z.Id == wt.TravelRateId).Name,
|
||||||
(long)wt.TravelRateId,
|
(long)wt.TravelRateId,
|
||||||
AyaType.TravelRate,
|
AyaType.TravelRate,
|
||||||
|
wi.WorkOrderId,
|
||||||
|
wi.Id,
|
||||||
MisMatchReason.NotLinkedToQB,
|
MisMatchReason.NotLinkedToQB,
|
||||||
MisMatches); ;
|
MisMatches); ;
|
||||||
}
|
}
|
||||||
@@ -5785,6 +5799,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch(AyaPartList.FirstOrDefault(z => z.Id == wp.PartId).Name,
|
AddMisMatch(AyaPartList.FirstOrDefault(z => z.Id == wp.PartId).Name,
|
||||||
wp.PartId,
|
wp.PartId,
|
||||||
AyaType.Part,
|
AyaType.Part,
|
||||||
|
wi.WorkOrderId,
|
||||||
|
wi.Id,
|
||||||
MisMatchReason.NotLinkedToQB,
|
MisMatchReason.NotLinkedToQB,
|
||||||
MisMatches);
|
MisMatches);
|
||||||
|
|
||||||
@@ -5821,6 +5837,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch($"WO: {w.Serial}{disco} Part: {ayaPartRecord.Name}",
|
AddMisMatch($"WO: {w.Serial}{disco} Part: {ayaPartRecord.Name}",
|
||||||
wp.PartId,
|
wp.PartId,
|
||||||
AyaType.Part,
|
AyaType.Part,
|
||||||
|
wi.WorkOrderId,
|
||||||
|
wi.Id,
|
||||||
MisMatchReason.PriceDifferent,
|
MisMatchReason.PriceDifferent,
|
||||||
MisMatches,
|
MisMatches,
|
||||||
qbPrice,
|
qbPrice,
|
||||||
@@ -5851,6 +5869,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch("Outside services - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
|
AddMisMatch("Outside services - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
|
||||||
0,
|
0,
|
||||||
AyaType.WorkOrderItemOutsideService,
|
AyaType.WorkOrderItemOutsideService,
|
||||||
|
wi.WorkOrderId,
|
||||||
|
wi.Id,
|
||||||
MisMatchReason.NotLinkedToQB,
|
MisMatchReason.NotLinkedToQB,
|
||||||
MisMatches);
|
MisMatches);
|
||||||
|
|
||||||
@@ -5881,6 +5901,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch("Workorder item loan - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
|
AddMisMatch("Workorder item loan - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
|
||||||
0,
|
0,
|
||||||
AyaType.WorkOrderItemLoan,
|
AyaType.WorkOrderItemLoan,
|
||||||
|
wi.WorkOrderId,
|
||||||
|
wi.Id,
|
||||||
MisMatchReason.NotLinkedToQB,
|
MisMatchReason.NotLinkedToQB,
|
||||||
MisMatches);
|
MisMatches);
|
||||||
break;
|
break;
|
||||||
@@ -5908,6 +5930,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch("Workorder item expense - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
|
AddMisMatch("Workorder item expense - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
|
||||||
0,
|
0,
|
||||||
AyaType.WorkOrderItemExpense,
|
AyaType.WorkOrderItemExpense,
|
||||||
|
wi.WorkOrderId,
|
||||||
|
wi.Id,
|
||||||
MisMatchReason.NotLinkedToQB,
|
MisMatchReason.NotLinkedToQB,
|
||||||
MisMatches);
|
MisMatches);
|
||||||
break;
|
break;
|
||||||
@@ -5929,6 +5953,8 @@ namespace AyaNovaQBI
|
|||||||
AddMisMatch("WO: " + w.Serial + " - Nothing chargeable on it, will not be invoiced",
|
AddMisMatch("WO: " + w.Serial + " - Nothing chargeable on it, will not be invoiced",
|
||||||
0,
|
0,
|
||||||
AyaType.NoType,
|
AyaType.NoType,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
MisMatchReason.NothingToInvoice,
|
MisMatchReason.NothingToInvoice,
|
||||||
MisMatches);
|
MisMatches);
|
||||||
|
|
||||||
@@ -5941,14 +5967,16 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void AddMisMatch(string Name, long ObjectId, AyaType ObjectType, MisMatchReason Reason, List<MisMatch> Mismatches)
|
private static void AddMisMatch(string Name, long ObjectId, AyaType ObjectType, long WorkOrderId, long WorkOrderItemId, MisMatchReason Reason, List<MisMatch> Mismatches)
|
||||||
{
|
{
|
||||||
AddMisMatch(Name, ObjectId, ObjectType, Reason, Mismatches, 0m, 0m, 0, "");
|
AddMisMatch(Name, ObjectId, ObjectType, WorkOrderId, WorkOrderItemId, Reason, Mismatches, 0m, 0m, 0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddMisMatch(string Name,
|
private static void AddMisMatch(string Name,
|
||||||
long ObjectId,
|
long ObjectId,
|
||||||
AyaType ObjectType,
|
AyaType ObjectType,
|
||||||
|
long WorkOrderId,
|
||||||
|
long WorkOrderItemId,
|
||||||
MisMatchReason Reason,
|
MisMatchReason Reason,
|
||||||
List<MisMatch> Mismatches,
|
List<MisMatch> Mismatches,
|
||||||
decimal QBPrice,
|
decimal QBPrice,
|
||||||
@@ -6011,6 +6039,8 @@ namespace AyaNovaQBI
|
|||||||
AyaPrice = AyaPrice,
|
AyaPrice = AyaPrice,
|
||||||
QBPrice = QBPrice,
|
QBPrice = QBPrice,
|
||||||
WorkOrderItemPartId = WorkOrderItemPartId,
|
WorkOrderItemPartId = WorkOrderItemPartId,
|
||||||
|
WorkOrderItemId=WorkOrderItemId,
|
||||||
|
WorkOrderId=WorkOrderId,
|
||||||
QBListID = QBListID,
|
QBListID = QBListID,
|
||||||
Fix = theFix
|
Fix = theFix
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user