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(); }
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(); } } }
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(); }