Skip to main content
Solved

Ext price not updating

  • Nov 18, 2022 7:05 AM UTC
  • 10 replies
  • 226 views
  • Translate All

param2022
Jr Varsity II
Forum|alt.badge.img

In sales quotes screen I am updating the ExtPrice of the non stock items based on some other fields by calculations. But the Amount is not changing as it does when we normally change the ExtPrice of the item. Can anyone help me here with this.

Best answer by Naveen Boga

HiĀ @param2022Ā  Can you please try with the belowĀ code?

     protected void CROpportunityProducts_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
{
CROpportunityProducts row = (CROpportunityProducts)e.Row;
CROpportunityProductsExt rowExtension = row.GetExtension<CROpportunityProductsExt>();
if (row is null) return;
InventoryItem inventoryItem = PXSelectorAttribute.Select<CROpportunityProducts.inventoryID>(cache, row) as InventoryItem;
if (inventoryItem is null) return;
InventoryItemCurySettings curySettings =
InventoryItemCurySettings.PK.Find(
this.Base, inventoryItem.InventoryID, rowExtension.UsrInventoryCuryId ?? "USD");

bool isStkItem = inventoryItem.StkItem ?? false;
if (!isStkItem)
{
// get inventoryItemCurySettings extension
InventoryItemCurySettingsExt inventoryItemCurySettingsExt = curySettings.GetExtension<InventoryItemCurySettingsExt>();
if (rowExtension.UsrSelectedPriceModifier != 0 || rowExtension.UsrSelectedPriceModifier != null)
{
PriceModifier priceModifier = PXSelectorAttribute.Select<CROpportunityProductsExt.usrSelectedPriceModifier>(cache, row) as PriceModifier;
if (priceModifier != null)
{
var extPrice = row.CuryExtPrice;
decimal data = (decimal)priceModifier.Percentage / 100;
row.CuryExtPrice = rowExtension.UsrInternalExtCost + (data * rowExtension.UsrInternalExtCost);
cache.RaiseFieldUpdated<CROpportunityProducts.curyExtPrice>(row, extPrice);
}
}
}
}

Ā 

View original

10 replies

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Nov 18, 2022 7:18 AM UTC

Hi @param2022Ā  Yes

Ext.Price = Qty * Unit Price

Amount = Qty * Unit Prie - Discount AmountĀ 

  1. Do you have any customization with those fields? if yes, please unpublish and check to identify the root cause
  2. I see there are no lineĀ level discounts but any Document level discount applied
Translate

param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Nov 18, 2022 8:43 AM UTC

@Naveen BogaĀ I have customization that updates the Ext.Price for the Non Stock Items. Here is the code snippet. The Ext.price is updated but not the Amount.


Ā 

CROpportunityProducts row = (CROpportunityProducts)e.Row;

CROpportunityProductsExt rowExtension = row.GetExtension<CROpportunityProductsExt>();

row.CuryExtPrice = rowExtension.UsrInternalExtCost + (data * rowExtension.UsrInternalExtCost);

Ā 

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Nov 18, 2022 9:07 AM UTC

Hi @param2022Ā  Can you share the complete event code?

Translate

param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Nov 18, 2022 9:27 AM UTC

@Naveen BogaĀ plz see it below

protected void CROpportunityProducts_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
{
CROpportunityProducts row = (CROpportunityProducts)e.Row;
CROpportunityProductsExt rowExtension = row.GetExtension<CROpportunityProductsExt>();
if (row is null) return;
InventoryItem inventoryItem = PXSelectorAttribute.Select<CROpportunityProducts.inventoryID>(cache, row) as InventoryItem;
if (inventoryItem is null) return;
InventoryItemCurySettings curySettings =
InventoryItemCurySettings.PK.Find(
this.Base, inventoryItem.InventoryID, rowExtension.UsrInventoryCuryId ?? "USD");

bool isStkItem = inventoryItem.StkItem ?? false;
if (!isStkItem)
{
// get inventoryItemCurySettings extension
InventoryItemCurySettingsExt inventoryItemCurySettingsExt = curySettings.GetExtension<InventoryItemCurySettingsExt>();
if (rowExtension.UsrSelectedPriceModifier != 0 || rowExtension.UsrSelectedPriceModifier != null)
{
PriceModifier priceModifier = PXSelectorAttribute.Select<CROpportunityProductsExt.usrSelectedPriceModifier>(cache, row) as PriceModifier;
if (priceModifier != null)
{
decimal data = (decimal)priceModifier.Percentage / 100;
row.CuryExtPrice = rowExtension.UsrInternalExtCost + (data * rowExtension.UsrInternalExtCost);
row.ExtPrice = rowExtension.UsrInternalExtCost + (data * rowExtension.UsrInternalExtCost);
}
}
}
}

Ā 

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • Nov 18, 2022 9:49 AM UTC

HiĀ @param2022Ā  Can you please try with the belowĀ code?

     protected void CROpportunityProducts_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
{
CROpportunityProducts row = (CROpportunityProducts)e.Row;
CROpportunityProductsExt rowExtension = row.GetExtension<CROpportunityProductsExt>();
if (row is null) return;
InventoryItem inventoryItem = PXSelectorAttribute.Select<CROpportunityProducts.inventoryID>(cache, row) as InventoryItem;
if (inventoryItem is null) return;
InventoryItemCurySettings curySettings =
InventoryItemCurySettings.PK.Find(
this.Base, inventoryItem.InventoryID, rowExtension.UsrInventoryCuryId ?? "USD");

bool isStkItem = inventoryItem.StkItem ?? false;
if (!isStkItem)
{
// get inventoryItemCurySettings extension
InventoryItemCurySettingsExt inventoryItemCurySettingsExt = curySettings.GetExtension<InventoryItemCurySettingsExt>();
if (rowExtension.UsrSelectedPriceModifier != 0 || rowExtension.UsrSelectedPriceModifier != null)
{
PriceModifier priceModifier = PXSelectorAttribute.Select<CROpportunityProductsExt.usrSelectedPriceModifier>(cache, row) as PriceModifier;
if (priceModifier != null)
{
var extPrice = row.CuryExtPrice;
decimal data = (decimal)priceModifier.Percentage / 100;
row.CuryExtPrice = rowExtension.UsrInternalExtCost + (data * rowExtension.UsrInternalExtCost);
cache.RaiseFieldUpdated<CROpportunityProducts.curyExtPrice>(row, extPrice);
}
}
}
}

Ā 

Translate

param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Nov 18, 2022 11:01 AM UTC

@Naveen BogaĀ that worked thank you.

Ā 

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Nov 18, 2022 11:29 AM UTC

Glad that I helped you with the above code and thanks for sharing the update! @param2022Ā 

Translate

Hi @param2022Ā and @Naveen Boga, do you have a codeĀ that updates the Ext.Price for theĀ Stock Items? Tia.

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • May 22, 2024 2:54 AM UTC

@sharmaineongyaco56Ā  Can you please let us know when you wanted to update ExtĀ  Price field?

Translate

We want to update some incorrectĀ Ext. Price onĀ the Sales Order with already completed status.

Translate