public override CATran DefaultValues(PXCache sender, CATran catran_Row, object orig_Row) { CATransfer parentDoc = (CATransfer)orig_Row; if ((parentDoc.Released == true) && (catran_Row.TranID != null)) { return(null); } if (catran_Row.TranID == null || catran_Row.TranID < 0) { catran_Row.OrigModule = BatchModule.CA; catran_Row.OrigRefNbr = parentDoc.TransferNbr; } if (object.Equals(_FieldOrdinal, sender.GetFieldOrdinal <CATransfer.tranIDOut>())) { catran_Row.CashAccountID = parentDoc.OutAccountID; catran_Row.OrigTranType = CATranType.CATransferOut; catran_Row.ExtRefNbr = parentDoc.OutExtRefNbr; catran_Row.CuryID = parentDoc.OutCuryID; catran_Row.CuryInfoID = parentDoc.OutCuryInfoID; catran_Row.CuryTranAmt = -parentDoc.CuryTranOut; catran_Row.TranAmt = -parentDoc.TranOut; catran_Row.DrCr = DrCr.Credit; catran_Row.Cleared = parentDoc.ClearedOut; catran_Row.ClearDate = parentDoc.ClearDateOut; catran_Row.TranDate = parentDoc.OutDate; SetPeriodsByMaster(sender, catran_Row, parentDoc.OutTranPeriodID); } else if (object.Equals(_FieldOrdinal, sender.GetFieldOrdinal <CATransfer.tranIDIn>())) { catran_Row.CashAccountID = parentDoc.InAccountID; catran_Row.OrigTranType = CATranType.CATransferIn; catran_Row.ExtRefNbr = parentDoc.InExtRefNbr; catran_Row.CuryID = parentDoc.InCuryID; catran_Row.CuryInfoID = parentDoc.InCuryInfoID; catran_Row.CuryTranAmt = parentDoc.CuryTranIn; catran_Row.TranAmt = parentDoc.TranIn; catran_Row.DrCr = DrCr.Debit; catran_Row.Cleared = parentDoc.ClearedIn; catran_Row.ClearDate = parentDoc.ClearDateIn; catran_Row.TranDate = parentDoc.InDate; SetPeriodsByMaster(sender, catran_Row, parentDoc.InTranPeriodID); } else { throw new PXException(AP.Messages.UnknownDocumentType); } SetCleared(catran_Row, GetCashAccount(catran_Row, sender.Graph)); catran_Row.TranDesc = parentDoc.Descr; catran_Row.ReferenceID = null; catran_Row.Released = parentDoc.Released; catran_Row.Hold = parentDoc.Hold; return(catran_Row); }
public void RowPersisted(PXCache sender, PXRowPersistedEventArgs e) { if (e.TranStatus == PXTranStatus.Completed) { return; } var newVal = sender.GetValue(e.Row, ordinal); // we should skip update if the row has not been changed int ixNote = sender.GetFieldOrdinal(NoteID); var noteId = sender.GetValue(e.Row, ixNote); bool updated = PXDatabase.Provider.Update(typeof(ExtraFieldValue), new PXDataFieldRestrict <ExtraFieldValue.noteId>(noteId), new PXDataFieldRestrict <ExtraFieldValue.extFieldId>(attributeId), new PXDataFieldAssign <ExtraFieldValue.value>(newVal)); if (!updated) { PXDatabase.Provider.Insert(typeof(ExtraFieldValue), new PXDataFieldAssign <ExtraFieldValue.noteId>(noteId), new PXDataFieldAssign <ExtraFieldValue.extFieldId>(attributeId), new PXDataFieldAssign <ExtraFieldValue.value>(newVal)); } }
protected virtual void AnyFieldSelecting(PXCache sender, PXFieldSelectingEventArgs e, string fieldName) { if (sender.GetFieldOrdinal(fieldName) < 0) { e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(string), visible: false); } }
public void RowDeleted(PXCache sender, PXRowDeletedEventArgs e) { int ixNote = sender.GetFieldOrdinal(NoteID); var noteId = sender.GetValue(e.Row, ixNote); // if the main table uses DeletedColumn, do not remove the records? PXDatabase.Provider.Delete(typeof(ExtraFieldValue), new PXDataFieldRestrict <ExtraFieldValue.noteId>(noteId), new PXDataFieldRestrict <ExtraFieldValue.extFieldId>(attributeId) ); }
public void RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { // ensure noteID is initialized on main object int ixNote = sender.GetFieldOrdinal(NoteID); var noteId = sender.GetValue(e.Row, ixNote); if (null == noteId) { sender.SetValue(e.Row, ixNote, SequentialGuid.Generate()); } }
public KeyValuesComparer(PXCache cache, IEnumerable <Type> keyFields) { _cache = cache; _keyOrdinals = keyFields.Select(f => _cache.GetFieldOrdinal(f.Name)).ToArray(); }
public override CATran DefaultValues(PXCache sender, CATran catran_Row, object orig_Row) { CATransfer parentDoc = (CATransfer)orig_Row; if ((parentDoc.Released == true) && (catran_Row.TranID != null)) { return(null); } if (catran_Row.TranID == null || catran_Row.TranID < 0) { catran_Row.OrigModule = BatchModule.CA; catran_Row.OrigRefNbr = parentDoc.TransferNbr; } if (object.Equals(_FieldOrdinal, sender.GetFieldOrdinal <CATransfer.tranIDOut>())) { catran_Row.CashAccountID = parentDoc.OutAccountID; catran_Row.OrigTranType = CATranType.CATransferOut; catran_Row.ExtRefNbr = parentDoc.OutExtRefNbr; catran_Row.CuryID = parentDoc.OutCuryID; catran_Row.CuryInfoID = parentDoc.OutCuryInfoID; catran_Row.CuryTranAmt = -parentDoc.CuryTranOut; catran_Row.TranAmt = -parentDoc.TranOut; catran_Row.DrCr = DrCr.Credit; catran_Row.Cleared = parentDoc.ClearedOut; catran_Row.ClearDate = parentDoc.ClearDateOut; catran_Row.TranDate = parentDoc.OutDate; } else if (object.Equals(_FieldOrdinal, sender.GetFieldOrdinal <CATransfer.tranIDIn>())) { catran_Row.CashAccountID = parentDoc.InAccountID; catran_Row.OrigTranType = CATranType.CATransferIn; catran_Row.ExtRefNbr = parentDoc.InExtRefNbr; catran_Row.CuryID = parentDoc.InCuryID; catran_Row.CuryInfoID = parentDoc.InCuryInfoID; catran_Row.CuryTranAmt = parentDoc.CuryTranIn; catran_Row.TranAmt = parentDoc.TranIn; catran_Row.DrCr = DrCr.Debit; catran_Row.Cleared = parentDoc.ClearedIn; catran_Row.ClearDate = parentDoc.ClearDateIn; catran_Row.TranDate = parentDoc.InDate; } else { throw new PXException(AP.Messages.UnknownDocumentType); } PXSelectBase <CashAccount> selectStatement = new PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > >(sender.Graph); CashAccount cashacc = (CashAccount)selectStatement.View.SelectSingle(catran_Row.CashAccountID); if (cashacc != null && cashacc.Reconcile == false && (catran_Row.Cleared != true || catran_Row.TranDate == null)) { catran_Row.Cleared = true; catran_Row.ClearDate = catran_Row.TranDate; } catran_Row.TranDesc = parentDoc.Descr; catran_Row.ReferenceID = null; catran_Row.Released = parentDoc.Released; catran_Row.Hold = parentDoc.Hold; return(catran_Row); }