This commit is contained in:
2022-07-12 21:13:45 +00:00
parent 965125256a
commit e09b083c1f

View File

@@ -334,7 +334,7 @@ namespace AyaNovaQBI
if (bOneWoPerInvoice) if (bOneWoPerInvoice)
{ {
foreach(var invwo in InvoiceableWorkOrdersList) foreach (var invwo in InvoiceableWorkOrdersList)
{ {
al.Add(invwo.Id); al.Add(invwo.Id);
w.Step = "Invoicing single workorder "; w.Step = "Invoicing single workorder ";
@@ -345,16 +345,15 @@ namespace AyaNovaQBI
else else
{ {
/* //Invoice grouped by customer
var results = persons.GroupBy( var grouped = InvoiceableWorkOrdersList.GroupBy(z => z.CustomerId, z => z.Id, (Key, g) => new { CustomerId = Key, WorkOrders = g.ToList() });
p => p.PersonId, foreach (var CustomerWoGroup in grouped)
p => p.car,
(key, g) => new { PersonId = key, Cars = g.ToList() });
*/
var grouped = InvoiceableWorkOrdersList.GroupBy(z => z.CustomerId, z => z.Id, (Key, g) => new { CustomerId=Key, WorkOrders=g.ToList() });
foreach(var vv in grouped)
{ {
string sss=vv.CustomerId.ToString(); foreach (var woid in CustomerWoGroup.WorkOrders)
al.Add(woid);
w.Step = $"Batch invoicing {CustomerWoGroup.WorkOrders.Count.ToString()}{((al.Count > 1) ? " Work Orders" : " Work Order")}";
await util.Invoice(al, alErrors);
al.Clear();
} }
} }
@@ -389,38 +388,38 @@ namespace AyaNovaQBI
//} //}
//work through selected items top to bottom ////work through selected items top to bottom
foreach (DataGridViewRow r in grid.SelectedRows) //foreach (DataGridViewRow r in grid.SelectedRows)
{ //{
//clear the workorder list // //clear the workorder list
al.Clear(); // al.Clear();
if ((bool)r.Cells["Linked"].Value == true) // if ((bool)r.Cells["Linked"].Value == true)
{ // {
al.Add((long)r.Cells["id"].Value); // al.Add((long)r.Cells["id"].Value);
//case 1604 // //case 1604
if (bOneWoPerInvoice) // if (bOneWoPerInvoice)
{ // {
//then invoice it out now // //then invoice it out now
w.Step = "Invoicing single workorder "; // w.Step = "Invoicing single workorder ";
await util.Invoice(al, alErrors); // await util.Invoice(al, alErrors);
//and clear al workorders list // //and clear al workorders list
al.Clear(); // al.Clear();
} // }
} // }
}//end of foreach loop //}//end of foreach loop
{ //{
w.Step = "Invoicing " + al.Count.ToString() + ((al.Count > 1) ? " Workorders" : " Workorder"); // w.Step = "Invoicing " + al.Count.ToString() + ((al.Count > 1) ? " Workorders" : " Workorder");
await util.Invoice(al, alErrors); // await util.Invoice(al, alErrors);
} //}
w.Close(); w.Close();
//display errors if any //display errors if any