Skip to main content
Question

Override Price Recalculate Method in sales order


Forum|alt.badge.img

I need to maintain existing unit price when recalculate the price in sales order screen.

I created a table to maintain the price History.

table name - XXSOPriceHistory

SOOrderEntry extension query 

public PXAction<SOOrder> recalculateDiscountsAction;
    [PXUIField(DisplayName = "Recalculate Prices", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
    [PXButton(CommitChanges = true, DisplayOnMainToolbar = false)]
    public virtual IEnumerable RecalculateDiscountsAction(PXAdapter adapter)
    {
      SOOrder order = Base.Document.Current;
      order.OrderDesc = "Testing1";

      XXSOPriceHistoryEntry sOPriceEntry = PXGraph.CreateInstance<XXSOPriceHistoryEntry>();



          XXSOPriceHistory toBeInserted = new XXSOPriceHistory();
          toBeInserted.LineNbr=1;
          toBeInserted.OrderNbr="SO1000";
          toBeInserted.InventoryID = 1435;

          toBeInserted = XXSOPriceHistoryData.Insert(toBeInserted);


      //sOPriceEntry.Save.Press();


      return Base.RecalculateDiscountsAction(adapter);
    }

When Click the recalculate button in sales order screen and click save , Same record add twice into the XXSOPriceHistory DAC.

Data Access query

#region TranID
    [PXDBIdentity(IsKey = true)]
    [PXUIField(DisplayName = "Tran ID")]
    public virtual int? TranID { get; set; }
    public abstract class tranID : PX.Data.BQL.BqlInt.Field<tranID> { }
    #endregion

    #region LineNbr
    [PXDBInt()]
    [PXUIField(DisplayName = "Line Nbr")]
    public virtual int? LineNbr { get; set; }
    public abstract class lineNbr : PX.Data.BQL.BqlInt.Field<lineNbr> { }
    #endregion

    #region OrderNbr
    [PXDBString(15, IsUnicode = true, InputMask = "")]
    [PXUIField(DisplayName = "Order Nbr")]
    public virtual string OrderNbr { get; set; }
    public abstract class orderNbr : PX.Data.BQL.BqlString.Field<orderNbr> { }
    #endregion

    #region OrderDate
    [PXDBDate()]
    [PXUIField(DisplayName = "Order Date")]
    public virtual DateTime? OrderDate { get; set; }
    public abstract class orderDate : PX.Data.BQL.BqlDateTime.Field<orderDate> { }
    #endregion

    #region InventoryID
    [PXDBInt()]
    [PXUIField(DisplayName = "Inventory ID")]
    public virtual int? InventoryID { get; set; }
    public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
    #endregion

Can I know why this happen and how to resolve it.

3 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • August 8, 2023

Hi @jeewanishalika20  To prevent these duplicates, a simple condition needs to added.

Prior to insertion, examine whether a corresponding record already exists in the table, considering factors such as Order Type, Order Number, and Inventory ID fields. If a match is found, you can effortlessly update the price value within this existing record.


Forum|alt.badge.img

Hi @Naveen Boga ,

It’s not possible.Because user can one more than recalculate the same order line price.Then table need to be insert the data all the time.

 

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2750 replies
  • August 29, 2023

Hi @jeewanishalika20 were you able to find a solution? Thank you!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings