This commit is contained in:
30
AyaNovaQBI/FixInvoiceProblems.Designer.cs
generated
30
AyaNovaQBI/FixInvoiceProblems.Designer.cs
generated
@@ -28,6 +28,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.grid = new System.Windows.Forms.DataGridView();
|
||||
this.btnOK = new System.Windows.Forms.Button();
|
||||
this.Object = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
@@ -44,9 +45,13 @@
|
||||
//
|
||||
// grid
|
||||
//
|
||||
this.grid.AllowUserToAddRows = false;
|
||||
this.grid.AllowUserToDeleteRows = false;
|
||||
this.grid.AllowUserToResizeRows = false;
|
||||
this.grid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.grid.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
|
||||
this.grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.Object,
|
||||
@@ -58,10 +63,13 @@
|
||||
this.QBPrice,
|
||||
this.WorkOrderItemPartId,
|
||||
this.QBListID});
|
||||
this.grid.Location = new System.Drawing.Point(2, 3);
|
||||
this.grid.Location = new System.Drawing.Point(12, 12);
|
||||
this.grid.Name = "grid";
|
||||
this.grid.Size = new System.Drawing.Size(1021, 519);
|
||||
this.grid.ReadOnly = true;
|
||||
this.grid.RowHeadersVisible = false;
|
||||
this.grid.Size = new System.Drawing.Size(1003, 510);
|
||||
this.grid.TabIndex = 0;
|
||||
this.grid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.grid_CellContentClick);
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
@@ -80,13 +88,18 @@
|
||||
this.Object.HeaderText = "Object";
|
||||
this.Object.Name = "Object";
|
||||
this.Object.ReadOnly = true;
|
||||
this.Object.Width = 63;
|
||||
//
|
||||
// Fix
|
||||
//
|
||||
this.Fix.DataPropertyName = "Fix";
|
||||
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Fix.DefaultCellStyle = dataGridViewCellStyle4;
|
||||
this.Fix.HeaderText = "Fix";
|
||||
this.Fix.Name = "Fix";
|
||||
this.Fix.ReadOnly = true;
|
||||
this.Fix.Width = 26;
|
||||
//
|
||||
// ObjectName
|
||||
//
|
||||
@@ -94,6 +107,7 @@
|
||||
this.ObjectName.HeaderText = "Name";
|
||||
this.ObjectName.Name = "ObjectName";
|
||||
this.ObjectName.ReadOnly = true;
|
||||
this.ObjectName.Width = 60;
|
||||
//
|
||||
// Problem
|
||||
//
|
||||
@@ -101,41 +115,52 @@
|
||||
this.Problem.HeaderText = "Problem";
|
||||
this.Problem.Name = "Problem";
|
||||
this.Problem.ReadOnly = true;
|
||||
this.Problem.Width = 70;
|
||||
//
|
||||
// ObjectId
|
||||
//
|
||||
this.ObjectId.DataPropertyName = "ObjectId";
|
||||
this.ObjectId.HeaderText = "ObjectId";
|
||||
this.ObjectId.Name = "ObjectId";
|
||||
this.ObjectId.ReadOnly = true;
|
||||
this.ObjectId.Visible = false;
|
||||
this.ObjectId.Width = 72;
|
||||
//
|
||||
// AyaPrice
|
||||
//
|
||||
this.AyaPrice.DataPropertyName = "AyaPrice";
|
||||
this.AyaPrice.HeaderText = "AyaPrice";
|
||||
this.AyaPrice.Name = "AyaPrice";
|
||||
this.AyaPrice.ReadOnly = true;
|
||||
this.AyaPrice.Visible = false;
|
||||
this.AyaPrice.Width = 74;
|
||||
//
|
||||
// QBPrice
|
||||
//
|
||||
this.QBPrice.DataPropertyName = "QBPrice";
|
||||
this.QBPrice.HeaderText = "QBPrice";
|
||||
this.QBPrice.Name = "QBPrice";
|
||||
this.QBPrice.ReadOnly = true;
|
||||
this.QBPrice.Visible = false;
|
||||
this.QBPrice.Width = 71;
|
||||
//
|
||||
// WorkOrderItemPartId
|
||||
//
|
||||
this.WorkOrderItemPartId.DataPropertyName = "WorkOrderItemPartId";
|
||||
this.WorkOrderItemPartId.HeaderText = "WorkOrderItemPartId";
|
||||
this.WorkOrderItemPartId.Name = "WorkOrderItemPartId";
|
||||
this.WorkOrderItemPartId.ReadOnly = true;
|
||||
this.WorkOrderItemPartId.Visible = false;
|
||||
this.WorkOrderItemPartId.Width = 132;
|
||||
//
|
||||
// QBListID
|
||||
//
|
||||
this.QBListID.DataPropertyName = "QBListID";
|
||||
this.QBListID.HeaderText = "QBListID";
|
||||
this.QBListID.Name = "QBListID";
|
||||
this.QBListID.ReadOnly = true;
|
||||
this.QBListID.Visible = false;
|
||||
this.QBListID.Width = 74;
|
||||
//
|
||||
// FixInvoiceProblems
|
||||
//
|
||||
@@ -149,6 +174,7 @@
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MinimumSize = new System.Drawing.Size(300, 300);
|
||||
this.Name = "FixInvoiceProblems";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Fix problems";
|
||||
this.Load += new System.EventHandler(this.FixInvoiceProblems_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit();
|
||||
|
||||
@@ -31,5 +31,271 @@ namespace AyaNovaQBI
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void grid_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var senderGrid = (DataGridView)sender;
|
||||
|
||||
if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn )
|
||||
{
|
||||
//MessageBox.Show($"Row was {e.RowIndex}");
|
||||
|
||||
switch ((Util.MisMatchReason)e.Cell.Row.Cells["Reason"].Value)
|
||||
{
|
||||
case Util.MisMatchReason.NothingToInvoice:
|
||||
MessageBox.Show("Nothing to invoice");
|
||||
break;
|
||||
case Util.MisMatchReason.PriceDifferent:
|
||||
{
|
||||
#region price problem
|
||||
FixPriceDifference d = new FixPriceDifference();
|
||||
d.PriceDescription = e.Cell.Row.Cells["Name"].Value.ToString() + "\r\n" +
|
||||
"Price on work order: " + ((decimal)e.Cell.Row.Cells["AyaPrice"].Value).ToString("c") + "\r\n" +
|
||||
"Price in QuickBooks: " + ((decimal)e.Cell.Row.Cells["QBPrice"].Value).ToString("c");
|
||||
if (d.ShowDialog() == DialogResult.Cancel) return;
|
||||
//Fixup price here
|
||||
switch (d.SelectedResolution)
|
||||
{
|
||||
case "AYAONCE":
|
||||
//Add to price override list so price on workorder item part record is used
|
||||
_PartPriceOverrides.Add((Guid)e.Cell.Row.Cells["WorkorderItemPartID"].Value);
|
||||
break;
|
||||
case "QBONCE":
|
||||
{
|
||||
//Change the workorder item part price only
|
||||
//to the quickbooks price, don't touch the default aya part price
|
||||
Guid WorkorderItemPartID = (Guid)e.Cell.Row.Cells["WorkorderItemPartID"].Value;
|
||||
Workorder w = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPart, WorkorderItemPartID);
|
||||
foreach (WorkorderItem wi in w.WorkorderItems)
|
||||
{
|
||||
if (w == null) break;
|
||||
foreach (WorkorderItemPart wp in wi.Parts)
|
||||
{
|
||||
if (wp.ID == WorkorderItemPartID)
|
||||
{
|
||||
wp.PriceOverride = (decimal)e.Cell.Row.Cells["QBPrice"].Value;
|
||||
w.Save();
|
||||
w = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "CHANGEAYA":
|
||||
{
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PartID != Guid.Empty)
|
||||
{
|
||||
Part p = Part.GetItem(PartID);
|
||||
p.Retail = (decimal)e.Cell.Row.Cells["QBPrice"].Value;
|
||||
p.Save();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "CHANGEQB":
|
||||
//Change the QB price to use the price on this workorder item part
|
||||
Util.ChangeQBItemPrice(e.Cell.Row.Cells["QBListID"].Value.ToString(), (decimal)e.Cell.Row.Cells["AyaPrice"].Value);
|
||||
break;
|
||||
}
|
||||
|
||||
//remove the object from the grid as it's now dealt with
|
||||
e.Cell.Row.Delete(false);
|
||||
_ChangesMade = true;
|
||||
//If all done then close up
|
||||
if (grid.Rows.Count == 0)
|
||||
this.Close();
|
||||
|
||||
#endregion price prob.
|
||||
}
|
||||
break;
|
||||
case Util.MisMatchReason.NotLinkedToQB:
|
||||
{
|
||||
#region link problem
|
||||
LinkOrImportAyaObject d = new LinkOrImportAyaObject();
|
||||
try
|
||||
{
|
||||
d.AyaItem = e.Cell.Row.Cells["Name"].Value.ToString();
|
||||
//Default for an import
|
||||
//otherwise in a link is just reset to the qb item name selected
|
||||
string QBItemName = e.Cell.Row.Cells["Name"].Value.ToString();
|
||||
|
||||
//Attempt a link or import
|
||||
//in any case of failure or new link not required
|
||||
//bails inside switch
|
||||
switch ((RootObjectTypes)e.Cell.Row.Cells["ObjectType"].Value)
|
||||
{
|
||||
case RootObjectTypes.Client:
|
||||
d.CanImport = true;
|
||||
d.QBItems = Util.QBClients;
|
||||
if (d.ShowDialog() == DialogResult.Cancel) return;
|
||||
if (d.Choice == "IMPORT")
|
||||
{
|
||||
ArrayList alErrors = new ArrayList();
|
||||
Util.ImportAyaClient((Guid)e.Cell.Row.Cells["RootObjectID"].Value, alErrors);
|
||||
//display errors if any
|
||||
if (alErrors.Count != 0)
|
||||
{
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("Import failed with error:\r\n\r\n");
|
||||
foreach (object o in alErrors)
|
||||
{
|
||||
sb.Append((string)o);
|
||||
sb.Append("\r\n************\r\n");
|
||||
|
||||
}
|
||||
|
||||
CopyableMessageBox cb = new CopyableMessageBox(sb.ToString());
|
||||
cb.ShowDialog();
|
||||
cb.Dispose();
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
goto REMOVEITEMS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//it's a link by default
|
||||
if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !Util.QBClients.Rows.Contains(d.SelectedQBItem))
|
||||
return;
|
||||
QBItemName = d.SelectedQBItemName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case RootObjectTypes.Rate:
|
||||
d.CanImport = false;
|
||||
d.QBItems = Util.QBItems;
|
||||
if (d.ShowDialog() == DialogResult.Cancel) return;
|
||||
|
||||
if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !Util.QBItems.Rows.Contains(d.SelectedQBItem))
|
||||
return;
|
||||
QBItemName = d.SelectedQBItemName;
|
||||
break;
|
||||
case RootObjectTypes.Part:
|
||||
d.CanImport = false;
|
||||
d.QBItems = Util.QBItems;
|
||||
if (d.ShowDialog() == DialogResult.Cancel) return;
|
||||
|
||||
if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !Util.QBItems.Rows.Contains(d.SelectedQBItem))
|
||||
return;
|
||||
QBItemName = d.SelectedQBItemName;
|
||||
|
||||
break;
|
||||
case RootObjectTypes.WorkorderItemOutsideService:
|
||||
d.CanImport = false;
|
||||
d.QBItems = Util.QBItems;
|
||||
if (d.ShowDialog() == DialogResult.Cancel) return;
|
||||
|
||||
|
||||
if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !Util.QBItems.Rows.Contains(d.SelectedQBItem))
|
||||
return;
|
||||
|
||||
Util.QDat.OutsideServiceChargeAs = d.SelectedQBItem;
|
||||
|
||||
//Case 299
|
||||
Util.QBI.AIObject = Util.QDat.XMLData;
|
||||
//Util.QBI.AIObject = Util.QDat;
|
||||
|
||||
Util.QBI = (Integration)Util.QBI.Save();
|
||||
Util.QDat.IsDirty = false;
|
||||
goto REMOVEITEMS;
|
||||
|
||||
|
||||
case RootObjectTypes.WorkorderItemLoan:
|
||||
d.CanImport = false;
|
||||
d.QBItems = Util.QBItems;
|
||||
if (d.ShowDialog() == DialogResult.Cancel) return;
|
||||
|
||||
|
||||
if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !Util.QBItems.Rows.Contains(d.SelectedQBItem))
|
||||
return;
|
||||
|
||||
Util.QDat.WorkorderItemLoanChargeAs = d.SelectedQBItem;
|
||||
//Case 299
|
||||
Util.QBI.AIObject = Util.QDat.XMLData;
|
||||
//Util.QBI.AIObject = Util.QDat;
|
||||
Util.QBI = (Integration)Util.QBI.Save();
|
||||
Util.QDat.IsDirty = false;
|
||||
goto REMOVEITEMS;
|
||||
|
||||
|
||||
case RootObjectTypes.WorkorderItemMiscExpense:
|
||||
d.CanImport = false;
|
||||
d.QBItems = Util.QBItems;
|
||||
if (d.ShowDialog() == DialogResult.Cancel) return;
|
||||
|
||||
|
||||
if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !Util.QBItems.Rows.Contains(d.SelectedQBItem))
|
||||
return;
|
||||
|
||||
Util.QDat.MiscExpenseChargeAs = d.SelectedQBItem;
|
||||
//Case 299
|
||||
Util.QBI.AIObject = Util.QDat.XMLData;
|
||||
//Util.QBI.AIObject = Util.QDat;
|
||||
Util.QBI = (Integration)Util.QBI.Save();
|
||||
Util.QDat.IsDirty = false;
|
||||
goto REMOVEITEMS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//add the new link
|
||||
IntegrationMap m = Util.QBI.Maps.Add(Util.QBI);
|
||||
m.RootObjectID = (Guid)e.Cell.Row.Cells["RootObjectID"].Value;
|
||||
m.RootObjectType = (RootObjectTypes)e.Cell.Row.Cells["ObjectType"].Value;
|
||||
m.ForeignID = d.SelectedQBItem;
|
||||
m.Name = QBItemName;
|
||||
m.LastSync = System.DateTime.Now;
|
||||
Util.QBI = (Integration)Util.QBI.Save();
|
||||
|
||||
REMOVEITEMS:
|
||||
|
||||
//remove the object from the grid as it's now dealt with
|
||||
e.Cell.Row.Delete(false);
|
||||
_ChangesMade = true;
|
||||
//If all done then close up
|
||||
if (grid.Rows.Count == 0)
|
||||
this.Close();
|
||||
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
d.Dispose();
|
||||
}
|
||||
#endregion link problem
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//eof
|
||||
}//eoc
|
||||
}//eons
|
||||
|
||||
@@ -5680,6 +5680,7 @@ namespace AyaNovaQBI
|
||||
public decimal QBPrice { get; set; }
|
||||
public long WorkOrderItemPartId { get; set; }
|
||||
public string QBListID { get; set; }
|
||||
public string Fix { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -5979,6 +5980,28 @@ namespace AyaNovaQBI
|
||||
|
||||
if (!bDuplicate)
|
||||
{
|
||||
string theFix = string.Empty;
|
||||
switch (Reason)
|
||||
{
|
||||
case MisMatchReason.NothingToInvoice:
|
||||
theFix = "Nothing to invoice";
|
||||
break;
|
||||
case MisMatchReason.PriceDifferent:
|
||||
theFix = "Fix price";
|
||||
break;
|
||||
case MisMatchReason.NotLinkedToQB:
|
||||
if (ObjectType == AyaType.Customer)
|
||||
{
|
||||
theFix = "Link / Export";
|
||||
}
|
||||
else
|
||||
{
|
||||
theFix = "Link";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Mismatches.Add(new MisMatch
|
||||
{
|
||||
Name = Name,
|
||||
@@ -5989,6 +6012,7 @@ namespace AyaNovaQBI
|
||||
QBPrice = QBPrice,
|
||||
WorkOrderItemPartId = WorkOrderItemPartId,
|
||||
QBListID = QBListID,
|
||||
Fix = theFix
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user