Solved

How to use decimal Precision in the DAC to default from company screen

  • 25 August 2022
  • 7 replies
  • 307 views

Userlevel 1
Badge

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.

 

 

icon

Best answer by harikanthm60 2 September 2022, 12:43

View original

7 replies

Userlevel 7
Badge +17

Hi @harikanthm60  Can you please share the DAC field?

Userlevel 1
Badge

 @Naveen Boga  i have shared the dac field

#region UnitCost
        public abstract class unitCost : PX.Data.BQL.BqlDecimal.Field<unitCost>
        {
        }
        protected decimal? _UnitCost;
        //[PXDBPriceCost(MinValue = 0)]
        [PXDBDecimal(typeof(Search<CommonSetup.decPlPrcCst>))]
        [PXDefault(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>>>>>))]
        [PXUIField(DisplayName = "Unit Cost",Enabled =false,IsReadOnly = true)]
        public virtual decimal? UnitCost
        {
            get
            {
                return this._UnitCost;
            }
            set
            {
                this._UnitCost = value;
            }
        }
        #endregion

Userlevel 7
Badge +17

@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?

[PXPriceCost]

Userlevel 1
Badge

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

 

Userlevel 7
Badge +17

@harikanthm60  Sorry for the multiple posts. [PXDBPriceCost] should work.

Have you tried this already?

Userlevel 1
Badge

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

Userlevel 1
Badge

@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


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