Solved

Sales Order Screen - Pricing Analysis should not show the Zero cost items

  • 20 December 2021
  • 6 replies
  • 142 views

Userlevel 3
Badge

Hello Everyone,

One of our clients using the Pricing Analysis functionality in the Sales Order screen, but we do not want to show the Zero unit cost items on it.

If anyone knows about this functionality could you please let us know how can we achieve this? Please find the some screenshots for your reference.

 

 

 

icon

Best answer by Dhiren Chhapgar 27 December 2021, 05:16

View original

6 replies

Userlevel 7
Badge +9

Hi @nsmith51 The easier way is to train the users to filter Unit Cost column in the grid as Not Equals Zero. 

Userlevel 7
Badge +9

Hi @nsmith51 The other solutions is to Customize as below:

  1. Add a checkbox “Do Not Show 0.00 cost”
  2. In the Code, based on the checkbox, the conditional logic should switch the BQL views with additional condition in<Where> stating Unit Cost <>0

Thanks

Userlevel 3
Badge

Hi @ChandrasekharM  With that filter, it will filter only non zero unit cost items, but we need to avoid the Unit Cost 0 items, because these items are getting involved in the average pricing calculations.

Userlevel 3
Badge

Hi @Dhiren Chhapgar  I took your code from below GIT Hub (https://github.com/Acumatica/Acumatica-PricingAnalysis/tree/2020 ) and created on top of customization and tried all the possible ways to avoid the Zero cost items in the Pricing Analysis grid. 

Below is sample code which I have tried to override the view delegate and added this ( if (orgLine.CuryExtCost > 0m)) condition, but still not working. :(

 

Could you please help me on this?

using PX.Data;
using PX.Objects.IN;
using PX.PricingAnalysis.Ext;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace PricingAnalysisExt
{
public abstract class PricingAnalysisGraphExt<TGraph, TPrimary> : PricingAnalysisGraph<TGraph, TPrimary>
where TGraph : PXGraph
where TPrimary : class, IBqlTable, new()
{
[PXOverride]
public override void InitializePreviewData()
{
int iRecordCounter = 0;

foreach (DocumentLine orgLine in DocumentLineData.Select())
{
if (orgLine.CuryExtCost > 0m)
{
if (!orgLine.IsStockItem.GetValueOrDefault(false) || orgLine.OrderQty.GetValueOrDefault(0) <= 0) { continue; }

var inventoryItem = InventoryItem.PK.Find(Base, orgLine.InventoryID);

PricingAnalysisPreviewLine line = new PricingAnalysisPreviewLine()
{
RecordID = iRecordCounter++,
LineNbr = orgLine.LineNbr,
LineType = ProfitLineType.CurrentLineType,
InventoryID = orgLine.InventoryID,
InventoryIDDisplay = inventoryItem.InventoryCD,
InventoryDescription = inventoryItem.Descr,
IsLastCostUsed = orgLine.IsLastCostUsed,
UOM = orgLine.UOM,
OrderQty = orgLine.OrderQty,
OrderQtyDisplay = orgLine.OrderQty,
CuryDiscAmt = orgLine.CuryDiscAmt,
CuryUnitPrice = orgLine.CuryUnitPrice,
CuryExtCost = orgLine.CuryExtCost,
CuryExtCostDisplay = orgLine.CuryExtCost,
CuryLineAmt = orgLine.CuryLineAmt,
CuryProfit = orgLine.CuryLineAmt - orgLine.CuryExtCost,
MarkupPercent = PXPriceCostAttribute.Round((decimal)((orgLine.CuryExtCost != 0) ? ((orgLine.CuryLineAmt - orgLine.CuryExtCost) / orgLine.CuryExtCost) * 100 : 0m)),
MarginPercent = PXPriceCostAttribute.Round((decimal)((orgLine.CuryLineAmt != 0) ? ((orgLine.CuryLineAmt - orgLine.CuryExtCost) / orgLine.CuryLineAmt) * 100 : 0m))
};
//if (line.CuryExtCost.GetValueOrDefault(0) <= 0m) { line.MarkupPercent = null; }
line = PricingAnalysisPreview.Insert(line);
PricingAnalysisPreview.Cache.SetStatus(line, PXEntryStatus.Held);
PricingAnalysisPreviewLine prvLine = PXCache<PricingAnalysisPreviewLine>.CreateCopy(line);
prvLine.RecordID = iRecordCounter++;
prvLine.LineType = ProfitLineType.PreviewLineType;
prvLine.InventoryIDDisplay = null;
prvLine.InventoryDescription = null;
prvLine.OrderQtyDisplay = null;
prvLine.UOM = null;
prvLine.CuryExtCostDisplay = null;
prvLine = PricingAnalysisPreview.Insert(prvLine);
PricingAnalysisPreview.Cache.SetStatus(prvLine, PXEntryStatus.Held);
}
}
InitializeFreightPreviewData(iRecordCounter);
}
}
}

CC: @community-admin 

Userlevel 2

​Hi @nsmith51 , We have couple options here. 

Option # 1 :

You can modify source of this extension as per your need since Pricing Analysis is open source solution. Add additional check to exclude lines with 0 cost in InitializePreviewData and InitializeFreightPreviewData. And use this modified compiled library.

Example:

Replace below line in PricingAnalysisGraph.cs


with  

if (!orgLine.IsStockItem.GetValueOrDefault(false) || orgLine.OrderQty.GetValueOrDefault(0) <= 0 || orgLine.CuryExtCost.GetValueOrDefault(0) <= 0) { continue; }.

Option # 2 :

Create second level extension and exclude 0 cost lines in view delegate as below.

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using PX.Data;
using PX.Objects.SO;
using PX.PricingAnalysis.Ext;

namespace PXPricingAnalysisPXExt
{
public class SOOrderEntryPricingAnalysisExt2 :
PXGraphExtension<SOOrderEntryPricingAnalysisExt, SOOrderEntry>
{
//View Delegate of PricingAnalysisPreview
public IEnumerable pricingAnalysisPreview()
{
//Locate Graph implementing PricingAnalysisGraph.
SOOrderEntryPricingAnalysisExt paGraph =
Base.GetExtension<SOOrderEntryPricingAnalysisExt>();
//Get data from Base
IEnumerable<PricingAnalysisPreviewLine> datalist =
paGraph.pricingAnalysisPreview().Cast<PricingAnalysisPreviewLine>();
//Exclude zero cost preview lines.
return datalist.Where(x => x.CuryExtCost.GetValueOrDefault(0) > 0);
}
}
}

 

Userlevel 3
Badge

Hi @Dhiren Chhapgar  Thanks a lot, it is working great.

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