Question

Override Price Recalculate Method in sales order

  • 8 August 2023
  • 3 replies
  • 55 views

Userlevel 3
Badge

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

Userlevel 7
Badge +17

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.

Userlevel 3
Badge

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.

 

 

Userlevel 7
Badge

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

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