|
@@ -33,6 +33,7 @@ public class SupplierBillLineGrid : DynamicOneToManyGrid<Bill, BillLine>
|
|
|
HiddenColumns.Add(x => x.IncTax);
|
|
|
HiddenColumns.Add(x => x.Description);
|
|
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.ID);
|
|
|
HiddenColumns.Add(x=>x.OrderItem.PurchaseOrderLink.PONumber);
|
|
|
HiddenColumns.Add(x=>x.OrderItem.Product.Code);
|
|
|
HiddenColumns.Add(x=>x.OrderItem.Description);
|
|
@@ -136,29 +137,21 @@ public class SupplierBillLineGrid : DynamicOneToManyGrid<Bill, BillLine>
|
|
|
|
|
|
private bool ImportPOLines(Button arg1, CoreRow[] arg2)
|
|
|
{
|
|
|
- MultiSelectDialog<PurchaseOrderItem> dlg = new MultiSelectDialog<PurchaseOrderItem>(
|
|
|
+ var poItems = ExtractValues(x => x.OrderItem.ID, Selection.All).ToArray();
|
|
|
+
|
|
|
+ var dlg = new MultiSelectDialog<PurchaseOrderItem>(
|
|
|
new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.SupplierLink.ID).IsEqualTo(Item.SupplierLink.ID)
|
|
|
- .And(x => x.BillLine.ID).IsEqualTo(Guid.Empty),
|
|
|
- new Columns<PurchaseOrderItem>
|
|
|
- (
|
|
|
+ .And(x => x.BillLine.ID).IsEqualTo(Guid.Empty)
|
|
|
+ .And(x => x.ID).NotInList(poItems),
|
|
|
+ new Columns<PurchaseOrderItem>(
|
|
|
x => x.ID,
|
|
|
- x => x.Description,
|
|
|
- x => x.Product.Code,
|
|
|
- x => x.ReceivedDate,
|
|
|
- x => x.Consignment.Number,
|
|
|
- x => x.PurchaseOrderLink.PONumber,
|
|
|
- x => x.PurchaseOrderLink.ID,
|
|
|
x => x.Consignment.ID,
|
|
|
- x => x.Qty,
|
|
|
- x => x.ExTax,
|
|
|
- x => x.TaxRate,
|
|
|
- x => x.IncTax
|
|
|
- ));
|
|
|
+ x => x.PurchaseOrderLink.ID));
|
|
|
if (dlg.ShowDialog() == true)
|
|
|
{
|
|
|
- var imports = dlg.Items();
|
|
|
- var poids = imports.Select(x => x.PurchaseOrderLink.ID).Distinct().ToArray();
|
|
|
- var consids = imports.Select(x => x.Consignment.ID).Distinct().ToArray();
|
|
|
+ var imports = dlg.Data();
|
|
|
+ var poids = imports.ExtractValues<PurchaseOrderItem, Guid>(x => x.PurchaseOrderLink.ID).Distinct().ToArray();
|
|
|
+ var consids = imports.ExtractValues<PurchaseOrderItem, Guid>(x => x.Consignment.ID).Distinct().ToArray();
|
|
|
|
|
|
var results = Client.QueryMultiple(
|
|
|
new KeyedQueryDef<PurchaseOrderItem>(
|
|
@@ -183,15 +176,16 @@ public class SupplierBillLineGrid : DynamicOneToManyGrid<Bill, BillLine>
|
|
|
.Add(x => x.Product.Name)
|
|
|
.Add(x => x.PurchaseGL.ID)
|
|
|
.Add(x => x.CostCentre.ID)),
|
|
|
- new KeyedQueryDef<Document>(
|
|
|
- new Filter<Document>(x => x.ID).InQuery(
|
|
|
- new Filter<PurchaseOrderDocument>(x => x.EntityLink.ID).InList(poids),
|
|
|
- x => x.DocumentLink.ID)
|
|
|
- .Or(x => x.ID).InQuery(
|
|
|
- new Filter<PurchaseOrderDocument>(x => x.EntityLink.ID).InList(poids),
|
|
|
- x => x.DocumentLink.ID),
|
|
|
- new Columns<Document>(x => x.ID)
|
|
|
- .Add(x => x.FileName)));
|
|
|
+ new KeyedQueryDef<PurchaseOrderDocument>(
|
|
|
+ new Filter<PurchaseOrderDocument>(x => x.EntityLink.ID).InList(poids),
|
|
|
+ new Columns<PurchaseOrderDocument>(x => x.DocumentLink.ID)
|
|
|
+ .Add(x => x.DocumentLink.FileName)
|
|
|
+ .Add(x => x.Thumbnail)),
|
|
|
+ new KeyedQueryDef<ConsignmentDocument>(
|
|
|
+ new Filter<ConsignmentDocument>(x => x.EntityLink.ID).InList(consids),
|
|
|
+ new Columns<ConsignmentDocument>(x => x.DocumentLink.ID)
|
|
|
+ .Add(x => x.DocumentLink.FileName)
|
|
|
+ .Add(x => x.Thumbnail)));
|
|
|
|
|
|
var items = results.Get<PurchaseOrderItem>();
|
|
|
foreach (var row in items.Rows)
|
|
@@ -239,14 +233,20 @@ public class SupplierBillLineGrid : DynamicOneToManyGrid<Bill, BillLine>
|
|
|
|
|
|
if (docpage != null)
|
|
|
{
|
|
|
- var docs = results.Get<Document>();
|
|
|
- foreach (var row in docs.Rows)
|
|
|
+ var docIDs = docpage.Data.ExtractValues<BillDocument, Guid>(x => x.DocumentLink.ID).ToHashSet();
|
|
|
+ foreach(var eDoc in (results.GetObjects<PurchaseOrderDocument>() as IEnumerable<IEntityDocument>)
|
|
|
+ .Concat(results.GetObjects<ConsignmentDocument>()))
|
|
|
{
|
|
|
- var doc = new BillDocument();
|
|
|
- doc.EntityLink.ID = Item.ID;
|
|
|
- doc.DocumentLink.ID = row.Get<Document, Guid>(x => x.ID);
|
|
|
- doc.DocumentLink.FileName = row.Get<Document, string>(x => x.FileName);
|
|
|
- docpage.SaveItem(doc);
|
|
|
+ if (!docIDs.Contains(eDoc.DocumentLink.ID))
|
|
|
+ {
|
|
|
+ var doc = new BillDocument();
|
|
|
+ doc.EntityLink.ID = Item.ID;
|
|
|
+ doc.DocumentLink.ID = eDoc.DocumentLink.ID;
|
|
|
+ doc.DocumentLink.FileName = eDoc.DocumentLink.FileName;
|
|
|
+ doc.Thumbnail = eDoc.Thumbnail;
|
|
|
+ docpage.SaveItem(doc);
|
|
|
+ docIDs.Add(eDoc.DocumentLink.ID);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
docpage.Refresh(false,true);
|