public virtual void loadTemplateColumnsSS() { PMSetup pmSetupRow = this.Base.Setup.Current; if (pmSetupRow == null) { throw new PXException(SmartsheetConstants.Messages.ERROR_SETUP); } PXCache <PMSSMapping> mappingCache = this.Base.Caches <PMSSMapping>(); if (MappingSetup.Select().Count() == 0) { InsertTemplate(mappingCache); } else { WebDialogResult result = this.Base.Setup.View.Ask(this.Base.Setup.Current, SmartsheetConstants.Messages.CONFIRM_HEADER, SmartsheetConstants.Messages.CONFIRM_RELOAD_VALUES, MessageButtons.YesNoCancel, MessageIcon.Warning); if (result == WebDialogResult.Yes) { foreach (PMSSMapping item in MappingSetup.Select()) { mappingCache.Delete(item); } mappingCache.Persist(PXDBOperation.Delete); InsertTemplate(mappingCache); } } }
protected void SafetyPersist(PXCache cache, params PXDBOperation[] operations) { if (operations.Length < 1) { return; } bool isAborted = false; try { using (PXTransactionScope tscope = new PXTransactionScope()) { foreach (PXDBOperation operation in operations) { cache.Persist(operation); } tscope.Complete(); } } catch (Exception) { isAborted = true; throw; } finally { cache.Persisted(isAborted); } }
protected virtual void _(Events.RowPersisted <EPEquipment> e) { if (e.Row == null) { return; } if (e.TranStatus == PXTranStatus.Open) { EPEquipment epEquipmentRow = (EPEquipment)e.Row; FSEquipment fsEquipmentRow = GetRelatedFSEquipmentRow(e.Cache.Graph); if (fsEquipmentRow != null) { PXCache <FSEquipment> cacheFSEquipment = new PXCache <FSEquipment>(Base); // This is to prevent an error on the FSEquipment cache trying to change a common field (status, description) // after extending an equipment to FSEquipment. cacheFSEquipment.Graph.SelectTimeStamp(); if (EquipmentHelper.UpdateFSEquipmentWithEPEquipment(cacheFSEquipment, fsEquipmentRow, e.Cache, epEquipmentRow)) { cacheFSEquipment.Update(fsEquipmentRow); cacheFSEquipment.Persist(PXDBOperation.Update); } } } }
public static bool RecordCostTrans(RegisterEntry registerEntry, List <EPActivityApprove> activities) { registerEntry.FieldVerifying.AddHandler <PMTran.inventoryID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });//restriction should be applicable only for budgeting. EmployeeCostEngine costEngine = new EmployeeCostEngine(registerEntry); registerEntry.Views.Caches.Add(typeof(EPActivity)); PXCache activityCache = registerEntry.Caches <EPActivity>(); registerEntry.Document.Cache.Insert(); bool success = true; bool activityAdded = false; for (int i = 0; i < activities.Count; i++) { EPActivity activity = PXSelect <EPActivity> .Search <EPActivity.taskID>(registerEntry, activities[i].TaskID); if (activity.Released == true) //activity can be released to PM via Timecard prior to releasing the case. { continue; } try { if (activity.ProjectTaskID != null) //cost transactions are created only if project is set. { EPEmployee employee = PXSelect <EPEmployee> .Search <EPEmployee.userID>(registerEntry, activity.Owner); activity.LabourItemID = costEngine.GetLaborClass(activity); activityCache.Update(activity); decimal?cost = costEngine.CalculateEmployeeCost(activity, employee.BAccountID, activity.StartDate.Value); registerEntry.CreateTransaction(activity, employee.BAccountID, activity.StartDate.Value, activity.TimeSpent, activity.TimeBillable, cost); activity.EmployeeRate = cost; activityAdded = true; } activity.Released = true; activityCache.Update(activity); } catch (Exception e) { PXProcessing <EPActivityApprove> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); success = false; } } if (success) { if (activityAdded) { registerEntry.Save.Press(); } else { activityCache.Persist(PXDBOperation.Update); } } return(success); }
private void CreateCustomerPaymentMethodDetailRecord(CustomerPaymentMethod customerPM, CCSynchronizeCard syncCard) { PXResultset <PaymentMethodDetail> details = GetPaymentMethodDetailParams(customerPM.PaymentMethodID); PXCache customerPaymentMethodDetailCache = Caches[typeof(CustomerPaymentMethodDetail)]; CustomerPaymentMethodDetail customerPaymentDetails; foreach (PaymentMethodDetail detail in details) { customerPaymentDetails = customerPaymentMethodDetailCache.CreateInstance() as CustomerPaymentMethodDetail; customerPaymentDetails.DetailID = detail.DetailID; customerPaymentDetails.PMInstanceID = customerPM.PMInstanceID; customerPaymentDetails.PaymentMethodID = customerPM.PaymentMethodID; if (customerPaymentDetails.DetailID == CreditCardAttributes.CardNumber) { Match match = new Regex("[\\d]+").Match(syncCard.CardNumber); if (match.Success) { string cardNum = match.Value.PadLeft(8, 'X'); customerPaymentDetails.Value = cardNum; } } if (customerPaymentDetails.DetailID == CreditCardAttributes.CCPID) { customerPaymentDetails.Value = syncCard.PaymentCCPID; } customerPaymentMethodDetailCache.Insert(customerPaymentDetails); customerPaymentMethodDetailCache.Persist(PXDBOperation.Insert); } }
public void UpdateCCProcessingSyncronizeCardRecord(CCSynchronizeCard item) { PXCache syncCardCache = Caches[typeof(CCSynchronizeCard)]; item.Imported = true; syncCardCache.Update(item); syncCardCache.Persist(PXDBOperation.Update); }
protected virtual void ARInvoice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { sender.Persist(e.Row, PXDBOperation.Normal); sender.PersistInserted(e.Row); sender.PersistUpdated(e.Row); sender.PersistDeleted(e.Row); }
protected virtual void userSetupDialog() { EnsureUserSetup(); PXCache setupCache = Base.Caches[typeof(TSetup)]; if (UserSetupView.AskExt() == WebDialogResult.OK) { using (var tr = new PXTransactionScope()) { setupCache.Persist(PXDBOperation.Insert); setupCache.Persist(PXDBOperation.Update); tr.Complete(); } Base.Clear(); } else { setupCache.Clear(); setupCache.ClearQueryCacheObsolete(); } }
public static bool RecordContractUsage(List <EPActivityApprove> activities, string description) { RegisterEntry registerEntry = PXGraph.CreateInstance <RegisterEntry>(); registerEntry.FieldVerifying.AddHandler <PMTran.projectID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); registerEntry.FieldVerifying.AddHandler <PMTran.inventoryID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });//restriction should be applicable only for budgeting. registerEntry.Document.Cache.Insert(); registerEntry.Document.Current.Description = description; registerEntry.Document.Current.Released = true; registerEntry.Views.Caches.Add(typeof(EPActivity)); PXCache activityCache = registerEntry.Caches <EPActivity>(); bool success = true; bool activityAdded = false; for (int i = 0; i < activities.Count; i++) { EPActivity activity = activities[i]; try { if (activity.RefNoteID != null && PXSelect <CRCase, Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > .Select(registerEntry, activity.RefNoteID).Count == 1) { //Add Contract-Usage activityAdded = registerEntry.CreateContractUsage(activity) != null || activityAdded; activity.Billed = true; activityCache.Update(activity); } } catch (Exception e) { PXProcessing <EPActivityApprove> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); success = false; } } if (success) { if (activityAdded) { registerEntry.Save.Press(); } else { activityCache.Persist(PXDBOperation.Update); } } return(success); }
protected IEnumerable reset(PXAdapter adapter) { EMailAccountSyncFilter filter = Filter.Current; EMailSyncAccount account = SelectedItems.Current; if (filter == null || account == null) { return(adapter.Get()); } EMailSyncAccount accountCopy = (EMailSyncAccount)SelectedItems.Cache.CreateCopy(account); accountCopy.ContactsExportDate = null; accountCopy.ContactsExportFolder = null; accountCopy.ContactsImportDate = null; accountCopy.ContactsImportFolder = null; accountCopy.EmailsExportDate = null; accountCopy.EmailsExportFolder = null; accountCopy.EmailsImportDate = null; accountCopy.EmailsImportFolder = null; accountCopy.EventsExportDate = null; accountCopy.EventsExportFolder = null; accountCopy.EventsImportDate = null; accountCopy.EventsImportFolder = null; accountCopy.TasksExportDate = null; accountCopy.TasksExportFolder = null; accountCopy.TasksImportDate = null; accountCopy.TasksImportFolder = null; PXCache cache = this.Caches[typeof(EMailSyncAccount)]; cache.Update(accountCopy); cache.Persist(PXDBOperation.Update); SelectedItems.Cache.ClearQueryCache(); SelectedItems.View.Clear(); SelectedItems.Cache.Clear(); CurrentItem.View.RequestRefresh(); SelectedItems.View.RequestRefresh(); return(adapter.Get()); }
public static void UpdateTaxHistorySums(PXGraph graph, RoundingManager rmanager, string taxPeriodId, int?revisionId, int?organizationID, int?branchID, Func <TaxReportLine, bool> ShowTaxReportLine = null) { if (!rmanager.IsRequireRounding) { return; } PXCache cache = graph.Caches[typeof(TaxHistory)]; using (new PXReadBranchRestrictedScope(organizationID.SingleToArray(), branchID.SingleToArrayOrNull(), requireAccessForAllSpecified: true)) { PXResultset <TaxHistory> lines = GetTaxHistoryLines(graph, rmanager.CurrentVendor.BAccountID, taxPeriodId, revisionId); if (lines.Count == 0) { return; } if (organizationID == null) { Branch branch = PXSelect <Branch, Where <Branch.branchID, Equal <Required <Branch.branchID> > > > .SelectSingleBound(graph, null, branchID); organizationID = branch?.OrganizationID; } TaxPeriod period = TaxYearMaint.GetTaxPeriodByKey(graph, organizationID, rmanager.CurrentVendor.BAccountID, taxPeriodId); Company company = PXSelect <Company> .Select(graph); PXResult <Currency, CurrencyRateByDate> curyWithRateSet = GetCurrencyAndRateByDate(graph, rmanager.CurrentVendor, company, period); Currency currency = curyWithRateSet; CurrencyRateByDate rateByDate = currency.CuryID != company.BaseCuryID ? curyWithRateSet : null; TaxBucketsCalculation taxBucketsAggregatesCalc = new TaxBucketsCalculation(TaxReportLineType.TaxAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine); TaxBucketsCalculation taxableBucketsAggregatesCalc = new TaxBucketsCalculation(TaxReportLineType.TaxableAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine); taxBucketsAggregatesCalc.CalculateTaxBuckets(lines); taxableBucketsAggregatesCalc.CalculateTaxBuckets(lines); } cache.Persist(PXDBOperation.Insert); cache.Persisted(isAborted: false); }
public static void CreateContractPostRegister(PXGraph graph, FSContractPostDoc fsContractPostDocRow) { PXCache <FSContractPostRegister> cacheFSPostRegister = new PXCache <FSContractPostRegister>(graph); FSContractPostRegister fsPostRegisterRow = new FSContractPostRegister(); fsPostRegisterRow.ServiceContractID = fsContractPostDocRow.ServiceContractID; fsPostRegisterRow.ContractPeriodID = fsContractPostDocRow.ContractPeriodID; fsPostRegisterRow.ContractPostBatchID = fsContractPostDocRow.ContractPostBatchID; fsPostRegisterRow.PostedTO = fsContractPostDocRow.PostedTO; fsPostRegisterRow.PostDocType = fsContractPostDocRow.PostDocType; fsPostRegisterRow.PostRefNbr = fsContractPostDocRow.PostRefNbr; cacheFSPostRegister.Insert(fsPostRegisterRow); cacheFSPostRegister.Persist(PXDBOperation.Insert); }
public static void RegenerateLastStatement(StatementCycleProcessBO graph, ARStatementCycle aCycle) { graph.Clear(); ARStatementCycle cycle = graph.CyclesList.Select(aCycle.StatementCycleId); if (cycle.LastStmtDate != null) { DateTime stmtDate = (DateTime)cycle.LastStmtDate; using (PXTransactionScope ts = new PXTransactionScope()) { DeleteStatement(cycle, stmtDate); graph.GenerateStatement(cycle, stmtDate); PXCache cache = graph.CyclesList.Cache; cache.Update(cycle); cache.Persist(PXDBOperation.Update); ts.Complete(); } } }
public static void UpdateTaxHistorySums(PXGraph graph, RoundingManager rmanager, string taxPeriodId, int?revisionId, int?branchID, Func <TaxReportLine, bool> ShowTaxReportLine = null) { if (!rmanager.IsRequireRounding) { return; } PXCache cache = graph.Caches[typeof(TaxHistory)]; using (new PXReadBranchRestrictedScope(branchID)) { PXResultset <TaxHistory> lines = GetTaxHistoryLines(graph, rmanager.CurrentVendor.BAccountID, taxPeriodId, revisionId); if (lines.Count == 0) { return; } Branch branch = BranchMaint.FindBranchByID(graph, branchID); TaxPeriod period = TaxYearMaint.GetTaxPeriodByKey(graph, branch.ParentBranchID, rmanager.CurrentVendor.BAccountID, taxPeriodId); Company company = PXSelect <Company> .Select(graph); PXResult <Currency, CurrencyRateByDate> curyWithRateSet = GetCurrencyAndRateByDate(graph, rmanager.CurrentVendor, company, period); Currency currency = curyWithRateSet; CurrencyRateByDate rateByDate = currency.CuryID != company.BaseCuryID ? curyWithRateSet : null; TaxBucketsCalculation taxBucketsAggregatesCalc = new TaxBucketsCalculation(TaxReportLineType.TaxAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine); TaxBucketsCalculation taxableBucketsAggregatesCalc = new TaxBucketsCalculation(TaxReportLineType.TaxableAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine); taxBucketsAggregatesCalc.CalculateTaxBuckets(lines); taxableBucketsAggregatesCalc.CalculateTaxBuckets(lines); } cache.Persist(PXDBOperation.Insert); cache.Persisted(isAborted: false); }
private void CreateCustomerProcessingCenterRecord(CustomerPaymentMethod customerPM, CCSynchronizeCard syncCard) { PXCache customerProcessingCenterCache = Caches[typeof(CustomerProcessingCenterID)]; customerProcessingCenterCache.ClearQueryCacheObsolete(); PXSelectBase <CustomerProcessingCenterID> checkRecordExist = new PXSelectReadonly <CustomerProcessingCenterID, Where <CustomerProcessingCenterID.cCProcessingCenterID, Equal <Required <CreditCardsFilter.processingCenterId> >, And <CustomerProcessingCenterID.bAccountID, Equal <Required <CustomerProcessingCenterID.bAccountID> >, And <CustomerProcessingCenterID.customerCCPID, Equal <Required <CustomerProcessingCenterID.customerCCPID> > > > > >(this); CustomerProcessingCenterID cProcessingCenter = checkRecordExist.SelectSingle(syncCard.CCProcessingCenterID, syncCard.BAccountID, syncCard.CustomerCCPID); if (cProcessingCenter == null) { cProcessingCenter = customerProcessingCenterCache.CreateInstance() as CustomerProcessingCenterID; cProcessingCenter.BAccountID = syncCard.BAccountID; cProcessingCenter.CCProcessingCenterID = syncCard.CCProcessingCenterID; cProcessingCenter.CustomerCCPID = syncCard.CustomerCCPID; customerProcessingCenterCache.Insert(cProcessingCenter); customerProcessingCenterCache.Persist(PXDBOperation.Insert); } }
protected void CreateCustomerProcessingCenterRecord(V2.TranProfile input) { PXCache customerProcessingCenterCache = Base.Caches[typeof(CustomerProcessingCenterID)]; customerProcessingCenterCache.ClearQueryCacheObsolete(); PXSelectBase <CustomerProcessingCenterID> checkRecordExist = new PXSelectReadonly <CustomerProcessingCenterID, Where <CustomerProcessingCenterID.cCProcessingCenterID, Equal <Required <CustomerProcessingCenterID.cCProcessingCenterID> >, And <CustomerProcessingCenterID.bAccountID, Equal <Required <CustomerProcessingCenterID.bAccountID> >, And <CustomerProcessingCenterID.customerCCPID, Equal <Required <CustomerProcessingCenterID.customerCCPID> > > > > >(Base); CustomerProcessingCenterID cProcessingCenter = checkRecordExist.SelectSingle(SelectedProcessingCenter, SelectedBAccount, input.CustomerProfileId); if (cProcessingCenter == null) { cProcessingCenter = customerProcessingCenterCache.CreateInstance() as CustomerProcessingCenterID; cProcessingCenter.BAccountID = SelectedBAccount; cProcessingCenter.CCProcessingCenterID = SelectedProcessingCenter; cProcessingCenter.CustomerCCPID = input.CustomerProfileId; customerProcessingCenterCache.Insert(cProcessingCenter); customerProcessingCenterCache.Persist(PXDBOperation.Insert); } }
public void CreateCustomerPaymentMethodRecord(CCSynchronizeCard item) { PXCache customerPaymentMethodCache = Caches[typeof(CustomerPaymentMethod)]; CustomerPaymentMethod customerPM = customerPaymentMethodCache.CreateInstance() as CustomerPaymentMethod; customerPM.BAccountID = item.BAccountID; customerPM.CustomerCCPID = item.CustomerCCPID; customerPM.Descr = item.CardNumber; customerPM.PaymentMethodID = item.PaymentMethodID; customerPM.CashAccountID = item.CashAccountID; customerPM.CCProcessingCenterID = item.CCProcessingCenterID; if (item.ExpirationDate != null) { customerPaymentMethodCache.SetValueExt <CustomerPaymentMethod.expirationDate>(customerPM, item.ExpirationDate); } customerPaymentMethodCache.Insert(customerPM); customerPaymentMethodCache.Persist(PXDBOperation.Insert); customerPM = customerPaymentMethodCache.Current as CustomerPaymentMethod; CreateCustomerPaymentMethodDetailRecord(customerPM, item); CreateCustomerProcessingCenterRecord(customerPM, item); }
protected virtual void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { sender.Persist(e.Row, PXDBOperation.Insert); sender.Persist(e.Row, PXDBOperation.Update); sender.Persist(e.Row, PXDBOperation.Delete); }
private static void Validate(CATranEntryLight te, CashAccount tlist) { using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { Account account = PXSelect <Account, Where <Account.isCashAccount, Equal <False>, And <Account.accountID, Equal <Required <Account.accountID> > > > > .Select(te, tlist.AccountID); if (account != null) { account.IsCashAccount = true; te.account.Update(account); te.account.Cache.Persist(PXDBOperation.Update); te.account.Cache.Persisted(false); } ts.Complete(te); } } te.Clear(); if (tlist.Reconcile != true) { te.Clear(); using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { PXCache adjcache = te.Caches[typeof(CATran)]; foreach (CATran catran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID)) { if (tlist.Reconcile != true && (catran.Cleared != true || catran.TranDate == null)) { catran.Cleared = true; catran.ClearDate = catran.TranDate; } te.catrancache.Update(catran); } te.catrancache.Persist(PXDBOperation.Update); ts.Complete(te); } te.catrancache.Persisted(false); } } te.Clear(); using (new PXConnectionScope()) { PXCache adjcache = te.Caches[typeof(CAAdj)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj, LeftJoin <CATran, On <CATran.tranID, Equal <CAAdj.tranID> >, LeftJoin <GLTranDoc, On <GLTranDoc.refNbr, Equal <CAAdj.adjRefNbr>, And <GLTranDoc.tranType, Equal <CAAdj.adjTranType>, And <GLTranDoc.tranModule, Equal <BatchModule.moduleCA> > > > > >, Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >, And <CATran.tranID, IsNull, And <GLTranDoc.refNbr, IsNull> > > > .Select(te, tlist.CashAccountID)) { CAAdj caadj = (CAAdj)res; GLTran gltran = PXSelectJoin <GLTran, InnerJoin <CashAccount, On <CashAccount.accountID, Equal <GLTran.accountID>, And <CashAccount.subID, Equal <GLTran.subID>, And <CashAccount.branchID, Equal <GLTran.branchID> > > > >, Where <GLTran.cATranID, Equal <Required <CAAdj.tranID> >, And <CashAccount.cashAccountID, Equal <Required <CAAdj.cashAccountID> > > > > .Select(te, caadj.TranID, caadj.CashAccountID); adjcache.SetValue <CAAdj.tranID>(caadj, null); adjcache.SetValue <CAAdj.cleared>(caadj, false); CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj); catran.BatchNbr = gltran?.BatchNbr; long?id = null; if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); id = Convert.ToInt64(PXDatabase.SelectIdentity()); te.SelectTimeStamp(); adjcache.SetValue <CAAdj.tranID>(caadj, id); adjcache.Update(caadj); } if (id.HasValue && gltran?.TranID != null) { gltran.CATranID = id; te.gltrancache.Update(gltran); te.gltrancache.Persist(PXDBOperation.Update); } } adjcache.Persist(PXDBOperation.Update); ts.Complete(te); } adjcache.Persisted(false); te.catrancache.Persisted(false); te.gltrancache.Persisted(false); } te.Clear(); using (new PXConnectionScope()) { PXCache transfercache = te.Caches[typeof(CATransfer)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDIn> > >, Where <CATransfer.inAccountID, Equal <Required <CATransfer.inAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDIn>(catransfer, null); transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedOut>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDIn>(transfercache, catransfer); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDIn>(catransfer, id); transfercache.Update(catransfer); } } foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDOut> > >, Where <CATransfer.outAccountID, Equal <Required <CATransfer.outAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDOut>(catransfer, null); transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedIn>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDOut>(transfercache, catransfer); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDOut>(catransfer, id); transfercache.Update(catransfer); } } transfercache.Persist(PXDBOperation.Update); ts.Complete(te); } transfercache.Persisted(false); te.catrancache.Persisted(false); } te.Clear(); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.module>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.batchNbr>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.ledgerID>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.finPeriodID>(te.Caches[typeof(GLTran)], null, false); using (new PXConnectionScope()) { const int rowsPerCycle = 10000; bool noMoreTran = false; int? lastGLTranIDOnPreviousStep = null; int previousCountRows = 0; while (!noMoreTran) { noMoreTran = true; int countRows = 0; int?lastGLTranID = null; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <GLTran, Ledger, Batch> res in PXSelectJoin <GLTran, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <GLTran.ledgerID> >, InnerJoin <Batch, On <Batch.module, Equal <GLTran.module>, And <Batch.batchNbr, Equal <GLTran.batchNbr>, And <Batch.scheduled, Equal <False>, And <Batch.voided, NotEqual <True> > > > > > >, Where <GLTran.accountID, Equal <Required <GLTran.accountID> >, And <GLTran.subID, Equal <Required <GLTran.subID> >, And <GLTran.branchID, Equal <Required <GLTran.branchID> >, And <Ledger.balanceType, Equal <LedgerBalanceType.actual>, //ignoring CM because DefaultValues always return null for CM And <GLTran.module, NotEqual <BatchModule.moduleCM>, And <GLTran.cATranID, IsNull> > > > > >, OrderBy <Asc <GLTran.tranID> > > .SelectWindowed(te, 0, rowsPerCycle, tlist.AccountID, tlist.SubID, tlist.BranchID)) { GLTran gltran = (GLTran)res; lastGLTranID = gltran.TranID; noMoreTran = false; countRows++; CATran catran = GLCashTranIDAttribute.DefaultValues <GLTran.cATranID>(te.gltrancache, gltran); if (catran != null) { long id; bool newCATRan = false; if (te.catrancache.Locate(catran) == null) { catran = (CATran)te.catrancache.Insert(catran); newCATRan = true; te.catrancache.PersistInserted(catran); id = Convert.ToInt64(PXDatabase.SelectIdentity()); } else { catran = (CATran)te.catrancache.Update(catran); te.catrancache.PersistUpdated(catran); id = catran.TranID.Value; } gltran.CATranID = id; te.gltrancache.Update(gltran); if (catran.OrigModule != GLTranType.GLEntry) { switch (catran.OrigModule) { case BatchModule.AR: ARPayment arPayment = PXSelect <ARPayment, Where <ARPayment.docType, Equal <Required <ARPayment.docType> >, And <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> > > > > .Select(te, catran.OrigTranType, catran.OrigRefNbr); if (arPayment != null && (arPayment.CATranID == null || newCATRan)) { arPayment.CATranID = id; arPayment = (ARPayment)te.Caches[typeof(ARPayment)].Update(arPayment); te.Caches[typeof(ARPayment)].PersistUpdated(arPayment); } break; case BatchModule.AP: APPayment apPayment = PXSelect <APPayment, Where <APPayment.docType, Equal <Required <APPayment.docType> >, And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > > .Select(te, catran.OrigTranType, catran.OrigRefNbr); if (apPayment != null && (apPayment.CATranID == null || newCATRan)) { apPayment.CATranID = id; apPayment = (APPayment)te.Caches[typeof(APPayment)].Update(apPayment); te.Caches[typeof(APPayment)].PersistUpdated(apPayment); } break; } } } } if (!noMoreTran && countRows == previousCountRows && lastGLTranID == lastGLTranIDOnPreviousStep) { throw new PXException(Messages.ProcessCannotBeCompleted); } previousCountRows = countRows; lastGLTranIDOnPreviousStep = lastGLTranID; te.gltrancache.ClearQueryCache(); te.gltrancache.Persist(PXDBOperation.Update); te.gltrancache.Clear(); te.catrancache.Clear(); te.catrancache.ClearQueryCache(); te.dailycache.Clear(); te.Caches[typeof(APPayment)].Clear(); te.Caches[typeof(ARPayment)].Clear(); ts.Complete(te); } } PXDatabase.Delete <CADailySummary>( new PXDataFieldRestrict("CashAccountID", PXDbType.Int, 4, tlist.CashAccountID, PXComp.EQ)); foreach (CATran tran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID)) { CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(te.catrancache, tran); } te.dailycache.Persist(PXDBOperation.Insert); te.dailycache.Persist(PXDBOperation.Update); te.gltrancache.Persisted(false); te.catrancache.Persisted(false); te.dailycache.Persisted(false); } }
protected virtual void FSCustomerBillingSetup_RowPersisting(PXCache cache, PXRowPersistingEventArgs e) { if (e.Row == null) { return; } FSCustomerBillingSetup fsCustomerBillingSetup = (FSCustomerBillingSetup)e.Row; FSxCustomer fsxCustomerRow = PXCache <Customer> .GetExtension <FSxCustomer>(Base.BAccount.Current); if (cache.GetStatus(fsCustomerBillingSetup) == PXEntryStatus.Updated) { bool insertNewRow = IsCBIDRelatedToPostedDocuments(fsCustomerBillingSetup.CBID); if (insertNewRow) { fsxCustomerRow.BillingOptionsChanged = true; cache.SetValue <FSCustomerBillingSetup.active>(fsCustomerBillingSetup, false); FSCustomerBillingSetup newCustomerBilingSetupRow = new FSCustomerBillingSetup(); var tempFSCustomerBillingSetupCache = new PXCache <FSCustomerBillingSetup>(Base); newCustomerBilingSetupRow.CustomerID = fsCustomerBillingSetup.CustomerID; newCustomerBilingSetupRow.SrvOrdType = fsCustomerBillingSetup.SrvOrdType; newCustomerBilingSetupRow.Active = true; newCustomerBilingSetupRow = (FSCustomerBillingSetup)tempFSCustomerBillingSetupCache.Insert(newCustomerBilingSetupRow); foreach (var field in cache.Fields) { if (!cache.Keys.Contains(field) && field.ToLower() != typeof(FSCustomerBillingSetup.active).Name.ToLower()) { tempFSCustomerBillingSetupCache.SetValue( newCustomerBilingSetupRow, field.ToString(), cache.GetValue( fsCustomerBillingSetup, field.ToString())); } } tempFSCustomerBillingSetupCache.Persist(PXDBOperation.Insert); foreach (var field in cache.Fields) { if (!cache.Keys.Contains(field) && field.ToLower() != typeof(FSCustomerBillingSetup.active).Name.ToLower()) { cache.SetValue( fsCustomerBillingSetup, field.ToString(), cache.GetValueOriginal( fsCustomerBillingSetup, field.ToString())); } } cache.SetValue <FSCustomerBillingSetup.active>(fsCustomerBillingSetup, false); } } if (e.Operation == PXDBOperation.Update) { VerifyPrepaidContractRelated(cache, fsCustomerBillingSetup); } }
private static void Validate(CATranEntry te, CashAccount tlist) { if (tlist.Reconcile != true) { te.Clear(); using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { PXCache adjcache = te.Caches[typeof(CATran)]; foreach (CATran catran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID)) { if (tlist.Reconcile != true && (catran.Cleared != true || catran.TranDate == null)) { catran.Cleared = true; catran.ClearDate = catran.TranDate; } te.catrancache.Update(catran); } te.catrancache.Persist(PXDBOperation.Update); ts.Complete(te); } te.catrancache.Persisted(false); } } te.Clear(); using (new PXConnectionScope()) { PXCache adjcache = te.Caches[typeof(CAAdj)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj, LeftJoin <CATran, On <CATran.tranID, Equal <CAAdj.tranID> > >, Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CAAdj caadj = (CAAdj)res; adjcache.SetValue <CAAdj.tranID>(caadj, null); adjcache.SetValue <CAAdj.cleared>(caadj, false); CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); adjcache.SetValue <CAAdj.tranID>(caadj, id); adjcache.Update(caadj); } } adjcache.Persist(PXDBOperation.Update); ts.Complete(te); } adjcache.Persisted(false); te.catrancache.Persisted(false); } te.Clear(); using (new PXConnectionScope()) { PXCache transfercache = te.Caches[typeof(CATransfer)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDIn> > >, Where <CATransfer.inAccountID, Equal <Required <CATransfer.inAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDIn>(catransfer, null); transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedOut>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDIn>(transfercache, catransfer); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDIn>(catransfer, id); transfercache.Update(catransfer); } } foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDOut> > >, Where <CATransfer.outAccountID, Equal <Required <CATransfer.outAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDOut>(catransfer, null); transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedIn>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDOut>(transfercache, catransfer); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDOut>(catransfer, id); transfercache.Update(catransfer); } } transfercache.Persist(PXDBOperation.Update); ts.Complete(te); } transfercache.Persisted(false); te.catrancache.Persisted(false); } te.Clear(); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.module>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.batchNbr>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.ledgerID>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.finPeriodID>(te.Caches[typeof(GLTran)], null, false); using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <GLTran, Ledger, Batch> res in PXSelectJoin <GLTran, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <GLTran.ledgerID> >, InnerJoin <Batch, On <Batch.module, Equal <GLTran.module>, And <Batch.batchNbr, Equal <GLTran.batchNbr>, And <Batch.scheduled, Equal <False> > > > > >, Where <GLTran.accountID, Equal <Required <GLTran.accountID> >, And <GLTran.subID, Equal <Required <GLTran.subID> >, And <Ledger.balanceType, Equal <LedgerBalanceType.actual>, And <GLTran.cATranID, IsNull> > > > > .Select(te, tlist.AccountID, tlist.SubID)) { GLTran gltran = (GLTran)res; CATran catran = GLCashTranIDAttribute.DefaultValues <GLTran.cATranID>(te.gltrancache, gltran); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); gltran.CATranID = id; te.gltrancache.Update(gltran); } } te.gltrancache.Persist(PXDBOperation.Update); te.dailycache.Clear(); PXDatabase.Delete <CADailySummary>( new PXDataFieldRestrict("CashAccountID", PXDbType.Int, 4, tlist.CashAccountID, PXComp.EQ) ); foreach (CATran tran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID)) { CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(te.catrancache, tran); } te.dailycache.Persist(PXDBOperation.Insert); te.dailycache.Persist(PXDBOperation.Update); ts.Complete(te); } te.gltrancache.Persisted(false); te.catrancache.Persisted(false); te.dailycache.Persisted(false); } }
public static bool RecordCostTrans(RegisterEntry registerEntry, List <EPActivityApprove> activities, out bool activityAdded) { registerEntry.FieldVerifying.AddHandler <PMTran.inventoryID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); //restriction should be applicable only for budgeting. EmployeeCostEngine costEngine = new EmployeeCostEngine(registerEntry); registerEntry.Views.Caches.Add(typeof(EPActivityApprove)); PXCache activityCache = registerEntry.Caches <EPActivityApprove>(); registerEntry.Document.Cache.Insert(); bool success = true; activityAdded = false; for (int i = 0; i < activities.Count; i++) { //Check the UNMERGED state of Released (it could be set to true just now by the calling code): EPActivityApprove activity = PXSelect <EPActivityApprove> .Search <EPActivityApprove.noteID>(registerEntry, activities[i].NoteID); if (activity.Released == true) //activity can be released to PM via Timecard prior to releasing the case. { continue; } try { if (activity.ProjectTaskID != null) //cost transactions are created only if project is set. { EPEmployee employee = PXSelect <EPEmployee> .Search <EPEmployee.userID>(registerEntry, activity.OwnerID); activity.LabourItemID = costEngine.GetLaborClass(activity); if (activity.LabourItemID == null) { throw new PXException(Messages.CannotFindLabor, employee.AcctName); } activityCache.Update(activity); var cost = costEngine.CalculateEmployeeCost(activity.TimeCardCD, activity.EarningTypeID, activity.LabourItemID, activity.ProjectID, activity.ProjectTaskID, activity.CertifiedJob, activity.UnionID, employee.BAccountID, activity.Date.Value); if (cost == null) { throw new PXException(Messages.EmployeeCostRateNotFound); } EPSetup epsetup = PXSelect <EPSetup> .Select(registerEntry); if (epsetup.PostingOption != EPPostOptions.DoNotPost) { registerEntry.CreateTransaction(activity, employee.BAccountID, activity.Date.Value, activity.TimeSpent, activity.TimeBillable, cost.Rate, cost.OvertimeMultiplier); } activity.EmployeeRate = cost.Rate; activityAdded = true; } activity.Released = true; activity.ApprovalStatus = ActivityStatusAttribute.Released; if (activity.RefNoteID != null) { PXUpdate < Set <CRActivity.isLocked, True>, CRActivity, Where <CRActivity.noteID, Equal <Required <CRActivity.noteID> > > > .Update(registerEntry, activity.RefNoteID); } activityCache.Update(activity); } catch (Exception e) { PXProcessing <EPActivityApprove> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); success = false; } } if (activityAdded) { registerEntry.Save.Press(); } else { activityCache.Persist(PXDBOperation.Update); registerEntry.SelectTimeStamp(); } return(success); }
public static List <EPActivityApprove> RecordContractUsage(List <EPActivityApprove> activities, string description) { RegisterEntry registerEntry = CreateInstance <RegisterEntry>(); registerEntry.FieldVerifying.AddHandler <PMTran.projectID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); registerEntry.FieldVerifying.AddHandler <PMTran.inventoryID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });//restriction should be applicable only for budgeting. registerEntry.Document.Cache.Insert(); registerEntry.Document.Current.Description = description; registerEntry.Document.Current.Released = true; registerEntry.Document.Current.Status = PMRegister.status.Released; registerEntry.Views.Caches.Add(typeof(EPActivityApprove)); PXCache activityCache = registerEntry.Caches <EPActivityApprove>(); List <EPActivityApprove> useActivities = new List <EPActivityApprove>(); for (int i = 0; i < activities.Count; i++) { EPActivityApprove activity = activities[i]; try { PMTran usage = null; if (activity.ContractID != null) { //Contract without CRM mode usage = CreateContractUsage(registerEntry, activity.ContractID, activity, activity.TimeBillable.GetValueOrDefault()); activity.Billed = true; activityCache.Update(activity); } else if (activity.RefNoteID != null && PXSelectJoin <CRCase, InnerJoin <CRActivityLink, On <CRActivityLink.refNoteID, Equal <CRCase.noteID> > >, Where <CRActivityLink.noteID, Equal <Required <PMTimeActivity.refNoteID> > > > .Select(registerEntry, activity.RefNoteID).Count == 1) { //Add Contract-Usage usage = registerEntry.CreateContractUsage(activity, activity.TimeBillable.GetValueOrDefault()); activity.Billed = true; activityCache.Update(activity); } if (usage != null) { UsageMaint.AddUsage(activityCache, usage.ProjectID, usage.InventoryID, usage.BillableQty ?? 0m, usage.UOM); } useActivities.Add(activity); } catch (Exception e) { PXProcessing <EPActivityApprove> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } } if (registerEntry.Transactions.Cache.IsInsertedUpdatedDeleted) { registerEntry.Save.Press(); } else { activityCache.Persist(PXDBOperation.Update); } return(useActivities); }
private static void ValidateCAAdjustments(CATranEntryLight graph, CashAccount cashAccount, IFinPeriod period) { using (new PXConnectionScope()) { PXCache adjcache = graph.Caches[typeof(CAAdj)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj, LeftJoin <CATran, On <CATran.tranID, Equal <CAAdj.tranID> >, LeftJoin <GLTranDoc, On <GLTranDoc.refNbr, Equal <CAAdj.adjRefNbr>, And <GLTranDoc.tranType, Equal <CAAdj.adjTranType>, And <GLTranDoc.tranModule, Equal <BatchModule.moduleCA> > > > > >, Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >, And <CATran.tranID, IsNull, And <GLTranDoc.refNbr, IsNull, And <CAAdj.finPeriodID, GreaterEqual <Required <CAAdj.finPeriodID> > > > > > > .Select(graph, cashAccount.CashAccountID, period.FinPeriodID)) { CAAdj caadj = (CAAdj)res; GLTran gltran = PXSelectJoin <GLTran, InnerJoin <CashAccount, On <CashAccount.accountID, Equal <GLTran.accountID>, And <CashAccount.subID, Equal <GLTran.subID>, And <CashAccount.branchID, Equal <GLTran.branchID> > > > >, Where <GLTran.cATranID, Equal <Required <CAAdj.tranID> >, And <CashAccount.cashAccountID, Equal <Required <CAAdj.cashAccountID> > > > > .Select(graph, caadj.TranID, caadj.CashAccountID); adjcache.SetValue <CAAdj.tranID>(caadj, null); adjcache.SetValue <CAAdj.cleared>(caadj, false); CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj); catran.BatchNbr = gltran?.BatchNbr; long?id = null; if (catran != null) { catran = (CATran)graph.catrancache.Insert(catran); graph.catrancache.PersistInserted(catran); id = Convert.ToInt64(PXDatabase.SelectIdentity()); graph.SelectTimeStamp(); adjcache.SetValue <CAAdj.tranID>(caadj, id); adjcache.Update(caadj); } if (id.HasValue && gltran?.TranID != null) { gltran.CATranID = id; graph.gltrancache.Update(gltran); graph.gltrancache.Persist(PXDBOperation.Update); } } adjcache.Persist(PXDBOperation.Update); ts.Complete(graph); } adjcache.Persisted(false); graph.catrancache.Persisted(false); graph.gltrancache.Persisted(false); } }
private static void ValidateCATransfers(CATranEntryLight graph, CashAccount cashAccount, IFinPeriod period) { using (new PXConnectionScope()) { PXCache transfercache = graph.Caches[typeof(CATransfer)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDIn> > >, Where <CATransfer.inAccountID, Equal <Required <CATransfer.inAccountID> >, And <CATran.tranID, IsNull, And <CATransfer.inDate, GreaterEqual <Required <CATransfer.inDate> > > > > > .Select(graph, cashAccount.CashAccountID, period.StartDate)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDIn>(catransfer, null); transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedOut>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDIn>(transfercache, catransfer); if (catran != null) { catran = (CATran)graph.catrancache.Insert(catran); graph.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDIn>(catransfer, id); transfercache.Update(catransfer); } } foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDOut> > >, Where <CATransfer.outAccountID, Equal <Required <CATransfer.outAccountID> >, And <CATran.tranID, IsNull, And <CATransfer.outDate, GreaterEqual <Required <CATransfer.outDate> > > > > > .Select(graph, cashAccount.CashAccountID, period.StartDate)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDOut>(catransfer, null); transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedIn>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDOut>(transfercache, catransfer); if (catran != null) { catran = (CATran)graph.catrancache.Insert(catran); graph.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDOut>(catransfer, id); transfercache.Update(catransfer); } } transfercache.Persist(PXDBOperation.Update); ts.Complete(graph); } transfercache.Persisted(false); graph.catrancache.Persisted(false); } }