protected virtual void APSalesPrice_PendingPrice_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { APSalesPrice row = (APSalesPrice)e.Row; if (row.EffectiveDate == null && row.IsPromotionalPrice == false && row.PendingPrice > 0m) { sender.SetDefaultExt <APSalesPrice.effectiveDate>(row); } }
private POVendorInventory getPOVendorInventory(APSalesPrice price) { return(PXSelect <POVendorInventory, Where <POVendorInventory.inventoryID, Equal <Required <APSalesPrice.inventoryID> >, And <POVendorInventory.vendorID, Equal <Required <APSalesPrice.vendorID> >, And <POVendorInventory.vendorLocationID, Equal <Required <APSalesPrice.vendorLocationID> >, And <POVendorInventory.purchaseUnit, Equal <Required <APSalesPrice.uOM> >, And <POVendorInventory.curyID, Equal <Required <APSalesPrice.curyID> >, And <POVendorInventory.subItemID, Equal <Required <APSalesPrice.subItemID> > > > > > > > > .Select(this, price.InventoryID, price.VendorID, price.VendorLocationID, price.UOM, price.CuryID, price.SubItemID)); }
protected virtual void APSalesPrice_RowInserting(PXCache sender, PXRowInsertingEventArgs e) { APSalesPrice row = (APSalesPrice)e.Row; if (row != null && Filter.Current != null) { row.CuryID = Filter.Current.CuryID; row.IsPromotionalPrice = Filter.Current.PromotionalPrice; } }
protected virtual void APSalesPrice_AllLocations_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { APSalesPrice row = (APSalesPrice)e.Row; if (row.AllLocations == true) { row.VendorLocationID = null; } else { row.VendorLocationID = Filter.Current.LocationID; } }
protected virtual void APSalesPrice_RowDeleted(PXCache sender, PXRowDeletedEventArgs e) { APSalesPrice price = e.Row as APSalesPrice; if (price.IsPromotionalPrice == false && price.PendingBreakQty == 0 && price.BreakQty == 0) { POVendorInventory vi = getPOVendorInventory(price); if (vi != null) { VendorItems.Delete(vi); } } }
public static void ValidateDuplicate(PXGraph graph, PXCache sender, APSalesPrice price) { PXSelectBase <APSalesPrice> selectDuplicate = new PXSelect <APSalesPrice, Where <APSalesPrice.curyID, Equal <Required <APSalesPrice.curyID> >, And <APSalesPrice.vendorID, Equal <Required <APSalesPrice.vendorID> >, And <APSalesPrice.inventoryID, Equal <Required <APSalesPrice.inventoryID> >, And <APSalesPrice.uOM, Equal <Required <APSalesPrice.uOM> >, And <APSalesPrice.recordID, NotEqual <Required <APSalesPrice.recordID> >, And <APSalesPrice.pendingBreakQty, Equal <Required <APSalesPrice.pendingBreakQty> >, And <APSalesPrice.breakQty, Equal <Required <APSalesPrice.breakQty> >, And <APSalesPrice.isPromotionalPrice, Equal <Required <APSalesPrice.isPromotionalPrice> >, And2 <Where <APSalesPrice.subItemID, Equal <Required <APSalesPrice.subItemID> >, Or <Required <APSalesPrice.subItemID>, IsNull, And <APSalesPrice.subItemID, IsNull> > >, And <Where <APSalesPrice.vendorLocationID, Equal <Required <APSalesPrice.vendorLocationID> >, Or <APSalesPrice.vendorLocationID, IsNull, And <Required <APSalesPrice.vendorLocationID>, IsNull> > > > > > > > > > > > > >(graph); APSalesPrice duplicate; if (price.IsPromotionalPrice == true) { selectDuplicate.WhereAnd <Where2 <Where <Required <APSalesPrice.lastDate>, Between <APSalesPrice.lastDate, APSalesPrice.expirationDate> >, Or <Required <APSalesPrice.expirationDate>, Between <APSalesPrice.lastDate, APSalesPrice.expirationDate>, Or <APSalesPrice.lastDate, Between <Required <APSalesPrice.lastDate>, Required <APSalesPrice.expirationDate> >, Or <APSalesPrice.expirationDate, Between <Required <APSalesPrice.lastDate>, Required <APSalesPrice.expirationDate> > > > > > >(); duplicate = selectDuplicate.SelectSingle(price.CuryID, price.VendorID, price.InventoryID, price.UOM, price.RecordID, price.PendingBreakQty, price.BreakQty, price.IsPromotionalPrice, price.SubItemID, price.SubItemID, price.VendorLocationID, price.VendorLocationID, price.LastDate, price.ExpirationDate, price.LastDate, price.ExpirationDate, price.LastDate, price.ExpirationDate); } else { duplicate = selectDuplicate.SelectSingle(price.CuryID, price.VendorID, price.InventoryID, price.UOM, price.RecordID, price.PendingBreakQty, price.BreakQty, price.IsPromotionalPrice, price.SubItemID, price.SubItemID, price.VendorLocationID, price.VendorLocationID); } if (duplicate != null) { sender.RaiseExceptionHandling <APSalesPrice.uOM>(price, price.UOM, new PXSetPropertyException(SO.Messages.DuplicateSalesPrice, PXErrorLevel.RowError)); } }
protected virtual void APSalesPrice_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { APSalesPrice row = e.Row as APSalesPrice; if (row == null) { return; } if (IsStockInventory(row.InventoryID)) { PXUIFieldAttribute.SetEnabled <APSalesPrice.subItemID>(sender, row, true); PXDefaultAttribute.SetPersistingCheck <APSalesPrice.subItemID>(sender, row, PXPersistingCheck.NullOrBlank); } else { PXUIFieldAttribute.SetEnabled <APSalesPrice.subItemID>(sender, row, false); PXDefaultAttribute.SetPersistingCheck <APSalesPrice.subItemID>(sender, row, PXPersistingCheck.Nothing); } }
private void InsertPOVendorInventory(APSalesPrice price) { POVendorInventory inventory = getPOVendorInventory(price); if (inventory == null) { POVendorInventory vi = new POVendorInventory(); vi.InventoryID = price.InventoryID; vi.VendorID = price.VendorID; vi.VendorLocationID = price.VendorLocationID; vi.PurchaseUnit = price.UOM; vi.SubItemID = price.SubItemID; vi.CuryID = price.CuryID; vi.PendingDate = price.EffectiveDate; vi.PendingPrice = price.PendingPrice; vi.EffDate = price.LastDate; vi.EffPrice = price.SalesPrice; vi.LastPrice = price.LastPrice; VendorItems.Insert(vi); } }
protected virtual void APSalesPrice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { APSalesPrice row = (APSalesPrice)e.Row; if (row.IsPromotionalPrice == true && row.LastDate == null) { sender.RaiseExceptionHandling <APSalesPrice.lastDate>(row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(APSalesPrice.lastDate).Name)); } if (row.IsPromotionalPrice == true && row.ExpirationDate == null) { sender.RaiseExceptionHandling <APSalesPrice.expirationDate>(row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(APSalesPrice.expirationDate).Name)); } if (row.IsPromotionalPrice == true && row.ExpirationDate < row.LastDate) { sender.RaiseExceptionHandling <APSalesPrice.lastDate>(row, row.LastDate, new PXSetPropertyException(AR.Messages.LastDateExpirationDate, PXErrorLevel.RowError)); } if (IsStockInventory(row.InventoryID) && row.SubItemID == null) { sender.RaiseExceptionHandling <APSalesPrice.subItemID>(row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(APSalesPrice.subItemID).Name)); } }
protected virtual void APSalesPrice_AllLocations_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { APSalesPrice row = (APSalesPrice)e.Row; if (e.NewValue != null && (bool)e.NewValue == true) { APSalesPrice parent = PXSelect <APSalesPrice, Where <APSalesPrice.inventoryID, Equal <Current <APSalesPrice.inventoryID> >, And <APSalesPrice.uOM, Equal <Current <APSalesPrice.uOM> >, And <APSalesPrice.pendingBreakQty, Equal <Current <APSalesPrice.pendingBreakQty> >, And <APSalesPrice.vendorID, Equal <Current <APSalesPrice.vendorID> >, And <APSalesPrice.vendorLocationID, IsNull, And <APSalesPrice.recordID, NotEqual <Current <APSalesPrice.recordID> >, And <APSalesPrice.curyID, Equal <Current <APSalesPrice.curyID> > > > > > > > > > .SelectSingleBound(this, new object[] { e.Row }, null); if (parent != null) { throw new PXSetPropertyException(PO.Messages.POVendorInventoryDuplicate); } } }
protected virtual void APSalesPrice_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { APSalesPrice price = e.Row as APSalesPrice; if (price.BreakQty == 0 && price.PendingBreakQty == 0 && price.IsPromotionalPrice != true && (!sender.ObjectsEqual <APSalesPrice.pendingPrice>(e.Row, e.OldRow) || !sender.ObjectsEqual <APSalesPrice.effectiveDate>(e.Row, e.OldRow) || !sender.ObjectsEqual <APSalesPrice.salesPrice>(e.Row, e.OldRow))) { POVendorInventory vi = getPOVendorInventory(price); if (vi != null) { POVendorInventory copy = PXCache <POVendorInventory> .CreateCopy(vi); copy.PendingPrice = price.PendingPrice; copy.PendingDate = price.EffectiveDate; copy.EffPrice = price.SalesPrice; copy.EffDate = price.LastDate; copy.LastPrice = price.LastPrice; VendorItems.Update(copy); } } }
public static void UpdateSalesPrice(APUpdateSalesPriceProcess graph, APSalesPrice item) { graph.UpdateSalesPrice(item); }
public virtual void UpdateSalesPrice(APSalesPrice item) { using (PXConnectionScope cs = new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { DateTime updateTime = DateTime.Now; //FOR UI: item.LastPrice = item.SalesPrice; item.SalesPrice = item.PendingPrice; item.LastBreakQty = item.BreakQty; item.BreakQty = item.PendingBreakQty; item.LastDate = item.EffectiveDate; item.EffectiveDate = null; item.PendingPrice = 0; item.PendingBreakQty = 0; PXDatabase.Update <APSalesPrice>( new PXDataFieldAssign(typeof(APSalesPrice.lastPrice).Name, PXDbType.Decimal, item.LastPrice), new PXDataFieldAssign(typeof(APSalesPrice.lastBreakQty).Name, PXDbType.Decimal, item.LastBreakQty), new PXDataFieldAssign(typeof(APSalesPrice.salesPrice).Name, PXDbType.Decimal, item.SalesPrice), new PXDataFieldAssign(typeof(APSalesPrice.breakQty).Name, PXDbType.Decimal, item.BreakQty), new PXDataFieldAssign(typeof(APSalesPrice.lastDate).Name, PXDbType.DateTime, item.LastDate), new PXDataFieldAssign(typeof(APSalesPrice.pendingPrice).Name, PXDbType.Decimal, 0), new PXDataFieldAssign(typeof(APSalesPrice.effectiveDate).Name, PXDbType.DateTime, null), new PXDataFieldAssign(typeof(APSalesPrice.pendingBreakQty).Name, PXDbType.Decimal, 0), new PXDataFieldAssign(typeof(APSalesPrice.lastModifiedDateTime).Name, PXDbType.DateTime, updateTime), new PXDataFieldRestrict(typeof(APSalesPrice.recordID).Name, PXDbType.Int, item.RecordID), PXDataFieldRestrict.OperationSwitchAllowed ); PXDatabase.Update <APSalesPrice>( new PXDataFieldAssign(typeof(APSalesPrice.salesPrice).Name, PXDbType.Decimal, item.SalesPrice), new PXDataFieldAssign(typeof(APSalesPrice.lastDate).Name, PXDbType.DateTime, item.LastDate), new PXDataFieldAssign(typeof(APSalesPrice.lastModifiedDateTime).Name, PXDbType.DateTime, updateTime), new PXDataFieldRestrict(typeof(APSalesPrice.inventoryID).Name, PXDbType.Int, item.InventoryID), new PXDataFieldRestrict(typeof(APSalesPrice.vendorID).Name, PXDbType.Int, item.VendorID), new PXDataFieldRestrict(typeof(APSalesPrice.vendorLocationID).Name, PXDbType.Int, item.VendorLocationID), new PXDataFieldRestrict(typeof(APSalesPrice.curyID).Name, PXDbType.NVarChar, item.CuryID), new PXDataFieldRestrict(typeof(APSalesPrice.uOM).Name, PXDbType.NVarChar, item.UOM), new PXDataFieldRestrict(typeof(APSalesPrice.subItemID).Name, PXDbType.Int, item.SubItemID), new PXDataFieldRestrict(typeof(APSalesPrice.breakQty).Name, PXDbType.Decimal, item.BreakQty), new PXDataFieldRestrict(typeof(APSalesPrice.isPromotionalPrice).Name, PXDbType.Bit, false), new PXDataFieldRestrict(typeof(APSalesPrice.recordID).Name, PXDbType.Int, 4, item.RecordID, PXComp.NE) ); if (item.BreakQty == 0) { PXDatabase.Update <PO.POVendorInventory>( new PXDataFieldAssign(typeof(PO.POVendorInventory.lastPrice).Name, PXDbType.Decimal, item.LastPrice), new PXDataFieldAssign(typeof(PO.POVendorInventory.effPrice).Name, PXDbType.Decimal, item.SalesPrice), new PXDataFieldAssign(typeof(PO.POVendorInventory.effDate).Name, PXDbType.DateTime, item.LastDate), new PXDataFieldAssign(typeof(PO.POVendorInventory.pendingPrice).Name, PXDbType.Decimal, 0), new PXDataFieldAssign(typeof(PO.POVendorInventory.pendingDate).Name, PXDbType.DateTime, null), new PXDataFieldAssign(typeof(PO.POVendorInventory.lastModifiedDateTime).Name, PXDbType.DateTime, updateTime), new PXDataFieldRestrict(typeof(PO.POVendorInventory.inventoryID).Name, PXDbType.Int, item.InventoryID), new PXDataFieldRestrict(typeof(PO.POVendorInventory.vendorID).Name, PXDbType.Int, item.VendorID), new PXDataFieldRestrict(typeof(PO.POVendorInventory.vendorLocationID).Name, PXDbType.Int, item.VendorLocationID), new PXDataFieldRestrict(typeof(PO.POVendorInventory.curyID).Name, PXDbType.NVarChar, item.CuryID), new PXDataFieldRestrict(typeof(PO.POVendorInventory.purchaseUnit).Name, PXDbType.NVarChar, item.UOM), new PXDataFieldRestrict(typeof(PO.POVendorInventory.subItemID).Name, PXDbType.Int, item.SubItemID) ); } ts.Complete(); } } }
public static UnitCostItem FindUnitCost(PXCache sender, int?vendorID, int?vendorLocationID, int?inventoryID, string curyID, decimal?quantity, string UOM, DateTime date) { PXSelectBase <APSalesPrice> unitCost = new PXSelect <AP.APSalesPrice, Where <AP.APSalesPrice.inventoryID, Equal <Required <AP.APSalesPrice.inventoryID> >, And <AP.APSalesPrice.vendorID, Equal <Required <AP.APSalesPrice.vendorID> >, And <AP.APSalesPrice.vendorLocationID, Equal <Required <AP.APSalesPrice.vendorLocationID> >, And <AP.APSalesPrice.curyID, Equal <Required <AP.APSalesPrice.curyID> >, And <AP.APSalesPrice.uOM, Equal <Required <AP.APSalesPrice.uOM> >, And <Where2 <Where2 <Where <AP.APSalesPrice.breakQty, LessEqual <Required <AP.APSalesPrice.breakQty> > >, And <Where2 <Where <AP.APSalesPrice.lastDate, LessEqual <Required <AP.APSalesPrice.lastDate> >, And <AP.APSalesPrice.isPromotionalPrice, Equal <False> > >, Or <Where <AP.APSalesPrice.lastDate, LessEqual <Required <AP.APSalesPrice.lastDate> >, And <AP.APSalesPrice.expirationDate, GreaterEqual <Required <AP.APSalesPrice.expirationDate> >, And <AP.APSalesPrice.isPromotionalPrice, Equal <True> > > > > > > >, Or <Where <AP.APSalesPrice.lastBreakQty, LessEqual <Required <AP.APSalesPrice.lastBreakQty> >, And <AP.APSalesPrice.lastDate, Greater <Required <AP.APSalesPrice.lastDate> >, And <AP.APSalesPrice.isPromotionalPrice, Equal <False> > > > > > > > > > > >, OrderBy <Desc <AP.APSalesPrice.isPromotionalPrice, Desc <AP.APSalesPrice.vendorID, Desc <AP.APSalesPrice.breakQty, Desc <AP.APSalesPrice.lastBreakQty> > > > > >(sender.Graph); PXSelectBase <APSalesPrice> unitCostBaseUOM = new PXSelectJoin <AP.APSalesPrice, InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <APSalesPrice.inventoryID>, And <InventoryItem.baseUnit, Equal <APSalesPrice.uOM> > > >, Where <AP.APSalesPrice.inventoryID, Equal <Required <AP.APSalesPrice.inventoryID> >, And <AP.APSalesPrice.vendorID, Equal <Required <AP.APSalesPrice.vendorID> >, And <AP.APSalesPrice.vendorLocationID, Equal <Required <AP.APSalesPrice.vendorLocationID> >, And <AP.APSalesPrice.curyID, Equal <Required <AP.APSalesPrice.curyID> >, And <Where2 <Where2 <Where <AP.APSalesPrice.breakQty, LessEqual <Required <AP.APSalesPrice.breakQty> > >, And <Where2 <Where <AP.APSalesPrice.lastDate, LessEqual <Required <AP.APSalesPrice.lastDate> >, And <AP.APSalesPrice.isPromotionalPrice, Equal <False> > >, Or <Where <AP.APSalesPrice.lastDate, LessEqual <Required <AP.APSalesPrice.lastDate> >, And <AP.APSalesPrice.expirationDate, GreaterEqual <Required <AP.APSalesPrice.expirationDate> >, And <AP.APSalesPrice.isPromotionalPrice, Equal <True> > > > > > > >, Or <Where <AP.APSalesPrice.lastBreakQty, LessEqual <Required <AP.APSalesPrice.lastBreakQty> >, And <AP.APSalesPrice.lastDate, Greater <Required <AP.APSalesPrice.lastDate> >, And <AP.APSalesPrice.isPromotionalPrice, Equal <False> > > > > > > > > > >, OrderBy <Desc <AP.APSalesPrice.isPromotionalPrice, Desc <AP.APSalesPrice.vendorID, Desc <AP.APSalesPrice.breakQty, Desc <AP.APSalesPrice.lastBreakQty> > > > > >(sender.Graph); APSalesPrice item = unitCost.SelectWindowed(0, 1, inventoryID, vendorID, vendorLocationID, curyID, UOM, quantity, date, date, date, quantity, date); string uomFound = null; if (item == null) { decimal baseUnitQty = INUnitAttribute.ConvertToBase(sender, inventoryID, UOM, (decimal)quantity, INPrecision.QUANTITY); item = unitCostBaseUOM.Select(inventoryID, vendorID, vendorLocationID, curyID, baseUnitQty, date, date, date, quantity, date); if (item == null) { return(null); } else { uomFound = item.UOM; } } else { uomFound = UOM; } if (item == null) { return(null); } if (item.LastDate != null && date < item.LastDate.Value) { return(new UnitCostItem(uomFound, (item.LastPrice ?? 0), item.CuryID)); } else { return(new UnitCostItem(uomFound, (item.SalesPrice ?? 0), item.CuryID)); } }