This commit is contained in:
@@ -6122,7 +6122,7 @@ namespace AyaNovaQBI
|
||||
{
|
||||
bFirstLoop = false;
|
||||
//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
|
||||
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 (QDat.SetMemoField)
|
||||
{
|
||||
sbMemo.Append(w.WorkorderService.ServiceNumber.ToString());
|
||||
|
||||
}
|
||||
sbMemo.Append(w.Serial.ToString());
|
||||
|
||||
|
||||
#region Invoice header text
|
||||
@@ -6164,7 +6161,7 @@ namespace AyaNovaQBI
|
||||
|
||||
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)
|
||||
@@ -6184,33 +6181,32 @@ namespace AyaNovaQBI
|
||||
|
||||
if (s.IndexOf("~PROJ~") != -1)
|
||||
{
|
||||
if (w.ProjectID == Guid.Empty)
|
||||
s = s.Replace("~PROJ~", "");
|
||||
else
|
||||
s = s.Replace("~PROJ~", NameFetcher.GetItem("aProject", "aName", w.ProjectID).RecordName);
|
||||
//no need to check if empty or not set as server populates this only if there is something anyway
|
||||
s = s.Replace("~PROJ~", w.ProjectViz);//if necessary to provide an empty string instead of null can do a null coalesce here
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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 (w.WorkorderService.WorkorderStatusID == Guid.Empty)
|
||||
s = s.Replace("~STAT~", "");
|
||||
else
|
||||
s = s.Replace("~STAT~", NameFetcher.GetItem("aWorkorderStatus", "aName", w.WorkorderService.WorkorderStatusID).RecordName);
|
||||
s = s.Replace("~STAT~", w.LastStateNameViz);
|
||||
}
|
||||
|
||||
if (s.IndexOf("~DESC~") != -1)
|
||||
{
|
||||
s = s.Replace("~DESC~", w.Summary);
|
||||
s = s.Replace("~DESC~", w.Notes);
|
||||
}
|
||||
|
||||
InvoiceAddText(i, s);
|
||||
@@ -6218,78 +6214,58 @@ namespace AyaNovaQBI
|
||||
#endregion header text
|
||||
|
||||
#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-----------------
|
||||
//Added:20-July-2006 to incorporate discounts on parts into qb invoice
|
||||
decimal charge;
|
||||
|
||||
//Case 269 this is incorrect:
|
||||
//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 != "")
|
||||
InvoiceAddCharge(i, QBIntegration.Items.First(z => z.ObjectId == p.PartId && z.AType == AyaType.Part).IntegrationItemId, p.Quantity, p.PriceViz);
|
||||
string sn = p.Serials;
|
||||
if (!string.IsNullOrWhiteSpace(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)
|
||||
if (!string.IsNullOrWhiteSpace(p.Description))
|
||||
InvoiceAddText(i, p.Description);
|
||||
|
||||
}
|
||||
}
|
||||
#endregion part 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
|
||||
if (l.ServiceBankID != Guid.Empty)
|
||||
{
|
||||
InvoiceAddCharge(i, QBI.Maps[l.ServiceRateID].ForeignID, l.ServiceRateQuantity, 0);
|
||||
//if (l.ServiceBankID != Guid.Empty)
|
||||
//{
|
||||
// InvoiceAddCharge(i, QBI.Maps[l.ServiceRateID].ForeignID, l.ServiceRateQuantity, 0);
|
||||
|
||||
}
|
||||
else
|
||||
InvoiceAddCharge(i, QBI.Maps[l.ServiceRateID].ForeignID, l.ServiceRateQuantity,
|
||||
AyaRateList[l.ServiceRateID].Charge);
|
||||
//}
|
||||
//else
|
||||
InvoiceAddCharge(i,
|
||||
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
|
||||
|
||||
#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
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -6301,9 +6277,9 @@ namespace AyaNovaQBI
|
||||
#endregion MiscExpense 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);
|
||||
|
||||
@@ -6312,7 +6288,7 @@ namespace AyaNovaQBI
|
||||
#endregion Loaner 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))
|
||||
{
|
||||
@@ -6329,10 +6305,10 @@ namespace AyaNovaQBI
|
||||
//inserting descriptive text as required
|
||||
if (QDat.HasAnyInvoiceFooterTemplateFields)
|
||||
{
|
||||
foreach (WorkorderItem it in w.WorkorderItems)
|
||||
foreach (var it in w.Items)
|
||||
{
|
||||
#region Item (footer) fields
|
||||
if (QDat.InvoiceFooterTemplate != "")
|
||||
if (!string.IsNullOrWhiteSpace(QDat.InvoiceFooterTemplate))
|
||||
{
|
||||
string s = QDat.InvoiceFooterTemplate;
|
||||
|
||||
@@ -6372,8 +6348,10 @@ namespace AyaNovaQBI
|
||||
#endregion item
|
||||
|
||||
#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;
|
||||
|
||||
UnitPickList up = UnitPickList.GetListOfOneSpecificUnit(it.UnitID);
|
||||
@@ -6418,9 +6396,9 @@ namespace AyaNovaQBI
|
||||
#endregion unit
|
||||
|
||||
#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;
|
||||
|
||||
@@ -6469,9 +6447,9 @@ namespace AyaNovaQBI
|
||||
#endregion service
|
||||
|
||||
#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;
|
||||
|
||||
@@ -6522,8 +6500,13 @@ namespace AyaNovaQBI
|
||||
#endregion travel fields
|
||||
|
||||
#region Outside fields
|
||||
if (QDat.OutsideServiceChargeAs != "" && it.HasOutsideService)
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(QDat.OutsideServiceChargeAs))
|
||||
{
|
||||
foreach (var os in it.OutsideServices)
|
||||
{
|
||||
TODO: LOOPIFY FROM ANOTHER this inside biody
|
||||
string s = QDat.InvoiceOutsideServiceTemplate;
|
||||
|
||||
if (s.IndexOf("~REPAIR_PRICE~") != -1)
|
||||
@@ -6550,6 +6533,7 @@ namespace AyaNovaQBI
|
||||
{
|
||||
s = s.Replace("~NOTES~", it.OutsideService.Notes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6558,9 +6542,9 @@ namespace AyaNovaQBI
|
||||
#endregion outside service
|
||||
|
||||
#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;
|
||||
|
||||
@@ -6590,9 +6574,9 @@ namespace AyaNovaQBI
|
||||
#endregion misc expense
|
||||
|
||||
#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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user