Skip to main content
Answer

Pulling Unit Cost from InventoryItemCurySettings for Sales Quotes

  • January 29, 2024
  • 1 reply
  • 72 views

Forum|alt.badge.img+8

Hello everyone,

 

I am attempting to pull the unit cost for Sales Quotes from InventoryItemCurySettings to automate our gross profit calculations.

Has anyone had any luck doing so?

 

Thanks,

Aleks

Best answer by aiwan

protected virtual void _(Events.FieldUpdated<CROpportunityProducts, CROpportunityProducts.inventoryID> e)
{
CROpportunityProducts row = e.Row;
if(row.InventoryID == null) return;

if(row.InventoryID != null)
{
InventoryItemCurySettings curySettings = SelectFrom<InventoryItemCurySettings>.
Where<InventoryItemCurySettings.inventoryID.IsEqual<@P.AsInt>>.View.Select(Base, row.InventoryID);

var unitCost = curySettings.StdCost;

e.Cache.SetValueExt<CROpportunityProducts.unitCost>(row, unitCost);
}
}

 

1 reply

Forum|alt.badge.img+8
  • Author
  • Captain II
  • Answer
  • May 22, 2024
protected virtual void _(Events.FieldUpdated<CROpportunityProducts, CROpportunityProducts.inventoryID> e)
{
CROpportunityProducts row = e.Row;
if(row.InventoryID == null) return;

if(row.InventoryID != null)
{
InventoryItemCurySettings curySettings = SelectFrom<InventoryItemCurySettings>.
Where<InventoryItemCurySettings.inventoryID.IsEqual<@P.AsInt>>.View.Select(Base, row.InventoryID);

var unitCost = curySettings.StdCost;

e.Cache.SetValueExt<CROpportunityProducts.unitCost>(row, unitCost);
}
}