public virtual void FillPOLineFromDemand(POLine dest, POFixedDemand demand, string OrderType, SOLineSplit3 solinesplit, FillPOLineFromDemandDelegate del) { if (demand.PlanType == INPlanConstants.PlanF6) { PXResult <FSSODetSplit, FSSODet> fsSODetSplitDetRow = (PXResult <FSSODetSplit, FSSODet>) PXSelectJoin <FSSODetSplit, InnerJoin <FSSODet, On < FSSODet.lineNbr, Equal <FSSODetSplit.lineNbr>, And <FSSODet.srvOrdType, Equal <FSSODetSplit.srvOrdType>, And <FSSODet.refNbr, Equal <FSSODetSplit.refNbr> > > > >, Where < FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> > > > .Select(Base, demand.PlanID); if (fsSODetSplitDetRow != null) { FSSODetSplit fsSODetSplitRow = (FSSODetSplit)fsSODetSplitDetRow; FSSODet fsSODetRow = (FSSODet)fsSODetSplitDetRow; dest.LineType = (fsSODetSplitRow.LineType == SO.SOLineType.Inventory ? POLineType.GoodsForServiceOrder : POLineType.NonStockForServiceOrder); if (fsSODetRow.ManualCost == true) { dest.CuryUnitCost = fsSODetRow.CuryUnitCost; } } } del(dest, demand, OrderType, solinesplit); }
public void CopyPOLineFields(POFixedDemand demand, POLine line) { PXResult <FSSODetSplit, FSSODet> fsSODetSplitDetRow = (PXResult <FSSODetSplit, FSSODet>) PXSelectJoin <FSSODetSplit, InnerJoin <FSSODet, On <FSSODet.lineNbr, Equal <FSSODetSplit.lineNbr>, And <FSSODet.srvOrdType, Equal <FSSODetSplit.srvOrdType>, And <FSSODet.refNbr, Equal <FSSODetSplit.refNbr> > > > >, Where <FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> > > > .Select(Base, demand.PlanID); if (fsSODetSplitDetRow != null) { FSSODet fsSODetRow = (FSSODet)fsSODetSplitDetRow; if (POSetupRecord.Current != null) { if (POSetupRecord.Current.CopyLineNotesFromServiceOrder == true || POSetupRecord.Current.CopyLineAttachmentsFromServiceOrder == true) { var fsSODetCache = new PXCache <FSSODet>(Base); fsSODetCache.Update(fsSODetRow); PXNoteAttribute.CopyNoteAndFiles(fsSODetCache, fsSODetRow, Base.Transactions.Cache, line, POSetupRecord.Current.CopyLineNotesFromServiceOrder == true, POSetupRecord.Current.CopyLineAttachmentsFromServiceOrder == true); } } line.TranDesc = fsSODetRow.TranDesc; } }
public static void InsertFSSODetFromOpportunity(ServiceOrderEntry graphServiceOrder, PXCache cacheOpportunityProducts, CRSetup crSetupRow, CROpportunityProducts crOpportunityProductRow, FSxCROpportunityProducts fsxCROpportunityProductsRow, InventoryItem inventoryItemRow) { if (graphServiceOrder == null || crOpportunityProductRow == null || fsxCROpportunityProductsRow == null || inventoryItemRow == null) { return; } //Insert a new SODet line FSSODet fsSODetRow = new FSSODet(); UpdateFSSODetFromOpportunity(graphServiceOrder.ServiceOrderDetails.Cache, fsSODetRow, crOpportunityProductRow, fsxCROpportunityProductsRow, SharedFunctions.GetLineTypeFromInventoryItem(inventoryItemRow)); SharedFunctions.CopyNotesAndFiles(cacheOpportunityProducts, graphServiceOrder.ServiceOrderDetails.Cache, crOpportunityProductRow, graphServiceOrder.ServiceOrderDetails.Current, crSetupRow.CopyNotes, crSetupRow.CopyFiles); }
public static void UpdateFSSODetFromOpportunity(PXCache soDetCache, FSSODet fsSODetRow, CROpportunityProducts crOpportunityProductRow, FSxCROpportunityProducts fsxCROpportunityProductsRow, string lineType) { if (crOpportunityProductRow == null || fsxCROpportunityProductsRow == null) { return; } fsSODetRow.SourceNoteID = crOpportunityProductRow.NoteID; soDetCache.Current = fsSODetRow = (FSSODet)soDetCache.Insert(fsSODetRow); fsSODetRow.LineType = lineType; fsSODetRow.InventoryID = crOpportunityProductRow.InventoryID; fsSODetRow.IsBillable = crOpportunityProductRow.IsFree == false; soDetCache.Current = fsSODetRow = (FSSODet)soDetCache.Update(fsSODetRow); fsSODetRow = (FSSODet)soDetCache.CreateCopy(fsSODetRow); fsSODetRow.BillingRule = fsxCROpportunityProductsRow.BillingRule; fsSODetRow.TranDesc = crOpportunityProductRow.Descr; if (crOpportunityProductRow.SiteID != null) { fsSODetRow.SiteID = crOpportunityProductRow.SiteID; } fsSODetRow.EstimatedDuration = fsxCROpportunityProductsRow.EstimatedDuration; fsSODetRow.EstimatedQty = crOpportunityProductRow.Qty; fsSODetRow.CuryUnitPrice = crOpportunityProductRow.CuryUnitPrice; fsSODetRow.ManualPrice = crOpportunityProductRow.ManualPrice; fsSODetRow.ProjectID = crOpportunityProductRow.ProjectID; fsSODetRow.ProjectTaskID = crOpportunityProductRow.TaskID; fsSODetRow.CostCodeID = crOpportunityProductRow.CostCodeID; fsSODetRow.CuryUnitCost = crOpportunityProductRow.CuryUnitCost; fsSODetRow.ManualCost = crOpportunityProductRow.POCreate; fsSODetRow.EnablePO = crOpportunityProductRow.POCreate; fsSODetRow.POVendorID = crOpportunityProductRow.VendorID; fsSODetRow.POVendorLocationID = fsxCROpportunityProductsRow.VendorLocationID; fsSODetRow.TaxCategoryID = crOpportunityProductRow.TaxCategoryID; fsSODetRow.DiscPct = crOpportunityProductRow.DiscPct; fsSODetRow.CuryDiscAmt = crOpportunityProductRow.CuryDiscAmt; fsSODetRow.CuryBillableExtPrice = crOpportunityProductRow.CuryExtPrice; soDetCache.Current = soDetCache.Update(fsSODetRow); }
public DocLineExt(PXResult <FSSODet, FSServiceOrder, FSSrvOrdType, FSSODetSplit, INItemPlan> soDetLine) { this.docLine = (IDocLine)(FSSODet)soDetLine; this.fsPostDoc = null; this.fsServiceOrder = (FSServiceOrder)soDetLine; this.fsSrvOrdType = (FSSrvOrdType)soDetLine; this.fsAppointment = null; this.fsPostInfo = null; this.fsSODet = (FSSODet)soDetLine; this.fsSODetSplit = (FSSODetSplit)soDetLine; this.inItemPlan = (INItemPlan)soDetLine; }
public DocLineExt(PXResult <FSAppointmentInventoryItem, FSAppointment, FSServiceOrder, FSSrvOrdType, FSPostDoc, FSPostInfo, INItemPlan> appointmentDetLine) { this.docLine = (IDocLine)(FSAppointmentInventoryItem)appointmentDetLine; this.fsPostDoc = (FSPostDoc)appointmentDetLine; this.fsServiceOrder = (FSServiceOrder)appointmentDetLine; this.fsSrvOrdType = (FSSrvOrdType)appointmentDetLine; this.fsAppointment = (FSAppointment)appointmentDetLine; this.fsPostInfo = (FSPostInfo)appointmentDetLine; this.fsSODet = null; this.fsSODetSplit = null; this.inItemPlan = (INItemPlan)appointmentDetLine; }
public DocLineExt(PXResult <FSAppointmentDet, FSAppointment, FSServiceOrder, FSSrvOrdType, FSPostDoc, FSPostInfo, PMTask> appointmentDetLine) { this.docLine = (IDocLine)(FSAppointmentDet)appointmentDetLine; this.fsPostDoc = (FSPostDoc)appointmentDetLine; this.fsServiceOrder = (FSServiceOrder)appointmentDetLine; this.fsSrvOrdType = (FSSrvOrdType)appointmentDetLine; this.fsAppointment = (FSAppointment)appointmentDetLine; this.fsPostInfo = (FSPostInfo)appointmentDetLine; this.fsSODet = null; this.fsSODetSplit = null; this.inItemPlan = null; this.pmTask = (PMTask)appointmentDetLine; }
public ContractInvoiceLine(PXResult <FSSODet, FSServiceOrder> row) : this((IDocLine)(FSSODet)row) { FSSODet fsSODetRow = (FSSODet)row; FSServiceOrder fsServiceOrderRow = (FSServiceOrder)row; SOID = fsSODetRow.SOID; SODetID = fsSODetRow.SODetID; BillingRule = fsSODetRow.BillingRule; ContractRelated = fsSODetRow.ContractRelated; Qty = fsSODetRow.ContractRelated == true ? fsSODetRow.EstimatedQty : fsSODetRow.BillableQty; OverageItemPrice = fsSODetRow.CuryExtraUsageUnitPrice; SalesPersonID = fsServiceOrderRow.SalesPersonID; Commissionable = fsServiceOrderRow.Commissionable; }
public ContractInvoiceLine(PXResult <FSAppointmentDet, FSSODet, FSAppointment> row) : this((IDocLine)(FSAppointmentDet)row) { FSAppointmentDet fsAppointmentDetRow = (FSAppointmentDet)row; FSAppointment fsAppointmentRow = (FSAppointment)row; FSSODet fsSODetRow = (FSSODet)row; AppointmentID = fsAppointmentDetRow.AppointmentID; AppDetID = fsAppointmentDetRow.AppDetID; BillingRule = fsSODetRow.BillingRule; ContractRelated = fsAppointmentDetRow.ContractRelated; Qty = fsAppointmentDetRow.ContractRelated == true ? fsAppointmentDetRow.Qty : fsAppointmentDetRow.BillableQty; OverageItemPrice = fsAppointmentDetRow.OverageItemPrice; SalesPersonID = fsAppointmentRow.SalesPersonID; Commissionable = fsAppointmentRow.Commissionable; }
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); } }
protected int?CalculateEstimatedDuration(FSSODet fsSODetRow, decimal?qty) { decimal estimatedDuration = 0m; if (fsSODetRow == null) { return((int?)estimatedDuration); } if (fsSODetRow.EstimatedQty != null && fsSODetRow.EstimatedDuration != null) { estimatedDuration = decimal.Divide((decimal)fsSODetRow.EstimatedDuration * (decimal)qty, (decimal)fsSODetRow.EstimatedQty); } return((int?)estimatedDuration); }
public virtual string GetPOFixDemandSorter(POFixedDemand line, GetPOFixDemandSorterDelegate del) { if (line.PlanType == INPlanConstants.PlanF6) { FSSODet row = PXSelectJoin <FSSODet, InnerJoin <FSSODetSplit, On <FSSODet.lineNbr, Equal <FSSODetSplit.lineNbr>, And <FSSODet.srvOrdType, Equal <FSSODetSplit.srvOrdType>, And <FSSODet.refNbr, Equal <FSSODetSplit.refNbr> > > > >, Where <FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> > > > .Select(Base, line.PlanID); return(row == null ? String.Empty : string.Format("{0}.{1}.{2:D7}", row.SrvOrdType, row.RefNbr, row.SortOrder.GetValueOrDefault())); } else { return(del(line)); } }
/// <summary> /// Adds the line <c>fsSODetRow</c> to the List <c>FSPostingLineDetailsToPostInAR_AP</c> or <c>FSPostingLineDetailsToPostInSO</c> depending on <c>addToArApList</c> and <c>addToSoList</c> flags. /// </summary> private void AddSOLineToList(PXGraph graph, FSSODet fsSODetRow, ServiceOrderInfo serviceOrderInfo, bool addToArApList, bool addToSoList) { PostingLine soLineRow = new PostingLine(); if (fsSODetRow != null) { int?itemID = fsSODetRow.InventoryID; soLineRow.TableSource = ID.TablePostSource.FSSO_DET; soLineRow.LineType = fsSODetRow.LineType; soLineRow.LineID = fsSODetRow.SODetID; soLineRow.BranchID = serviceOrderInfo.FSServiceOrderRow.BranchID; soLineRow.InventoryID = itemID; soLineRow.UOM = fsSODetRow.UOM; soLineRow.AcctID = this.GetAcct(graph, fsSODetRow, null, serviceOrderInfo.FSServiceOrderRow, serviceOrderInfo.FSSrvOrdTypeRow); soLineRow.SubID = fsSODetRow.SubID; soLineRow.SiteID = fsSODetRow.SiteID; soLineRow.LocationID = fsSODetRow.SiteLocationID; soLineRow.SubItemID = fsSODetRow.SubItemID; soLineRow.TranDesc = fsSODetRow.TranDesc; soLineRow.ProjectID = fsSODetRow.ProjectID; soLineRow.ProjectTaskID = fsSODetRow.ProjectTaskID; soLineRow.CuryUnitPrice = fsSODetRow.CuryUnitPrice; soLineRow.Qty = fsSODetRow.EstimatedQty; soLineRow.CuryTranAmt = fsSODetRow.CuryEstimatedTranAmt; soLineRow.PostID = fsSODetRow.PostID; soLineRow.IsBillable = fsSODetRow.IsBillable; } if (addToArApList) { this.FSPostingLineDetailsToPostInAR_AP.Add(soLineRow); } else if (addToSoList) { this.FSPostingLineDetailsToPostInSO.Add(soLineRow); } }
public virtual void InsertUpdateDeleteSODet(ServiceOrderEntry graphServiceOrder, PMTimeActivity pmTimeActivityRow, FSxPMTimeActivity fsxPMTimeActivityRow, PXDBOperation operation) { FSSODet fsSODetServiceRow; graphServiceOrder.ServiceOrderDetails.Current = graphServiceOrder.ServiceOrderDetails.Search <FSSODet.sourceNoteID>(pmTimeActivityRow.NoteID); if (graphServiceOrder.ServiceOrderDetails.Current != null) { if (operation == PXDBOperation.Delete || fsxPMTimeActivityRow.ServiceID == null) { graphServiceOrder.ServiceOrderDetails.Delete(graphServiceOrder.ServiceOrderDetails.Current); return; } } else { //This line does not require appointment if (fsxPMTimeActivityRow.ServiceID == null) { return; } //Insert a new SODet line fsSODetServiceRow = new FSSODet(); //Assign the PMTimeActivity reference to the new FSSODet line fsSODetServiceRow.SourceNoteID = pmTimeActivityRow.NoteID; graphServiceOrder.ServiceOrderDetails.Current = graphServiceOrder.ServiceOrderDetails.Insert(fsSODetServiceRow); } //Update the SODet line UpdateSODetServiceRow(graphServiceOrder, graphServiceOrder.ServiceOrderDetails.Current, pmTimeActivityRow, fsxPMTimeActivityRow); }
public virtual void UpdateSODetServiceRow(ServiceOrderEntry graphServiceOrder, FSSODet fsSODetRow, PMTimeActivity pmTimeActivity, FSxPMTimeActivity fsxPMTimeActivity) { //TODO AC-142850 SD-7788 //************************************************************** // Update all FSSODetService fields but key fields ************* //************************************************************** if (fsSODetRow.LineType != ID.LineType_ServiceTemplate.SERVICE) { graphServiceOrder.ServiceOrderDetails.SetValueExt <FSSODet.lineType>(fsSODetRow, ID.LineType_ServiceTemplate.SERVICE); } if (fsSODetRow.InventoryID != fsxPMTimeActivity.ServiceID) { graphServiceOrder.ServiceOrderDetails.SetValueExt <FSSODet.inventoryID>(fsSODetRow, fsxPMTimeActivity.ServiceID); } if (fsSODetRow.ProjectID != pmTimeActivity.ProjectID) { graphServiceOrder.ServiceOrderDetails.SetValueExt <FSSODet.projectID>(fsSODetRow, pmTimeActivity.ProjectID); } if (fsSODetRow.ProjectTaskID != pmTimeActivity.ProjectTaskID) { graphServiceOrder.ServiceOrderDetails.SetValueExt <FSSODet.projectTaskID>(fsSODetRow, pmTimeActivity.ProjectTaskID); } if (fsSODetRow.CostCodeID != pmTimeActivity.CostCodeID) { graphServiceOrder.ServiceOrderDetails.SetValueExt <FSSODet.costCodeID>(fsSODetRow, pmTimeActivity.CostCodeID); } graphServiceOrder.ServiceOrderDetails.Update(fsSODetRow); }
/// <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); } } }
public static void X_LineType_FieldUpdated <DAC>(PXCache cache, PXFieldUpdatedEventArgs e) where DAC : class, IBqlTable, IFSSODetBase, new() { if (e.Row == null) { return; } var row = (DAC)e.Row; Type dacType = typeof(DAC); FSSODet fsSODetRow = null; FSAppointmentDet fsAppointmentDetRow = null; if (dacType == typeof(FSAppointmentDet) || dacType == typeof(FSAppointmentDetService) || dacType == typeof(FSAppointmentDetPart) || dacType == typeof(FSAppointmentInventoryItem)) { fsAppointmentDetRow = (FSAppointmentDet)e.Row; } else { fsSODetRow = (FSSODet)e.Row; } if (IsInventoryLine(row.LineType) == false) { // Clear fields for non-inventory lines row.IsBillable = false; row.ManualPrice = false; row.InventoryID = null; row.SubItemID = null; row.BillingRule = ID.BillingRule.NONE; cache.SetDefaultExt <FSSODet.uOM>(e.Row); row.CuryUnitPrice = 0; row.SetDuration(FieldType.EstimatedField, 0, cache, false); row.SetQty(FieldType.EstimatedField, 0, cache, false); row.SiteID = null; row.SiteLocationID = null; row.ProjectTaskID = null; row.AcctID = null; row.SubID = null; if (fsAppointmentDetRow != null) { fsAppointmentDetRow.ActualDuration = 0; fsAppointmentDetRow.Qty = 0; } if (fsSODetRow != null) { fsSODetRow.EnablePO = false; fsSODetRow.POVendorID = null; fsSODetRow.POVendorLocationID = null; } return; } // Set default values for common fields of FSSODet and FSAppointmentDet cache.SetDefaultExt <FSSODet.isBillable>(e.Row); cache.SetDefaultExt <FSSODet.projectTaskID>(e.Row); // Set default values for specific fields of FSSODet if (fsSODetRow != null) { cache.SetDefaultExt <FSSODet.enablePO>(e.Row); } // Set default values for specific fields of FSAppointmentDet if (fsAppointmentDetRow != null) { } }
protected GetTaxRequest BuildGetTaxRequest(FSServiceOrder order) { if (order == null) { throw new PXArgumentException(ErrorMessages.ArgumentNullException); } BAccount cust = (BAccount)PXSelect <BAccount, Where <BAccount.bAccountID, Equal <Required <BAccount.bAccountID> > > > . Select(Base, order.BillCustomerID); Location loc = (Location)PXSelect <Location, Where <Location.bAccountID, Equal <Required <Location.bAccountID> >, And <Location.locationID, Equal <Required <Location.locationID> > > > > . Select(Base, order.BillCustomerID, order.BillLocationID); IAddressBase addressFrom = GetFromAddress(); IAddressBase addressTo = GetToAddress(order); if (addressFrom == null) { throw new PXException(PX.Objects.CR.Messages.FailedGetFromAddressSO); } if (addressTo == null) { throw new PXException(PX.Objects.CR.Messages.FailedGetToAddressSO); } GetTaxRequest request = new GetTaxRequest(); request.CompanyCode = CompanyCodeFromBranch(order.TaxZoneID, Base.Accessinfo.BranchID); request.CurrencyCode = order.CuryID; request.CustomerCode = cust.AcctCD; request.OriginAddress = AddressConverter.ConvertTaxAddress(addressFrom); request.DestinationAddress = AddressConverter.ConvertTaxAddress(addressTo); request.DocCode = $"CR.{order.SOID}"; request.DocDate = order.OrderDate.GetValueOrDefault(); int mult = 1; if (!string.IsNullOrEmpty(loc.CAvalaraCustomerUsageType)) { request.CustomerUsageType = loc.CAvalaraCustomerUsageType; } if (!string.IsNullOrEmpty(loc.CAvalaraExemptionNumber)) { request.ExemptionNo = loc.CAvalaraExemptionNumber; } request.DocType = TaxDocumentType.SalesOrder; PXSelectBase <FSSODet> select = new PXSelectJoin <FSSODet, LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <FSSODet.inventoryID> >, LeftJoin <Account, On <Account.accountID, Equal <InventoryItem.salesAcctID> > > >, Where <FSSODet.sOID, Equal <Current <FSServiceOrder.sOID> > >, OrderBy <Asc <FSSODet.lineNbr> > >(Base); foreach (PXResult <FSSODet, InventoryItem, Account> res in select.View.SelectMultiBound(new object[] { order })) { FSSODet tran = (FSSODet)res; InventoryItem item = (InventoryItem)res; Account salesAccount = (Account)res; var line = new TaxCartItem(); line.Index = tran.LineNbr ?? 0; line.Amount = mult * tran.CuryBillableTranAmt.GetValueOrDefault(); line.Description = tran.TranDesc; line.DestinationAddress = request.DestinationAddress; line.OriginAddress = request.OriginAddress; line.ItemCode = item.InventoryCD; line.Quantity = Math.Abs(tran.BillableQty.GetValueOrDefault()); line.Discounted = request.Discount > 0; line.RevAcct = salesAccount.AccountCD; line.TaxCode = tran.TaxCategoryID; request.CartItems.Add(line); } return(request); }
protected virtual void _(Events.RowPersisted <INItemPlan> e) { if (e.Row == null) { return; } if (e.TranStatus == PXTranStatus.Open) { INItemPlan inItemPlanRow = (INItemPlan)e.Row; if (e.Operation == PXDBOperation.Update) { if (inItemPlanRow.SupplyPlanID != null && inItemPlanRow.PlanType == INPlanConstants.PlanF6) { FSSODet fsSODetRow = FSSODetFixedDemand.Select(inItemPlanRow.PlanID); if (fsSODetRow != null) { POLine poLineRow = Base.Transactions.Select().Where(x => ((POLine)x).PlanID == inItemPlanRow.SupplyPlanID).First(); fsSODetRow.POType = Base.Document.Current.OrderType; fsSODetRow.PONbr = Base.Document.Current.OrderNbr; fsSODetRow.POLineNbr = poLineRow.LineNbr; fsSODetRow.POStatus = Base.Document.Current.Status; FSSODetFixedDemand.Update(fsSODetRow); FSSODetFixedDemand.Cache.Persist(PXDBOperation.Update); FSSODetSplit fsSODetSplitRow = FSSODetSplitFixedDemand.Select(inItemPlanRow.PlanID); if (fsSODetSplitRow != null) { fsSODetSplitRow.POType = Base.Document.Current.OrderType; fsSODetSplitRow.PONbr = Base.Document.Current.OrderNbr; fsSODetSplitRow.POLineNbr = poLineRow.LineNbr; FSSODetSplitFixedDemand.Update(fsSODetSplitRow); FSSODetSplitFixedDemand.Cache.Persist(PXDBOperation.Update); } } } } else if (e.Operation == PXDBOperation.Delete && (inItemPlanRow.PlanType == INPlanConstants.PlanF7 || inItemPlanRow.PlanType == INPlanConstants.PlanF8) ) { inItemPlanRow = PXSelect <INItemPlan, Where <INItemPlan.supplyPlanID, Equal <Required <INItemPlan.supplyPlanID> > > > .Select(Base, inItemPlanRow.PlanID); if (inItemPlanRow != null && inItemPlanRow.SupplyPlanID != null) { FSSODet fsSODetRow = FSSODetFixedDemand.Select(inItemPlanRow.PlanID); if (fsSODetRow != null) { fsSODetRow.POType = null; fsSODetRow.PONbr = null; fsSODetRow.POLineNbr = null; fsSODetRow.POStatus = null; FSSODetFixedDemand.Update(fsSODetRow); FSSODetFixedDemand.Cache.Persist(PXDBOperation.Update); inItemPlanRow.SupplyPlanID = null; Base.Caches[typeof(INItemPlan)].Update(inItemPlanRow); Base.Caches[typeof(INItemPlan)].Persist(PXDBOperation.Update); FSSODetSplit fsSODetSplitRow = FSSODetSplitFixedDemand.Select(inItemPlanRow.PlanID); if (fsSODetSplitRow != null) { fsSODetSplitRow.POType = null; fsSODetSplitRow.PONbr = null; fsSODetSplitRow.POLineNbr = null; FSSODetSplitFixedDemand.Update(fsSODetSplitRow); FSSODetSplitFixedDemand.Cache.Persist(PXDBOperation.Update); } } } } } }
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); } } }
private static void X_RowSelected <DAC>( PXCache cache, object eRow, EventType eventType, FSServiceOrder fsServiceOrderRow, FSSrvOrdType fsSrvOrdTypeRow, bool disableSODetReferenceFields, bool docAllowsActualFieldEdition) where DAC : class, IBqlTable, IFSSODetBase, new() { if (eRow == null) { return; } var row = (DAC)eRow; Type dacType = typeof(DAC); FSSODet fsSODetRow = null; bool calledFromSO = false; bool calledFromAPP = false; FSAppointmentDet fsAppointmentDetRow = null; FSAppointmentDetPart fsAppointmentDetPart = null; if (dacType == typeof(FSAppointmentDet) || dacType == typeof(FSAppointmentDetService) || dacType == typeof(FSAppointmentDetPart) || dacType == typeof(FSAppointmentInventoryItem)) { fsAppointmentDetRow = (FSAppointmentDet)eRow; if (dacType == typeof(FSAppointmentDetPart)) { fsAppointmentDetPart = (FSAppointmentDetPart)eRow; } calledFromAPP = true; } else { fsSODetRow = (FSSODet)eRow; calledFromSO = true; } bool isEnabled; PXPersistingCheck persistingCheck; bool isInventoryLine = IsInventoryLine(row.LineType); bool isStockItem; if (isInventoryLine == false) { isStockItem = false; } else { if (row.LineType != ID.LineType_All.SERVICE && row.LineType != ID.LineType_All.NONSTOCKITEM) { isStockItem = true; } else { isStockItem = false; } } // Enable/Disable SODetID SetEnabledAndPersistingCheck <FSSODet.sODetID>(cache, eRow, eventType, isEnabled: !disableSODetReferenceFields, persistingCheck: null); // Enable/Disable LineType SetEnabledAndPersistingCheck <FSSODet.lineType>(cache, eRow, eventType, isEnabled: !disableSODetReferenceFields, persistingCheck: null); // Set InventoryID properties (SetEnabled and SetPersistingCheck) isEnabled = true; persistingCheck = PXPersistingCheck.NullOrBlank; if (isInventoryLine == false) { isEnabled = false; persistingCheck = PXPersistingCheck.Nothing; } else if (row.IsPrepaid == true || disableSODetReferenceFields == true || (calledFromSO == true && fsServiceOrderRow.AllowInvoice == true)) { isEnabled = false; } SetEnabledAndPersistingCheck <FSSODet.inventoryID>(cache, eRow, eventType, isEnabled, persistingCheck); if (PXAccess.FeatureInstalled <FeaturesSet.subItem>()) { // Set SubItemID properties BASED ON InventoryID and LineType SetEnabledAndPersistingCheck <FSSODet.subItemID>(cache, eRow, eventType, isEnabled: isEnabled && isStockItem, persistingCheck: isStockItem == true ? persistingCheck : PXPersistingCheck.Nothing); } // Set UOM properties SAME AS InventoryID SetEnabledAndPersistingCheck <FSSODet.uOM>(cache, eRow, eventType, isEnabled, persistingCheck); // Enable/Disable billingRule isEnabled = false; if ((row.LineType == ID.LineType_All.SERVICE || row.LineType == ID.LineType_All.NONSTOCKITEM) && row.IsPrepaid == false && (fsSODetRow == null || fsSODetRow.Mem_LastReferencedBy == null) && (calledFromAPP == true || (calledFromSO == true && fsServiceOrderRow?.AllowInvoice == false))) { isEnabled = true; } SetEnabledAndPersistingCheck <FSSODet.billingRule>(cache, eRow, eventType, isEnabled, persistingCheck: null); // Enable/Disable ManualPrice isEnabled = true; if (row.IsPrepaid == true || isInventoryLine == false || row.InventoryID == null || (calledFromSO && fsServiceOrderRow?.AllowInvoice == true)) { isEnabled = false; } SetEnabledAndPersistingCheck <FSSODet.manualPrice>(cache, eRow, eventType, isEnabled, persistingCheck: null); // Enable/Disable IsBillable Same as ManualPrice SetEnabledAndPersistingCheck <FSSODet.isBillable>(cache, eRow, eventType, isEnabled, persistingCheck: null); // Enable/Disable CuryUnitPrice isEnabled = false; if (row.BillingRule != ID.BillingRule.NONE && row.IsPrepaid == false && row.InventoryID != null && (calledFromAPP == true || (calledFromSO == true && fsServiceOrderRow?.AllowInvoice == false))) { isEnabled = true; } SetEnabledAndPersistingCheck <FSSODet.curyUnitPrice>(cache, eRow, eventType, isEnabled, persistingCheck: null); // Enable/Disable EstimatedDuration and ActualDuration isEnabled = false; if (row.LineType == ID.LineType_All.SERVICE && row.InventoryID != null && (calledFromAPP == true || (calledFromSO == true && fsServiceOrderRow?.AllowInvoice == false))) { isEnabled = true; } SetEnabledAndPersistingCheck <FSSODet.estimatedDuration>(cache, eRow, eventType, isEnabled, persistingCheck: null); if (fsAppointmentDetRow != null) { //Enable when there is only 1 or 0 staff related to the service bool enableByStaffRelated = fsAppointmentDetRow.StaffRelatedCount < 2; SetEnabledAndPersistingCheck <FSAppointmentDet.actualDuration>(cache, eRow, eventType, isEnabled: isEnabled && docAllowsActualFieldEdition && enableByStaffRelated, persistingCheck: null); } // Enable/Disable EstimatedQty and ActualQty isEnabled = false; if (isInventoryLine == true && row.BillingRule != ID.BillingRule.TIME && row.IsPrepaid == false && row.InventoryID != null && (fsAppointmentDetPart == null || (string.IsNullOrEmpty(fsAppointmentDetPart.LotSerialNbr) == true || (string.IsNullOrEmpty(fsAppointmentDetPart.LotSerialNbr) == false && fsAppointmentDetPart.LotSerTrack != INLotSerTrack.SerialNumbered))) && (calledFromAPP == true || (calledFromSO == true && fsServiceOrderRow?.AllowInvoice == false))) { isEnabled = true; } SetEnabledAndPersistingCheck <FSSODet.estimatedQty>(cache, eRow, eventType, isEnabled, persistingCheck: null); if (fsAppointmentDetRow != null) { SetEnabledAndPersistingCheck <FSAppointmentDet.qty>(cache, eRow, eventType, isEnabled: isEnabled && docAllowsActualFieldEdition, persistingCheck: null); } // Set SiteID properties (SetEnabled and SetPersistingCheck) isEnabled = false; persistingCheck = PXPersistingCheck.Nothing; if (isInventoryLine == true && row.InventoryID != null) { if (row.IsPrepaid == false) { if (fsAppointmentDetPart != null) { isEnabled = fsAppointmentDetPart.SODetID == null; } else { isEnabled = true; } } persistingCheck = PXPersistingCheck.NullOrBlank; } SetEnabledAndPersistingCheck <FSSODet.siteID>(cache, eRow, eventType, isEnabled, persistingCheck); // Set SiteLocationID properties SAME AS SiteID SetEnabledAndPersistingCheck <FSSODet.siteLocationID>(cache, eRow, eventType, isEnabled, persistingCheck); // Set ProjectID properties (SetEnabled and SetPersistingCheck) isEnabled = false; persistingCheck = PXPersistingCheck.Nothing; if (isInventoryLine == true && row.InventoryID != null) { isEnabled = true; persistingCheck = PXPersistingCheck.NullOrBlank; } SetEnabledAndPersistingCheck <FSSODet.projectID>(cache, eRow, eventType, isEnabled, persistingCheck); // Set ProjectTaskID properties (SetEnabled and SetPersistingCheck) isEnabled = true; persistingCheck = PXPersistingCheck.Nothing; if (isInventoryLine == false || row.InventoryID == null) { isEnabled = false; } else if (ProjectDefaultAttribute.IsProject(cache.Graph, row.ProjectID) == true) { persistingCheck = PXPersistingCheck.NullOrBlank; } SetEnabledAndPersistingCheck <FSSODet.projectTaskID>(cache, eRow, eventType, isEnabled, persistingCheck); // Set CostCodeID properties (SetEnabled and SetPersistingCheck) isEnabled = true; persistingCheck = PXPersistingCheck.Nothing; if (isInventoryLine == false || row.InventoryID == null) { isEnabled = false; } else if (ProjectDefaultAttribute.IsProject(cache.Graph, row.ProjectID) == true) { persistingCheck = PXPersistingCheck.NullOrBlank; } SetEnabledAndPersistingCheck <FSSODet.costCodeID>(cache, eRow, eventType, isEnabled, persistingCheck); // Set AcctID properties (SetEnabled and SetPersistingCheck) isEnabled = false; persistingCheck = PXPersistingCheck.Nothing; if (isInventoryLine == true && row.InventoryID != null && fsServiceOrderRow?.Quote == false && fsSrvOrdTypeRow?.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT) { isEnabled = true; persistingCheck = PXPersistingCheck.NullOrBlank; } SetEnabledAndPersistingCheck <FSSODet.acctID>(cache, eRow, eventType, isEnabled, persistingCheck); // Set SubID properties SAME AS AcctID SetEnabledAndPersistingCheck <FSSODet.subID>(cache, eRow, eventType, isEnabled, persistingCheck); // Set PickupDeliveryServiceID properties (SetEnabled and SetPersistingCheck) if (fsAppointmentDetRow != null && dacType == typeof(FSAppointmentInventoryItem)) { isEnabled = false; persistingCheck = PXPersistingCheck.Nothing; if (row.LineType == ID.LineType_All.PICKUP_DELIVERY) { isEnabled = true; persistingCheck = PXPersistingCheck.NullOrBlank; } SetEnabledAndPersistingCheck <FSAppointmentInventoryItem.pickupDeliveryServiceID>(cache, eRow, eventType, isEnabled, persistingCheck); } // Set IsBillable properties (SetEnabled and SetPersistingCheck) isEnabled = true; if (row.ContractRelated == true || row.IsPrepaid == true) { isEnabled = false; } SetEnabledAndPersistingCheck <FSSODet.isBillable>(cache, eRow, eventType, isEnabled, persistingCheck: null); // Set TranDesc properties (SetEnabled and SetPersistingCheck) isEnabled = true; persistingCheck = PXPersistingCheck.Nothing; if (isInventoryLine == false) { persistingCheck = PXPersistingCheck.NullOrBlank; } SetEnabledAndPersistingCheck <FSSODet.tranDesc>(cache, eRow, eventType, isEnabled, persistingCheck); isEnabled = false; persistingCheck = PXPersistingCheck.Nothing; if (fsSODetRow != null && fsSODetRow.EnablePO == true) { persistingCheck = PXPersistingCheck.NullOrBlank; isEnabled = true; } SetEnabledAndPersistingCheck <FSSODet.curyUnitCost>(cache, eRow, eventType, isEnabled, persistingCheck); SharedFunctions.UpdateEquipmentAction(cache, eRow); // Additional Enable/Disable for Equipment fields if ((calledFromSO == true && fsServiceOrderRow?.AllowInvoice == true)) { isEnabled = false; SetEnabledAndPersistingCheck <FSSODet.SMequipmentID>(cache, eRow, eventType, isEnabled, persistingCheck: null); } }
public override List <DocLineExt> GetInvoiceLines(Guid currentProcessID, int billingCycleID, string groupKey, bool getOnlyTotal, out decimal?invoiceTotal, string postTo) { PXGraph tempGraph = new PXGraph(); if (getOnlyTotal == true) { /* Always keep both BQLs with the same Joins and Where conditions */ FSSODet fsSODetRow = PXSelectJoinGroupBy <FSSODet, InnerJoin <FSServiceOrder, On <FSServiceOrder.srvOrdType, Equal <FSSODet.srvOrdType>, And <FSServiceOrder.refNbr, Equal <FSSODet.refNbr> > >, InnerJoin <FSSrvOrdType, On <FSSrvOrdType.srvOrdType, Equal <FSServiceOrder.srvOrdType> >, InnerJoin <FSPostDoc, On < FSPostDoc.sOID, Equal <FSSODet.sOID>, And <FSPostDoc.entityType, Equal <ListField_PostDoc_EntityType.Service_Order> > >, LeftJoin <FSPostInfo, On < FSPostInfo.postID, Equal <FSSODet.postID> > > > > >, Where < FSPostDoc.processID, Equal <Required <FSPostDoc.processID> >, And <FSPostDoc.billingCycleID, Equal <Required <FSPostDoc.billingCycleID> >, And <FSPostDoc.groupKey, Equal <Required <FSPostDoc.groupKey> >, And <FSSODet.lineType, NotEqual <FSLineType.Comment>, And <FSSODet.lineType, NotEqual <FSLineType.Instruction>, And <FSSODet.status, NotEqual <FSSODet.status.Canceled>, And <FSSODet.isPrepaid, Equal <False>, And <FSSODet.isBillable, Equal <True>, And < Where2 < Where < FSSODet.postID, IsNull>, Or < Where < FSPostInfo.aRPosted, Equal <False>, And <FSPostInfo.aPPosted, Equal <False>, And <FSPostInfo.sOPosted, Equal <False>, And <FSPostInfo.sOInvPosted, Equal <False>, And < Where2 < Where < Required <FSPostBatch.postTo>, NotEqual <FSPostBatch.postTo.SO> >, Or < Where < Required <FSPostBatch.postTo>, Equal <FSPostBatch.postTo.SO>, And <FSPostInfo.iNPosted, Equal <False> > > > > > > > > > > > > > > > > > > > >, Aggregate < Sum <FSSODet.curyBillableTranAmt> > > .Select(tempGraph, currentProcessID, billingCycleID, groupKey, postTo, postTo); invoiceTotal = fsSODetRow.CuryBillableTranAmt; return(null); } else { invoiceTotal = null; /* Always keep both BQLs with the same Joins and Where conditions */ var resultSet = PXSelectJoin <FSSODet, InnerJoin <FSServiceOrder, On <FSServiceOrder.srvOrdType, Equal <FSSODet.srvOrdType>, And <FSServiceOrder.refNbr, Equal <FSSODet.refNbr> > >, InnerJoin <FSSrvOrdType, On <FSSrvOrdType.srvOrdType, Equal <FSServiceOrder.srvOrdType> >, InnerJoin <FSPostDoc, On < FSPostDoc.sOID, Equal <FSSODet.sOID>, And <FSPostDoc.entityType, Equal <ListField_PostDoc_EntityType.Service_Order> > >, LeftJoin <FSPostInfo, On < FSPostInfo.postID, Equal <FSSODet.postID> >, LeftJoin <FSSODetSplit, On <FSSODetSplit.srvOrdType, Equal <FSSODet.srvOrdType>, And <FSSODetSplit.refNbr, Equal <FSSODet.refNbr>, And <FSSODetSplit.lineNbr, Equal <FSSODet.lineNbr>, And <FSSODetSplit.completed, Equal <False> > > > >, LeftJoin <INItemPlan, On <INItemPlan.planID, Equal <FSSODetSplit.planID> >, LeftJoin <PMTask, On <PMTask.taskID, Equal <FSSODet.projectTaskID> > > > > > > > >, Where < FSPostDoc.processID, Equal <Required <FSPostDoc.processID> >, And <FSPostDoc.billingCycleID, Equal <Required <FSPostDoc.billingCycleID> >, And <FSPostDoc.groupKey, Equal <Required <FSPostDoc.groupKey> >, And <FSSODet.lineType, NotEqual <FSLineType.Comment>, And <FSSODet.lineType, NotEqual <FSLineType.Instruction>, And <FSSODet.status, NotEqual <FSSODet.status.Canceled>, And <FSSODet.isPrepaid, Equal <False>, And < Where2 < Where < FSSODet.postID, IsNull>, Or < Where < FSPostInfo.aRPosted, Equal <False>, And <FSPostInfo.aPPosted, Equal <False>, And <FSPostInfo.sOPosted, Equal <False>, And <FSPostInfo.sOInvPosted, Equal <False>, And < Where2 < Where < Required <FSPostBatch.postTo>, NotEqual <FSPostBatch.postTo.SO> >, Or < Where < Required <FSPostBatch.postTo>, Equal <FSPostBatch.postTo.SO>, And <FSPostInfo.iNPosted, Equal <False> > > > > > > > > > > > > > > > > > > >, OrderBy < Asc <FSServiceOrder.orderDate, Asc <FSSODet.sOID, Asc <FSSODet.sODetID> > > > > .Select(tempGraph, currentProcessID, billingCycleID, groupKey, postTo, postTo); var docLines = new List <DocLineExt>(); foreach (PXResult <FSSODet, FSServiceOrder, FSSrvOrdType, FSPostDoc, FSPostInfo, FSSODetSplit, INItemPlan, PMTask> row in resultSet) { docLines.Add(new DocLineExt(row)); } return(docLines); } }
public virtual void CloneParts(AppointmentEntry gOriginalAppt, AppointmentEntry gNewAppt, FSAppointment newAppointmentRow, FSAppointmentDet sourceRow) { if (sourceRow == null || sourceRow.Status == ID.Status_AppointmentDet.CANCELED) { return; } FSSODet fsSODetRow = ServiceOrderCore.GetSODetFromAppointmentDet(gOriginalAppt, sourceRow); if (fsSODetRow == null) { return; } if (ReadingGraph == null) { ReadingGraph = new PXGraph(); } FSAppointmentDet takenQtyByAppointments = PXSelectJoinGroupBy <FSAppointmentDet, InnerJoin <FSAppointment, On < FSAppointment.srvOrdType, Equal <FSAppointmentDet.srvOrdType>, And <FSAppointment.refNbr, Equal <FSAppointmentDet.refNbr> > > >, Where < FSAppointmentDet.sODetID, Equal <Required <FSAppointmentDet.sODetID> >, And <FSAppointment.status, NotEqual <FSAppointment.status.Canceled>, And <FSAppointmentDet.isCanceledNotPerformed, NotEqual <True> > > >, Aggregate < GroupBy <FSAppointmentDet.sODetID, Sum <FSAppointmentDet.billableQty> > > > .Select(ReadingGraph, sourceRow.SODetID); decimal?openQty = fsSODetRow.BillableQty - (takenQtyByAppointments?.BillableQty ?? 0m); decimal?qtyFromBal = openQty >= sourceRow.BillableQty ? sourceRow.BillableQty : openQty > 0m ? openQty : 0m; decimal? missingQty = sourceRow.BillableQty - qtyFromBal; FSAppointmentDet noteLine = null; // Creates a copy to not edit the original row. FSAppointmentDet sourceRowCopy = PXCache <FSAppointmentDet> .CreateCopy(sourceRow); ClearSourceLineBeforeCopy(sourceRowCopy); if (qtyFromBal > 0) { sourceRowCopy.EstimatedQty = qtyFromBal; sourceRowCopy.BillableQty = qtyFromBal; FSAppointmentDet newRow = new FSAppointmentDet(); newRow = AppointmentEntry.InsertDetailLine <FSAppointmentDet, FSAppointmentDet>( gNewAppt.AppointmentDetails.Cache, newRow, gOriginalAppt.AppointmentDetails.Cache, sourceRowCopy, null, sourceRowCopy.SODetID, copyTranDate: false, tranDate: sourceRowCopy.TranDate, SetValuesAfterAssigningSODetID: true, copyingFromQuote: false); noteLine = newRow; } if (missingQty > 0) { sourceRowCopy.EstimatedQty = missingQty; sourceRowCopy.BillableQty = missingQty; FSAppointmentDet newRow = new FSAppointmentDet(); newRow = AppointmentEntry.InsertDetailLine <FSAppointmentDet, FSAppointmentDet>( gNewAppt.AppointmentDetails.Cache, newRow, gOriginalAppt.AppointmentDetails.Cache, sourceRowCopy, null, null, copyTranDate: false, tranDate: sourceRowCopy.TranDate, SetValuesAfterAssigningSODetID: true, copyingFromQuote: false); if (noteLine == null) { noteLine = newRow; } } if (noteLine != null) { PXNoteAttribute.CopyNoteAndFiles(gOriginalAppt.AppointmentDetails.Cache, sourceRow, gNewAppt.AppointmentDetails.Cache, noteLine, copyNotes: true, copyFiles: false); } }