Skip to main content

I facing the issue with the unitcost field where datatype is decimal(25,6) and in the DAC, i have used 
>PXDBDecimal(typeof(Search<CommonSetup.decPlPrcCst>))]. In Company Screen i have set Price/Cost  = 4 still its defaulting 6 decimal place. please guide if missed any thing to default from the company set up.

 

 

Hi @harikanthm60  Can you please share the DAC field?


 @Naveen Boga  i have shared the dac field

#region UnitCost
        public abstract class unitCost : PX.Data.BQL.BqlDecimal.Field<unitCost>
        {
        }
        protected decimal? _UnitCost;
        //tPXDBPriceCost(MinValue = 0)]
        nPXDBDecimal(typeof(Search<CommonSetup.decPlPrcCst>))]
        cPXDefault(TypeCode.Decimal, "0.0", typeof(Coalesce<Search<INItemSite.tranUnitCost, Where<INItemSite.inventoryID, 
            Equal<Current<TSProdFormula.inventoryID>>, And<INItemSite.siteID, Equal<Current<TSProdFormula.siteID>>>>>,
            Search<INItemCost.tranUnitCost, Where<INItemCost.inventoryID, Equal<Current<TSProdFormula.inventoryID>>>>>))]
        nPXUIField(DisplayName = "Unit Cost",Enabled =false,IsReadOnly = true)]
        public virtual decimal? UnitCost
        {
            get
            {
                return this._UnitCost;
            }
            set
            {
                this._UnitCost = value;
            }
        }
        #endregion


@harikanthm60  Can you please try with below instead of this -   PXDBDecimal(typeof(Search<CommonSetup.decPlPrcCst>))]

 

I have not tested but can you try with the below one?

oPXPriceCost]


I have tried Using >PXPriceCost] its not working. @Naveen Boga 

 


@harikanthm60  Sorry for the multiple posts. gPXDBPriceCost] should work.

Have you tried this already?


@Naveen Boga i have already tried  nPXDBPriceCost] an i pasted the DAC please do check its not working.


@Naveen Boga thank you for you support. Using this DefaultUnitCost method its working as expected.
  protected virtual void DefaultUnitCost(PXCache sender, TSProdMTran row)
        {
            object UnitCost;
            sender.RaiseFieldDefaulting<TSProdMTran.unitCost>(row, out UnitCost);
            if (UnitCost != null && (decimal)UnitCost != 0m)
            {
                decimal? unitcost = INUnitAttribute.ConvertToBase<TSProdMTran.inventoryID>(sender, row, row.UOM, (decimal)UnitCost, INPrecision.UNITCOST);
                sender.SetValueExt<TSProdMTran.unitCost>(row, unitcost);
                decimal? extcost = row.IssueQty * row.UnitCost;
                sender.SetValueExt<TSProdMTran.extCost>(row, extcost);
            }

Below code is changing the decimal precision as set in the company screen using Price?cost decimal field.
decimal? unitcost = INUnitAttribute.ConvertToBase<TSProdMTran.inventoryID>(sender, row, row.UOM, (decimal)UnitCost, INPrecision.UNITCOST);


Reply