/// <summary> /// Update an Schedule (lastGeneratedAppointmentDate and lastProcessedDate). /// </summary> protected void UpdateGeneratedSchedule(int scheduleID, DateTime?toDate, DateTime?lastGeneratedElementDate, FSSchedule fsScheduleRow) { FSSchedule fsScheduleRowInDB = PXSelect <FSSchedule, Where < FSSchedule.scheduleID, Equal <Required <FSSchedule.scheduleID> > > > .SelectSingleBound(this, null, scheduleID); if (fsScheduleRowInDB != null) { if (lastGeneratedElementDate != null || toDate == null) { if (fsScheduleRow != null) { fsScheduleRow.LastGeneratedElementDate = lastGeneratedElementDate; fsScheduleRow.NextExecutionDate = SharedFunctions.GetNextExecution(this.ScheduleSelected.Cache, fsScheduleRow); } PXUpdate < Set <FSSchedule.lastGeneratedElementDate, Required <FSSchedule.lastGeneratedElementDate>, Set <FSSchedule.nextExecutionDate, Required <FSSchedule.nextExecutionDate> > >, FSSchedule, Where < FSSchedule.scheduleID, Equal <Required <FSSchedule.scheduleID> > > > .Update(this, lastGeneratedElementDate, fsScheduleRow.NextExecutionDate, scheduleID); } } }
public void TestUpdateCall(SOOrder order) { PXUpdate < Set <SOOrder.status, Required <SOOrder.status>, Set <SOOrder.orderType, Null> >, SOOrder, Where <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> >, And <SOOrder.orderType, IsNotNull, And <SOOrder.orderDate, Equal <Required <SOOrder.orderDate> > > > > > .Update(this, order.Status, order.OrderNbr, order.OrderDate); //No diagnostic here // Acuminator disable once PX1015 IncorrectNumberOfSelectParameters [Justification] PXUpdate < Set <SOOrder.status, Required <SOOrder.status>, Set <SOOrder.orderType, Null> >, SOOrder, Where <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> >, And <SOOrder.orderType, IsNotNull, And <SOOrder.orderDate, Equal <Required <SOOrder.orderDate> > > > > > .Update(this, order.Status, order.OrderDate); //diagnostic here // Acuminator disable once PX1015 IncorrectNumberOfSelectParameters [Justification] PXUpdateJoin < Set <SOOrder.status, Required <SOOrder.status>, Set <SOOrder.orderType, Null> >, SOOrder, InnerJoin <SOTran, On <SOOrder.orderNbr, Equal <SOTran.orderNbr> > >, Where <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> >, And <SOOrder.orderType, IsNotNull, And <SOOrder.orderDate, Equal <Required <SOOrder.orderDate> > > > > > .Update(this, order.Status, order.OrderDate); //diagnostic here }
public override void Persist() { if (Header.Cache.IsDirty && Detail.Select().Count == 0 && Header.Current != null) { throw new PXException(Messages.DimensionIsEmpty); } var dimension = Header.Current; if (dimension == null) { base.Persist(); } else { try { using (PXTransactionScope tscope = new PXTransactionScope()) { if (Header.Cache.GetStatus(dimension) != PXEntryStatus.Deleted) { InsertNumberingValue(Header.Current); CorrectChildDimensions(); } var oldLength = (short?)Header.Cache.GetValueOriginal <Dimension.length>(dimension); if (dimension.Length < oldLength) { if (dimension.DimensionID == "SUBACCOUNT") { CheckLongerSubKeysDoNotExist(dimension.Length); PXUpdate <Set <Sub.subCD, Substring <Sub.subCD, int1, CurrentValue <Dimension.length> > >, Sub> .Update(this); } ValidateDimensionForKeyDuplication(dimension); } PXDimensionAttribute.Clear(); base.Persist(); Header.Current = dimension; PXDimensionAttribute.Clear(); tscope.Complete(); } } catch (PXDatabaseException e) { if (e.ErrorCode == PXDbExceptions.DeleteForeignKeyConstraintViolation) { throw new PXException(Messages.SegmentHasValues, e.Keys[1]); } throw; } } PXPageCacheUtils.InvalidateCachedPages(); }
public void TestUpdateCall(SOOrder order) { PXUpdate < Set <SOOrder.status, Required <SOOrder.status>, Set <SOOrder.orderType, Null> >, SOOrder, Where <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> >, And <SOOrder.orderType, IsNotNull, And <SOOrder.orderDate, Equal <Required <SOOrder.orderDate> > > > > > .Update(this, order.Status, order.OrderNbr, order.OrderDate); //No diagnostic here PXUpdate < Set <SOOrder.status, Required <SOOrder.status>, Set <SOOrder.orderType, Null> >, SOOrder, Where <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> >, And <SOOrder.orderType, IsNotNull, And <SOOrder.orderDate, Equal <Required <SOOrder.orderDate> > > > > > .Update(this, order.Status, order.OrderDate); //diagnostic here PXUpdateJoin < Set <SOOrder.status, Required <SOOrder.status>, Set <SOOrder.orderType, Null> >, SOOrder, InnerJoin <SOTran, On <SOOrder.orderNbr, Equal <SOTran.orderNbr> > >, Where <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> >, And <SOOrder.orderType, IsNotNull, And <SOOrder.orderDate, Equal <Required <SOOrder.orderDate> > > > > > .Update(this, order.Status, order.OrderDate); //diagnostic here }
protected void _(Events.RowDeleted <APInvoice> e, PXRowDeleted invokeBaseHandler) { if (invokeBaseHandler != null) { invokeBaseHandler(e.Cache, e.Args); } PXUpdate <Set <FLXCommissionTran.aPBillCreated, Required <FLXCommissionTran.aPBillCreated>, Set <FLXCommissionTran.aPBillRefNBr, Required <FLXCommissionTran.aPBillRefNBr> > >, FLXCommissionTran, Where <FLXCommissionTran.aPBillRefNBr, Equal <Required <APInvoice.refNbr> > > > .Update((PXGraph)this.Base, (object)false, null, (object)e.Row.RefNbr); }
/// <summary> /// Updates <c>FSSrvOrdType.createTimeActivitiesFromAppointment</c> when the Time Card integration is enabled. /// </summary> /// <param name="graph">PXGraph instance.</param> /// <param name="enableEmpTimeCardIntegration">Flag that says whether the TimeCard integration is enabled or not.</param> public virtual void Update_SrvOrdType_TimeActivitiesFromAppointment(PXGraph graph, bool?enableEmpTimeCardIntegration) { if (enableEmpTimeCardIntegration == true) { PXUpdate < Set <FSSrvOrdType.createTimeActivitiesFromAppointment, True>, FSSrvOrdType> .Update(graph); } }
public static void UpdateGUIStatus(string gUINbr) { PXUpdate <Set <TWNGUITrans.gUIStatus, Required <TWNGUITrans.gUIStatus> >, TWNGUITrans, Where <TWNGUITrans.gUIStatus, Equal <TWNGUIStatus.used>, And <TWNGUITrans.gUIDirection, Equal <TWNGUIDirection.issue>, And <TWNGUITrans.sequenceNo, Equal <Zero>, And <TWNGUITrans.gUINbr, Equal <Required <TWNGUITrans.gUINbr> > > > > > > .Update(new PXGraph(), TWNGUIStatus.Voided, gUINbr); }
public static void CreateAPBill(System.Collections.Generic.List <FLXCommissionTran> list, FLXSetup setup) { try { APInvoiceEntry instance1 = PXGraph.CreateInstance <APInvoiceEntry>(); string str = string.Empty; string format = "[{0}] Isn't A Vendor."; for (int index = 0; index < list.Count; ++index) { FLXCommissionTran flxCommissionTran = list[index]; if (FLXGenBillAPInvoice.CheckBAType((PXGraph)instance1, flxCommissionTran.SalesRepID)) { if (instance1.CurrentDocument.Current == null) { APInvoice instance2 = instance1.Document.Cache.CreateInstance() as APInvoice; instance2.DocType = "INV"; instance2.VendorID = flxCommissionTran.SalesRepID; instance2.DocDate = flxCommissionTran.APDate; instance2.InvoiceNbr = string.Format("{0} {1}", (object)flxCommissionTran.CommissionTranID, (object)instance1.vendor.Select((object)instance2.VendorID).TopFirst.AcctCD.Trim()); instance1.Document.Insert(instance2); } APTran instance3 = instance1.Transactions.Cache.CreateInstance() as APTran; instance3.BranchID = flxCommissionTran.BranchID; instance3.InventoryID = setup.CommissionItem; instance3.Qty = new Decimal?((Decimal)1); instance3.CuryUnitCost = flxCommissionTran.CommisionAmt; instance3.TranDesc = string.Format("{0},{1},{2},{3},{4}", (object)flxCommissionTran.CommissionTranID, (object)flxCommissionTran.OrderNbr, (object)flxCommissionTran.ProjectNbr, (object)instance1.nonStockItem.Select((object)flxCommissionTran.InventoryID).TopFirst.InventoryCD.Trim(), (object)instance1.nonStockItem.Select((object)flxCommissionTran.NonStockItem).TopFirst.InventoryCD.Trim()); instance3.SubID = instance1.nonStockItem.Select((object)instance3.InventoryID).TopFirst.COGSSubID; instance1.Transactions.Insert(instance3); str = str + flxCommissionTran.CommissionTranID + "/"; } else { throw new PXException(format, new object[1] { (object)SelectFrom <BAccountR> .Where <BAccountR.bAccountID.IsEqual <P.AsInt> > .View.Select((PXGraph)instance1, (object)flxCommissionTran.SalesRepID).TopFirst.AcctCD.Trim() }); } } instance1.Document.Current.DocDesc = str.Substring(0, (str.Length > PX.Objects.Common.Constants.TranDescLength ? PX.Objects.Common.Constants.TranDescLength : str.Length) - 1); instance1.Document.UpdateCurrent(); instance1.Save.Press(); for (int index = 0; index < list.Count; ++index) { FLXCommissionTran flxCommissionTran = list[index]; PXUpdate <Set <FLXCommissionTran.aPBillCreated, Required <FLXCommissionTran.aPBillCreated>, Set <FLXCommissionTran.aPBillRefNBr, Required <APInvoice.refNbr> > >, FLXCommissionTran, Where <FLXCommissionTran.commissionTranID, Equal <Required <FLXCommissionTran.commissionTranID> > > > .Update((PXGraph)instance1, (object)true, (object)instance1.Document.Current.RefNbr, (object)flxCommissionTran.CommissionTranID); } } catch (PXException ex) { PXProcessing.SetError((Exception)ex); throw ex; } }
public override void UpdateSourcePostDoc(PXCache <FSPostDet> cacheFSPostDet, FSPostBatch fsPostBatchRow, FSPostDoc fsPostDocRow) { PXUpdate < Set <FSServiceOrder.finPeriodID, Required <FSServiceOrder.finPeriodID>, Set <FSServiceOrder.postedBy, Required <FSServiceOrder.postedBy>, Set <FSServiceOrder.pendingAPARSOPost, False> > >, FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> >, And <FSServiceOrder.pendingAPARSOPost, Equal <True> > > > .Update(cacheFSPostDet.Graph, fsPostBatchRow.FinPeriodID, ID.Billing_By.SERVICE_ORDER, fsPostDocRow.SOID); }
public virtual void CleanPostInfo(PXGraph cleanerGraph, FSPostDet fsPostDetRow) { PXUpdate < Set <FSPostInfo.aPLineNbr, Null, Set <FSPostInfo.apRefNbr, Null, Set <FSPostInfo.apDocType, Null, Set <FSPostInfo.aPPosted, False> > > >, FSPostInfo, Where < FSPostInfo.postID, Equal <Required <FSPostInfo.postID> >, And <FSPostInfo.aPPosted, Equal <True> > > > .Update(cleanerGraph, fsPostDetRow.PostID); }
/// <summary> Active Standard Report </summary> public void ActiveStandardReport(string _reportID) { PXUpdate <Set < UserReport.isActive, Required <UserReport.isActive> >, UserReport, Where <UserReport.reportFileName, Equal <Required <UserReport.reportFileName> > > > .Update(this, false, $"{_reportID}.rpx"); PXUpdate <Set < UserReport.isActive, Required <UserReport.isActive> >, UserReport, Where <UserReport.reportFileName, Equal <Required <UserReport.reportFileName> >, And <UserReport.description, Equal <Required <UserReport.description> > > > > .Update(this, true, $"{_reportID}.rpx", "Standard"); }
public static void PMTimeActivity_RowPersisting_Handler(PXCache cache, PXGraph graph, PMTimeActivity pmTimeActivityRow, PXRowPersistingEventArgs e) { FSxPMTimeActivity fsxPMTimeActivityRow = PXCache <PMTimeActivity> .GetExtension <FSxPMTimeActivity>(pmTimeActivityRow); if (e.Operation == PXDBOperation.Delete && graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.APPOINTMENT)) { if (fsxPMTimeActivityRow.AppointmentID != null && fsxPMTimeActivityRow.AppEmpID != null) { PXUpdate <Set <FSAppointmentEmployee.trackTime, False>, FSAppointmentEmployee, Where < FSAppointmentEmployee.appointmentID, Equal <Required <FSAppointmentEmployee.appointmentID> >, And <FSAppointmentEmployee.lineNbr, Equal <Required <FSAppointmentEmployee.lineNbr> > > > > .Update(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.AppEmpID); } } if ((e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update) && graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.APPOINTMENT)) { if (fsxPMTimeActivityRow.AppointmentID != null && fsxPMTimeActivityRow.AppEmpID != null && fsxPMTimeActivityRow.ServiceID != null && (int?)cache.GetValueOriginal <EPActivityApprove.timeSpent>(pmTimeActivityRow) != pmTimeActivityRow.TimeSpent) { AppointmentEntry graphAppointmentEntry = PXGraph.CreateInstance <AppointmentEntry>(); FSAppointment fsAppointmentRow = PXSelect <FSAppointment, Where <FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > > .Select(graph, fsxPMTimeActivityRow.AppointmentID); FSAppointmentEmployee fsAppointmentEmployeeRow = PXSelect <FSAppointmentEmployee, Where < FSAppointmentEmployee.appointmentID, Equal <Required <FSAppointmentEmployee.appointmentID> >, And <FSAppointmentEmployee.lineNbr, Equal <Required <FSAppointmentEmployee.lineNbr> > > > > .Select(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.AppEmpID); fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Current = graphAppointmentEntry.AppointmentRecords.Search <FSAppointment.appointmentID> (fsAppointmentRow.AppointmentID, fsAppointmentRow.SrvOrdType); graphAppointmentEntry.SkipTimeCardUpdate = true; fsAppointmentEmployeeRow.ActualDuration = pmTimeActivityRow.TimeSpent; AppointmentDateTimeHelper.UpdateStaffActualDateTimeEndFromActualDuration(fsAppointmentEmployeeRow); fsAppointmentEmployeeRow.EarningType = pmTimeActivityRow.EarningTypeID; fsAppointmentEmployeeRow = graphAppointmentEntry.AppointmentEmployees.Update(fsAppointmentEmployeeRow); graphAppointmentEntry.Save.Press(); } } }
protected virtual void FSStaffSchedule_RowDeleted(PXCache cache, PXRowDeletedEventArgs e) { if (e.Row == null) { return; } FSStaffSchedule fsContractScheduleRow = (FSStaffSchedule)e.Row; //Detaching TimeSlots created by schedule generation linked to this Schedule. PXUpdate < Set <FSTimeSlot.scheduleID, Required <FSTimeSlot.scheduleID> >, FSTimeSlot, Where <FSTimeSlot.scheduleID, Equal <Required <FSTimeSlot.scheduleID> > > > .Update(this, null, fsContractScheduleRow.ScheduleID); }
public void UpdateOAuthToken(OAuthToken o) { PXUpdate < Set <OAuthToken.accessToken, Required <OAuthToken.accessToken>, Set <OAuthToken.refreshToken, Required <OAuthToken.refreshToken>, Set <OAuthToken.utcExpiredOn, Required <OAuthToken.utcExpiredOn>, Set <OAuthToken.bearer, Required <OAuthToken.bearer> > > > >, OAuthToken, Where <OAuthToken.applicationID, Equal <Required <OAuthToken.applicationID> > > > .Update(this, o.AccessToken, o.RefreshToken, o.UtcExpiredOn, o.Bearer, o.ApplicationID); }
protected virtual void ClearFSSODetReferences(PXGraph graph, POOrder poOrderRow) { try { PXUpdateJoin < Set <FSServiceOrder.waitingForParts, Required <FSServiceOrder.waitingForParts> >, FSServiceOrder, InnerJoin <FSSODet, On < FSSODet.sOID, Equal <FSServiceOrder.sOID> > >, Where < FSSODet.poType, Equal <Required <FSSODet.poType> >, And <FSSODet.poNbr, Equal <Required <FSSODet.poNbr> > > > > .Update(graph, 1, poOrderRow.OrderType, poOrderRow.OrderNbr); PXUpdateJoin < Set <FSAppointment.waitingForParts, Required <FSAppointment.waitingForParts> >, FSAppointment, InnerJoin <FSAppointmentDet, On < FSAppointmentDet.appointmentID, Equal <FSAppointment.appointmentID> >, InnerJoin <FSSODet, On < FSSODet.sODetID, Equal <FSAppointmentDet.sODetID> > > >, Where < FSSODet.poType, Equal <Required <FSSODet.poType> >, And <FSSODet.poNbr, Equal <Required <FSSODet.poNbr> > > > > .Update(graph, 1, poOrderRow.OrderType, poOrderRow.OrderNbr); PXUpdate < Set <FSSODet.poNbr, Required <FSSODet.poNbr>, Set <FSSODet.poStatus, Required <FSSODet.poStatus>, Set <FSSODet.poCompleted, Required <FSSODet.poCompleted> > > >, FSSODet, Where < FSSODet.poType, Equal <Required <FSSODet.poType> >, And <FSSODet.poNbr, Equal <Required <FSSODet.poNbr> > > > > .Update(graph, null, null, null, poOrderRow.OrderType, poOrderRow.OrderNbr); } catch (Exception exception) { throw new PXException(PXMessages.Localize(TX.Error.UPDATING_FSSODET_PO_REFERENCES) + exception.Message); } }
private void PostProcessMessage(SMEmail message) { PXDatabase.Update <CRActivity>( new PXDataFieldAssign <CRActivity.startDate>(PXTimeZoneInfo.UtcNow), new PXDataFieldAssign <CRActivity.uistatus>(message.Exception == null ? ActivityStatusAttribute.Completed : ActivityStatusAttribute.Open), new PXDataFieldRestrict <CRActivity.noteID>(PXDbType.UniqueIdentifier, 16, message.RefNoteID, PXComp.EQ)); if (message.Exception == null) { PXUpdate <Set <PMTimeActivity.approvalStatus, Switch <Case <Where <PMTimeActivity.approverID, IsNull>, ActivityStatusAttribute.completed>, ActivityStatusAttribute.pendingApproval> >, PMTimeActivity, Where <PMTimeActivity.refNoteID, Equal <Required <PMTimeActivity.refNoteID> >, And <PMTimeActivity.isCorrected, Equal <Zero> > > > .Update(_graph, message.RefNoteID); } if (message.Exception == null) { message.RetryCount = 0; message.MPStatus = MailStatusListAttribute.Processed; } else { message.RetryCount += 1; if (message.Exception.StartsWith("5") || message.RetryCount >= MailAccountManager.GetEmailPreferences().RepeatOnErrorSending) { message.RetryCount = 0; message.MPStatus = MailStatusListAttribute.Failed; } else { message.MPStatus = MailStatusListAttribute.PreProcess; } } UpdateMessage(message); }
protected virtual IEnumerable productionInstruction(PXAdapter adapter) { var _reportID = "lm625000"; //Get Print Count and Update var row = (AMProdItem)Base.GetCacheCurrent <AMProdItem>().Current; var _printCount = row.GetExtension <AMProdItemExt>().UsrPrintCount; PXUpdate <Set <AMProdItemExt.usrPrintCount, Required <AMProdItemExt.usrPrintCount> >, AMProdItem, Where <AMProdItem.prodOrdID, Equal <Required <AMProdItem.prodOrdID> >, And <AMProdItem.orderType, Equal <Required <AMProdItem.orderType> > > > > .Update(Base, _printCount == null? 1 : _printCount.Value + 1, row.ProdOrdID, row.OrderType); Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["Production_Nbr"] = Base.ProdMaintRecords.Current.ProdOrdID; parameters["OrderType"] = Base.ProdMaintRecords.Current.OrderType; throw new PXReportRequiredException(parameters, _reportID, string.Format("Report {0}", _reportID)); }
protected void materialIssuesAction() { var curAMBatchCache = (AMBatch)Base.batch.Cache.Current; var _printCount = curAMBatchCache.GetExtension <AMBatchExt>().UsrPrintCount ?? 0; //Calculate Print Count PXUpdate <Set <AMBatchExt.usrPrintCount, Required <AMBatchExt.usrPrintCount> >, AMBatch, Where <AMBatch.batNbr, Equal <Required <AMBatch.batNbr> >, And <AMBatch.docType, Equal <Required <AMBatch.docType> > > > > .Update(Base, ++_printCount, curAMBatchCache.BatNbr, curAMBatchCache.DocType); // create the parameter for report Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["BatNbr"] = curAMBatchCache.BatNbr; parameters["AttributeID"] = "PRODLINE"; // using Report Required Exception to call the report throw new PXReportRequiredException(parameters, "LM206100", "LM206100"); }
public virtual void VoidReportProc(TaxTran taxTran) { using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { PXUpdate < Set <TaxTran.taxPeriodID, Null, Set <TaxTran.revisionID, Null> >, TaxTran, Where <TaxTran.vendorID, Equal <Required <TaxTran.vendorID> >, And <TaxTran.taxPeriodID, Equal <Required <TaxTran.taxPeriodID> >, And <TaxTran.revisionID, Equal <Required <TaxTran.revisionID> >, And <TaxTran.released, Equal <True>, And <TaxTran.voided, Equal <False> > > > > > > .Update(this, taxTran.VendorID, taxTran.TaxPeriodID); ts.Complete(this); } } }
public override void UpdateSourcePostDoc(PXCache <FSPostDet> cacheFSPostDet, FSPostBatch fsPostBatchRow, FSPostDoc fsPostDocRow) { PXUpdate < Set <FSAppointment.finPeriodID, Required <FSAppointment.finPeriodID>, Set <FSAppointment.pendingAPARSOPost, False, Set <FSAppointment.postingStatusAPARSO, ListField_Status_Posting.Posted> > >, FSAppointment, Where < FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > > .Update(cacheFSPostDet.Graph, fsPostBatchRow.FinPeriodID, fsPostDocRow.AppointmentID); PXUpdate < Set <FSServiceOrder.finPeriodID, Required <FSServiceOrder.finPeriodID>, Set <FSServiceOrder.postedBy, Required <FSServiceOrder.postedBy>, Set <FSServiceOrder.pendingAPARSOPost, False> > >, FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> >, And <FSServiceOrder.pendingAPARSOPost, Equal <True> > > > .Update(cacheFSPostDet.Graph, fsPostBatchRow.FinPeriodID, ID.Billing_By.APPOINTMENT, fsPostDocRow.SOID); }
public virtual void VoidReportProc(TaxTran taxTran) { using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { // Acuminator disable once PX1015 IncorrectNumberOfSelectParameters [Justification] PXUpdate < Set <TaxTran.taxPeriodID, Null, Set <TaxTran.revisionID, Null> >, TaxTran, Where <TaxTran.vendorID, Equal <Required <TaxTran.vendorID> >, And <TaxTran.taxPeriodID, Equal <Required <TaxTran.taxPeriodID> >, And <TaxTran.revisionID, Equal <Required <TaxTran.revisionID> >, And <TaxTran.released, Equal <True>, And <TaxTran.voided, Equal <False> > > > > > > .Update(this, taxTran.VendorID, taxTran.TaxPeriodID); ts.Complete(this); } } }
protected virtual void _(Events.RowPersisted <CASetup> e) { if (e.TranStatus == PXTranStatus.Open) { PXUpdate <Set <CashAccount.receiptTranDaysBefore, Required <CashAccount.receiptTranDaysBefore>, Set <CashAccount.receiptTranDaysAfter, Required <CashAccount.receiptTranDaysAfter>, Set <CashAccount.disbursementTranDaysBefore, Required <CashAccount.disbursementTranDaysBefore>, Set <CashAccount.disbursementTranDaysAfter, Required <CashAccount.disbursementTranDaysAfter>, Set <CashAccount.allowMatchingCreditMemo, Required <CashAccount.allowMatchingCreditMemo>, Set <CashAccount.refNbrCompareWeight, Required <CashAccount.refNbrCompareWeight>, Set <CashAccount.dateCompareWeight, Required <CashAccount.dateCompareWeight>, Set <CashAccount.payeeCompareWeight, Required <CashAccount.payeeCompareWeight>, Set <CashAccount.dateMeanOffset, Required <CashAccount.dateMeanOffset>, Set <CashAccount.dateSigma, Required <CashAccount.dateSigma>, Set <CashAccount.skipVoided, Required <CashAccount.skipVoided>, Set <CashAccount.curyDiffThreshold, Required <CashAccount.curyDiffThreshold>, Set <CashAccount.amountWeight, Required <CashAccount.amountWeight>, Set <CashAccount.emptyRefNbrMatching, Required <CashAccount.emptyRefNbrMatching> > > > > > > > > > > > > > >, CashAccount, Where <CashAccount.matchSettingsPerAccount, NotEqual <True> > > .Update(this, e.Row.ReceiptTranDaysBefore, e.Row.ReceiptTranDaysAfter, e.Row.DisbursementTranDaysBefore, e.Row.DisbursementTranDaysAfter, e.Row.AllowMatchingCreditMemo, e.Row.RefNbrCompareWeight, e.Row.DateCompareWeight, e.Row.PayeeCompareWeight, e.Row.DateMeanOffset, e.Row.DateSigma, e.Row.SkipVoided, e.Row.CuryDiffThreshold, e.Row.AmountWeight, e.Row.EmptyRefNbrMatching); } }
/// <summary> RowPersisted ENGineering </summary> public void _(Events.RowPersisted <ENGineering> e) { int count = 0; var row = e.Row as ENGineering; if (string.IsNullOrEmpty(row.Description) || string.IsNullOrEmpty(row.Prjtype) || string.IsNullOrEmpty(row.Priority) || string.IsNullOrEmpty(row.SalesRegion)) { return; } var _RevenueData = new PXGraph().Select <ENGRevenueLine>().Where(x => x.EngrRef == row.EngrRef); if (_RevenueData.Count() == 0) { var _graph = PXGraph.CreateInstance <ENGineeringMaint>(); var _oppProduct = Base.Products.Select().RowCast <CROpportunityProducts>(); foreach (var _prod in _oppProduct) { var _data = _graph.RevenueLine.Insert(_graph.RevenueLine.Cache.CreateInstance() as ENGRevenueLine); _data.EngrRef = row.EngrRef; _data.InventoryID = _prod.InventoryID; _data.Descr = _prod.Descr; _data.Quantity = _prod.Quantity; _data.Uom = _prod.UOM; _data.UnitPrice = _prod.UnitPrice; _data.ExtPrice = _prod.ExtPrice; _data.LineNbr = ++count; } _graph.Actions.PressSave(); // update reveCntr PXUpdate <Set <ENGineering.reveCntr, Required <ENGineering.reveCntr> >, ENGineering, Where <ENGineering.engrRef, Equal <Required <ENGineering.engrRef> > > > .Update(Base, count, row.EngrRef); } }
protected static void CreatePPDApplications(APPaymentEntry paymentEntry, List <PendingPPDDebitAdjApp> list, APPayment debitAdj) { foreach (PendingPPDDebitAdjApp doc in list) { var adj = new APAdjust(); adj.AdjdDocType = doc.AdjdDocType; adj.AdjdRefNbr = doc.AdjdRefNbr; adj = paymentEntry.Adjustments_Raw.Insert(adj); adj.CuryAdjgAmt = doc.InvCuryDocBal; adj = paymentEntry.Adjustments_Raw.Update(adj); string refNbr = debitAdj.RefNbr; PXUpdate <Set <APAdjust.pPDDebitAdjRefNbr, Required <APAdjust.pPDDebitAdjRefNbr> >, APAdjust, Where <APAdjust.adjdDocType, Equal <Required <APAdjust.adjdDocType> >, And <APAdjust.adjdRefNbr, Equal <Required <APAdjust.adjdRefNbr> >, And <APAdjust.adjgDocType, Equal <Required <APAdjust.adjgDocType> >, And <APAdjust.adjgRefNbr, Equal <Required <APAdjust.adjgRefNbr> >, And <APAdjust.released, Equal <True>, And <APAdjust.voided, NotEqual <True>, And <APAdjust.pendingPPD, Equal <True> > > > > > > > > .Update(paymentEntry, refNbr, doc.AdjdDocType, doc.AdjdRefNbr, doc.AdjgDocType, doc.AdjgRefNbr); } }
private void UpdateCosts() { if (IsSMRelated() == true) { Dictionary <int?, decimal?> appointmentIDs = new Dictionary <int?, decimal?>(); var appointmentSet = PXSelectJoin <FSAppointmentDet, InnerJoin <FSAppointment, On <FSAppointment.appointmentID, Equal <FSAppointmentDet.appointmentID> >, InnerJoin <FSPostDet, On <FSPostDet.postDetID, Equal <FSAppointmentDet.postID> >, LeftJoin <INTran, On <INTran.sOOrderType, Equal <FSPostDet.sOOrderType>, And <INTran.sOOrderNbr, Equal <FSPostDet.sOOrderNbr>, And <INTran.sOOrderLineNbr, Equal <FSPostDet.sOLineNbr> > > > > > >, Where < FSPostDet.sOOrderType, Equal <Required <FSPostDet.sOOrderType> >, And < FSPostDet.sOOrderNbr, Equal <Required <FSPostDet.sOOrderNbr> > > > > .Select(Base, Base.inregister.Current.SOOrderType, Base.inregister.Current.SOOrderNbr); using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <FSAppointmentDet, FSAppointment, FSPostDet, INTran> bqlResult in appointmentSet) { FSAppointmentDet fsAppointmentDetRow = (FSAppointmentDet)bqlResult; FSAppointment fsAppointmentRow = (FSAppointment)bqlResult; INTran inTranRow = (INTran)bqlResult; if (inTranRow.RefNbr != null) { PXUpdate < Set <FSAppointmentDet.unitCost, Required <FSAppointmentDet.unitCost>, Set <FSAppointmentDet.curyUnitCost, Required <FSAppointmentDet.curyUnitCost>, Set <FSAppointmentDet.extCost, Required <FSAppointmentDet.extCost>, Set <FSAppointmentDet.curyExtCost, Required <FSAppointmentDet.curyExtCost> > > > >, FSAppointmentDet, Where < FSAppointmentDet.appDetID, Equal <Required <FSAppointmentDet.appDetID> > > > .Update( Base, inTranRow.UnitCost, inTranRow.UnitCost, inTranRow.TranCost, inTranRow.TranCost, fsAppointmentDetRow.AppDetID); } decimal?costTotal = 0.0m; if (appointmentIDs.ContainsKey(fsAppointmentDetRow.AppointmentID) == false) { appointmentIDs.Add(fsAppointmentDetRow.AppointmentID, inTranRow.TranCost ?? fsAppointmentDetRow.ExtCost); } else if (appointmentIDs.TryGetValue(fsAppointmentDetRow.AppointmentID, out costTotal)) { costTotal += inTranRow.TranCost ?? fsAppointmentDetRow.ExtCost; appointmentIDs.Remove(fsAppointmentDetRow.AppointmentID); appointmentIDs.Add(fsAppointmentDetRow.AppointmentID, costTotal); } } foreach (KeyValuePair <int?, decimal?> pair in appointmentIDs.ToList()) { PXUpdate < Set <FSAppointment.costTotal, Required <FSAppointment.costTotal>, Set <FSAppointment.curyCostTotal, Required <FSAppointment.curyCostTotal> > >, FSAppointment, Where < FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > > .Update( new PXGraph(), pair.Value, pair.Value, pair.Key); } ts.Complete(); } } }
/// <summary> /// Update the publisher with some price update - not all publishers /// will action this. /// </summary> /// <param name="pxUpdate"></param> public void OnUpdate(string mnemonic, PXUpdate pxUpdate) { // No action }
/// <summary> /// Create a Service Order from a TimeSlot. /// </summary> protected void CreateServiceOrder(TimeSlot timeSlotServiceOrder, bool createAppointmentFlag = false, bool appointmentsBelongToRoute = false) { // This action allows to avoid errors related to cache if (graphServiceOrderEntry != null) { graphServiceOrderEntry.Clear(PXClearOption.ClearAll); } else { graphServiceOrderEntry = PXGraph.CreateInstance <ServiceOrderEntry>(); graphServiceOrderEntry.DisableServiceOrderUnboundFieldCalc = true; } FSSchedule fsScheduleRow = ScheduleSelected.Select(timeSlotServiceOrder.ScheduleID); FSServiceContract fsServiceContractRow = ServiceContractSelected.Select(fsScheduleRow.EntityID); bool isPrepaidContract = fsServiceContractRow.BillingType == ID.Contract_BillingType.STANDARDIZED_BILLINGS; //Services from the Schedule var fsScheduleDetSet = ScheduleLinesSelected.Select(timeSlotServiceOrder.ScheduleID); //Templates from the Schedule var fsScheduleDetTemplateSet = ScheduleTemplatesSelected.Select(timeSlotServiceOrder.ScheduleID); FSServiceOrder fsServiceOrderRow = new FSServiceOrder(); fsServiceOrderRow.SrvOrdType = fsScheduleRow.SrvOrdType; graphServiceOrderEntry.ServiceOrderRecords.Insert(fsServiceOrderRow); fsServiceOrderRow = graphServiceOrderEntry.ServiceOrderRecords.Cache.CreateCopy(graphServiceOrderEntry.ServiceOrderRecords.Current) as FSServiceOrder; fsServiceOrderRow.BranchID = fsScheduleRow.BranchID; fsServiceOrderRow.BranchLocationID = fsScheduleRow.BranchLocationID; fsServiceOrderRow.OrderDate = timeSlotServiceOrder.DateTimeBegin.Date; fsServiceOrderRow.CustomerID = fsServiceContractRow.CustomerID; fsServiceOrderRow.LocationID = fsScheduleRow.CustomerLocationID; graphServiceOrderEntry.ServiceOrderRecords.Update(fsServiceOrderRow); fsServiceOrderRow = graphServiceOrderEntry.ServiceOrderRecords.Cache.CreateCopy(graphServiceOrderEntry.ServiceOrderRecords.Current) as FSServiceOrder; // Currently Service-Management's contracts DO NOT support multi-currency specification // therefore their ServiceOrders MUST be created in customer base currency if (PXAccess.FeatureInstalled <FeaturesSet.multicurrency>()) { string curyID = null; Customer customer = (Customer)PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > > .Select(this, fsServiceContractRow.CustomerID); if (customer != null) { curyID = customer.CuryID; } if (string.IsNullOrEmpty(curyID) == true) { curyID = this.Accessinfo.BaseCuryID ?? new PXSetup <PX.Objects.GL.Company>(this).Current?.BaseCuryID; } fsServiceOrderRow.CuryID = curyID; } fsServiceOrderRow.DocDesc = timeSlotServiceOrder.Descr; fsServiceOrderRow.BillCustomerID = fsServiceContractRow.BillCustomerID; fsServiceOrderRow.BillLocationID = fsServiceContractRow.BillLocationID; fsServiceOrderRow.ServiceContractID = fsServiceContractRow.ServiceContractID; fsServiceOrderRow.ProjectID = fsServiceContractRow.ProjectID; fsServiceOrderRow.DfltProjectTaskID = fsServiceContractRow.DfltProjectTaskID; if (isPrepaidContract == true && graphServiceOrderEntry.BillingCycleRelated.Current != null && graphServiceOrderEntry.BillingCycleRelated.Current.BillingBy == ID.Billing_By.SERVICE_ORDER) { fsServiceOrderRow.BillServiceContractID = fsServiceContractRow.ServiceContractID; } fsServiceOrderRow.ScheduleID = timeSlotServiceOrder.ScheduleID; fsServiceOrderRow.ServiceContractID = fsServiceContractRow.ServiceContractID; fsServiceOrderRow.GenerationID = timeSlotServiceOrder.GenerationID; fsServiceOrderRow.SalesPersonID = fsServiceContractRow.SalesPersonID; fsServiceOrderRow.Commissionable = fsServiceContractRow.Commissionable; fsServiceOrderRow = graphServiceOrderEntry.ServiceOrderRecords.Update(fsServiceOrderRow); if (fsServiceOrderRow.SalesPersonID == null) { object salesPersonID; graphServiceOrderEntry.ServiceOrderRecords.Cache.RaiseFieldDefaulting <FSServiceOrder.salesPersonID>(fsServiceOrderRow, out salesPersonID); fsServiceOrderRow.SalesPersonID = (int?)salesPersonID; object commissionable; graphServiceOrderEntry.ServiceOrderRecords.Cache.RaiseFieldDefaulting <FSServiceOrder.commissionable>(fsServiceOrderRow, out commissionable); fsServiceOrderRow.Commissionable = (bool?)commissionable; } graphServiceOrderEntry.Answers.CopyAllAttributes(fsServiceOrderRow, fsScheduleRow); #region Setting Service Order Details foreach (FSScheduleDet fsScheduleDetRow in fsScheduleDetSet) { if (fsScheduleDetRow.LineType == ID.LineType_ServiceContract.SERVICE_TEMPLATE) { foreach (FSScheduleDet fsScheduleDetLocalRow in fsScheduleDetTemplateSet.Where(x => ((FSScheduleDet)x).ServiceTemplateID == fsScheduleDetRow.ServiceTemplateID)) { var fsServiceTemplateDetSet_Service = ServiceTemplateSelected.Select(fsScheduleDetRow.ServiceTemplateID); foreach (FSServiceTemplateDet fsServiceTemplateDetRow_Service in fsServiceTemplateDetSet_Service) { FSSODet fsSODetRow = new FSSODet(); // Insert the new row with key fields fsSODetRow.ScheduleID = fsScheduleDetLocalRow.ScheduleID; fsSODetRow.ScheduleDetID = fsScheduleDetLocalRow.ScheduleDetID; fsSODetRow.LineType = fsServiceTemplateDetRow_Service.LineType; fsSODetRow = graphServiceOrderEntry.ServiceOrderDetails.Insert(fsSODetRow); fsSODetRow.InventoryID = fsServiceTemplateDetRow_Service.InventoryID; fsSODetRow = graphServiceOrderEntry.ServiceOrderDetails.Update(fsSODetRow); PXNoteAttribute.CopyNoteAndFiles(ScheduleLinesSelected.Cache, fsScheduleDetLocalRow, graphServiceOrderEntry.ServiceOrderDetails.Cache, fsSODetRow, copyNotes: true, copyFiles: true); // Create a copy to update the other fields fsSODetRow = (FSSODet)graphServiceOrderEntry.ServiceOrderDetails.Cache.CreateCopy(fsSODetRow); fsSODetRow.TranDesc = fsServiceTemplateDetRow_Service.TranDesc; InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(this, fsServiceTemplateDetRow_Service.InventoryID); if (inventoryItemRow != null) { FSxService fsxServiceRow = PXCache <InventoryItem> .GetExtension <FSxService>(inventoryItemRow); if (fsxServiceRow != null && fsxServiceRow.BillingRule == ID.BillingRule.TIME) { int?estimatedDuration = CalculateEstimatedDuration(fsSODetRow, fsServiceTemplateDetRow_Service.Qty); fsSODetRow.EstimatedDuration = estimatedDuration; } else { fsSODetRow.EstimatedQty = fsServiceTemplateDetRow_Service.Qty; } } if (fsServiceContractRow.SourcePrice == ID.SourcePrice.CONTRACT) { fsSODetRow.ManualPrice = true; // TODO: Check where is assigned the contract price? } if (createAppointmentFlag) { fsSODetRow.Scheduled = true; fsSODetRow.Status = ID.Status_SODet.SCHEDULED; } fsSODetRow.EquipmentAction = fsScheduleDetRow.EquipmentAction; fsSODetRow.SMEquipmentID = fsScheduleDetRow.SMEquipmentID; fsSODetRow.ComponentID = fsScheduleDetRow.ComponentID; fsSODetRow.EquipmentLineRef = fsScheduleDetRow.EquipmentLineRef; fsSODetRow.ProjectTaskID = fsScheduleDetRow.ProjectTaskID; fsSODetRow.CostCodeID = fsScheduleDetRow.CostCodeID; if (fsSODetRow.InventoryID != null) { fsSODetRow.ProjectTaskID = fsScheduleDetRow.ProjectTaskID; fsSODetRow.CostCodeID = fsScheduleDetRow.CostCodeID; } graphServiceOrderEntry.ServiceOrderDetails.Update(fsSODetRow); } } } else { FSSODet fsSODetRow = new FSSODet(); // Insert the new row with key fields fsSODetRow.ScheduleID = fsScheduleDetRow.ScheduleID; fsSODetRow.ScheduleDetID = fsScheduleDetRow.ScheduleDetID; fsSODetRow.LineType = fsScheduleDetRow.LineType; fsSODetRow = graphServiceOrderEntry.ServiceOrderDetails.Insert(fsSODetRow); fsSODetRow.InventoryID = fsScheduleDetRow.InventoryID; fsSODetRow = graphServiceOrderEntry.ServiceOrderDetails.Update(fsSODetRow); PXNoteAttribute.CopyNoteAndFiles(ScheduleLinesSelected.Cache, fsScheduleDetRow, graphServiceOrderEntry.ServiceOrderDetails.Cache, fsSODetRow, copyNotes: true, copyFiles: true); // Create a copy to update the other fields fsSODetRow = (FSSODet)graphServiceOrderEntry.ServiceOrderDetails.Cache.CreateCopy(fsSODetRow); fsSODetRow.TranDesc = fsScheduleDetRow.TranDesc; fsSODetRow.BillingRule = fsScheduleDetRow.BillingRule; if (fsSODetRow.BillingRule == ID.BillingRule.TIME) { int?estimatedDuration = CalculateEstimatedDuration(fsSODetRow, fsScheduleDetRow?.Qty); fsSODetRow.EstimatedDuration = estimatedDuration; } else { fsSODetRow.EstimatedQty = fsScheduleDetRow.Qty; } if (fsServiceContractRow.SourcePrice == ID.SourcePrice.CONTRACT) { fsSODetRow.ManualPrice = true; // TODO: AC-142850 Check where is assigned the contract price? } if (createAppointmentFlag) { fsSODetRow.Scheduled = true; fsSODetRow.Status = ID.Status_SODet.SCHEDULED; } fsSODetRow.EquipmentAction = fsScheduleDetRow.EquipmentAction; fsSODetRow.SMEquipmentID = fsScheduleDetRow.SMEquipmentID; fsSODetRow.ComponentID = fsScheduleDetRow.ComponentID; fsSODetRow.EquipmentLineRef = fsScheduleDetRow.EquipmentLineRef; fsSODetRow.ProjectTaskID = fsScheduleDetRow.ProjectTaskID; fsSODetRow.CostCodeID = fsScheduleDetRow.CostCodeID; if (fsSODetRow.InventoryID != null) { fsSODetRow.ProjectTaskID = fsScheduleDetRow.ProjectTaskID; fsSODetRow.CostCodeID = fsScheduleDetRow.CostCodeID; } graphServiceOrderEntry.ServiceOrderDetails.Update(fsSODetRow); } } if (fsScheduleRow.VendorID != null) { FSSOEmployee fsSOEmployeeRow = new FSSOEmployee(); fsSOEmployeeRow.EmployeeID = fsScheduleRow.VendorID; graphServiceOrderEntry.ServiceOrderEmployees.Insert(fsSOEmployeeRow); } #endregion graphServiceOrderEntry.Save.Press(); if (createAppointmentFlag) { string origStatus = graphServiceOrderEntry.ServiceOrderRecords.Current.Status; if (origStatus != ID.Status_ServiceOrder.OPEN) { //Due to FSAppointment.sORefNbr selector, Service Order status must be OPEN to allow the SetValueExt<SORefNbr> inside createAppointment() work properly. //PXUpdate is used to avoid raising any ServiceOrderEntry event. PXUpdate < Set <FSServiceOrder.status, FSServiceOrder.status.Open>, FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> > > > .Update(this, graphServiceOrderEntry.ServiceOrderRecords.Current.SOID); } CreateAppointment(graphServiceOrderEntry.ServiceOrderRecords.Current, timeSlotServiceOrder, fsScheduleRow, true, appointmentsBelongToRoute, isPrepaidContract); if (origStatus != ID.Status_ServiceOrder.OPEN) { PXUpdate < Set <FSServiceOrder.status, Required <FSServiceOrder.status> >, FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> > > > .Update(this, origStatus, graphServiceOrderEntry.ServiceOrderRecords.Current.SOID); } } }
protected virtual void UpdateBillingInfoInDoc(PXGraph tempGraph, FSServiceOrder fsServiceOrderRow, int?newCBID, int?newBillingCycleID, bool updateCutOffDate, bool forceUpdate, Dictionary <BillingCycleIDAndDate, DateTime?> cutOffDateCache) { if (fsServiceOrderRow.CBID == newCBID && updateCutOffDate == false && fsServiceOrderRow.CutOffDate != null && forceUpdate == false) { return; } if (fsServiceOrderRow.PostedBy == null) { using (PXTransactionScope ts = new PXTransactionScope()) { DateTime?newCutOffDate = null; BillingCycleIDAndDate billingCycleIDAndDate = null; if (newBillingCycleID != null) { billingCycleIDAndDate = new BillingCycleIDAndDate(); billingCycleIDAndDate.BillingCycleID = newBillingCycleID; billingCycleIDAndDate.DocDate = fsServiceOrderRow.OrderDate; if (cutOffDateCache.TryGetValue(billingCycleIDAndDate, out newCutOffDate) == false) { newCutOffDate = ServiceOrderCore.GetCutOffDate(tempGraph, fsServiceOrderRow.CBID, fsServiceOrderRow.OrderDate); cutOffDateCache.Add(billingCycleIDAndDate, newCutOffDate); } } if (fsServiceOrderRow.CBID != newCBID || fsServiceOrderRow.CutOffDate != newCutOffDate) { PXUpdate < Set <FSServiceOrder.cBID, Required <FSServiceOrder.cBID>, Set <FSServiceOrder.cutOffDate, Required <FSServiceOrder.cutOffDate> > >, FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> > > > .Update(tempGraph, newCBID, newCutOffDate, fsServiceOrderRow.SOID); } var appointmentSet = PXSelect <FSAppointment, Where < FSAppointment.sOID, Equal <Required <FSAppointment.sOID> > > > .Select(tempGraph, fsServiceOrderRow.SOID); foreach (FSAppointment fsAppointmentRow in appointmentSet) { newCutOffDate = null; if (newBillingCycleID != null) { billingCycleIDAndDate.DocDate = fsAppointmentRow.ExecutionDate; if (cutOffDateCache.TryGetValue(billingCycleIDAndDate, out newCutOffDate) == false) { newCutOffDate = ServiceOrderCore.GetCutOffDate(tempGraph, fsServiceOrderRow.CBID, fsAppointmentRow.ExecutionDate); cutOffDateCache.Add(billingCycleIDAndDate, newCutOffDate); } } if (fsAppointmentRow.CutOffDate != newCutOffDate) { PXUpdate < Set <FSAppointment.cutOffDate, Required <FSAppointment.cutOffDate> >, FSAppointment, Where < FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > > .Update(tempGraph, newCutOffDate, fsAppointmentRow.AppointmentID); } } ts.Complete(); } } }
private bool ProcessTranForReclassGroup(IReadOnlyCollection <GLTranForReclassTriple> tranForReclassTriples, Dictionary <GLTranForReclassification, GLTranForReclassification> workOrigTranMap, List <GLTranForReclassification> origTransForReclass, Batch batchForEdit = null) { Batch reclassBatch; List <GLTran> transMovedFromExistingBatch = new List <GLTran>(); try { using (PXTransactionScope ts = new PXTransactionScope()) { reclassBatch = BuildReclassificationBatch(tranForReclassTriples, transMovedFromExistingBatch, batchForEdit); JournalEntryInstance.Actions.PressSave(); foreach (var tran in transMovedFromExistingBatch) { JournalEntryInstance.GLTranModuleBatNbr.Delete(tran); } JournalEntryInstance.Actions.PressSave(); foreach (var tranForReclassTriple in tranForReclassTriples) { var srcTran = tranForReclassTriple.Tran; PXUpdate < Set <GLTran.reclassBatchNbr, Required <GLTran.reclassBatchNbr>, Set <GLTran.reclassBatchModule, Required <GLTran.reclassBatchModule> > >, GLTran, Where <GLTran.module, Equal <Required <GLTran.module> >, And <GLTran.batchNbr, Equal <Required <GLTran.batchNbr> >, And <GLTran.lineNbr, Equal <Required <GLTran.lineNbr> > > > > > .Update(this, reclassBatch.BatchNbr, reclassBatch.Module, srcTran.Module, srcTran.BatchNbr, srcTran.LineNbr); } ts.Complete(); foreach (var tranCuryPair in tranForReclassTriples) { var origTran = workOrigTranMap[tranCuryPair.Tran]; origTran.ReclassBatchModule = reclassBatch.Module; origTran.ReclassBatchNbr = reclassBatch.BatchNbr; } if (batchForEdit != null) { State.GLTranForReclassToDelete.Clear(); } } } catch (Exception ex) { var exMessage = GetExceptionMessage(ex); var message = string.Concat(PXMessages.LocalizeNoPrefix(Messages.ReclassificationBatchHasNotBeenCreatedForTheTransaction), Environment.NewLine, exMessage); foreach (var tranCuryPair in tranForReclassTriples) { GLTranForReclass.Cache.RestoreCopy(tranCuryPair.Tran, workOrigTranMap[tranCuryPair.Tran]); PXProcessing <GLTranForReclassification> .SetError(origTransForReclass.IndexOf(workOrigTranMap[tranCuryPair.Tran]), message); } JournalEntryInstance.Clear(); PrepareJournalEntryGraph(); return(false); } if (GLSetup.Current.AutoReleaseReclassBatch == true && batchForEdit == null) { try { JournalEntry.ReleaseBatch(new[] { reclassBatch }, externalPostList: null, unholdBatch: true); } catch (Exception ex) { var exMessage = GetExceptionMessage(ex); var message = string.Concat( PXMessages.LocalizeNoPrefix(Messages.ReclassificationBatchGeneratedForThisTransactionHasNotBeenReleasedOrPosted), Environment.NewLine, exMessage); foreach (var tranCuryPair in tranForReclassTriples) { PXProcessing <GLTranForReclassification> .SetError( origTransForReclass.IndexOf(workOrigTranMap[tranCuryPair.Tran]), message); } return(false); } } foreach (var tranCuryPair in tranForReclassTriples) { PXProcessing <GLTranForReclassification> .SetInfo(origTransForReclass.IndexOf(workOrigTranMap[tranCuryPair.Tran]), ActionsMessages.RecordProcessed); } return(true); }
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 IEnumerable requestValidation(PXAdapter adapter) { foreach (FeaturesSet feature in adapter.Get()) { if (feature.Status == 3) { bool? customerDiscountsOld = PXAccess.FeatureInstalled <FeaturesSet.customerDiscounts>(); bool? branchOld = PXAccess.FeatureInstalled <FeaturesSet.branch>(); PXCache cache = new PXCache <FeaturesSet>(this); FeaturesSet update = PXCache <FeaturesSet> .CreateCopy(feature); update.Status = 0; update = this.Features.Update(update); this.Features.Delete(feature); if (update.Status != 1) { this.Features.Delete(new FeaturesSet() { Status = 1 }); } this.Persist(); PXAccess.Version++; var tasks = PXSelect <WZTask> .Select(this); WZTaskEntry taskGraph = CreateInstance <WZTaskEntry>(); foreach (WZTask task in tasks) { bool disableTask = false; bool enableTask = false; foreach ( WZTaskFeature taskFeature in PXSelectReadonly <WZTaskFeature, Where <WZTaskFeature.taskID, Equal <Required <WZTask.taskID> > > > .Select( this, task.TaskID)) { bool featureInstalled = (bool?)cache.GetValue(update, taskFeature.Feature) == true; if (!featureInstalled) { disableTask = true; enableTask = false; break; } enableTask = true; } if (disableTask) { task.Status = WizardTaskStatusesAttribute._DISABLED; taskGraph.TaskInfo.Update(task); taskGraph.Save.Press(); } if (enableTask && task.Status == WizardTaskStatusesAttribute._DISABLED) { bool needToBeOpen = false; WZScenario scenario = PXSelect <WZScenario, Where <WZScenario.scenarioID, Equal <Required <WZTask.scenarioID> > > > .Select(this, task.ScenarioID); if (scenario != null && scenario.Status == WizardScenarioStatusesAttribute._ACTIVE) { WZTask parentTask = PXSelect <WZTask, Where <WZTask.taskID, Equal <Required <WZTask.parentTaskID> > > > .Select( this, task.ParentTaskID); if (parentTask != null && (parentTask.Status == WizardTaskStatusesAttribute._OPEN || parentTask.Status == WizardTaskStatusesAttribute._ACTIVE)) { needToBeOpen = true; } foreach ( PXResult <WZTaskPredecessorRelation, WZTask> predecessorResult in PXSelectJoin <WZTaskPredecessorRelation, InnerJoin <WZTask, On <WZTask.taskID, Equal <WZTaskPredecessorRelation.predecessorID> > >, Where <WZTaskPredecessorRelation.taskID, Equal <Required <WZTask.taskID> > > > . Select(this, task.TaskID)) { WZTask predecessorTask = (WZTask)predecessorResult; if (predecessorTask != null) { if (predecessorTask.Status == WizardTaskStatusesAttribute._COMPLETED) { needToBeOpen = true; } else { needToBeOpen = false; break; } } } } task.Status = needToBeOpen ? WizardTaskStatusesAttribute._OPEN : WizardTaskStatusesAttribute._PENDING; taskGraph.TaskInfo.Update(task); taskGraph.Save.Press(); } } if (customerDiscountsOld == true && update.CustomerDiscounts != true) { PXUpdate <Set <ARSetup.applyLineDiscountsIfCustomerPriceDefined, True>, ARSetup> .Update(this); PXUpdate <Set <ARSetup.applyLineDiscountsIfCustomerClassPriceDefined, True>, ARSetup> .Update(this); PXUpdate <Set <SOOrderType.recalculateDiscOnPartialShipment, False, Set <SOOrderType.postLineDiscSeparately, False> >, SOOrderType> .Update(this); } if (branchOld != update.Branch) { PXUpdate <Set <ListEntryPoint.isActive, Required <ListEntryPoint.isActive> >, ListEntryPoint, Where <ListEntryPoint.entryScreenID, Equal <Required <ListEntryPoint.entryScreenID> > > > .Update(this, update.Branch == true, "CS101500"); } yield return(update); } else { yield return(feature); } } bool needRefresh = !(ActivationBehaviour.Current != null && ActivationBehaviour.Current.Refresh == false); PXDatabase.ResetSlots(); PXPageCacheUtils.InvalidateCachedPages(); this.Clear(); if (needRefresh) { throw new PXRefreshException(); } }