//@TODO SD-7694 public static IEnumerable RouteRecordsDelegate( PXFilter <RouteAppointmentAssignmentFilter> filter, PXSelectBase <FSRouteDocument> cmd) { if (filter.Current == null) { yield break; } foreach (PXResult <FSRouteDocument, FSRoute> bqlResult in cmd.Select()) { FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult; FSRoute fsRouteRow = (FSRoute)bqlResult; if (filter.Current.RouteDate.HasValue == true) { if (!fsRouteDocumentRow.TimeBegin.HasValue) { fsRouteDocumentRow.TimeBegin = AppointmentCore.GetDateTimeEnd(fsRouteDocumentRow.Date, 0, 0, 0); } if (fsRouteDocumentRow.Date.Value.Date >= filter.Current.RouteDate.Value.Date && fsRouteDocumentRow.Date.Value.Date <= AppointmentCore.GetDateTimeEnd(filter.Current.RouteDate.Value.Date, 23, 59, 59)) { yield return(bqlResult); } } else { yield return(bqlResult); } } }
private void CloneServices(AppointmentEntry sourceAppointmentGraph, AppointmentEntry newAppointmentGraph, FSAppointment newAppointmentRow) { foreach (FSAppointmentDetService sourceRow in sourceAppointmentGraph.AppointmentDetServices.Select()) { FSSODet fsSODetRow = ServiceOrderCore.GetSODetFromAppointmentDet(sourceAppointmentGraph, sourceRow); if (fsSODetRow != null && (fsSODetRow.Status == ID.Status_AppointmentDet.CANCELED || fsSODetRow.Status == ID.Status_AppointmentDet.COMPLETED)) { continue; } FSAppointmentDetService newRow = PXCache <FSAppointmentDetService> .CreateCopy(sourceRow); newRow.ActualDuration = 0; newRow.ActualDateTimeBegin = null; newRow.ActualDateTimeEnd = null; newRow.Qty = 0; newRow = AppointmentEntry.InsertServicePartLine <FSAppointmentDetService, FSAppointmentDetService>( newAppointmentGraph.AppointmentDetServices.Cache, newRow, sourceAppointmentGraph.AppointmentDetServices.Cache, sourceRow, null, sourceRow.SODetID, copyTranDate: false, tranDate: sourceRow.TranDate, SetValuesAfterAssigningSODetID: true, copyingFromQuote: false); PXNoteAttribute.CopyNoteAndFiles( sourceAppointmentGraph.AppointmentDetServices.Cache, sourceRow, newAppointmentGraph.AppointmentDetServices.Cache, newRow, copyNotes: true, copyFiles: false); newAppointmentGraph.AppointmentDetServices.SetValueExt <FSAppointmentDetService.acctID>(newRow, sourceRow.AcctID); newAppointmentGraph.AppointmentDetServices.SetValueExt <FSAppointmentDetService.subID>(newRow, sourceRow.SubID); AppointmentCore.UpdateAppointmentsInfoInServiceOrder(newAppointmentGraph.AppointmentDetServices.Cache, newRow, ServiceOrderRelated); } }
private void CloneParts(AppointmentEntry sourceAppointmentGraph, AppointmentEntry newAppointmentGraph, FSAppointment newAppointmentRow) { foreach (FSAppointmentDetPart sourceRow in sourceAppointmentGraph.AppointmentDetParts.Select()) { FSSODet fsSODetRow = ServiceOrderCore.GetSODetFromAppointmentDet(sourceAppointmentGraph, sourceRow); if (fsSODetRow != null && (fsSODetRow.Status == ID.Status_AppointmentDet.CANCELED || fsSODetRow.Status == ID.Status_AppointmentDet.COMPLETED)) { continue; } FSAppointmentDet sumFSAppointmentDetPartBillable = PXSelectJoinGroupBy <FSAppointmentDet, InnerJoin <FSAppointment, On <FSAppointment.srvOrdType, Equal <FSAppointmentDet.srvOrdType>, And <FSAppointment.refNbr, Equal <FSAppointmentDetPart.refNbr> > > >, Where <FSAppointmentDet.sODetID, Equal <Required <FSAppointmentDet.sODetID> >, And <FSAppointment.status, NotEqual <FSAppointment.status.Canceled>, And <FSAppointmentDet.status, NotEqual <FSAppointmentDet.status.Canceled> > > >, Aggregate <GroupBy <FSAppointmentDet.sODetID, Sum <FSAppointmentDet.billableQty> > > > .Select(dummyGraph, sourceRow.SODetID); decimal?openQty = fsSODetRow.BillableQty - sumFSAppointmentDetPartBillable.BillableQty; bool? lineCloned = false; FSAppointmentDetPart newRow = PXCache <FSAppointmentDetPart> .CreateCopy(sourceRow); if (openQty >= sourceRow.BillableQty) { newRow = AppointmentEntry.InsertServicePartLine <FSAppointmentDetPart, FSAppointmentDetPart>( newAppointmentGraph.AppointmentDetParts.Cache, newRow, sourceAppointmentGraph.AppointmentDetParts.Cache, sourceRow, null, sourceRow.SODetID, copyTranDate: false, tranDate: sourceRow.TranDate, SetValuesAfterAssigningSODetID: true, copyingFromQuote: false); lineCloned = true; } else { if (openQty > 0) { decimal?remainingQty = sourceRow.BillableQty - openQty; newRow.Qty = 0; sourceRow.EstimatedQty = openQty; sourceRow.BillableQty = openQty; newRow = AppointmentEntry.InsertServicePartLine <FSAppointmentDetPart, FSAppointmentDetPart>( newAppointmentGraph.AppointmentDetParts.Cache, newRow, sourceAppointmentGraph.AppointmentDetParts.Cache, sourceRow, null, sourceRow.SODetID, copyTranDate: false, tranDate: sourceRow.TranDate, SetValuesAfterAssigningSODetID: true, copyingFromQuote: false); lineCloned = true; FSAppointmentDetPart secondNewRow = PXCache <FSAppointmentDetPart> .CreateCopy(sourceRow); secondNewRow.Qty = 0; sourceRow.EstimatedQty = remainingQty; sourceRow.BillableQty = remainingQty; secondNewRow.SODetID = null; secondNewRow = AppointmentEntry.InsertServicePartLine <FSAppointmentDetPart, FSAppointmentDetPart>( newAppointmentGraph.AppointmentDetParts.Cache, secondNewRow, sourceAppointmentGraph.AppointmentDetParts.Cache, sourceRow, null, null, copyTranDate: false, tranDate: sourceRow.TranDate, SetValuesAfterAssigningSODetID: false, copyingFromQuote: false); } else { newRow.SODetID = null; newRow.Qty = 0; newRow = AppointmentEntry.InsertServicePartLine <FSAppointmentDetPart, FSAppointmentDetPart>( newAppointmentGraph.AppointmentDetParts.Cache, newRow, sourceAppointmentGraph.AppointmentDetParts.Cache, sourceRow, null, null, copyTranDate: false, tranDate: sourceRow.TranDate, SetValuesAfterAssigningSODetID: false, copyingFromQuote: false); } } if (lineCloned == true) { PXNoteAttribute.CopyNoteAndFiles( sourceAppointmentGraph.AppointmentDetParts.Cache, sourceRow, newAppointmentGraph.AppointmentDetParts.Cache, newRow, copyNotes: true, copyFiles: false); AppointmentCore.UpdateAppointmentsInfoInServiceOrder(newAppointmentGraph.AppointmentDetParts.Cache, newRow, ServiceOrderRelated); } } }
protected virtual void CloneAppointment(AppointmentEntry graphOriginalAppointment, AppointmentEntry graphNewAppointment) { if (AppointmentSelected.Current == null) { return; } graphNewAppointment.Clear(PXClearOption.ClearAll); graphNewAppointment.clearLocalServiceOrder(); FSAppointment fsAppointmentRow = PXCache <FSAppointment> .CreateCopy(AppointmentSelected.Current); //Clear key and special fields fsAppointmentRow.RefNbr = null; fsAppointmentRow.AppointmentID = null; fsAppointmentRow.NoteID = null; fsAppointmentRow.CuryInfoID = null; fsAppointmentRow.AgreementSignature = false; fsAppointmentRow.FullNameSignature = null; fsAppointmentRow.customerSignaturePath = null; fsAppointmentRow.BillServiceContractID = null; fsAppointmentRow.HandleManuallyActualTime = null; fsAppointmentRow.HandleManuallyScheduleTime = null; fsAppointmentRow.OriginalAppointmentID = AppointmentSelected.Current.AppointmentID; fsAppointmentRow.ScheduledDateTimeBegin = AppointmentCore.GetDateTimeEnd( Filter.Current.ScheduledDate, Filter.Current.ScheduledStartTime); fsAppointmentRow.ScheduledDateTimeEnd = AppointmentCore.GetDateTimeEnd( Filter.Current.ScheduledDate, Filter.Current.ScheduledEndTime); fsAppointmentRow.ExecutionDate = fsAppointmentRow.ScheduledDateTimeBegin.Value.Date; fsAppointmentRow.CutOffDate = ServiceOrderCore.GetCutOffDate(graphNewAppointment, graphOriginalAppointment.ServiceOrderRelated.Current.CBID, fsAppointmentRow.ExecutionDate); fsAppointmentRow.Status = ID.Status_Appointment.MANUAL_SCHEDULED; fsAppointmentRow.Hold = false; fsAppointmentRow.AdditionalCommentsCustomer = null; fsAppointmentRow.AdditionalCommentsStaff = null; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Clean total fields fsAppointmentRow.EstimatedDurationTotal = 0; fsAppointmentRow.ActualDurationTotal = 0; fsAppointmentRow.CuryEstimatedLineTotal = 0; fsAppointmentRow.CuryLineTotal = 0; fsAppointmentRow.CuryBillableLineTotal = 0; fsAppointmentRow.CuryCostTotal = 0; fsAppointmentRow.EstimatedLineTotal = 0; fsAppointmentRow.LineTotal = 0; fsAppointmentRow.BillableLineTotal = 0; fsAppointmentRow.CostTotal = 0; //---------------------------------------------------------------------- graphNewAppointment.IsCloningAppointment = true; fsAppointmentRow = graphNewAppointment.AppointmentRecords.Insert(fsAppointmentRow); graphNewAppointment.AttributeListRecords.Current = graphNewAppointment.AttributeListRecords.Select(); graphNewAppointment.Answers.Current = graphNewAppointment.Answers.Select(); graphNewAppointment.Answers.CopyAllAttributes(graphNewAppointment.AppointmentRecords.Current, AppointmentSelected.Current); PXNoteAttribute.CopyNoteAndFiles( AppointmentSelected.Cache, AppointmentSelected.Current, graphNewAppointment.AppointmentSelected.Cache, fsAppointmentRow, copyNotes: true, copyFiles: false); this.CloneParts(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow); this.CloneServices(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow); this.CloneEmployees(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow); this.CloneAttendees(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow); this.CloneResources(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow); if (graphNewAppointment.AppointmentRecords.Current.ScheduledDateTimeEnd != Filter.Current.ScheduledEndTime) { graphNewAppointment.AppointmentRecords.Cache.SetValueExt <FSAppointment.handleManuallyScheduleTime>(fsAppointmentRow, true); graphNewAppointment.AppointmentRecords.Cache.SetValueExt <FSAppointment.scheduledDateTimeEnd>(fsAppointmentRow, Filter.Current.ScheduledEndTime); } graphNewAppointment.AppointmentRecords.Cache.SetDefaultExt <FSAppointment.billContractPeriodID>(fsAppointmentRow); graphNewAppointment.Save.Press(); }
public virtual void CloneAppointment(AppointmentEntry graphOriginalAppointment, AppointmentEntry graphNewAppointment) { if (AppointmentSelected.Current == null) { return; } graphNewAppointment.Clear(PXClearOption.ClearAll); graphNewAppointment.clearLocalServiceOrder(); FSAppointment fsAppointmentRow = PXCache <FSAppointment> .CreateCopy(AppointmentSelected.Current); var itemLineRefNbr = new Dictionary <string, string>(); //Clear key and special fields fsAppointmentRow.RefNbr = null; fsAppointmentRow.AppointmentID = null; fsAppointmentRow.NoteID = null; fsAppointmentRow.CuryInfoID = null; fsAppointmentRow.FullNameSignature = null; fsAppointmentRow.customerSignaturePath = null; fsAppointmentRow.BillServiceContractID = null; fsAppointmentRow.HandleManuallyActualTime = null; fsAppointmentRow.HandleManuallyScheduleTime = null; fsAppointmentRow.LogLineCntr = 0; fsAppointmentRow.FinPeriodID = null; fsAppointmentRow.PostingStatusAPARSO = ID.Status_Posting.PENDING_TO_POST; fsAppointmentRow.PendingAPARSOPost = true; fsAppointmentRow.OriginalAppointmentID = AppointmentSelected.Current.AppointmentID; fsAppointmentRow.ScheduledDateTimeBegin = AppointmentCore.GetDateTimeEnd( Filter.Current.ScheduledDate, Filter.Current.ScheduledStartTime); DateTime?scheduledDateTimeEnd = null; fsAppointmentRow.ScheduledDateTimeEnd = scheduledDateTimeEnd = AppointmentCore.GetDateTimeEnd( Filter.Current.ScheduledDate, Filter.Current.ScheduledEndTime); fsAppointmentRow.ExecutionDate = fsAppointmentRow.ScheduledDateTimeBegin.Value.Date; fsAppointmentRow.CutOffDate = ServiceOrderCore.GetCutOffDate(graphNewAppointment, graphOriginalAppointment.ServiceOrderRelated.Current.CBID, fsAppointmentRow.ExecutionDate, fsAppointmentRow.SrvOrdType); fsAppointmentRow.Status = ID.Status_Appointment.MANUAL_SCHEDULED; fsAppointmentRow.Hold = false; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Clean total fields fsAppointmentRow.EstimatedDurationTotal = 0; fsAppointmentRow.ActualDurationTotal = 0; fsAppointmentRow.CuryEstimatedLineTotal = 0; fsAppointmentRow.CuryLineTotal = 0; fsAppointmentRow.CuryBillableLineTotal = 0; fsAppointmentRow.CuryCostTotal = 0; fsAppointmentRow.EstimatedLineTotal = 0; fsAppointmentRow.LineTotal = 0; fsAppointmentRow.BillableLineTotal = 0; fsAppointmentRow.CostTotal = 0; fsAppointmentRow.LineCntr = 0; //---------------------------------------------------------------------- graphNewAppointment.IsCloningAppointment = true; fsAppointmentRow = graphNewAppointment.AppointmentRecords.Insert(fsAppointmentRow); graphNewAppointment.Answers.Current = graphNewAppointment.Answers.Select(); graphNewAppointment.Answers.CopyAllAttributes(graphNewAppointment.AppointmentRecords.Current, AppointmentSelected.Current); PXNoteAttribute.CopyNoteAndFiles(AppointmentSelected.Cache, AppointmentSelected.Current, graphNewAppointment.AppointmentSelected.Cache, fsAppointmentRow, copyNotes: true, copyFiles: false); foreach (FSAppointmentDet sourceRow in graphOriginalAppointment.AppointmentDetails.Select()) { if (sourceRow.IsInventoryItem == true) { this.CloneParts(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow, sourceRow); } else if (sourceRow.IsInventoryItem == false && sourceRow.IsPickupDelivery == false) { this.CloneServices(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow, sourceRow, itemLineRefNbr); } } this.CloneEmployees(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow, itemLineRefNbr); this.CloneResources(graphOriginalAppointment, graphNewAppointment, fsAppointmentRow); if (graphNewAppointment.AppointmentRecords.Current.ScheduledDateTimeEnd != scheduledDateTimeEnd) { graphNewAppointment.AppointmentRecords.Cache.SetValueExt <FSAppointment.handleManuallyScheduleTime>(fsAppointmentRow, true); graphNewAppointment.AppointmentRecords.Cache.SetValueExt <FSAppointment.scheduledDateTimeEnd>(fsAppointmentRow, scheduledDateTimeEnd); } graphNewAppointment.AppointmentRecords.Cache.SetDefaultExt <FSAppointment.billContractPeriodID>(fsAppointmentRow); graphNewAppointment.Save.Press(); }