The default search in acumatica selector is contains and it creates lots off issue while entering the data in once of selector in custom page. Is there a way to change the behaviour to start with instead of contains.
Update
I have tried the following code and it is filtering based on start with but not displaying all the columns in the selector
#region Custom Selector Attribute
public class LotSerialNbrSelectionAttribute : PXCustomSelectorAttribute
{
public LotSerialNbrSelectionAttribute(Type type, Type[] fieldlist)
: base(type,fieldlist)
{
}
protected virtual IEnumerable GetRecords()
{
PXView view = new PXView(this._Graph, !this._DirtyRead, this._Select);
PXCache lotSerCach = this._Graph.Caches[typeof(InfoLotSerialFilter)];
List<object> result = new List<object>();
Int32 totalrow = 0;
Int32 startrow = PXView.StartRow;
result = view.Select(PXView.Currents, PXView.Parameters,
PXView.Searches, PXView.SortColumns, PXView.Descendings,
PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
PXView.StartRow = 0;
string searchval = string.Empty;
if(PXView.Filters.Length > 0)
searchval = PXView.Filters[0].Value.ToString();
InfoLotSerialFilter searchrow = lotSerCach.Current as InfoLotSerialFilter;
foreach(PXResult<INLotSerialStatus> line in result)
{
INLotSerialStatus row = line;
if(string.IsNullOrEmpty(searchval))
yield return row;
else
{
if(row.LotSerialNbr.StartsWith(searchval))
yield return row;
}
}
}
}
#endregion
Calling the attribute
#region LotSerialNbr
public abstract class lotSerialNbr : IBqlField
{
}
protected string _LotSerialNbr;
[PXString(100, IsUnicode = true )]
[PXUIField(DisplayName = "Serial Number" )]
[LotSerialNbrSelectionAttribute(typeof(Search2<INLotSerialStatus.lotSerialNbr,InnerJoin<INSite,On<INSite.siteID,Equal<INLotSerialStatus.siteID>>,CrossJoin<MemoSetUp>>,Where<INLotSerialStatus.qtyHardAvail,Greater<decimal0>,And<INLotSerialStatus.siteID,NotEqual<MemoSetUp.memoOutSiteId>>>>),
new Type[]{typeof(INLotSerialStatus.inventoryID),
typeof(INLotSerialStatus.lotSerialNbr),
typeof(INSite.siteCD) }
)]
public virtual string LotSerialNbr
{
get
{
return this._LotSerialNbr;
}
set
{
this._LotSerialNbr = value;
}
}
#endregion
Result
InventoryID & SiteID is not displaying in the selection browser
I have tried the modified code given below and works fine
#region Custom Selector Attribute
public class LotSerialNbrSelectionAttribute : PXCustomSelectorAttribute
{
public LotSerialNbrSelectionAttribute(Type type, Type[] fieldlist)
: base(type, typeof(INLotSerialStatus.inventoryID), typeof(INLotSerialStatus.lotSerialNbr), typeof(INSite.siteCD))
{
}
protected virtual IEnumerable GetRecords()
{
PXView view = new PXView(this._Graph, !this._DirtyRead, this._Select);
string searchval = string.Empty;
if (PXView.Filters.Length > 0)
searchval = PXView.Filters[0].Value.ToString();
PXView.Filters.Clear();
//PXCache lotSerCach = this._Graph.Caches[typeof(InfoLotSerialFilter)];
List<object> result = new List<object>();
Int32 totalrow = 0;
Int32 startrow = PXView.StartRow;
result = view.Select(PXView.Currents, PXView.Parameters,
PXView.Searches, PXView.SortColumns, PXView.Descendings,
PXView.Filters, ref startrow, 10000, ref totalrow);
PXView.StartRow = 0;
foreach(PXResult<INLotSerialStatus,INSite> line in result)
{
INLotSerialStatus row = line;
if(string.IsNullOrEmpty(searchval))
yield return line;
else
{
if(row.LotSerialNbr.StartsWith(searchval))
yield return line;
}
}
}
}
#endregion
Related
I have created an Action in Sales Quotes screen to create a sales order. The sales order is getting created. I want the created Order Nbr to be populated in a custom field of Sales Quote Screen and the Action button to be disabled if the Sales order is created. Though I am not getting any error in the system.
When I refresh the Sales Quote Screen I get the exact result, but not during the Click of Create SO Action.
I am not sure where I am going wrong. Please refer the code and Image below: Thanks.
Following is my Code :
public class QuoteMaint_Extension : PXGraphExtension<QuoteMaint>
{
#region Event Handlers
protected void CRQuote_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (CRQuote)e.Row;
CRQuoteExt quoteExt = PXCache<CRQuote>.GetExtension<CRQuoteExt>(row);
if (quoteExt.UsrOrderNbr != null)
{
createSalesOrder.SetEnabled(false);
}
else
{
createSalesOrder.SetEnabled(true);
}
}
#endregion
#region Create Sales Order
public PXAction<CRQuote> createSalesOrder;
[PXUIField(DisplayName = "Create SO", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
[PXProcessButton(CommitChanges = true)]
public IEnumerable CreateSalesOrder(PXAdapter adapter)
{
QuoteMaint graphObject = PXGraph.CreateInstance<QuoteMaint>();
foreach (CRQuote quote in adapter.Get())
{
//Create resultset for Quote Details
PXResultset<CROpportunityProducts> PXSetLine = PXSelect<CROpportunityProducts,
Where<CROpportunityProducts.quoteID,
Equal<Required<CROpportunityProducts.quoteID>>>>.Select(this.Base, quote.QuoteID);
List<CROpportunityProducts> QuoteList = new List<CROpportunityProducts>();
foreach (CROpportunityProducts line in PXSetLine)
{
QuoteList.Add(line);
}
PXLongOperation.StartOperation(this, delegate ()
{
CreateSalesOrderMethod(quote, QuoteList);
});
yield return quote;
}
}
//Private Method for Create Sales Order
public virtual void CreateSalesOrderMethod(CRQuote quote, List<CROpportunityProducts> QuoteList)
{
//Base.Save.Press();
bool var_orderCreated = false;
bool erroroccured = false;
string ErrMsg = "";
SOOrderEntry orderGraphObjet = PXGraph.CreateInstance<SOOrderEntry>();
SOOrder orderHeaderObject = new SOOrder();
QuoteMaint currGRPH = PXGraph.CreateInstance<QuoteMaint>();
var Extension = this.Base.GetExtension<QuoteMaint_Extension>();
try
{
BAccount customer = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Current<CRQuote.bAccountID>>>>.Select(this.Base, quote.BAccountID);
if (customer.Type == "CU")
{
orderHeaderObject.CustomerID = quote.BAccountID;
}
else
{
throw new PXException("Business Account not converted to Customer yet");
}
orderHeaderObject.CuryOrderTotal = quote.CuryProductsAmount;
orderHeaderObject.CuryTaxTotal = quote.CuryTaxTotal;
orderHeaderObject.OrderDesc = quote.Subject;
orderHeaderObject = orderGraphObjet.CurrentDocument.Insert(orderHeaderObject);
orderGraphObjet.CurrentDocument.Current = orderHeaderObject;
orderGraphObjet.Actions.PressSave();
orderHeaderObject = orderGraphObjet.CurrentDocument.Current;
foreach (CROpportunityProducts tran in QuoteList)
{
CROpportunityProductsExt xOppProductExt = PXCache<CROpportunityProducts>.GetExtension<CROpportunityProductsExt>(tran);
SOLine transline = new SOLine();
SOLineExt _soLext = PXCache<SOLine>.GetExtension<SOLineExt>(transline);
transline.OrderNbr = orderHeaderObject.OrderNbr;
transline.BranchID = orderHeaderObject.BranchID;
transline.InventoryID = tran.InventoryID;
transline.TranDesc = tran.Descr;
transline.UOM = tran.UOM;
transline.OrderQty = tran.Quantity;
transline.SiteID = tran.SiteID;
transline.CuryUnitPrice = tran.CuryUnitPrice;
transline.CuryExtPrice = tran.CuryExtPrice;
_soLext.UsrXSeqID = xOppProductExt.UsrXSequenceID;
_soLext.UsrXGroupID = xOppProductExt.UsrXGroupID;
_soLext.UsrInternalRemk = xOppProductExt.UsrInternalRemk;
orderGraphObjet.Transactions.Insert(transline);
}
orderGraphObjet.Actions.PressSave();
var_orderCreated = true;
}
catch (Exception e)
{
erroroccured = true;
ErrMsg = e.Message;
}
if (erroroccured)
{
throw new PXException("Cannot create Order: " + ErrMsg);
}
else
{
if(var_orderCreated)
{
CRQuote QUOT = Base.Quote.Current;
CRQuoteExt QUOT_EXT = PXCache<CRQuote>.GetExtension<CRQuoteExt>(QUOT);
QUOT_EXT.UsrOrderNbr = orderHeaderObject.OrderNbr;
Base.Quote.Update(QUOT);
Base.Save.Press();
}
}
}
#endregion
}
}
DAC FIELD :
#region UsrOrderNbr
[PXDBString(50)]
[PXUIField(DisplayName = "Sales Order Nbr", IsReadOnly = true)]
[PXSelector(
typeof(Search<SOOrder.orderNbr>),
typeof(SOOrder.orderType),
typeof(SOOrder.orderNbr),
typeof(SOOrder.curyOrderTotal),
typeof(SOOrder.status),
Filterable = true)]
public virtual string UsrOrderNbr { get; set; }
public abstract class usrOrderNbr : PX.Data.BQL.BqlString.Field<usrOrderNbr> { }
#endregion
The DAC extension is fetched from transLine object before the SOLine keys are defined. Try moving the GetExtension call after transLine is inserted in the dataview.
SOLine transline = new SOLine();
SOLineExt _soLext = PXCache<SOLine>.GetExtension<SOLineExt>(transline);
The pattern should look like this:
Create empty DAC object
Insert DAC object in dataview
Get DAC extension and assign custom field
Update DAC object in dataview
I want data to be displayed as shown in imageenter image description here
I want to add multiple item of same date in single card view instead of creating another card view for the item of same date
I have tried in Android Studio grouping recycler view called as sanctioned Recycler view where I used date as header but it's not the solution
My Adapter Class
private Context mContext;
List<ListItem> consolidatedList = new ArrayList<>();
public AttendanceAdapter(Context context, List<ListItem>
consolidatedList) {
this.consolidatedList = consolidatedList;
this.mContext = context;
}
#Override
public RecyclerView.ViewHolder
onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder viewHolder = null;
LayoutInflater inflater =
LayoutInflater.from(parent.getContext());
switch (viewType) {
case ListItem.TYPE_GENERAL:
View v1 =
inflater.inflate(R.layout.attendance_adapter_layout, parent,
false);
viewHolder = new GeneralViewHolder(v1);
break;
case ListItem.TYPE_DATE:
View v2 =
inflater.inflate(R.layout.attn_item_header, parent, false);
viewHolder = new DateViewHolder(v2);
break;
}
return viewHolder;
}
#Override
public void onBindViewHolder(RecyclerView.ViewHolder
viewHolder, int position)
{
switch (viewHolder.getItemViewType()) {
case ListItem.TYPE_GENERAL:
GeneralItem generalItem = (GeneralItem)
consolidatedList.get(position);
GeneralViewHolder generalViewHolder=
(GeneralViewHolder) viewHolder;
//generalViewHolder.txt_date.setText(
generalItem.getAttendance_data().getDate());
generalViewHolder.txt_month.setText(
generalItem.getAttendance_data().getMonth_name());
generalViewHolder.txt_date.setText(
generalItem.getAttendance_data().getDate_no());
generalViewHolder.txt_out.setText(
generalItem.getAttendance_data().getAttn_out_time());
generalViewHolder.txt_in.setText(
generalItem.getAttendance_data().getAttn_In_time());
generalViewHolder.txtreason.setText
(generalItem.getAttendance_data().getRemark());
break;
case ListItem.TYPE_DATE:
DateItem dateItem = (DateItem)
consolidatedList.get(position);
DateViewHolder dateViewHolder = (DateViewHolder) viewHolder;
dateViewHolder.txtTitle.setText(dateItem.getDate());
// Populate date item data here
break;
}
}
class DateViewHolder extends RecyclerView.ViewHolder {
protected TextView txtTitle;
public DateViewHolder(View v) {
super(v);
this.txtTitle = (TextView)
v.findViewById(R.id.attn_date);
}
}
// View holder for general row item
class GeneralViewHolder extends RecyclerView.ViewHolder {
protected TextView
txt_in,txtreason,txt_out,txt_date,txt_month;
public GeneralViewHolder(View v) {
super(v);
this.txt_in =v.findViewById(R.id.attn_in_txt);
this.txt_out=v.findViewById(R.id.attn_out_txt);
this.txtreason=v.findViewById(R.id.attn_reason_txt);
this.txt_date=v.findViewById(R.id.date_view);
this.txt_month=v.findViewById(R.id.month_view);
}
}
#Override
public int getItemViewType(int position) {
return consolidatedList.get(position).getType();
}
#Override
public int getItemCount() {
return consolidatedList != null ? consolidatedList.size() : 0;
}
}
MainActivity.Java
public class CurrentMonth extends AsyncTask<Void,Void,Void> {
#Override
protected Void doInBackground(Void... voids) {
attn_list_data_cur_month();
return null;
}
#Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
updateUi();
}
#Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
}
public void attn_list_data_cur_month(){
try {
this.connection=createConnection();
Statement stmt=connection.createStatement();
Calendar current_month_data = Calendar.getInstance();
current_month_data.add(Calendar.MONTH, 0);
//Calendar current_month_date = Calendar.getInstance();
//current_month_date.set(Calendar.DAY_OF_MONTH,0);
n=current_month_data.get(Calendar.DAY_OF_MONTH);
String current_month_year = new SimpleDateFormat("MMM-
yyyy").format(current_month_data.getTime());
String month_name=currentMonth.getText().toString();
for (int i=1;i<=n;i++) {
String date = i + "-" + current_month_year;
ResultSet resultSet = stmt.executeQuery("Select * from
MATTN_MAS where ATTN_DATE='" + date + "' and Username='" +
Username + "'");
String Attn_Type;
if (resultSet.next()) {
while (resultSet.next()) {
Attn_Type = resultSet.getString(8);
String Time = null;
String Reason = resultSet.getString(11);
if (Attn_Type.equals("I")) {
String Attn_Type_In = "I";
String Attn_Type_Out = null;
StringBuilder stringBuilder = new StringBuilder("" + i);
String date_no = stringBuilder.toString();
myOptions.add(new Attendance_Data(Attn_Type_In,
date, Reason, Attn_Type_Out, i, date_no, month_name));
} else {
String Attn_Type_Out = "O";
String Attn_Type_In = null;
StringBuilder stringBuilder = new StringBuilder("" + i);
String date_no = stringBuilder.toString();
myOptions.add(new Attendance_Data(Attn_Type_In,
date, Reason, Attn_Type_Out, i, date_no, month_name));
}
}
} else {
Attn_Type = "Absent";
String Time = null;
String Reason = null;
String out = null;
StringBuilder stringBuilder = new StringBuilder("" + i);
String date_no = stringBuilder.toString();
myOptions.add(new Attendance_Data(Attn_Type, date, Reason,
out, i, date_no, month_name));
}
}
}catch (Exception e){
System.out.println("my Error"+e);
}
}
public void updateUi(){
//sortedData= (List<PojoOfJsonArray>)
PojoOfJsonArray.sortList(myOptions);
HashMap<String, List<Attendance_Data>> groupedHashMap =
groupDataIntoHashMap(myOptions);
for (String date1 : groupedHashMap.keySet()) {
DateItem dateItem = new DateItem();
dateItem.setDate(date1);
consolidatedList.add(dateItem);
for (Attendance_Data pojoOfJsonArray : groupedHashMap.get(date1))
{
GeneralItem generalItem = new GeneralItem();
generalItem.setAttendance_data(pojoOfJsonArray);
consolidatedList.add(generalItem);
}
}
adapter = new AttendanceAdapter(this, consolidatedList);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
attn_report_view.setLayoutManager(layoutManager);
attn_report_view.setAdapter(adapter);
}
private HashMap<String, List<Attendance_Data>>
groupDataIntoHashMap(List<Attendance_Data> listOfPojosOfJsonArray) {
HashMap<String, List<Attendance_Data>> groupedHashMap = new HashMap<>
();
for (Attendance_Data pojoOfJsonArray : listOfPojosOfJsonArray) {
String hashMapKey = pojoOfJsonArray.getDate();
if (groupedHashMap.containsKey(hashMapKey)) {
// The key is already in the HashMap; add the pojo object
// against the existing key.
groupedHashMap.get(hashMapKey).add(pojoOfJsonArray);
} else {
List<Attendance_Data> list = new ArrayList<>();
list.add(pojoOfJsonArray);
groupedHashMap.put(hashMapKey, list);
}
}
return groupedHashMap;
}
I want to add multiple items of same date in same single single card view but instead it is creating multiple Card View for multiple items of same date
You have to use RecyclerView Multiple ViewTypes. for detail please check this example.
Also visit this example.
Yeah I found the solution it worked perfect for Me.....we
have to just make changes to the card View by removing
spaces..
.
like this below...
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardMaxElevation="0.1dp"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:background="#303030"
card_view:cardElevation="5dp"
android:foreground="?android:attr/selectableItemBackground"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginLeft="#dimen/dp_2"
android:layout_marginRight="#dimen/dp_2">
<...Your All Text Boxes and further Layout inside this
cardView...>
</android.support.v7.widget.CardView>
and I have add Header for each CardView....and it looks like
this
Outout is shown in below image
I have modified portal copy order functionality to carry forward the source order shipping address detail into new order.
I have added a custom field to Portalcartlines DAC to store source order type & order number and while Proceed to Checkout action I am filling the address from the source order.
The address is properly carry forward to new order, but while saving I am getting error.
Error: Inserting 'Shipping Address' record raised at least one error. Please review the errors. Error: 'RevisionID' cannot be empty. Error: 'Country' cannot be empty
I am using the following code
public class PortalCardLinesExtn : PXCacheExtension<SP.Objects.IN.PortalCardLines>
{
#region UsrSourceOrderType
[PXDBString(2)]
//[PXUIField(DisplayName = "SourceOrderType")]
public virtual string UsrSourceOrderType { get; set; }
public abstract class usrSourceOrderType : IBqlField { }
#endregion
#region UsrSourceOrderNbr
[PXDBString(15)]
//[PXUIField(DisplayName = "SourceOrderNbr")]
public virtual string UsrSourceOrderNbr { get; set; }
public abstract class usrSourceOrderNbr : IBqlField { }
#endregion
}
public class InventoryCardMaint_Extension : PXGraphExtension<InventoryCardMaint>
{
public PXAction<PortalCardLine> ProceedToCheckOut;
[PXButton]
[PXUIField(DisplayName = "Proceed to Checkout")]
public IEnumerable proceedToCheckOut(PXAdapter adapter)
{
Base.DocumentDetails.Cache.Persist(PXDBOperation.Update);
Base.DocumentDetails.Cache.Persist(PXDBOperation.Insert);
Base.DocumentDetails.Cache.Persist(PXDBOperation.Delete);
foreach (PXCache value in Base.Caches.Values)
{
value.IsDirty = false;
}
SOOrderEntry sOOrderEntry = PXGraph.CreateInstance<SOOrderEntry>();
SOOrder sOOrder = sOOrderEntry.Document.Cache.CreateInstance() as SOOrder;
sOOrder = sOOrderEntry.Document.Insert();
sOOrderEntry.Document.Cache.SetValueExt<SOOrderExt.isSecondScreen>(sOOrder, 1);
//sOOrderEntry.Document.Cache.SetValueExt<SOOrderExt.overrideShipment>(sOOrder, true);
SOOrderExt extension = PXCache<SOOrder>.GetExtension<SOOrderExt>(sOOrder);
SOShippingContact sOShippingContact = sOOrderEntry.Shipping_Contact.Cache.Current as SOShippingContact;
SOShippingAddress sOShippingAddress = sOOrderEntry.Shipping_Address.Cache.Current as SOShippingAddress;
PortalCardLines prow = Base.DocumentDetails.Current;
if (prow != null)
{
PortalCardLinesExtn extn = Base.DocumentDetails.Cache.GetExtension<PortalCardLinesTSExtn>(prow);
if (!string.IsNullOrEmpty(extn.UsrSourceOrderNbr) && !string.IsNullOrEmpty(extn.UsrSourceOrderType))
{
SOOrder order = PXSelect<SOOrder, Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>, And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>.Select(Base, extn.UsrSourceOrderType, extn.UsrSourceOrderNbr);
if (order != null)
{
SOOrderExt sourceextension = PXCache<SOOrder>.GetExtension<SOOrderExt>(order);
sOOrderEntry.Document.Cache.SetValueExt<SOOrderExt.comment>(sOOrder, sourceextension.Comment);
SOShippingContact contact = PXSelect<SOShippingContact, Where<SOShippingContact.contactID, Equal<Required<SOShippingContact.contactID>>>>.Select(Base, order.ShipContactID);
SOShippingAddress address = PXSelect<SOShippingAddress, Where<SOShippingAddress.addressID, Equal<Required<SOShippingAddress.addressID>>>>.Select(Base, order.ShipAddressID);
contact.OverrideContact = true;
address.OverrideAddress = true;
sOShippingAddress.OverrideAddress = true;
sOShippingContact.OverrideContact = true;
if (contact != null)
{
sOShippingContact.FullName = contact.FullName;
sOShippingContact.Attention = contact.Attention;
sOShippingContact.Phone1 = contact.Phone1;
sOShippingContact.Email = contact.Email;
}
if (address != null)
{
sOShippingAddress.AddressLine1 = address.AddressLine1;
sOShippingAddress.AddressLine2 = address.AddressLine2;
sOShippingAddress.AddressLine3 = address.AddressLine3;
sOShippingAddress.City = address.City;
sOShippingAddress.CountryID = address.CountryID;
sOShippingAddress.State = address.State;
sOShippingAddress.PostalCode = address.PostalCode;
}
sOOrderEntry.Shipping_Contact.Cache.Update(sOShippingContact);
sOOrderEntry.Shipping_Address.Cache.Update(sOShippingAddress);
}
}
}
PXRedirectHelper.TryRedirect(sOOrderEntry, PXRedirectHelper.WindowMode.Same);
return adapter.Get();
}
}
I have tried it on customerid field updated event and this solved the issue.
The code is given below
protected void SOOrder_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOOrder)e.Row;
if (row == null) return;
SOOrderExt ext = cache.GetExtension<SOOrderExt>(row);
PortalCardLines prow = Base1.DocumentCardDetails.SelectSingle();
if (prow != null)
{
PortalCardLinesTSExtn extn = PXCache<PortalCardLines>.GetExtension<PortalCardLinesTSExtn>(prow);
if (!string.IsNullOrEmpty(extn.UsrSourceOrderNbr) && !string.IsNullOrEmpty(extn.UsrSourceOrderType))
{
//UsrDeliveryNotes
SOOrder order = PXSelect<SOOrder, Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>, And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>.Select(Base, extn.UsrSourceOrderType, extn.UsrSourceOrderNbr);
if (order != null )
{
string notes = PXNoteAttribute.GetNote(Base.Document.Cache, order);
ext.Comment = notes;
row.ShipAddressID = order.ShipAddressID;
row.ShipContactID = order.ShipContactID;
}
}
}
}
I have a grid that displays rows based on the form's filters. When navigated to the next page the data remains the same. I have exported the data into excel which gets all the rows. Only the first page and last page navigation change the rows. Please help on what am I missing in the ASPX
Graph containing view delegate and DAC
public class InventorySales : PXGraph<InventorySales>
{
[Serializable]
public class Filter : IBqlTable
{
public abstract class wareHouse : IBqlField { }
[PXDefault()]
[PXUIField(DisplayName = "Warehouse")]
[PX.Objects.IN.POSiteAvail(typeof(POReceiptLine.inventoryID), typeof(POReceiptLine.subItemID))]
public virtual int? WareHouse { get; set; }
#region InventoryID
public abstract class inventoryCD : PX.Data.IBqlField
{
}
protected Int32? _InventoryCD;
[PXInt()]
[PXUIField(DisplayName = "SKU", Visibility = PXUIVisibility.SelectorVisible)]
[PXSelector(typeof(Search<
InventoryItem.inventoryID,
Where<InventoryItem.itemStatus, Equal<InventoryItemStatus.active>>>),
new Type[] { typeof(InventoryItem.inventoryID), typeof(InventoryItem.inventoryCD),
typeof(InventoryItem.itemStatus),
typeof(InventoryItem.descr)},
SubstituteKey = typeof(InventoryItem.inventoryCD),
DescriptionField = typeof(InventoryItem.descr))]
public virtual Int32? InventoryCD
{
get
{
return this._InventoryCD;
}
set
{
this._InventoryCD = value;
}
}
#endregion
#region BeginDate
public abstract class beginDate : IBqlField
{
}
protected DateTime? _BeginDate;
[PXDBDate]
[PXDefault(typeof(AccessInfo.businessDate))]
[PXUIField(DisplayName = "Start Date")]
public virtual DateTime? BeginDate
{
get
{
return _BeginDate;
}
set
{
_BeginDate = value;
}
}
#endregion
#region EndDate
public abstract class endDate : IBqlField { }
[PXDBDate]
[PXDefault(typeof(AccessInfo.businessDate))]
[PXUIField(DisplayName = "End Date")]
public virtual DateTime? EndDate { get; set; }
#endregion
#region Sales
public abstract class sales : PX.Data.IBqlField
{
}
protected Int32? _Sales;
[PXInt()]
[PXUnboundDefault("30")]
[PXUIField(DisplayName = "Sales")]
[InvSales.List]
public virtual Int32? Sales
{
get
{
return this._Sales;
}
set
{
this._Sales = value;
}
}
#endregion
}
public PXCancel<Filter> Cancel;
public PXFilter<Filter> MasterView;
public PXSelectJoin<
POReceiptLine,
InnerJoin<POReceipt,
On<POReceiptLine.receiptType, Equal<POReceipt.receiptType>,
And<POReceiptLine.receiptNbr, Equal<POReceipt.receiptNbr>>>,
InnerJoin<INSiteStatus,
On<INSiteStatus.inventoryID, Equal<POReceiptLine.inventoryID>,
And<INSiteStatus.siteID, Equal<POReceiptLine.siteID>>>>>,
Where2<
Where2<
Where<POReceiptLine.siteID, Equal<Current<Filter.wareHouse>>,
And<POReceipt.receiptType, Equal<POReceiptType.poreceipt>>>,
And<Where<POReceiptLine.inventoryID, Equal<Current<Filter.inventoryCD>>,
Or<Current<Filter.inventoryCD>, IsNull>>>>,
And<Where<POReceiptLine.receiptDate, GreaterEqual<Current<Filter.beginDate>>,
And<POReceiptLine.receiptDate, LessEqual<Current<Filter.endDate>>>>>>>
DetailsView;
public PXSelectJoin<
SOLine,
InnerJoin<SOOrder,
On<SOLine.orderType, Equal<SOOrder.orderType>,
And<SOOrder.orderNbr, Equal<SOLine.orderNbr>>>>,
Where<SOOrder.status, NotEqual<SOStatus>,
And<SOOrder.orderDate, GreaterEqual<Sub<Current<AccessInfo.businessDate>,Current<Filter.sales>>>,
And<SOOrder.orderDate, LessEqual<Current<AccessInfo.businessDate>>>>>> ss;
List<PXResult<SOLine>> list = new List<PXResult<SOLine>>();
public IEnumerable detailsView()
{
list = PXSelectJoin<
SOLine,
InnerJoin<SOOrder,
On<SOLine.orderType, Equal<SOOrder.orderType>,
And<SOOrder.orderNbr, Equal<SOLine.orderNbr>>>>,
Where<SOOrder.status, NotEqual<SOStatus>,
And<SOOrder.orderDate, GreaterEqual<Sub<Current<AccessInfo.businessDate>, Current<Filter.sales>>>,
And<SOOrder.orderDate, LessEqual<Current<AccessInfo.businessDate>>>>>>.Select(this).ToList();
Int32 startrow = PXView.StartRow;
List<POReceiptLine> poReceiptLineList = new List<POReceiptLine>();
PXView.StartRow = 0;
foreach (PXResult<POReceiptLine, POReceipt, INSiteStatus> result in PXSelectJoin<
POReceiptLine,
InnerJoin<POReceipt,
On<POReceiptLine.receiptType, Equal<POReceipt.receiptType>,
And<POReceiptLine.receiptNbr, Equal<POReceipt.receiptNbr>>>,
InnerJoin<INSiteStatus,
On<INSiteStatus.inventoryID, Equal<POReceiptLine.inventoryID>,
And<INSiteStatus.siteID, Equal<POReceiptLine.siteID>>>>>,
Where2<
Where2<
Where<POReceiptLine.siteID, Equal<Current<Filter.wareHouse>>,
And<POReceipt.receiptType, Equal<POReceiptType.poreceipt>>>,
And<Where<POReceiptLine.inventoryID, Equal<Current<Filter.inventoryCD>>,
Or<Current<Filter.inventoryCD>, IsNull>>>>,
And<Where<POReceiptLine.receiptDate, GreaterEqual<Current<Filter.beginDate>>,
And<POReceiptLine.receiptDate, LessEqual<Current<Filter.endDate>>>>>>>
.Select(this))
{
decimal? sum = 0.00M;
POReceiptLine objsalesprice = (POReceiptLine)result;
INSiteStatus objInSiteStatus = (INSiteStatus)result;
if (objsalesprice != null)
{
POReceiptLineExt obj = objsalesprice.GetExtension<POReceiptLineExt>();
foreach (PXResult<SOLine> res in list)
{
SOLine so = (SOLine)res;
if (so.InventoryID == objsalesprice.InventoryID)
sum = sum + so.CuryLineAmt;
}
obj.UsrSales = sum;
obj.UsrQtyAvail = objInSiteStatus.QtyAvail;
if (!poReceiptLineList.Any(x => x.InventoryID == objsalesprice.InventoryID))
{
poReceiptLineList.Add(objsalesprice);
}
else if (poReceiptLineList.Any(x => x.InventoryID == objsalesprice.InventoryID && x.ReceiptDate.Value.Date < objsalesprice.ReceiptDate.Value.Date))
{
var itemToRemove = poReceiptLineList.Single(r => (r.InventoryID == objsalesprice.InventoryID));
poReceiptLineList.Remove(itemToRemove);
poReceiptLineList.Add(objsalesprice);
}
else if (poReceiptLineList.Any(x => x.InventoryID == objsalesprice.InventoryID
&& x.ReceiptDate.Value.Date == objsalesprice.ReceiptDate.Value.Date && x.CreatedDateTime < objsalesprice.CreatedDateTime))
{
var itemToRemove = poReceiptLineList.Single(r => (r.InventoryID == objsalesprice.InventoryID));
poReceiptLineList.Remove(itemToRemove);
poReceiptLineList.Add(objsalesprice);
}
}
}
return poReceiptLineList;
}
}
You will have to re-work the 'detailsView' delegate method so that it uses the PXView pattern to handle paging.
Detailed instructions on using PXView with Paging in delegate can be found here: https://asiablog.acumatica.com/2016/06/using-pxview-in-dataview-delegate.html
Here's the relevant code excerpt from that page:
public PXSelect<DAC> DataView;
public IEnumerable dataView()
{
PXView select = new PXView(this, true, DataView.View.BqlSelect);
Int32 totalrow = 0;
Int32 startrow = PXView.StartRow;
List<object> result = select.Select(PXView.Currents, PXView.Parameters,
PXView.Searches, PXView.SortColumns, PXView.Descendings,
PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
PXView.StartRow = 0;
foreach (PXResult<DAC> row in result)
{
// Do any dynamic calculations
yield return row;
}
}
Alternatively you can remove paging on the grid by setting the AllowPaging="false" property of the Grid element if you don't need paging.
Apologies, I am new to Acumatica and can't find anything online about this customized BLC (business logic code) problem.
I have made an extension off the existing class, "Testing" and copied the PXSelectJoin statement from the original class which uses a InventoryTranHistEnqResult. Problem is however whenever I include InventoryTranHistEnqResult in any PXSelectJoin, it will have a runtime error saying: Table 'InventoryTranHistEnqResult' doesn't exist.
Looking at the SQL profiler, it seems InventoryTranHistEnqResult is made up of different tables and there is indeed no table called InventoryTranHistEnqResult. So how can I modify the PXSelectJoin using InventoryTranHistEnqResult?
DAC:
public partial class InventoryTranHistEnqResult : PX.Data.IBqlTable { #region GridLineNbr
// just for sorting in gris
public abstract class gridLineNbr : PX.Data.IBqlField { }
protected Int32? _GridLineNbr;
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Grid Line Nbr.", Visibility = PXUIVisibility.SelectorVisible, Visible = false)]
public virtual Int32? GridLineNbr
{
get
{
return this._GridLineNbr;
}
set
{
this._GridLineNbr = value;
}
}
#endregion
#region InventoryID
public abstract class inventoryID : PX.Data.IBqlField { }
protected Int32? _InventoryID;
[Inventory(Visibility = PXUIVisibility.SelectorVisible, DisplayName = "Inventory ID")]
public virtual Int32? InventoryID
{
get
{
return this._InventoryID;
}
set
{
this._InventoryID = value;
}
}
#endregion #region TranDate
public abstract class tranDate : PX.Data.IBqlField
{
}
protected DateTime? _TranDate;
[PXDBDate()]
[PXUIField(DisplayName = "Date")]
public virtual DateTime? TranDate
{
get
{
return this._TranDate;
}
set
{
this._TranDate = value;
}
}
#endregion #region TranType
public abstract class tranType : PX.Data.IBqlField { }
protected String _TranType;
[PXString(3)] // ???
[INTranType.List()]
[PXUIField(DisplayName = "Tran. Type", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String TranType
{
get
{
return this._TranType;
}
set
{
this._TranType = value;
}
}
#endregion #region DocType
public abstract class docType : PX.Data.IBqlField
{
}
protected String _DocType;
[PXDBString(1, IsKey = true, IsFixed = true)]
[PXUIField(DisplayName = "Doc Type", Visibility = PXUIVisibility.Visible, Visible = false)]
public virtual String DocType
{
get
{
return this._DocType;
}
set
{
this._DocType = value;
}
}
#endregion #region DocRefNbr
public abstract class docRefNbr : PX.Data.IBqlField
{
}
protected String _DocRefNbr;
[PXString(15, IsUnicode = true)]
[PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.SelectorVisible)]
[PXSelector(typeof(Search<INRegister.refNbr>))]
public virtual String DocRefNbr
{
get
{
return this._DocRefNbr;
}
set
{
this._DocRefNbr = value;
}
}
#endregion
#region SubItemID
public abstract class subItemID : PX.Data.IBqlField
{
}
protected Int32? _SubItemID;
[SubItem(Visibility = PXUIVisibility.SelectorVisible, DisplayName = "Subitem")]
public virtual Int32? SubItemID
{
get
{
return this._SubItemID;
}
set
{
this._SubItemID = value;
}
}
#endregion #region SiteId
public abstract class siteID : PX.Data.IBqlField { }
protected Int32? _SiteID;
//[PXDBInt(IsKey = true)] //???
[Site(Visibility = PXUIVisibility.SelectorVisible, DisplayName = "Warehouse")]
public virtual Int32? SiteID
{
get
{
return this._SiteID;
}
set
{
this._SiteID = value;
}
}
#endregion #region LocationID
public abstract class locationID : PX.Data.IBqlField { }
protected Int32? _LocationID;
// [PXDBInt(IsKey = true)] //???
[Location(Visibility = PXUIVisibility.SelectorVisible, DisplayName = "Location")]
public virtual Int32? LocationID
{
get
{
return this._LocationID;
}
set
{
this._LocationID = value;
}
}
#endregion #region LotSerialNbr
public abstract class lotSerialNbr : PX.Data.IBqlField
{
}
protected String _LotSerialNbr;
[PXDBString(100, IsUnicode = true, IsKey = true, InputMask = "")]
[PXUIField(DisplayName = "Lot/Serial Number", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String LotSerialNbr
{
get
{
return this._LotSerialNbr;
}
set
{
this._LotSerialNbr = value;
}
}
#endregion #region FinPerNbr
public abstract class finPerNbr : PX.Data.IBqlField { };
protected String _FinPerNbr;
[GL.FinPeriodID()]
[PXUIField(DisplayName = "Fin. Period", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String FinPerNbr
{
get
{
return this._FinPerNbr;
}
set
{
this._FinPerNbr = value;
}
}
#endregion #region TranPerNbr
public abstract class tranPerNbr : PX.Data.IBqlField { };
protected String _TranPerNbr;
[GL.FinPeriodID()]
[PXUIField(DisplayName = "Tran. Period", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String TranPerNbr
{
get
{
return this._TranPerNbr;
}
set
{
this._TranPerNbr = value;
}
}
#endregion
#region Released
public abstract class released : PX.Data.IBqlField { }
protected bool? _Released = false;
[PXBool]
[PXUIField(DisplayName = "Released", Visibility = PXUIVisibility.SelectorVisible)]
public virtual bool? Released
{
get
{
return this._Released;
}
set
{
this._Released = value;
}
}
#endregion
// Qtys in stock UOM here #region BegQty
public abstract class begQty : PX.Data.IBqlField
{
}
protected Decimal? _BegQty;
[PXDBQuantity()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Beginning Qty.", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? BegQty
{
get
{
return this._BegQty;
}
set
{
this._BegQty = value;
}
}
#endregion #region QtyIn
public abstract class qtyIn : PX.Data.IBqlField
{
}
protected Decimal? _QtyIn;
[PXDBQuantity()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Qty. In", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? QtyIn
{
get
{
return this._QtyIn;
}
set
{
this._QtyIn = value;
}
}
#endregion #region QtyOut
public abstract class qtyOut : PX.Data.IBqlField
{
}
protected Decimal? _QtyOut;
[PXDBQuantity()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Qty. Out", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? QtyOut
{
get
{
return this._QtyOut;
}
set
{
this._QtyOut = value;
}
}
#endregion #region EndQty
public abstract class endQty : PX.Data.IBqlField
{
}
protected Decimal? _EndQty;
[PXDBQuantity()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Ending Qty.", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? EndQty
{
get
{
return this._EndQty;
}
set
{
this._EndQty = value;
}
}
#endregion
#region UnitCost
public abstract class unitCost : PX.Data.IBqlField
{
}
protected Decimal? _UnitCost;
[PXDBPriceCost()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Unit Cost", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? UnitCost
{
get
{
return this._UnitCost;
}
set
{
this._UnitCost = value;
}
}
#endregion
// not used currently : #region ExtCost
public abstract class extCost : PX.Data.IBqlField
{
}
protected Decimal? _ExtCost;
[PXDBBaseCury()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Extended Cost", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? ExtCost
{
get
{
return this._ExtCost;
}
set
{
this._ExtCost = value;
}
}
#endregion #region BegBalance
public abstract class begBalance : PX.Data.IBqlField
{
}
protected Decimal? _BegBalance;
[PXDBBaseCury()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Beginning Balance", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? BegBalance
{
get
{
return this._BegBalance;
}
set
{
this._BegBalance = value;
}
}
#endregion #region EndBalance
public abstract class endBalance : PX.Data.IBqlField
{
}
protected Decimal? _EndBalance;
[PXDBBaseCury()]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Ending Balance", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? EndBalance
{
get
{
return this._EndBalance;
}
set
{
this._EndBalance = value;
}
}
#endregion
}
BLC:
public class Testing_Extension:PXGraph<InventoryTranHistEnq> {
public PXFilter<InventoryTranHistEnqFilter> Filter;
[PXFilterable]
public PXSelectJoin<InventoryTranHistEnqResult,
CrossJoin<INTran>,
Where<True, Equal<True>>,
OrderBy<Asc<InventoryTranHistEnqResult.gridLineNbr>>> ResultRecords;
public PXSelectJoin<InventoryTranHistEnqResult,
CrossJoin<INTran>,
Where<True, Equal<True>>,
OrderBy<Asc<InventoryTranHistEnqResult.gridLineNbr>>> InternalResultRecords;
public PXCancel<InventoryTranHistEnqFilter> Cancel;
public PXAction<InventoryTranHistEnqFilter> viewSummary;
public PXAction<InventoryTranHistEnqFilter> viewAllocDet;
protected virtual void InventoryTranHistEnqFilter_StartDate_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
if (true)
{
DateTime businessDate = (DateTime)this.Accessinfo.BusinessDate;
e.NewValue = new DateTime(businessDate.Year, businessDate.Month, 01);
e.Cancel = true;
}
}
public override void Initialize()
{
ResultRecords.Cache.AllowInsert = false;
ResultRecords.Cache.AllowDelete = false;
ResultRecords.Cache.AllowUpdate = false;
}
protected virtual IEnumerable resultRecords()
{
int startRow = 0;
int totalRows = 0;
PXResultset<InventoryTranHistEnqResult> usortedList = InternalResultRecords.Select();
if (usortedList.Count == 0)
return usortedList;
decimal beginQty = ((InventoryTranHistEnqResult)usortedList[0]).BegQty ?? 0m;
List<object> list = InternalResultRecords.View.Select(PXView.Currents, PXView.Parameters, new object[PXView.SortColumns.Length], PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, 0, ref totalRows);
foreach (PXResult<InventoryTranHistEnqResult> item in list)
{
InventoryTranHistEnqResult it = (InventoryTranHistEnqResult)item;
it.BegQty = beginQty;
decimal? QtyIn = it.QtyIn;
decimal? QtyOut = it.QtyOut;
beginQty += (QtyIn ?? 0m) - (QtyOut ?? 0m);
it.EndQty = beginQty;
}
return list;
}
protected virtual IEnumerable internalResultRecords()
{
InventoryTranHistEnqFilter filter = Filter.Current;
bool summaryByDay = filter.SummaryByDay ?? false;
bool includeUnreleased = filter.IncludeUnreleased ?? false;
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.inventoryID>(ResultRecords.Cache, null, false);
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.finPerNbr>(ResultRecords.Cache, null, false); //???
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.tranPerNbr>(ResultRecords.Cache, null, false); //???
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.tranType>(ResultRecords.Cache, null, !summaryByDay);
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.docRefNbr>(ResultRecords.Cache, null, !summaryByDay);
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.subItemID>(ResultRecords.Cache, null, !summaryByDay);
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.siteID>(ResultRecords.Cache, null, !summaryByDay);
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.locationID>(ResultRecords.Cache, null, !summaryByDay);
PXUIFieldAttribute.SetVisible<InventoryTranHistEnqResult.lotSerialNbr>(ResultRecords.Cache, null, !summaryByDay);
PXUIFieldAttribute.SetVisible(Tran.Cache, null, !summaryByDay);
var resultList = new List<PXResult<InventoryTranHistEnqResult, INTran>>();
if (filter.InventoryID == null)
{
return resultList; //empty
}
// it's better for perfomance to calc. BegQty in the separate GROUP BY query before main.. but currently as is
PXSelectBase<INTranSplit> cmd = new PXSelectReadonly3<INTranSplit,
InnerJoin<INTran,
On<INTran.tranType, Equal<INTranSplit.tranType>,
And<INTran.refNbr, Equal<INTranSplit.refNbr>,
And<INTran.lineNbr, Equal<INTranSplit.lineNbr>>>>,
InnerJoin<INSubItem,
On<INSubItem.subItemID, Equal<INTranSplit.subItemID>>,
InnerJoin<INSite, On<INSite.siteID, Equal<INTran.siteID>>>>>,
OrderBy<Asc<INTranSplit.tranDate, Asc<INTranSplit.createdDateTime, Asc<INTranSplit.lastModifiedDateTime>>>>>(this);
cmd.WhereAnd<Where<INTranSplit.inventoryID, Equal<Current<InventoryTranHistEnqFilter.inventoryID>>, And<Match<INSite, Current<AccessInfo.userName>>>>>();
if (!SubCDUtils.IsSubCDEmpty(filter.SubItemCD))
{
cmd.WhereAnd<Where<INSubItem.subItemCD, Like<Current<InventoryTranHistEnqFilter.subItemCDWildcard>>>>();
}
if (filter.SiteID != null)
{
cmd.WhereAnd<Where<INTranSplit.siteID, Equal<Current<InventoryTranHistEnqFilter.siteID>>>>();
}
if ((filter.LocationID ?? -1) != -1) // there are cases when filter.LocationID = -1
{
cmd.WhereAnd<Where<INTranSplit.locationID, Equal<Current<InventoryTranHistEnqFilter.locationID>>>>();
}
if ((filter.LotSerialNbr ?? "") != "")
{
cmd.WhereAnd<Where<INTranSplit.lotSerialNbr, Like<Current<InventoryTranHistEnqFilter.lotSerialNbrWildcard>>>>();
}
if (!includeUnreleased)
{
cmd.WhereAnd<Where<INTranSplit.released, Equal<boolTrue>>>();
}
// commented because we need all the trans to calc BegQty
// if (filter.StartDate != null)
// {
// cmd.WhereAnd<Where<INTranSplit.tranDate, GreaterEqual<Current<InventoryTranHistEnqFilter.startDate>>>>();
// }
if (filter.EndDate != null)
{
cmd.WhereAnd<Where<INTranSplit.tranDate, LessEqual<Current<InventoryTranHistEnqFilter.endDate>>>>();
}
PXResultset<INTranSplit> intermediateResult = (PXResultset<INTranSplit>)cmd.Select();
decimal cumulativeQty = 0m;
int gridLineNbr = 0;
foreach (PXResult<INTranSplit, INTran, INSubItem> it in intermediateResult)
{
INTranSplit ts_rec = (INTranSplit)it;
INTran t_rec = (INTran)it;
if (ts_rec.TranDate < filter.StartDate)
{
cumulativeQty += (ts_rec.InvtMult * ts_rec.BaseQty) ?? 0m;
}
else
{
if (summaryByDay)
{
if ((resultList.Count > 0) && (((InventoryTranHistEnqResult)resultList[resultList.Count - 1]).TranDate == ts_rec.TranDate))
{
InventoryTranHistEnqResult lastItem = resultList[resultList.Count - 1];
if (ts_rec.InvtMult * ts_rec.BaseQty >= 0)
{
lastItem.QtyIn += ts_rec.InvtMult * ts_rec.BaseQty;
}
else
{
lastItem.QtyOut -= ts_rec.InvtMult * ts_rec.BaseQty;
}
lastItem.EndQty += ts_rec.InvtMult * ts_rec.BaseQty;
}
else
{
InventoryTranHistEnqResult item = new InventoryTranHistEnqResult();
item.BegQty = cumulativeQty;
item.TranDate = ts_rec.TranDate;
if (ts_rec.InvtMult * ts_rec.BaseQty >= 0)
{
item.QtyIn = ts_rec.InvtMult * ts_rec.BaseQty;
item.QtyOut = 0m;
}
else
{
item.QtyIn = 0m;
item.QtyOut = -ts_rec.InvtMult * ts_rec.BaseQty;
}
item.EndQty = item.BegQty + (ts_rec.InvtMult * ts_rec.BaseQty);
item.GridLineNbr = ++gridLineNbr;
resultList.Add(new PXResult<InventoryTranHistEnqResult, INTran>(item, null));
}
cumulativeQty += (ts_rec.InvtMult * ts_rec.BaseQty) ?? 0m;
}
else
{
InventoryTranHistEnqResult item = new InventoryTranHistEnqResult();
item.BegQty = cumulativeQty;
item.TranDate = ts_rec.TranDate;
if (ts_rec.InvtMult * ts_rec.BaseQty >= 0)
{
item.QtyIn = ts_rec.InvtMult * ts_rec.BaseQty;
item.QtyOut = 0m;
}
else
{
item.QtyIn = 0m;
item.QtyOut = -ts_rec.InvtMult * ts_rec.BaseQty;
}
item.EndQty = item.BegQty + (ts_rec.InvtMult * ts_rec.BaseQty);
item.InventoryID = ts_rec.InventoryID;
item.TranType = ts_rec.TranType;
item.DocType = ts_rec.DocType;
item.DocRefNbr = ts_rec.RefNbr;
item.SubItemID = ts_rec.SubItemID;
item.SiteID = ts_rec.SiteID;
item.LocationID = ts_rec.LocationID;
item.LotSerialNbr = ts_rec.LotSerialNbr;
item.FinPerNbr = t_rec.FinPeriodID;
item.TranPerNbr = t_rec.TranPeriodID;
item.Released = t_rec.Released;
item.GridLineNbr = ++gridLineNbr;
item.UnitCost = (t_rec.BaseQty != null && t_rec.BaseQty != 0m && t_rec.TranCost != null && t_rec.TranCost != 0m) ? t_rec.TranCost / t_rec.BaseQty : t_rec.UnitCost;
resultList.Add(new PXResult<InventoryTranHistEnqResult, INTran>(item, t_rec));
cumulativeQty += (ts_rec.InvtMult * ts_rec.BaseQty) ?? 0m;
}
}
}
return resultList;
}
public override bool IsDirty
{
get
{
return false;
}
}
public static void Redirect(string finPeriodID, int? inventoryID, string subItemCD, string lotSerNum, int? siteID, int? locationID)
{
InventoryTranHistEnq graph = PXGraph.CreateInstance<InventoryTranHistEnq>();
graph.Filter.Current.InventoryID = inventoryID;
graph.Filter.Current.SubItemCD = subItemCD;
graph.Filter.Current.SiteID = siteID;
graph.Filter.Current.LocationID = locationID;
graph.Filter.Current.LotSerialNbr = lotSerNum;
throw new PXRedirectRequiredException(graph, Messages.InventoryTranHist);
}
}