This commit is contained in:
@@ -6039,8 +6039,8 @@ namespace AyaNovaQBI
|
|||||||
AyaPrice = AyaPrice,
|
AyaPrice = AyaPrice,
|
||||||
QBPrice = QBPrice,
|
QBPrice = QBPrice,
|
||||||
WorkOrderItemPartId = WorkOrderItemPartId,
|
WorkOrderItemPartId = WorkOrderItemPartId,
|
||||||
WorkOrderItemId=WorkOrderItemId,
|
WorkOrderItemId = WorkOrderItemId,
|
||||||
WorkOrderId=WorkOrderId,
|
WorkOrderId = WorkOrderId,
|
||||||
QBListID = QBListID,
|
QBListID = QBListID,
|
||||||
Fix = theFix
|
Fix = theFix
|
||||||
});
|
});
|
||||||
@@ -6110,7 +6110,7 @@ namespace AyaNovaQBI
|
|||||||
bool bFirstLoop = true;
|
bool bFirstLoop = true;
|
||||||
|
|
||||||
//Loop through alworkorders
|
//Loop through alworkorders
|
||||||
foreach (long SelectedWorkOrderId in selectedWorkOrderIdList)
|
foreach (long SelectedWorkOrderId in selectedWorkOrderIdList)
|
||||||
{
|
{
|
||||||
var woReponse = await GetAsync($"workorder/{SelectedWorkOrderId}");
|
var woReponse = await GetAsync($"workorder/{SelectedWorkOrderId}");
|
||||||
WorkOrder w = woReponse.ObjectResponse["data"].ToObject<WorkOrder>();
|
WorkOrder w = woReponse.ObjectResponse["data"].ToObject<WorkOrder>();
|
||||||
@@ -6122,7 +6122,7 @@ namespace AyaNovaQBI
|
|||||||
{
|
{
|
||||||
bFirstLoop = false;
|
bFirstLoop = false;
|
||||||
//Set client
|
//Set client
|
||||||
i.CustomerRef.ListID.SetValue(QBI.Maps[w.ClientID].ForeignID);
|
i.CustomerRef.ListID.SetValue(QBIntegration.Items.First(z => z.ObjectId == w.CustomerId && z.AType == AyaType.Customer).IntegrationItemId);
|
||||||
|
|
||||||
//Set QB Invoice template
|
//Set QB Invoice template
|
||||||
if (!(QVersion < 3))//templates are qbxml 3 or greater
|
if (!(QVersion < 3))//templates are qbxml 3 or greater
|
||||||
@@ -6151,10 +6151,7 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
//if set memo true then build memo string from workorder service numbers etc
|
//if set memo true then build memo string from workorder service numbers etc
|
||||||
if (QDat.SetMemoField)
|
if (QDat.SetMemoField)
|
||||||
{
|
sbMemo.Append(w.Serial.ToString());
|
||||||
sbMemo.Append(w.WorkorderService.ServiceNumber.ToString());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region Invoice header text
|
#region Invoice header text
|
||||||
@@ -6164,7 +6161,7 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
if (s.IndexOf("~WO#~") != -1)
|
if (s.IndexOf("~WO#~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~WO#~", w.WorkorderService.ServiceNumber.ToString());
|
s = s.Replace("~WO#~", w.Serial.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~CONTACT~") != -1)
|
if (s.IndexOf("~CONTACT~") != -1)
|
||||||
@@ -6184,33 +6181,32 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
if (s.IndexOf("~PROJ~") != -1)
|
if (s.IndexOf("~PROJ~") != -1)
|
||||||
{
|
{
|
||||||
if (w.ProjectID == Guid.Empty)
|
//no need to check if empty or not set as server populates this only if there is something anyway
|
||||||
s = s.Replace("~PROJ~", "");
|
s = s.Replace("~PROJ~", w.ProjectViz);//if necessary to provide an empty string instead of null can do a null coalesce here
|
||||||
else
|
|
||||||
s = s.Replace("~PROJ~", NameFetcher.GetItem("aProject", "aName", w.ProjectID).RecordName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~CLIENT~") != -1)
|
if (s.IndexOf("~CLIENT~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~CLIENT~", NameFetcher.GetItem("aClient", "aName", w.ClientID).RecordName);
|
s = s.Replace("~CLIENT~", w.CustomerViz);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~SERVDATE~") != -1)
|
if (s.IndexOf("~SERVDATE~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~SERVDATE~", w.WorkorderService.ServiceDate.ToString());
|
var servDateString = "-";
|
||||||
|
if (w.ServiceDate != null)
|
||||||
|
servDateString = ((DateTime)w.ServiceDate).ToLocalTime().ToString();
|
||||||
|
s = s.Replace("~SERVDATE~", servDateString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~STAT~") != -1)
|
if (s.IndexOf("~STAT~") != -1)
|
||||||
{
|
{
|
||||||
if (w.WorkorderService.WorkorderStatusID == Guid.Empty)
|
s = s.Replace("~STAT~", w.LastStateNameViz);
|
||||||
s = s.Replace("~STAT~", "");
|
|
||||||
else
|
|
||||||
s = s.Replace("~STAT~", NameFetcher.GetItem("aWorkorderStatus", "aName", w.WorkorderService.WorkorderStatusID).RecordName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~DESC~") != -1)
|
if (s.IndexOf("~DESC~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~DESC~", w.Summary);
|
s = s.Replace("~DESC~", w.Notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceAddText(i, s);
|
InvoiceAddText(i, s);
|
||||||
@@ -6218,78 +6214,58 @@ namespace AyaNovaQBI
|
|||||||
#endregion header text
|
#endregion header text
|
||||||
|
|
||||||
#region Part charges
|
#region Part charges
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (var it in w.Items)
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemPart p in it.Parts)
|
foreach (var p in it.Parts)
|
||||||
{
|
{
|
||||||
//------------DISCOUNT-----------------
|
InvoiceAddCharge(i, QBIntegration.Items.First(z => z.ObjectId == p.PartId && z.AType == AyaType.Part).IntegrationItemId, p.Quantity, p.PriceViz);
|
||||||
//Added:20-July-2006 to incorporate discounts on parts into qb invoice
|
string sn = p.Serials;
|
||||||
decimal charge;
|
if (!string.IsNullOrWhiteSpace(sn))
|
||||||
|
InvoiceAddText(i, "SN: " + sn);
|
||||||
//Case 269 this is incorrect:
|
if (!string.IsNullOrWhiteSpace(p.Description))
|
||||||
//charge = decimal.Round(p.Quantity * p.Price, 2, MidpointRounding.AwayFromZero);
|
|
||||||
charge = decimal.Round(1 * p.Price, 2, MidpointRounding.AwayFromZero);
|
|
||||||
|
|
||||||
|
|
||||||
charge = charge - (decimal.Round(charge * p.Discount, 2, MidpointRounding.AwayFromZero));
|
|
||||||
//-----------------------------
|
|
||||||
|
|
||||||
InvoiceAddCharge(i, QBI.Maps[p.PartID].ForeignID, p.Quantity, charge);
|
|
||||||
string sn = "";
|
|
||||||
if (p.PartSerialID != Guid.Empty)
|
|
||||||
{
|
|
||||||
sn = PartSerial.GetSerialNumberFromPartSerialID(p.PartSerialID);
|
|
||||||
if (sn != "")
|
|
||||||
InvoiceAddText(i, "SN: " + sn);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Added:18-Nov-2006 case 125
|
|
||||||
//checks for nonempty description, also checks to see if description is
|
|
||||||
//same as serial number because it's copied there in some cases and no sense
|
|
||||||
//in showing it twice
|
|
||||||
if (p.Description != "" && sn != p.Description)
|
|
||||||
InvoiceAddText(i, p.Description);
|
InvoiceAddText(i, p.Description);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion part charges
|
#endregion part charges
|
||||||
|
|
||||||
#region Service charges
|
#region Service charges
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (var it in w.Items)
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemLabor l in it.Labors)
|
foreach (var l in it.Labors)
|
||||||
{
|
{
|
||||||
//Added 20-July-2006 to not charge for banked hours
|
//Added 20-July-2006 to not charge for banked hours
|
||||||
if (l.ServiceBankID != Guid.Empty)
|
//if (l.ServiceBankID != Guid.Empty)
|
||||||
{
|
//{
|
||||||
InvoiceAddCharge(i, QBI.Maps[l.ServiceRateID].ForeignID, l.ServiceRateQuantity, 0);
|
// InvoiceAddCharge(i, QBI.Maps[l.ServiceRateID].ForeignID, l.ServiceRateQuantity, 0);
|
||||||
|
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
InvoiceAddCharge(i, QBI.Maps[l.ServiceRateID].ForeignID, l.ServiceRateQuantity,
|
InvoiceAddCharge(i,
|
||||||
AyaRateList[l.ServiceRateID].Charge);
|
QBIntegration.Items.First(z => z.ObjectId == l.ServiceRateId && z.AType == AyaType.ServiceRate).IntegrationItemId,
|
||||||
|
l.ServiceRateQuantity,
|
||||||
|
AyaServiceRateList.First(z => z.Id == l.ServiceRateId).Charge);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion Service charges
|
#endregion Service charges
|
||||||
|
|
||||||
#region Travel charges
|
#region Travel charges
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (var it in w.Items)
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemTravel l in it.Travels)
|
foreach (var l in it.Travels)
|
||||||
{
|
{
|
||||||
InvoiceAddCharge(i, QBI.Maps[l.TravelRateID].ForeignID, l.TravelRateQuantity, AyaRateList[l.TravelRateID].Charge);
|
InvoiceAddCharge(i,
|
||||||
|
QBIntegration.Items.First(z => z.ObjectId == l.TravelRateId && z.AType == AyaType.TravelRate).IntegrationItemId,
|
||||||
|
l.TravelRateQuantity,
|
||||||
|
AyaTravelRateList.First(z => z.Id == l.TravelRateId).Charge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion Travel charges
|
#endregion Travel charges
|
||||||
|
|
||||||
#region MiscExpense charges
|
#region MiscExpense charges
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (var it in w.Items)
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemMiscExpense l in it.Expenses)
|
foreach (var l in it.Expenses)
|
||||||
{
|
{
|
||||||
if (l.ChargeToClient)
|
if (l.ChargeToClient)
|
||||||
{
|
{
|
||||||
@@ -6301,9 +6277,9 @@ namespace AyaNovaQBI
|
|||||||
#endregion MiscExpense charges
|
#endregion MiscExpense charges
|
||||||
|
|
||||||
#region Loaner charges
|
#region Loaner charges
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (var it in w.Items)
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemLoan l in it.Loans)
|
foreach (var l in it.Loans)
|
||||||
{
|
{
|
||||||
InvoiceAddCharge(i, QDat.WorkorderItemLoanChargeAs, 1, l.Charges);
|
InvoiceAddCharge(i, QDat.WorkorderItemLoanChargeAs, 1, l.Charges);
|
||||||
|
|
||||||
@@ -6312,7 +6288,7 @@ namespace AyaNovaQBI
|
|||||||
#endregion Loaner charges
|
#endregion Loaner charges
|
||||||
|
|
||||||
#region OutsideService charges
|
#region OutsideService charges
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (var it in w.Items)
|
||||||
{
|
{
|
||||||
if (it.HasOutsideService && (it.OutsideService.ShippingPrice != 0 || it.OutsideService.RepairPrice != 0))
|
if (it.HasOutsideService && (it.OutsideService.ShippingPrice != 0 || it.OutsideService.RepairPrice != 0))
|
||||||
{
|
{
|
||||||
@@ -6329,10 +6305,10 @@ namespace AyaNovaQBI
|
|||||||
//inserting descriptive text as required
|
//inserting descriptive text as required
|
||||||
if (QDat.HasAnyInvoiceFooterTemplateFields)
|
if (QDat.HasAnyInvoiceFooterTemplateFields)
|
||||||
{
|
{
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (var it in w.Items)
|
||||||
{
|
{
|
||||||
#region Item (footer) fields
|
#region Item (footer) fields
|
||||||
if (QDat.InvoiceFooterTemplate != "")
|
if (!string.IsNullOrWhiteSpace(QDat.InvoiceFooterTemplate))
|
||||||
{
|
{
|
||||||
string s = QDat.InvoiceFooterTemplate;
|
string s = QDat.InvoiceFooterTemplate;
|
||||||
|
|
||||||
@@ -6372,8 +6348,10 @@ namespace AyaNovaQBI
|
|||||||
#endregion item
|
#endregion item
|
||||||
|
|
||||||
#region Unit fields
|
#region Unit fields
|
||||||
if (QDat.InvoiceUnitTemplate != "" && it.UnitID != Guid.Empty)
|
if (!string.IsNullOrWhiteSpace(QDat.InvoiceUnitTemplate))
|
||||||
{
|
{
|
||||||
|
TODO: LOOPIFY THIS BLOCK TO NEW STANDARD
|
||||||
|
|
||||||
string s = QDat.InvoiceUnitTemplate;
|
string s = QDat.InvoiceUnitTemplate;
|
||||||
|
|
||||||
UnitPickList up = UnitPickList.GetListOfOneSpecificUnit(it.UnitID);
|
UnitPickList up = UnitPickList.GetListOfOneSpecificUnit(it.UnitID);
|
||||||
@@ -6418,9 +6396,9 @@ namespace AyaNovaQBI
|
|||||||
#endregion unit
|
#endregion unit
|
||||||
|
|
||||||
#region Labor fields
|
#region Labor fields
|
||||||
if (QDat.InvoiceServiceTemplate != "" && it.HasLabor)
|
if (!string.IsNullOrWhiteSpace(QDat.InvoiceServiceTemplate))
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemLabor wl in it.Labors)
|
foreach (var wl in it.Labors)
|
||||||
{
|
{
|
||||||
string s = QDat.InvoiceServiceTemplate;
|
string s = QDat.InvoiceServiceTemplate;
|
||||||
|
|
||||||
@@ -6469,9 +6447,9 @@ namespace AyaNovaQBI
|
|||||||
#endregion service
|
#endregion service
|
||||||
|
|
||||||
#region Travel fields
|
#region Travel fields
|
||||||
if (QDat.InvoiceTravelTemplate != "" && it.HasTravel)
|
if (!string.IsNullOrWhiteSpace(QDat.InvoiceTravelTemplate))
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemTravel wt in it.Travels)
|
foreach (var wt in it.Travels)
|
||||||
{
|
{
|
||||||
string s = QDat.InvoiceTravelTemplate;
|
string s = QDat.InvoiceTravelTemplate;
|
||||||
|
|
||||||
@@ -6522,33 +6500,39 @@ namespace AyaNovaQBI
|
|||||||
#endregion travel fields
|
#endregion travel fields
|
||||||
|
|
||||||
#region Outside fields
|
#region Outside fields
|
||||||
if (QDat.OutsideServiceChargeAs != "" && it.HasOutsideService)
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(QDat.OutsideServiceChargeAs))
|
||||||
{
|
{
|
||||||
string s = QDat.InvoiceOutsideServiceTemplate;
|
foreach (var os in it.OutsideServices)
|
||||||
|
|
||||||
if (s.IndexOf("~REPAIR_PRICE~") != -1)
|
|
||||||
{
|
{
|
||||||
s = s.Replace("~REPAIR_PRICE~", it.OutsideService.RepairPrice.ToString("c"));
|
TODO: LOOPIFY FROM ANOTHER this inside biody
|
||||||
}
|
string s = QDat.InvoiceOutsideServiceTemplate;
|
||||||
|
|
||||||
if (s.IndexOf("~SHIP_CHARGE~") != -1)
|
if (s.IndexOf("~REPAIR_PRICE~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~SHIP_CHARGE~", it.OutsideService.ShippingPrice.ToString("c"));
|
s = s.Replace("~REPAIR_PRICE~", it.OutsideService.RepairPrice.ToString("c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~SENT~") != -1)
|
if (s.IndexOf("~SHIP_CHARGE~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~SENT~", it.OutsideService.DateSent.ToString());
|
s = s.Replace("~SHIP_CHARGE~", it.OutsideService.ShippingPrice.ToString("c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~RETURNED~") != -1)
|
if (s.IndexOf("~SENT~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~RETURNED~", it.OutsideService.DateReturned.ToString());
|
s = s.Replace("~SENT~", it.OutsideService.DateSent.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.IndexOf("~NOTES~") != -1)
|
if (s.IndexOf("~RETURNED~") != -1)
|
||||||
{
|
{
|
||||||
s = s.Replace("~NOTES~", it.OutsideService.Notes);
|
s = s.Replace("~RETURNED~", it.OutsideService.DateReturned.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.IndexOf("~NOTES~") != -1)
|
||||||
|
{
|
||||||
|
s = s.Replace("~NOTES~", it.OutsideService.Notes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -6558,9 +6542,9 @@ namespace AyaNovaQBI
|
|||||||
#endregion outside service
|
#endregion outside service
|
||||||
|
|
||||||
#region Misc expense fields
|
#region Misc expense fields
|
||||||
if (QDat.InvoiceMiscExpenseTemplate != "" && it.HasExpenses)
|
if (!string.IsNullOrWhiteSpace(QDat.InvoiceMiscExpenseTemplate))
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemMiscExpense e in it.Expenses)
|
foreach (var e in it.Expenses)
|
||||||
{
|
{
|
||||||
string s = QDat.InvoiceMiscExpenseTemplate;
|
string s = QDat.InvoiceMiscExpenseTemplate;
|
||||||
|
|
||||||
@@ -6590,9 +6574,9 @@ namespace AyaNovaQBI
|
|||||||
#endregion misc expense
|
#endregion misc expense
|
||||||
|
|
||||||
#region Loan item fields
|
#region Loan item fields
|
||||||
if (QDat.InvoiceLoanItemTemplate != "" && it.HasLoans)
|
if (!string.IsNullOrWhiteSpace(QDat.InvoiceLoanItemTemplate))
|
||||||
{
|
{
|
||||||
foreach (WorkorderItemLoan l in it.Loans)
|
foreach (var l in it.Loans)
|
||||||
{
|
{
|
||||||
string s = QDat.InvoiceLoanItemTemplate;
|
string s = QDat.InvoiceLoanItemTemplate;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user