Solved

Creating a pop up to show various vendor pricing

  • 23 June 2022
  • 1 reply
  • 79 views

I need to create a link on each line item(Inventory Item on a sales order) of the graph on page PO505000 that will pop up a screen showing all of the vendors for that item and the cost from each vendor. Any ideas how to approach this?  

icon

Best answer by JKurtz29 23 June 2022, 20:02

View original

1 reply

Userlevel 2
Badge

Hello,

We did something similar with a POOrderEntry graph extension that uses the in-field warning to create a hint/message that shows the quantity pricing for the current vendor.  Maybe you could use that as a basis to create what you need to show multiple vendor’s prices?

Here’s the graph extension’s code:

 

using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.AP;
using System;
using System.Text;

namespace PX.Objects.PO
{
public class POOrderEntry_ExtensionAI : PXGraphExtension<POOrderEntry>
{
public static bool IsActive() => true;

#region Event Handlers

protected void _(Events.RowUpdated<POLine> e)
{
var row = (POLine)e.Row;
if (row == null || row.InventoryID == null || row.OrderQty == null) return;

PXUIFieldAttribute.SetWarning<POLine.curyUnitCost>(Base.Transactions.Cache, row, null);
string msg = GetQtyMessage(row.InventoryID, row.VendorID, row.OrderQty, row.RequestedDate);
PXUIFieldAttribute.SetWarning<POLine.curyUnitCost>(Base.Transactions.Cache, row, msg);
}

protected decimal GetItemQtyTotalOnPO(int? inventoryID)
{
decimal retval = 0;

foreach(POLine line in Base.Transactions.Select())
{
if (line.InventoryID == inventoryID)
{
retval += line.OrderQty ?? 0;
}
}
return retval;
}

protected string GetQtyMessage(int? inventoryID, int? vendorID, decimal? lineQty, DateTime? requestedDate)
{
if (inventoryID == null || vendorID == null || lineQty == null) return null;

StringBuilder p = new StringBuilder();
decimal orderQty = GetItemQtyTotalOnPO(inventoryID);
if (requestedDate == null) requestedDate = Base.Accessinfo.BusinessDate;

var prices =
SelectFrom<APVendorPrice>
.Where<APVendorPrice.inventoryID.IsEqual<@P.AsInt>
.And<APVendorPrice.vendorID.IsEqual<@P.AsInt>>
.And<APVendorPrice.effectiveDate.IsLessEqual<@P.AsDateTime>
.Or<APVendorPrice.effectiveDate.IsNull>>
.And<APVendorPrice.expirationDate.IsGreaterEqual<@P.AsDateTime>
.Or<APVendorPrice.expirationDate.IsNull>>>
.View.ReadOnly.Select(Base, inventoryID, vendorID, requestedDate, requestedDate);


if (prices == null) return null;

p.AppendLine("Quantity pricing available:");
foreach (APVendorPrice price in prices)
{
p.AppendLine($"{price.BreakQty:n2} @ {price.SalesPrice:n2}");
}
p.AppendLine("");
p.AppendLine($"You have {orderQty:n2} on this Purchase Order");
return p.ToString();
}
#endregion
}
}

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved