public override void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { if (object.Equals(DRScheduleDetail.EmptyComponentID, e.NewValue)) return; base.FieldVerifying(sender, e); }
void Page_ColumnSet_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { var gridHeader = sp1.FindControl("gridHeader") as PXGrid; var gridColumn = sp1.FindControl("gridColumn") as PXGrid; CreateColumns(ds.GetSchema("Headers"), gridHeader); CreateColumns(ds.GetSchema("Properties"), gridColumn); }
private CMSetup getCMSetup(PXCache cache) { CMSetup CMSetup = (CMSetup)cache.Graph.Caches[typeof(CMSetup)].Current; if (CMSetup == null) { CMSetup = PXSelectReadonly<CMSetup>.Select(cache.Graph); } return CMSetup; }
private CurrencyRate getCuryRate(PXCache cache) { return PXSelectReadonly<CurrencyRate, Where<CurrencyRate.toCuryID, Equal<Required<CurrencyInfo.baseCuryID>>, And<CurrencyRate.fromCuryID, Equal<Required<CurrencyInfo.curyID>>, And<CurrencyRate.curyRateType, Equal<Required<CurrencyInfo.curyRateTypeID>>, And<CurrencyRate.curyEffDate, LessEqual<Required<CurrencyInfo.curyEffDate>>>>>>, OrderBy<Desc<CurrencyRate.curyEffDate>>>.SelectWindowed(cache.Graph, 0, 1, BaseCuryID, CuryID, CuryRateTypeID, CuryEffDate); }
private void SetDefaultEffDate(PXCache cache) { object newValue; if (cache.RaiseFieldDefaulting<CurrencyInfo.curyEffDate>(this, out newValue)) { cache.RaiseFieldUpdating<CurrencyInfo.curyEffDate>(this, ref newValue); } this.CuryEffDate = (DateTime?)newValue; }
public override void SubstituteKeyFieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e) { if (object.Equals(EmptyComponentCD, e.NewValue)) { e.NewValue = DRScheduleDetail.EmptyComponentID; } else base.SubstituteKeyFieldUpdating(sender, e); }
protected void Users_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { Users user = (Users)e.Row; if (user == null) return; bool isNotFromAD = user.Source != PXUsersSourceListAttribute.ActiveDirectory; PXDefaultAttribute.SetPersistingCheck<Users.password>(sender, user, isNotFromAD ? PXPersistingCheck.Null : PXPersistingCheck.Nothing); PXDefaultAttribute.SetPersistingCheck<Users.email>(sender, user, isNotFromAD ? PXPersistingCheck.Null : PXPersistingCheck.Nothing); }
private void defaultCuryRate(PXCache cache, bool ForceDefault) { CurrencyRate rate = getCuryRate(cache); if (rate != null) { DateTime? UserCuryEffDate = CuryEffDate; CuryEffDate = rate.CuryEffDate; CuryRate = Math.Round((decimal)rate.CuryRate, 8); CuryMultDiv = rate.CuryMultDiv; RecipRate = Math.Round((decimal)rate.RateReciprocal, 8); if (rate.CuryEffDate < UserCuryEffDate) { CurrencyRateType ratetype = (CurrencyRateType)PXSelectorAttribute.Select<CurrencyInfo.curyRateTypeID>(cache, this); if (ratetype != null && ratetype.RateEffDays > 0 && ((TimeSpan)(UserCuryEffDate - rate.CuryEffDate)).Days > ratetype.RateEffDays) { throw new PXRateIsNotDefinedForThisDateException(rate.CuryRateType, rate.FromCuryID, rate.ToCuryID, (DateTime)UserCuryEffDate); } } } else if (ForceDefault) { if (object.Equals(this._CuryID, this._BaseCuryID)) { bool dirty = cache.IsDirty; CurrencyInfo dflt = new CurrencyInfo(); cache.SetDefaultExt<CurrencyInfo.curyRate>(dflt); cache.SetDefaultExt<CurrencyInfo.curyMultDiv>(dflt); cache.SetDefaultExt<CurrencyInfo.recipRate>(dflt); CuryRate = Math.Round((decimal)dflt.CuryRate, 8); CuryMultDiv = dflt.CuryMultDiv; RecipRate = Math.Round((decimal)dflt.RecipRate, 8); cache.IsDirty = dirty; } else if (this._CuryRateTypeID == null || this._CuryEffDate == null) { this.CuryRate = null; this.RecipRate = null; this.CuryMultDiv = "M"; } else { this.CuryRate = null; this.RecipRate = null; this.CuryMultDiv = "M"; throw new PXSetPropertyException(Messages.RateNotFound, PXErrorLevel.Warning); } } }
protected override bool PrepareInsert(PXCache sender, object row, PXAccumulatorCollection columns) { if (!base.PrepareInsert(sender, row, columns)) { return false; } DRExpenseProjectionAccum item = (DRExpenseProjectionAccum)row; columns.Update<DRExpenseProjectionAccum.pTDProjected>(item.PTDProjected, PXDataFieldAssign.AssignBehavior.Summarize); columns.Update<DRExpenseProjectionAccum.pTDRecognized>(item.PTDRecognized, PXDataFieldAssign.AssignBehavior.Summarize); columns.Update<DRExpenseProjectionAccum.pTDRecognizedSamePeriod>(item.PTDRecognizedSamePeriod, PXDataFieldAssign.AssignBehavior.Summarize); return true; }
private void RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { var val = (PropertyValue)e.Row; var oldValue = (PropertyValue)e.OldRow; if (Equals(val.Value, oldValue.Value)) return; var itemsCache = View.Cache; foreach (PropertyValue item in sender.Cached. Cast<PropertyValue>(). Where(_ => _.Order > val.Order). OrderBy(_ => _.Order)) { if (string.IsNullOrWhiteSpace(item.Name)) continue; var propertyInfo = itemsCache.GetType().GetProperty(item.Name); if (propertyInfo == null) continue; var verifier = Attribute.GetCustomAttribute(propertyInfo, PropertyMarkAttribute) as PXMassProcessFieldAttribute; if (verifier == null || verifier.SearchCommand == null) continue; var searchCommand = (BqlCommand)Activator.CreateInstance(verifier.SearchCommand); var verifingParams = new List<object>(); var itemOrder = item.Order; foreach(IBqlParameter param in searchCommand.GetParameters()) { var refType = param.GetReferencedType(); if (refType == null) continue; var propVal = sender.Cached.Cast<PropertyValue>().FirstOrDefault(_ => _.Order < itemOrder && Equals(refType.Name, _.Name)); verifingParams.Add(propVal.With(_ => _.Value)); } int startRow = 0; int totalRows = 0; var searchResult = new PXView(Graph, true, searchCommand). Select(null, verifingParams.ToArray(), new object[] { item.Value }, new string[] { ((IBqlSearch)searchCommand).GetField().Name }, new bool[] { false }, null, ref startRow, 1, ref totalRows); if (searchResult == null || searchResult.Count == 0) { item.Value = null; } } }
public virtual void INTran_UOM_CacheAttached(PXCache sender) { }
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { GLSetup gLSetup = PXSelect <GLSetup> .Select(sender.Graph); decimal?result = 0m; object cashAccountID = sender.GetValue(e.Row, _CashAccount); object finPeriodID = null; if (string.IsNullOrEmpty(_FinPeriodID)) { object finDate = sender.GetValue(e.Row, _FinDate); var finPeriod = ""; if (finPeriod != null) { CashAccount cashaccount = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(sender.Graph, cashAccountID); if (cashaccount != null) { finPeriodID = sender.Graph.GetService <IFinPeriodRepository>().FindFinPeriodByDate((DateTime?)sender.GetValue(e.Row, _FinDate), PXAccess.GetParentOrganizationID(cashaccount.BranchID))?.FinPeriodID; } } } else { finPeriodID = sender.GetValue(e.Row, _FinPeriodID); } if (cashAccountID != null && finPeriodID != null) { // clear glhistory cache for ReleasePayments longrun sender.Graph.Caches <GLHistory>().ClearQueryCacheObsolete(); sender.Graph.Caches <GLHistory>().Clear(); GLHistory gLHistory = PXSelectJoin <GLHistory, InnerJoin <GLHistoryByPeriod, On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>, And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>, And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>, And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>, And <GLHistoryByPeriod.lastActivityPeriod, Equal <GLHistory.finPeriodID> > > > > >, InnerJoin <Branch, On <Branch.branchID, Equal <GLHistory.branchID>, And <Branch.ledgerID, Equal <GLHistory.ledgerID> > >, InnerJoin <CashAccount, On <GLHistoryByPeriod.branchID, Equal <CashAccount.branchID>, And <GLHistoryByPeriod.accountID, Equal <CashAccount.accountID>, And <GLHistoryByPeriod.subID, Equal <CashAccount.subID> > > >, InnerJoin <Account, On <GLHistoryByPeriod.accountID, Equal <Account.accountID>, And <Match <Account, Current <AccessInfo.userName> > > >, InnerJoin <Sub, On <GLHistoryByPeriod.subID, Equal <Sub.subID>, And <Match <Sub, Current <AccessInfo.userName> > > > > > > > >, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> >, And <GLHistoryByPeriod.finPeriodID, Equal <Required <GLHistoryByPeriod.finPeriodID> > > > > .Select(sender.Graph, cashAccountID, finPeriodID); if (gLHistory != null) { result = gLHistory.CuryFinYtdBalance; } } e.ReturnValue = result; e.Cancel = true; }
public virtual void AccountFilter_AssetID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { sender.SetDefaultExt <AccountFilter.bookID>(e.Row); }
public INSetupMaint() { PXCache setupCache = setup.Cache; }
protected virtual void ReleaseChecksFilter_PayTypeID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { sender.SetDefaultExt <ReleaseChecksFilter.payAccountID>(e.Row); }
protected virtual void LocationAPPaymentInfo_VCashAccountID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { //LocationAPPaymentInfo row = (LocationAPPaymentInfo)e.Row; e.NewValue = null; e.Cancel = true; }
protected virtual void APPayment_DocType_CacheAttached(PXCache sender) { }
public virtual void INTranSplit_LocationID_CacheAttached(PXCache sender) { }
protected virtual void INTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { InventoryItem item = (InventoryItem)PXSelectorAttribute.Select <INTran.inventoryID>(sender, e.Row); PXUIFieldAttribute.SetEnabled <INTran.unitCost>(sender, e.Row, (item == null || item.ValMethod != INValMethod.Standard)); }
protected virtual void INTran_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { sender.SetDefaultExt <INTran.uOM>(e.Row); sender.SetDefaultExt <INTran.tranDesc>(e.Row); }
protected virtual void INTran_OrigRefNbr_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { DefaultUnitCost(sender, e); }
protected virtual void INTran_InvtMult_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { e.NewValue = INTranType.InvtMult(((INTran)e.Row).TranType); }
protected virtual void INTran_TranType_CacheAttached(PXCache sender) { }
protected virtual void INTran_DocType_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { e.NewValue = INDocType.Adjustment; }
protected virtual void LocationAPPaymentInfo_IsRemitContactSameAsMain_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { LocationAPPaymentInfo owner = (LocationAPPaymentInfo)e.Row; if (owner != null) { if (owner.IsRemitContactSameAsMain == true) { if (owner.VRemitContactID != owner.VDefContactID) { Contact contact = this.FindContact(owner.VRemitContactID); if (contact != null && contact.ContactID == owner.VRemitContactID) { this.RemitContact.Delete(contact); } owner.VRemitContactID = owner.VDefContactID; //if (this.Location.Cache.Locate(owner) != null) // this.Location.Cache.Update(owner); } } if (owner.IsRemitContactSameAsMain == false) { if (owner.VRemitContactID != null) { if (owner.VRemitContactID == owner.VDefContactID) { Contact defContact = this.FindContact(owner.VDefContactID); Contact cont = PXCache<Contact>.CreateCopy(defContact); cont.ContactID = null; cont.BAccountID = owner.BAccountID; cont.ContactType = ContactTypesAttribute.BAccountProperty; cont = (Contact)this.RemitContact.Cache.Insert(cont); owner.VRemitContactID = cont.ContactID; //if (this.Location.Cache.Locate(owner) != null) // this.Location.Cache.Update(owner); } } } } }
protected virtual void DefaultUnitCost(PXCache sender, PXFieldUpdatedEventArgs e) { if (adjustment.Current != null && adjustment.Current.OrigModule == INRegister.origModule.PI) { return; } object UnitCost = null; InventoryItem item = (InventoryItem)PXSelectorAttribute.Select <INTran.inventoryID>(sender, e.Row); if (item.ValMethod == INValMethod.Specific && string.IsNullOrEmpty(((INTran)e.Row).LotSerialNbr) == false) { INCostStatus status = PXSelectJoin <INCostStatus, LeftJoin <INLocation, On <INLocation.locationID, Equal <Current <INTran.locationID> > >, InnerJoin <INCostSubItemXRef, On <INCostSubItemXRef.costSubItemID, Equal <INCostStatus.costSubItemID> > > >, Where <INCostStatus.inventoryID, Equal <Current <INTran.inventoryID> >, And2 <Where <INLocation.isCosted, Equal <boolFalse>, And <INCostStatus.costSiteID, Equal <Current <INTran.siteID> >, Or <INCostStatus.costSiteID, Equal <Current <INTran.locationID> > > > >, And <INCostSubItemXRef.subItemID, Equal <Current <INTran.subItemID> >, And <INCostStatus.lotSerialNbr, Equal <Current <INTran.lotSerialNbr> > > > > > > .SelectSingleBound(this, new object[] { e.Row }); if (status != null && status.QtyOnHand != 0m) { UnitCost = PXDBPriceCostAttribute.Round((decimal)(status.TotalCost / status.QtyOnHand)); } } else if (item.ValMethod == INValMethod.FIFO && string.IsNullOrEmpty(((INTran)e.Row).OrigRefNbr) == false) { INCostStatus status = PXSelectJoin <INCostStatus, LeftJoin <INLocation, On <INLocation.locationID, Equal <Current <INTran.locationID> > >, InnerJoin <INCostSubItemXRef, On <INCostSubItemXRef.costSubItemID, Equal <INCostStatus.costSubItemID> > > >, Where <INCostStatus.inventoryID, Equal <Current <INTran.inventoryID> >, And2 <Where <INLocation.isCosted, Equal <boolFalse>, And <INCostStatus.costSiteID, Equal <Current <INTran.siteID> >, Or <INCostStatus.costSiteID, Equal <Current <INTran.locationID> > > > >, And <INCostSubItemXRef.subItemID, Equal <Current <INTran.subItemID> >, And <INCostStatus.receiptNbr, Equal <Current <INTran.origRefNbr> > > > > > > .SelectSingleBound(this, new object[] { e.Row }); if (status != null && status.QtyOnHand != 0m) { UnitCost = PXDBPriceCostAttribute.Round((decimal)(status.TotalCost / status.QtyOnHand)); } } else { if (item.ValMethod == INValMethod.Average) { sender.RaiseFieldDefaulting <INTran.avgCost>(e.Row, out UnitCost); } if (UnitCost == null || (decimal)UnitCost == 0m) { sender.RaiseFieldDefaulting <INTran.unitCost>(e.Row, out UnitCost); } } decimal?qty = (decimal?)sender.GetValue <INTran.qty>(e.Row); if (UnitCost != null && ((decimal)UnitCost != 0m || qty < 0m)) { if ((decimal)UnitCost < 0m) { sender.RaiseFieldDefaulting <INTran.unitCost>(e.Row, out UnitCost); } decimal?unitcost = INUnitAttribute.ConvertToBase <INTran.inventoryID>(sender, e.Row, ((INTran)e.Row).UOM, (decimal)UnitCost, INPrecision.UNITCOST); //suppress trancost recalculation for cost only adjustments if (qty == 0m) { sender.SetValue <INTran.unitCost>(e.Row, unitcost); } else { sender.SetValueExt <INTran.unitCost>(e.Row, unitcost); } } }
protected virtual void LocationAPPaymentInfo_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { LocationAPPaymentInfo record = (LocationAPPaymentInfo)e.Row; if (!sender.ObjectsEqual<LocationAPPaymentInfo.vCashAccountID, LocationAPPaymentInfo.vPaymentMethodID, LocationAPPaymentInfo.vPaymentLeadTime, LocationAPPaymentInfo.vPaymentByType, LocationAPPaymentInfo.vSeparateCheck, LocationAPPaymentInfo.isRemitAddressSameAsMain, LocationAPPaymentInfo.isRemitContactSameAsMain>(e.Row, e.OldRow)) { Location mainloc = Location.Current; mainloc.VCashAccountID = record.VCashAccountID; mainloc.VPaymentMethodID = record.VPaymentMethodID; mainloc.VPaymentLeadTime = record.VPaymentLeadTime; mainloc.VPaymentByType = record.VPaymentByType; mainloc.VSeparateCheck = record.VSeparateCheck; mainloc.IsRemitAddressSameAsMain = record.IsRemitAddressSameAsMain; mainloc.VRemitAddressID = record.VRemitAddressID; mainloc.IsRemitContactSameAsMain = record.IsRemitContactSameAsMain; mainloc.VRemitContactID = record.VRemitContactID; if (Location.Cache.GetStatus(mainloc) == PXEntryStatus.Notchanged) { Location.Cache.SetStatus(mainloc, PXEntryStatus.Updated); } sender.Graph.Caches[typeof (Location)].IsDirty = true; } }
protected override bool PrepareInsert(PXCache sender, object row, PXAccumulatorCollection columns) { if (!base.PrepareInsert(sender, row, columns)) { return false; } PMHistory hist = (PMHistory)row; columns.RestrictPast<PMHistory.periodID>(PXComp.GE, hist.PeriodID.Substring(0, 4) + "01"); columns.RestrictFuture<PMHistory.periodID>(PXComp.LE, hist.PeriodID.Substring(0, 4) + "99"); return true; }
protected override void Address_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { Address row = e.Row as Address; if (row != null) { BAccount acct = BAccountUtility.FindAccount(this, row.BAccountID); bool isSameAsMain = false; if (acct != null) { isSameAsMain = (row.AddressID == acct.DefAddressID); } if (!isSameAsMain && Location.Current != null && APPaymentInfoLocation.Current != null && object.Equals(APPaymentInfoLocation.Current.VRemitAddressID, row.AddressID)) { PXUIFieldAttribute.SetEnabled(sender, e.Row, object.Equals(Location.Current.LocationID, Location.Current.VPaymentInfoLocationID)); } else { base.Address_RowSelected(sender, e); } } }
protected override void Location_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); PXUIFieldAttribute.SetEnabled<CR.Location.isAPAccountSameAsMain>(sender, e.Row, baccount!=null && !object.Equals(baccount.DefLocationID, ((Location)e.Row).LocationID)); PXUIFieldAttribute.SetEnabled<CR.Location.isAPPaymentInfoSameAsMain>(sender, e.Row, baccount != null && !object.Equals(baccount.DefLocationID, ((Location)e.Row).LocationID)); base.Location_RowSelected(sender, e); }
protected virtual void RelationGroup_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { PX.SM.RelationGroup group = (PX.SM.RelationGroup)e.Row; group.SpecificModule = typeof(INSetup).Namespace; group.SpecificType = typeof(SegmentValue).FullName; int count = GroupHelper.Count; foreach (PX.SM.RelationGroup inserted in sender.Inserted) { if (inserted.GroupMask != null && inserted.GroupMask.Length > 0) { int cnt = 0; for (int i = 0; i < inserted.GroupMask.Length; i++) { if (inserted.GroupMask[i] == 0x00) { cnt += 8; } else { for (int j = 1; j <= 8; j++) { if ((inserted.GroupMask[i] >> j) == 0x00) { cnt += (9 - j); break; } } break; } } if (cnt > count) { count = cnt; } } } byte[] mask; if (count == 0) { mask = new byte[] { (byte)128, (byte)0, (byte)0, (byte)0 }; } else { if (count == 0 || count % 32 != 0) { mask = new byte[((count + 31) / 32) * 4]; mask[count / 8] = (byte)(128 >> (count % 8)); } else { mask = new byte[((count + 31) / 32) * 4 + 4]; mask[mask.Length - 4] = (byte)128; } } group.GroupMask = mask; if (GroupHelper.Count < mask.Length * 8) { if (!Views.Caches.Contains(typeof(PX.SM.Neighbour))) { Views.Caches.Add(typeof(PX.SM.Neighbour)); } PXCache c = Caches[typeof(PX.SM.Neighbour)]; foreach (PX.SM.Neighbour n in PXSelect <PX.SM.Neighbour> .Select(this)) { byte[] ext = n.CoverageMask; Array.Resize <byte>(ref ext, mask.Length); n.CoverageMask = ext; ext = n.InverseMask; Array.Resize <byte>(ref ext, mask.Length); n.InverseMask = ext; ext = n.WinCoverageMask; Array.Resize <byte>(ref ext, mask.Length); n.WinCoverageMask = ext; ext = n.WinInverseMask; Array.Resize <byte>(ref ext, mask.Length); n.WinInverseMask = ext; c.Update(n); } c.IsDirty = false; } }
protected virtual void Location_IsAPAccountSameAsMain_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { CR.Location record = (CR.Location)e.Row; if (record.IsAPAccountSameAsMain == false) { LocationAPAccountSub mainloc = APAccountSubLocation.Select(); record.VAPAccountID = mainloc.VAPAccountID; record.VAPSubID = mainloc.VAPSubID; record.VAPAccountLocationID = record.LocationID; LocationAPAccountSub copyloc = new LocationAPAccountSub(); copyloc.BAccountID = record.BAccountID; copyloc.LocationID = record.LocationID; copyloc.VAPAccountID = record.VAPAccountID; copyloc.VAPSubID = record.VAPSubID; BusinessAccount.Cache.Current = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); APAccountSubLocation.Insert(copyloc); } if (record.IsAPAccountSameAsMain == true) { record.VAPAccountID = null; record.VAPSubID = null; BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); if (baccount != null) { record.VAPAccountLocationID = baccount.DefLocationID; } } }
protected virtual void INLocation_SiteID_CacheAttached(PXCache sender) { }
protected virtual void Location_CBranchID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { e.NewValue = null; e.Cancel = true; }
protected virtual void ReleaseChecksFilter_PayAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { Filter.Cache.SetDefaultExt <ReleaseChecksFilter.curyID>(e.Row); APPaymentList.Cache.Clear(); }
protected virtual void LocationAPAccountSub_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { if (e.Row == null) return; if (Location.Current != null) { PXUIFieldAttribute.SetEnabled(sender, e.Row, object.Equals(Location.Current.LocationID, Location.Current.VAPAccountLocationID)); } }
public static CustomerPaymentMethod CreateCopy(this CustomerPaymentMethod cpm, PXCache cache) { CustomerPaymentMethod ret = cache.CreateCopy(cpm) as CustomerPaymentMethod; return(ret); }
protected virtual void LocationAPPaymentInfo_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { if (e.Row == null) return; LocationAPPaymentInfo row = (LocationAPPaymentInfo)e.Row; if (Location.Current != null) { bool enableEdit = object.Equals(Location.Current.LocationID, Location.Current.VPaymentInfoLocationID); bool hasPaymentMethod = (row!= null) && (String.IsNullOrEmpty(row.VPaymentMethodID) == false); PXUIFieldAttribute.SetEnabled(sender, e.Row, enableEdit); PXUIFieldAttribute.SetEnabled<LocationAPPaymentInfo.vCashAccountID>(sender, e.Row, enableEdit && hasPaymentMethod); } }
protected virtual void INTranSplit_PlanID_CacheAttached(PXCache sender) { }
public virtual void INTran_TranCost_CacheAttached(PXCache sender) { }
protected virtual void FilterRow_Operator_CacheAttached(PXCache sender) { }
protected virtual void INTran_UnitCost_CacheAttached(PXCache sender) { }
protected override void Location_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { Location record = (Location)e.Row; record.IsAPAccountSameAsMain = !object.Equals(record.LocationID, record.VAPAccountLocationID); record.IsAPPaymentInfoSameAsMain = !object.Equals(record.LocationID, record.VPaymentInfoLocationID); base.Location_RowInserted(sender, e); }
public virtual IEnumerable glaccountlist() { foreach (PXResult <GLHistoryByPeriod, RevaluedGLHistory, Account, Branch, GLHistoryLastRevaluation> res in PXSelectJoin <GLHistoryByPeriod, InnerJoin <RevaluedGLHistory, On <RevaluedGLHistory.ledgerID, Equal <GLHistoryByPeriod.ledgerID>, And <RevaluedGLHistory.branchID, Equal <GLHistoryByPeriod.branchID>, And <RevaluedGLHistory.accountID, Equal <GLHistoryByPeriod.accountID>, And <RevaluedGLHistory.subID, Equal <GLHistoryByPeriod.subID>, And <RevaluedGLHistory.finPeriodID, Equal <GLHistoryByPeriod.lastActivityPeriod> > > > > >, InnerJoin <Account, On <Account.accountID, Equal <GLHistoryByPeriod.accountID> >, InnerJoin <Branch, On <Branch.branchID, Equal <GLHistoryByPeriod.branchID>, And <Branch.ledgerID, Equal <GLHistoryByPeriod.ledgerID> > >, LeftJoin <GLHistoryLastRevaluation, On <GLHistoryByPeriod.ledgerID, Equal <GLHistoryLastRevaluation.ledgerID>, And <GLHistoryByPeriod.branchID, Equal <GLHistoryLastRevaluation.branchID>, And <GLHistoryByPeriod.accountID, Equal <GLHistoryLastRevaluation.accountID>, And <GLHistoryByPeriod.subID, Equal <GLHistoryLastRevaluation.subID> > > > > > > > >, Where <Account.curyID, Equal <Current <RevalueFilter.curyID> >, And <GLHistoryByPeriod.finPeriodID, Equal <Current <RevalueFilter.finPeriodID> >, And <Where <RevaluedGLHistory.curyFinYtdBalance, NotEqual <decimal0>, Or <RevaluedGLHistory.finYtdBalance, NotEqual <decimal0>, Or <RevaluedGLHistory.finPtdRevalued, NotEqual <decimal0> > > > > > > > .Select(this)) { GLHistoryByPeriod histbyper = res; GLHistoryLastRevaluation lastRevaluationPeriod = res; RevaluedGLHistory hist = PXCache <RevaluedGLHistory> .CreateCopy(res); RevaluedGLHistory existing; if ((existing = GLAccountList.Locate(hist)) != null) { yield return(existing); continue; } else { GLAccountList.Cache.SetStatus(hist, PXEntryStatus.Held); } if (string.IsNullOrEmpty(hist.CuryRateTypeID = ((Account)res).RevalCuryRateTypeId)) { hist.CuryRateTypeID = cmsetup.Current.GLRateTypeReval; } if (string.IsNullOrEmpty(hist.CuryRateTypeID)) { GLAccountList.Cache.RaiseExceptionHandling <RevaluedGLHistory.curyRateTypeID>(hist, null, new PXSetPropertyException(Messages.RateTypeNotFound)); } else { CurrencyRate curyrate = PXSelect <CurrencyRate, Where <CurrencyRate.fromCuryID, Equal <Current <RevalueFilter.curyID> >, And <CurrencyRate.toCuryID, Equal <Current <Company.baseCuryID> >, And <CurrencyRate.curyRateType, Equal <Required <Account.revalCuryRateTypeId> >, And <CurrencyRate.curyEffDate, LessEqual <Current <RevalueFilter.curyEffDate> > > > > >, OrderBy <Desc <CurrencyRate.curyEffDate> > > .Select(this, hist.CuryRateTypeID); if (curyrate == null || curyrate.CuryMultDiv == null) { hist.CuryMultDiv = "M"; hist.CuryRate = 1m; hist.RateReciprocal = 1m; hist.CuryEffDate = Filter.Current.CuryEffDate; GLAccountList.Cache.RaiseExceptionHandling <RevaluedGLHistory.curyRate>(hist, 1m, new PXSetPropertyException(Messages.RateNotFound, PXErrorLevel.RowWarning)); } else { hist.CuryRate = curyrate.CuryRate; hist.RateReciprocal = curyrate.RateReciprocal; hist.CuryEffDate = curyrate.CuryEffDate; hist.CuryMultDiv = curyrate.CuryMultDiv; } CurrencyInfo info = new CurrencyInfo(); info.BaseCuryID = company.Current.BaseCuryID; info.CuryID = hist.CuryID; info.CuryMultDiv = hist.CuryMultDiv; info.CuryRate = hist.CuryRate; decimal baseval; PXCurrencyAttribute.CuryConvBase(currencyinfo.Cache, info, (decimal)hist.CuryFinYtdBalance, out baseval); hist.FinYtdRevalued = baseval; hist.FinPtdRevalued = hist.FinYtdRevalued - hist.FinYtdBalance; hist.LastRevaluedFinPeriodID = lastRevaluationPeriod?.LastActivityPeriod; } yield return(hist); } }
protected virtual void Location_IsAPPaymentInfoSameAsMain_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { CR.Location record = (CR.Location)e.Row; if (record.IsAPPaymentInfoSameAsMain == false) { LocationAPPaymentInfo mainloc = APPaymentInfoLocation.Select(); record.VCashAccountID = mainloc.VCashAccountID; record.VPaymentMethodID = mainloc.VPaymentMethodID; record.VPaymentLeadTime = mainloc.VPaymentLeadTime; record.VPaymentByType = mainloc.VPaymentByType; record.VSeparateCheck = mainloc.VSeparateCheck; record.IsRemitAddressSameAsMain = mainloc.IsRemitAddressSameAsMain; record.VRemitAddressID = mainloc.VRemitAddressID; record.IsRemitContactSameAsMain = mainloc.IsRemitContactSameAsMain; record.VRemitContactID = mainloc.VRemitContactID; record.VPaymentInfoLocationID = record.LocationID; LocationAPPaymentInfo copyloc = new LocationAPPaymentInfo(); copyloc.BAccountID = record.BAccountID; copyloc.LocationID = record.LocationID; copyloc.VCashAccountID = record.VCashAccountID; copyloc.VPaymentMethodID = record.VPaymentMethodID; copyloc.VPaymentLeadTime = record.VPaymentLeadTime; copyloc.VPaymentByType = record.VPaymentByType; copyloc.VSeparateCheck = record.VSeparateCheck; copyloc.IsRemitAddressSameAsMain = record.IsRemitAddressSameAsMain; copyloc.VDefAddressID = record.VDefAddressID; copyloc.VRemitAddressID = record.VRemitAddressID; copyloc.IsRemitContactSameAsMain = record.IsRemitContactSameAsMain; copyloc.VRemitContactID = record.VRemitContactID; copyloc.VDefContactID = record.VDefContactID; if (copyloc.VDefAddressID != copyloc.VRemitAddressID) { Address copyaddr = FindAddress(copyloc.VRemitAddressID); copyaddr = PXCache<Address>.CreateCopy(copyaddr); copyaddr.AddressID = null; copyaddr = RemitAddress.Insert(copyaddr); copyloc.VRemitAddressID = copyaddr.AddressID; } if (copyloc.VDefContactID != copyloc.VRemitContactID) { Contact copycont = FindContact(copyloc.VRemitContactID); copycont = PXCache<Contact>.CreateCopy(copycont); copycont.ContactID = null; copycont = RemitContact.Insert(copycont); copyloc.VRemitContactID = copycont.ContactID; } foreach (VendorPaymentMethodDetail maindet in this.PaymentDetails.Select(mainloc.BAccountID, mainloc.LocationID, mainloc.VPaymentMethodID)) { VendorPaymentMethodDetail copydet = PXCache<VendorPaymentMethodDetail>.CreateCopy(maindet); copydet.LocationID = copyloc.LocationID; this.PaymentDetails.Insert(copydet); } BusinessAccount.Cache.Current = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); APPaymentInfoLocation.Insert(copyloc); } if (record.IsAPPaymentInfoSameAsMain == true) { foreach (VendorPaymentMethodDetail copydet in this.PaymentDetails.Select(record.BAccountID, record.LocationID, record.VPaymentMethodID)) { this.PaymentDetails.Delete(copydet); } BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); if (baccount != null) { record.VPaymentInfoLocationID = baccount.DefLocationID; Location mainloc = PXSelect<CR.Location, Where<CR.Location.bAccountID, Equal<Required<CR.Location.bAccountID>>, And<CR.Location.locationID, Equal<Required<CR.Location.locationID>>>>>.Select(sender.Graph, baccount.BAccountID, baccount.DefLocationID); if (mainloc != null) { if (record.DefAddressID != record.VRemitAddressID && mainloc.VRemitAddressID != record.VRemitAddressID) { Address copyaddr = FindAddress(record.VRemitAddressID); RemitAddress.Delete(copyaddr); } if (record.DefContactID != record.VRemitContactID && mainloc.VRemitContactID != record.VRemitContactID) { Contact copycont = FindContact(record.VRemitContactID); RemitContact.Delete(copycont); } } } record.VCashAccountID = null; record.VPaymentMethodID = null; record.VPaymentLeadTime = 0; record.VSeparateCheck = false; record.VRemitAddressID = null; record.VRemitContactID = null; } }
public static void Revalue(RevalueFilter filter, List <RevaluedGLHistory> list) { JournalEntry je = PXGraph.CreateInstance <JournalEntry>(); PostGraph pg = PXGraph.CreateInstance <PostGraph>(); PXCache basecache = je.Caches[typeof(AcctHist)]; je.Views.Caches.Add(typeof(AcctHist)); string extRefNbrNumbering = je.CMSetup.Current.ExtRefNbrNumberingID; if (string.IsNullOrEmpty(extRefNbrNumbering) == false) { RevaluationRefNbrHelper helper = new RevaluationRefNbrHelper(extRefNbrNumbering); helper.Subscribe(je); } DocumentList <Batch> created = new DocumentList <Batch>(je); Currency currency = PXSelect <Currency, Where <Currency.curyID, Equal <Required <Currency.curyID> > > > .Select(je, filter.CuryID); using (PXTransactionScope ts = new PXTransactionScope()) { foreach (RevaluedGLHistory hist in list) { if (hist.FinPtdRevalued == 0m) { continue; } if (je.GLTranModuleBatNbr.Cache.IsInsertedUpdatedDeleted) { je.Save.Press(); if (created.Find(je.BatchModule.Current) == null) { created.Add(je.BatchModule.Current); } } Batch cmbatch = created.Find <Batch.branchID>(hist.BranchID) ?? new Batch(); if (cmbatch.BatchNbr == null) { je.Clear(); CurrencyInfo info = new CurrencyInfo(); info.CuryID = hist.CuryID; info.CuryEffDate = hist.CuryEffDate; info.BaseCalc = false; info = je.currencyinfo.Insert(info) ?? info; cmbatch = new Batch(); cmbatch.BranchID = hist.BranchID; cmbatch.Module = "CM"; cmbatch.Status = "U"; cmbatch.AutoReverse = false; cmbatch.Released = true; cmbatch.Hold = false; cmbatch.DateEntered = filter.CuryEffDate; cmbatch.FinPeriodID = filter.FinPeriodID; cmbatch.TranPeriodID = filter.FinPeriodID; cmbatch.CuryID = hist.CuryID; cmbatch.CuryInfoID = info.CuryInfoID; cmbatch.DebitTotal = 0m; cmbatch.CreditTotal = 0m; cmbatch.Description = filter.Description; je.BatchModule.Insert(cmbatch); CurrencyInfo b_info = je.currencyinfo.Select(); if (b_info != null) { b_info.CuryID = hist.CuryID; b_info.CuryEffDate = hist.CuryEffDate; b_info.CuryRateTypeID = hist.CuryRateTypeID; b_info.CuryRate = hist.CuryRate; b_info.RecipRate = hist.RateReciprocal; b_info.CuryMultDiv = hist.CuryMultDiv; je.currencyinfo.Update(b_info); } } else { if (!je.BatchModule.Cache.ObjectsEqual(je.BatchModule.Current, cmbatch)) { je.Clear(); } je.BatchModule.Current = je.BatchModule.Search <Batch.batchNbr>(cmbatch.BatchNbr, cmbatch.Module); } { GLTran tran = new GLTran(); tran.SummPost = false; tran.AccountID = hist.AccountID; tran.SubID = hist.SubID; tran.CuryDebitAmt = 0m; tran.CuryCreditAmt = 0m; if (hist.AccountType == AccountType.Asset || hist.AccountType == AccountType.Expense) { tran.DebitAmt = (hist.FinPtdRevalued < 0m) ? 0m : hist.FinPtdRevalued; tran.CreditAmt = (hist.FinPtdRevalued < 0m) ? -1m * hist.FinPtdRevalued : 0m; } else { tran.DebitAmt = (hist.FinPtdRevalued < 0m) ? -1m * hist.FinPtdRevalued : 0m; tran.CreditAmt = (hist.FinPtdRevalued < 0m) ? 0m : hist.FinPtdRevalued; } tran.TranType = "REV"; tran.TranClass = hist.AccountType; tran.RefNbr = string.Empty; tran.TranDesc = filter.Description; tran.TranPeriodID = filter.FinPeriodID; tran.FinPeriodID = filter.FinPeriodID; tran.TranDate = filter.CuryEffDate; tran.CuryInfoID = null; tran.Released = true; tran.ReferenceID = null; tran.ProjectID = PM.ProjectDefaultAttribute.NonProject(); je.GLTranModuleBatNbr.Insert(tran); } foreach (GLTran tran in je.GLTranModuleBatNbr.SearchAll <Asc <GLTran.tranClass> >(new object[] { "G" })) { je.GLTranModuleBatNbr.Delete(tran); } { GLTran tran = new GLTran(); tran.SummPost = true; tran.ZeroPost = false; tran.CuryDebitAmt = 0m; tran.CuryCreditAmt = 0m; if (je.BatchModule.Current.DebitTotal > je.BatchModule.Current.CreditTotal) { tran.AccountID = currency.RevalGainAcctID; tran.SubID = GainLossSubAccountMaskAttribute.GetSubID <Currency.revalGainSubID>(je, hist.BranchID, currency); tran.DebitAmt = 0m; tran.CreditAmt = (je.BatchModule.Current.DebitTotal - je.BatchModule.Current.CreditTotal); } else { tran.AccountID = currency.RevalLossAcctID; tran.SubID = GainLossSubAccountMaskAttribute.GetSubID <Currency.revalLossSubID>(je, hist.BranchID, currency); tran.DebitAmt = (je.BatchModule.Current.CreditTotal - je.BatchModule.Current.DebitTotal); tran.CreditAmt = 0m; } tran.TranType = "REV"; tran.TranClass = GLTran.tranClass.UnrealizedAndRevaluationGOL; tran.RefNbr = string.Empty; tran.TranDesc = filter.Description; tran.Released = true; tran.ReferenceID = null; je.GLTranModuleBatNbr.Insert(tran); } { AcctHist accthist = new AcctHist(); accthist.BranchID = hist.BranchID; accthist.LedgerID = hist.LedgerID; accthist.AccountID = hist.AccountID; accthist.SubID = hist.SubID; accthist.FinPeriodID = filter.FinPeriodID; accthist.CuryID = hist.CuryID; accthist.BalanceType = "A"; accthist = (AcctHist)basecache.Insert(accthist); accthist.FinPtdRevalued += hist.FinPtdRevalued; } } if (je.GLTranModuleBatNbr.Cache.IsInsertedUpdatedDeleted) { je.Save.Press(); if (created.Find(je.BatchModule.Current) == null) { created.Add(je.BatchModule.Current); } } ts.Complete(); } CMSetup cmsetup = PXSelect <CMSetup> .Select(je); for (int i = 0; i < created.Count; i++) { if (cmsetup.AutoPostOption == true) { pg.Clear(); pg.PostBatchProc(created[i]); } } if (created.Count > 0) { je.BatchModule.Current = created[created.Count - 1]; throw new PXRedirectRequiredException(je, "Preview"); } }
protected override void Location_VBranchID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { }
protected virtual void RevalueFilter_CuryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { GLAccountList.Cache.Clear(); }
protected virtual void LocationAPAccountSub_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { LocationAPAccountSub record = (LocationAPAccountSub)e.Row; if (!sender.ObjectsEqual<LocationAPAccountSub.vAPAccountID, LocationAPAccountSub.vAPSubID>(e.Row, e.OldRow)) { Location mainloc = Location.Current; mainloc.VAPAccountID = record.VAPAccountID; mainloc.VAPSubID = record.VAPSubID; if (Location.Cache.GetStatus(mainloc) == PXEntryStatus.Notchanged) { Location.Cache.SetStatus(mainloc, PXEntryStatus.Updated); } } }
protected virtual void EPActivity_ParentTaskID_CacheAttached(PXCache cache) { }
protected virtual void LocationAPPaymentInfo_IsRemitAddressSameAsMain_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { LocationAPPaymentInfo owner = (LocationAPPaymentInfo)e.Row; if (owner != null) { if (owner.IsRemitAddressSameAsMain == true) { if (owner.VRemitAddressID != owner.VDefAddressID) { Address extAddr = this.FindAddress(owner.VRemitAddressID); if (extAddr != null && extAddr.AddressID == owner.VRemitAddressID) { this.RemitAddress.Delete(extAddr); } owner.VRemitAddressID = owner.VDefAddressID; //if (this.Location.Cache.Locate(owner) != null) // this.Location.Cache.Update(owner); } } if (owner.IsRemitAddressSameAsMain == false) { if (owner.VRemitAddressID != null) { if (owner.VRemitAddressID == owner.VDefAddressID) { Address defAddress = this.FindAddress(owner.VDefAddressID); Address addr = PXCache<Address>.CreateCopy(defAddress); addr.AddressID = null; addr.BAccountID = owner.BAccountID; addr = this.RemitAddress.Insert(addr); owner.VRemitAddressID = addr.AddressID; //if (this.Location.Cache.Locate(owner) != null) // this.Location.Cache.Update(owner); } } } } }
protected virtual void EPActivity_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { EPActivity row = (EPActivity)e.Row; if (row == null) { return; } bool isPmVisible = ProjectAttribute.IsPMVisible(this, BatchModule.EP); PXUIFieldAttribute.SetVisible <EPActivity.projectID>(cache, row, isPmVisible); PXUIFieldAttribute.SetVisible <EPActivity.projectTaskID>(cache, row, isPmVisible); PXUIFieldAttribute.SetEnabled <EPActivity.endDate>(cache, row, false); bool showMinutes = EPSetupCurrent.RequireTimes == true; PXDBDateAndTimeAttribute.SetTimeVisible <EPActivity.startDate>(cache, row, showMinutes && row.TrackTime == true); PXDBDateAndTimeAttribute.SetTimeVisible <EPActivity.endDate>(cache, row, showMinutes && row.TrackTime == true); bool wasUsed = !string.IsNullOrEmpty(row.TimeCardCD) || row.Billed == true; if (wasUsed) { PXUIFieldAttribute.SetEnabled(cache, row, false); } PXUIFieldAttribute.SetVisible <EPActivity.timeSpent>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.earningTypeID>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.isBillable>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.released>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.timeBillable>(cache, row, row.IsBillable == true && row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.uistatus>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.approverID>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.projectID>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.projectTaskID>(cache, row, row.TrackTime == true); PXUIFieldAttribute.SetVisible <EPActivity.overtimeSpent>(cache, row, false); PXUIFieldAttribute.SetVisible <EPActivity.overtimeBillable>(cache, row, false); string origStatus = (string)this.Activites.Cache.GetValueOriginal <EPActivity.uistatus>(row) ?? ActivityStatusListAttribute.Open; bool?oringTrackTime = (bool?)this.Activites.Cache.GetValueOriginal <EPActivity.trackTime>(row) ?? false; if (origStatus == ActivityStatusListAttribute.Completed && oringTrackTime != true) { origStatus = ActivityStatusListAttribute.Open; } if (row.Released == true) { origStatus = ActivityStatusListAttribute.Completed; } if (origStatus == ActivityStatusListAttribute.Open) { PXUIFieldAttribute.SetEnabled(cache, row, true); PXUIFieldAttribute.SetEnabled <EPActivity.timeBillable>(cache, row, !wasUsed && row.IsBillable == true); PXUIFieldAttribute.SetEnabled <EPActivity.overtimeBillable>(cache, row, !wasUsed && row.IsBillable == true); Delete.SetEnabled(!wasUsed); } else { PXUIFieldAttribute.SetEnabled(cache, row, false); PXUIFieldAttribute.SetEnabled <EPActivity.uistatus>(cache, row, !wasUsed && row.Released != true); Delete.SetEnabled(false); } PXUIFieldAttribute.SetEnabled <EPActivity.released>(cache, row, false); PXUIFieldAttribute.SetEnabled <EPActivity.taskID>(cache, row); MarkAsCompleted.SetEnabled(origStatus == ActivityStatusListAttribute.Open); MarkAsCompleted.SetVisible(origStatus == ActivityStatusListAttribute.Open && row.TrackTime == true); MarkAsCompletedAndFollowUp.SetVisible(false); ValidateTimeBillable(cache, row); ValidateOvertimeBillable(cache, row); GotoParentActivity.SetEnabled(row.ParentTaskID != null); PXDefaultAttribute.SetPersistingCheck <EPActivity.owner>(cache, row, row.TrackTime == true ? PXPersistingCheck.Null : PXPersistingCheck.Nothing); PXDefaultAttribute.SetPersistingCheck <EPActivity.type>(cache, row, PXPersistingCheck.Null); }
protected virtual void LocationAPPaymentInfo_RowSelecting(PXCache sender, PXRowSelectingEventArgs e) { if (e.Row != null) { LocationAPPaymentInfo record = (LocationAPPaymentInfo)e.Row; record.IsRemitAddressSameAsMain = object.Equals(record.VDefAddressID, record.VRemitAddressID); record.IsRemitContactSameAsMain = object.Equals(record.VDefContactID, record.VRemitContactID); } }
public static bool Validate <T>(PXGraph aGraph, T aAddress, bool aSynchronous, bool updateToValidAddress) where T : IAddressBase, IValidatedAddress { if (!AddressValidatorPluginMaint.IsActive(aGraph, aAddress.CountryID)) { if (aSynchronous) { PXCache cache = aGraph.Caches[typeof(T)]; string countryFieldName = nameof(IAddressBase.CountryID); cache.RaiseExceptionHandling(countryFieldName, aAddress, aAddress.CountryID, new PXSetPropertyException(Messages.AddressVerificationServiceIsNotSetup, PXErrorLevel.Warning, aAddress.CountryID)); return(false); } else { throw new PXException(Messages.AddressVerificationServiceIsNotSetup, aAddress.CountryID); } } bool isValid = true; Country country = Country.PK.Find(aGraph, aAddress.CountryID); updateToValidAddress = updateToValidAddress && country.AutoOverrideAddress == true; IAddressValidator service = AddressValidatorPluginMaint.CreateAddressValidator(aGraph, country.AddressValidatorPluginID); if (service != null) { PXCache cache = aGraph.Caches[typeof(T)]; Dictionary <string, string> messages = new Dictionary <string, string>(); T validAddress = (T)cache.CreateCopy(aAddress); try { isValid = service.ValidateAddress(validAddress, messages); } catch { throw new PXException(Messages.UnknownErrorOnAddressValidation); } if (isValid) { string[] fields = { nameof(IAddressBase.AddressLine1), nameof(IAddressBase.AddressLine2), //nameof(IAddressBase.AddressLine3), nameof(IAddressBase.City), nameof(IAddressBase.State), nameof(IAddressBase.PostalCode) }; var modifiedFields = fields.Select(field => new { Field = field, OriginalValue = ((string)cache.GetValue(aAddress, field)) ?? string.Empty, ValidValue = ((string)cache.GetValue(validAddress, field)) ?? string.Empty }).Where(x => string.Compare(x.OriginalValue.Trim(), x.ValidValue.Trim(), StringComparison.OrdinalIgnoreCase) != 0).ToArray(); if (aSynchronous && !updateToValidAddress && modifiedFields.Any()) { var fieldsShouldBeEqual = new HashSet <string>() { nameof(IAddressBase.PostalCode) }; foreach (var m in modifiedFields) { cache.RaiseExceptionHandling(m.Field, aAddress, m.OriginalValue, new PXSetPropertyException(Messages.AddressVerificationServiceReturnsField, PXErrorLevel.Warning, m.ValidValue)); if (fieldsShouldBeEqual.Contains(m.Field)) { isValid = false; } } } if (isValid) { T copyToUpdate = (T)cache.CreateCopy(aAddress); Action <T> raiseWarnings = null; if (aSynchronous && updateToValidAddress) { foreach (var m in modifiedFields) { var validValue = m.ValidValue == string.Empty ? null : m.ValidValue; cache.SetValue(copyToUpdate, m.Field, validValue); raiseWarnings += (a) => cache.RaiseExceptionHandling(m.Field, a, validValue, new PXSetPropertyException(Messages.AddressVerificationServiceReplaceValue, PXErrorLevel.Warning, m.OriginalValue)); } } copyToUpdate.IsValidated = true; aAddress = (T)cache.Update(copyToUpdate); raiseWarnings?.Invoke(aAddress); } } else { string message = string.Empty; StringBuilder messageBuilder = new StringBuilder(); int count = 0; foreach (var iMsg in messages) { if (!aSynchronous) { if (count > 0) { messageBuilder.Append(","); } messageBuilder.AppendFormat("{0}:{1}", iMsg.Key, iMsg.Value); count++; } else { object value = cache.GetValue(aAddress, iMsg.Key); cache.RaiseExceptionHandling(iMsg.Key, aAddress, value, new PXSetPropertyException(iMsg.Value)); } } if (!aSynchronous) { throw new PXException(messageBuilder.ToString()); } } } return(isValid); }
protected virtual void LocationAPPaymentInfo_VPaymentMethodID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { string oldValue = (string)e.OldValue; LocationAPPaymentInfo row = (LocationAPPaymentInfo)e.Row; if (!String.IsNullOrEmpty(oldValue)) { this.ClearPaymentDetails((LocationAPPaymentInfo)e.Row, oldValue, true); } this.FillPaymentDetails((LocationAPPaymentInfo)e.Row); sender.SetDefaultExt<LocationAPPaymentInfo.vCashAccountID>(e.Row); }
protected virtual void PMCostBudget_ProjectTaskID_CacheAttached(PXCache cache) { }
protected virtual void VendorPaymentMethodDetail_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { if (e.Row == null) return; if (Location.Current != null) { PXUIFieldAttribute.SetEnabled(sender, e.Row, object.Equals(Location.Current.LocationID, Location.Current.VPaymentInfoLocationID)); } }
protected virtual void UsersInRoles_Username_CacheAttached(PXCache sender) { }
protected virtual void Address_CountryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { Address addr = (Address)e.Row; if ((string)e.OldValue != addr.CountryID) { addr.State = null; } }
protected virtual void INSiteFilter_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e) { INItemList.Cache.Clear(); }