protected virtual void _(Events.RowPersisted <APInvoice> e) { if (e.Row == null || SharedFunctions.isFSSetupSet(Base) == false) { return; } APInvoice apInvoiceRow = (APInvoice)e.Row; if (e.Operation == PXDBOperation.Delete && e.TranStatus == PXTranStatus.Open) { InvoicingFunctions.CleanPostingInfoLinkedToDoc(apInvoiceRow); } }
protected virtual void ARInvoice_RowPersisted(PXCache cache, PXRowPersistedEventArgs e) { if (e.Row == null || SharedFunctions.isFSSetupSet(Base) == false) { return; } ARInvoice arInvoiceRow = (ARInvoice)e.Row; if (e.Operation == PXDBOperation.Delete && e.TranStatus == PXTranStatus.Open) { InvoicingFunctions.CleanPostingInfoLinkedToDoc(arInvoiceRow); InvoicingFunctions.CleanContractPostingInfoLinkedToDoc(arInvoiceRow); } }
protected virtual void _(Events.RowPersisted <SOInvoice> e) { if (e.Row == null) { return; } SOInvoice soInvoiceRow = (SOInvoice)e.Row; if (e.TranStatus == PXTranStatus.Open) { if (e.Operation == PXDBOperation.Delete) { InvoicingFunctions.CleanPostingInfoLinkedToDoc(soInvoiceRow); } } }
public virtual void CreateInvoice(PXGraph graphProcess, List <DocLineExt> docLines, List <DocLineExt> docLinesGrouped, short invtMult, DateTime?invoiceDate, string invoiceFinPeriodID, OnDocumentHeaderInsertedDelegate onDocumentHeaderInserted, OnTransactionInsertedDelegate onTransactionInserted, PXQuickProcess.ActionFlow quickProcessFlow) { if (docLinesGrouped.Count == 0) { return; } bool?initialHold = false; FSServiceOrder fsServiceOrderRow = docLinesGrouped[0].fsServiceOrder; FSSrvOrdType fsSrvOrdTypeRow = docLinesGrouped[0].fsSrvOrdType; FSPostDoc fsPostDocRow = docLinesGrouped[0].fsPostDoc; FSAppointment fsAppointmentRow = docLinesGrouped[0].fsAppointment; Vendor vendorRow = SharedFunctions.GetVendorRow(graphProcess, fsServiceOrderRow.BillCustomerID); if (vendorRow == null) { throw new PXException(TX.Error.AP_POSTING_VENDOR_NOT_FOUND); } Base.FieldDefaulting.AddHandler <APInvoice.branchID>((sender, e) => { e.NewValue = fsServiceOrderRow.BranchID; e.Cancel = true; }); APInvoice apInvoiceRow = new APInvoice(); if (invtMult >= 0) { apInvoiceRow.DocType = APDocType.DebitAdj; AutoNumberHelper.CheckAutoNumbering(Base, Base.APSetup.SelectSingle().DebitAdjNumberingID); } else { apInvoiceRow.DocType = APDocType.Invoice; AutoNumberHelper.CheckAutoNumbering(Base, Base.APSetup.SelectSingle().InvoiceNumberingID); } apInvoiceRow.DocDate = invoiceDate; apInvoiceRow.FinPeriodID = invoiceFinPeriodID; apInvoiceRow = PXCache <APInvoice> .CreateCopy(Base.Document.Insert(apInvoiceRow)); initialHold = apInvoiceRow.Hold; apInvoiceRow.NoteID = null; PXNoteAttribute.GetNoteIDNow(Base.Document.Cache, apInvoiceRow); apInvoiceRow.VendorID = fsServiceOrderRow.BillCustomerID; apInvoiceRow.VendorLocationID = fsServiceOrderRow.BillLocationID; apInvoiceRow.CuryID = fsServiceOrderRow.CuryID; apInvoiceRow.TaxZoneID = fsAppointmentRow != null ? fsAppointmentRow.TaxZoneID : fsServiceOrderRow.TaxZoneID; apInvoiceRow.TaxCalcMode = fsAppointmentRow != null ? fsAppointmentRow.TaxCalcMode : fsServiceOrderRow.TaxCalcMode; apInvoiceRow.SuppliedByVendorLocationID = fsServiceOrderRow.BillLocationID; string termsID = InvoicingFunctions.GetTermsIDFromCustomerOrVendor(graphProcess, null, fsServiceOrderRow.BillCustomerID); if (termsID == null) { termsID = fsSrvOrdTypeRow.DfltTermIDAP; } apInvoiceRow.FinPeriodID = invoiceFinPeriodID; apInvoiceRow.TermsID = termsID; apInvoiceRow.DocDesc = fsServiceOrderRow.DocDesc; apInvoiceRow.Hold = true; apInvoiceRow = Base.Document.Update(apInvoiceRow); apInvoiceRow.TaxCalcMode = PX.Objects.TX.TaxCalculationMode.TaxSetting; apInvoiceRow = Base.Document.Update(apInvoiceRow); InvoicingFunctions.SetContactAndAddress(Base, fsServiceOrderRow); if (onDocumentHeaderInserted != null) { onDocumentHeaderInserted(Base, apInvoiceRow); } IDocLine docLine = null; APTran apTranRow = null; FSxAPTran fsxAPTranRow = null; PMTask pmTaskRow = null; foreach (DocLineExt docLineExt in docLinesGrouped) { docLine = docLineExt.docLine; fsPostDocRow = docLineExt.fsPostDoc; fsServiceOrderRow = docLineExt.fsServiceOrder; fsSrvOrdTypeRow = docLineExt.fsSrvOrdType; fsAppointmentRow = docLineExt.fsAppointment; apTranRow = new APTran(); apTranRow = Base.Transactions.Insert(apTranRow); Base.Transactions.Cache.SetValueExtIfDifferent <APTran.branchID>(apTranRow, docLine.BranchID); Base.Transactions.Cache.SetValueExtIfDifferent <APTran.inventoryID>(apTranRow, docLine.InventoryID); Base.Transactions.Cache.SetValueExtIfDifferent <APTran.uOM>(apTranRow, docLine.UOM); pmTaskRow = docLineExt.pmTask; if (pmTaskRow != null && pmTaskRow.Status == ProjectTaskStatus.Completed) { throw new PXException(TX.Error.POSTING_PMTASK_ALREADY_COMPLETED, fsServiceOrderRow.RefNbr, docLine.LineRef, pmTaskRow.TaskCD); } if (docLine.AcctID != null) { Base.Transactions.Cache.SetValueExtIfDifferent <APTran.accountID>(apTranRow, docLine.AcctID); } if (docLine.SubID != null) { try { Base.Transactions.Cache.SetValueExtIfDifferent <APTran.subID>(apTranRow, docLine.SubID); } catch (PXException) { apTranRow.SubID = null; } } else { InvoicingFunctions.SetCombinedSubID(graphProcess, Base.Transactions.Cache, null, apTranRow, null, fsSrvOrdTypeRow, apTranRow.BranchID, apTranRow.InventoryID, apInvoiceRow.VendorLocationID, fsServiceOrderRow.BranchLocationID, fsServiceOrderRow.SalesPersonID, docLine.IsService); } if (docLine.ProjectID != null && docLine.ProjectTaskID != null) { Base.Transactions.Cache.SetValueExtIfDifferent <APTran.taskID>(apTranRow, docLine.ProjectTaskID); } Base.Transactions.Cache.SetValueExtIfDifferent <APTran.qty>(apTranRow, docLine.GetQty(FieldType.BillableField)); Base.Transactions.Cache.SetValueExtIfDifferent <APTran.tranDesc>(apTranRow, docLine.TranDesc); apTranRow = Base.Transactions.Update(apTranRow); Base.Transactions.Cache.SetValueExtIfDifferent <APTran.curyUnitCost>(apTranRow, docLine.CuryUnitPrice * invtMult); if (docLine.ProjectID != null) { Base.Transactions.Cache.SetValueExtIfDifferent <APTran.projectID>(apTranRow, docLine.ProjectID); } Base.Transactions.Cache.SetValueExtIfDifferent <APTran.taxCategoryID>(apTranRow, docLine.TaxCategoryID); Base.Transactions.Cache.SetValueExtIfDifferent <APTran.costCodeID>(apTranRow, docLine.CostCodeID); if (docLine.IsBillable == false) { Base.Transactions.Cache.SetValueExtIfDifferent <APTran.manualDisc>(apTranRow, true); Base.Transactions.Cache.SetValueExtIfDifferent <APTran.curyDiscAmt>(apTranRow, docLine.GetQty(FieldType.BillableField) * docLine.CuryUnitPrice * invtMult); } else { Base.Transactions.Cache.SetValueExtIfDifferent <APTran.discPct>(apTranRow, docLine.DiscPct); } fsxAPTranRow = Base.Transactions.Cache.GetExtension <FSxAPTran>(apTranRow); fsxAPTranRow.Source = docLine.BillingBy; fsxAPTranRow.SOID = fsServiceOrderRow.SOID; fsxAPTranRow.ServiceOrderDate = fsServiceOrderRow.OrderDate; fsxAPTranRow.BillCustomerID = fsServiceOrderRow.CustomerID; fsxAPTranRow.CustomerLocationID = fsServiceOrderRow.LocationID; fsxAPTranRow.SODetID = docLine.PostSODetID; fsxAPTranRow.AppointmentID = docLine.PostAppointmentID; fsxAPTranRow.AppointmentDate = fsAppointmentRow?.ExecutionDate; fsxAPTranRow.AppDetID = docLine.PostAppDetID; if (docLine.BillingBy == ID.Billing_By.APPOINTMENT) { //// TODO AC-142850 ////fsxAPTranRow.AppointmentDate = new DateTime( //// fsAppointmentRow.ActualDateTimeBegin.Value.Year, //// fsAppointmentRow.ActualDateTimeBegin.Value.Month, //// fsAppointmentRow.ActualDateTimeBegin.Value.Day, //// 0, //// 0, //// 0); } fsxAPTranRow.Mem_PreviousPostID = docLine.PostID; fsxAPTranRow.Mem_TableSource = docLine.SourceTable; SharedFunctions.CopyNotesAndFiles(Base.Transactions.Cache, apTranRow, docLine, fsSrvOrdTypeRow); fsPostDocRow.DocLineRef = apTranRow = Base.Transactions.Update(apTranRow); if (onTransactionInserted != null) { onTransactionInserted(Base, apTranRow); } } apInvoiceRow = Base.Document.Update(apInvoiceRow); if (Base.APSetup.Current.RequireControlTotal == true) { Base.Document.Cache.SetValueExtIfDifferent <APInvoice.curyOrigDocAmt>(apInvoiceRow, apInvoiceRow.CuryDocBal); } if (initialHold != true) { Base.Document.Cache.SetValueExtIfDifferent <APInvoice.hold>(apInvoiceRow, false); } apInvoiceRow = Base.Document.Update(apInvoiceRow); }
public virtual void CreateInvoice(PXGraph graphProcess, List <DocLineExt> docLines, List <DocLineExt> docLinesGrouped, short invtMult, DateTime?invoiceDate, string invoiceFinPeriodID, OnDocumentHeaderInsertedDelegate onDocumentHeaderInserted, OnTransactionInsertedDelegate onTransactionInserted, PXQuickProcess.ActionFlow quickProcessFlow) { if (docLinesGrouped.Count == 0) { return; } bool?initialHold = false; FSServiceOrder fsServiceOrderRow = docLines[0].fsServiceOrder; FSSrvOrdType fsSrvOrdTypeRow = docLines[0].fsSrvOrdType; FSPostDoc fsPostDocRow = docLines[0].fsPostDoc; FSAppointment fsAppointmentRow = docLines[0].fsAppointment; Base.FieldDefaulting.AddHandler <ARInvoice.branchID>((sender, e) => { e.NewValue = fsServiceOrderRow.BranchID; e.Cancel = true; }); ARInvoice arInvoiceRow = new ARInvoice(); if (invtMult >= 0) { arInvoiceRow.DocType = ARInvoiceType.Invoice; AutoNumberHelper.CheckAutoNumbering(Base, Base.ARSetup.SelectSingle().InvoiceNumberingID); } else { arInvoiceRow.DocType = ARInvoiceType.CreditMemo; AutoNumberHelper.CheckAutoNumbering(Base, Base.ARSetup.SelectSingle().CreditAdjNumberingID); } arInvoiceRow.DocDate = invoiceDate; arInvoiceRow.FinPeriodID = invoiceFinPeriodID; arInvoiceRow.InvoiceNbr = fsServiceOrderRow.CustPORefNbr; arInvoiceRow = Base.Document.Insert(arInvoiceRow); initialHold = arInvoiceRow.Hold; arInvoiceRow.NoteID = null; PXNoteAttribute.GetNoteIDNow(Base.Document.Cache, arInvoiceRow); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.hold>(arInvoiceRow, true); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.customerID>(arInvoiceRow, fsServiceOrderRow.BillCustomerID); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.customerLocationID>(arInvoiceRow, fsServiceOrderRow.BillLocationID); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.curyID>(arInvoiceRow, fsServiceOrderRow.CuryID); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.taxZoneID>(arInvoiceRow, fsAppointmentRow != null ? fsAppointmentRow.TaxZoneID : fsServiceOrderRow.TaxZoneID); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.taxCalcMode>(arInvoiceRow, fsAppointmentRow != null ? fsAppointmentRow.TaxCalcMode : fsServiceOrderRow.TaxCalcMode); string termsID = InvoicingFunctions.GetTermsIDFromCustomerOrVendor(graphProcess, fsServiceOrderRow.BillCustomerID, null); if (termsID != null) { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.termsID>(arInvoiceRow, termsID); } else { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.termsID>(arInvoiceRow, fsSrvOrdTypeRow.DfltTermIDARSO); } if (fsServiceOrderRow.ProjectID != null) { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.projectID>(arInvoiceRow, fsServiceOrderRow.ProjectID); } Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.docDesc>(arInvoiceRow, fsServiceOrderRow.DocDesc); arInvoiceRow.FinPeriodID = invoiceFinPeriodID; arInvoiceRow = Base.Document.Update(arInvoiceRow); InvoicingFunctions.SetContactAndAddress(Base, fsServiceOrderRow); if (onDocumentHeaderInserted != null) { onDocumentHeaderInserted(Base, arInvoiceRow); } IDocLine docLine = null; ARTran arTranRow = null; FSxARTran fsxARTranRow = null; PMTask pmTaskRow = null; List <SharedClasses.SOARLineEquipmentComponent> componentList = new List <SharedClasses.SOARLineEquipmentComponent>(); int?acctID; int?pivotAppointmentDetID = -1; foreach (DocLineExt docLineExt in docLines) { docLine = docLineExt.docLine; if (docLineExt.fsAppointment != null) { if (pivotAppointmentDetID != docLineExt.docLine.LineID) { pivotAppointmentDetID = docLineExt.docLine.LineID; } else { continue; } } FSSODetSplit fsSODetSplitRow = docLineExt.fsSODetSplit; fsPostDocRow = docLineExt.fsPostDoc; fsServiceOrderRow = docLineExt.fsServiceOrder; fsSrvOrdTypeRow = docLineExt.fsSrvOrdType; fsAppointmentRow = docLineExt.fsAppointment; arTranRow = new ARTran(); arTranRow = Base.Transactions.Insert(arTranRow); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.branchID>(arTranRow, docLine.BranchID); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.inventoryID>(arTranRow, docLine.InventoryID); pmTaskRow = docLineExt.pmTask; if (pmTaskRow != null && pmTaskRow.Status == ProjectTaskStatus.Completed) { throw new PXException(TX.Error.POSTING_PMTASK_ALREADY_COMPLETED, fsServiceOrderRow.RefNbr, docLine.LineRef, pmTaskRow.TaskCD); } if (docLine.ProjectID != null && docLine.ProjectTaskID != null) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.taskID>(arTranRow, docLine.ProjectTaskID); } Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.uOM>(arTranRow, fsSODetSplitRow != null && fsSODetSplitRow.SplitLineNbr > 0 ? fsSODetSplitRow.UOM : docLine.UOM); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.siteID>(arTranRow, fsSODetSplitRow != null && fsSODetSplitRow.SplitLineNbr > 0 ? fsSODetSplitRow.SiteID : docLine.SiteID); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.locationID>(arTranRow, fsSODetSplitRow != null && fsSODetSplitRow.SplitLineNbr > 0 ? fsSODetSplitRow.LocationID : docLine.SiteLocationID); if (docLine.IsService == true || fsAppointmentRow != null) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.qty>(arTranRow, docLine.GetQty(FieldType.BillableField)); } else { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.qty>(arTranRow, fsSODetSplitRow != null && fsSODetSplitRow.SplitLineNbr > 0 ? fsSODetSplitRow.Qty : docLine.GetQty(FieldType.BillableField)); } Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.tranDesc>(arTranRow, docLine.TranDesc); fsPostDocRow.DocLineRef = arTranRow = Base.Transactions.Update(arTranRow); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.salesPersonID>(arTranRow, fsAppointmentRow == null ? fsServiceOrderRow.SalesPersonID : fsAppointmentRow.SalesPersonID); if (docLine.AcctID != null) { acctID = docLine.AcctID; } else { acctID = ServiceOrderCore.Get_TranAcctID_DefaultValue(graphProcess, fsSrvOrdTypeRow.SalesAcctSource, docLine.InventoryID, docLine.SiteID, fsServiceOrderRow); } Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.accountID>(arTranRow, acctID); if (docLine.SubID != null) { try { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.subID>(arTranRow, docLine.SubID); } catch (PXException) { arTranRow.SubID = null; } } else { InvoicingFunctions.SetCombinedSubID(graphProcess, Base.Transactions.Cache, arTranRow, null, null, fsSrvOrdTypeRow, arTranRow.BranchID, arTranRow.InventoryID, arInvoiceRow.CustomerLocationID, fsServiceOrderRow.BranchLocationID, fsServiceOrderRow.SalesPersonID, docLine.IsService); } Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.manualPrice>(arTranRow, docLine.ManualPrice); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.curyUnitPrice>(arTranRow, docLine.CuryUnitPrice * invtMult); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.taxCategoryID>(arTranRow, docLine.TaxCategoryID); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.commissionable>(arTranRow, fsAppointmentRow?.Commissionable ?? fsServiceOrderRow.Commissionable ?? false); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.costCodeID>(arTranRow, docLine.CostCodeID); if (docLine.IsBillable == false) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.manualDisc>(arTranRow, true); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.curyDiscAmt>(arTranRow, docLine.GetQty(FieldType.BillableField) * docLine.CuryUnitPrice * invtMult); } else { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.curyExtPrice>(arTranRow, ((docLine.CuryBillableExtPrice * invtMult) / docLine.GetQty(FieldType.BillableField)) * arTranRow.Qty); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.discPct>(arTranRow, docLine.DiscPct); } if (fsAppointmentRow != null && !string.IsNullOrEmpty(docLine.LotSerialNbr)) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.lotSerialNbr>(arTranRow, docLine.LotSerialNbr); } else if (fsSODetSplitRow.SplitLineNbr > 0 && !string.IsNullOrEmpty(fsSODetSplitRow.LotSerialNbr)) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.lotSerialNbr>(arTranRow, fsSODetSplitRow.LotSerialNbr); } fsxARTranRow = Base.Transactions.Cache.GetExtension <FSxARTran>(arTranRow); fsxARTranRow.Source = docLine.BillingBy; fsxARTranRow.SOID = fsServiceOrderRow.SOID; fsxARTranRow.ServiceOrderDate = fsServiceOrderRow.OrderDate; fsxARTranRow.BillCustomerID = fsServiceOrderRow.CustomerID; fsxARTranRow.CustomerLocationID = fsServiceOrderRow.LocationID; fsxARTranRow.SODetID = docLine.PostSODetID; fsxARTranRow.AppointmentID = docLine.PostAppointmentID; fsxARTranRow.AppointmentDate = fsAppointmentRow?.ExecutionDate; fsxARTranRow.AppDetID = docLine.PostAppDetID; fsxARTranRow.Mem_PreviousPostID = docLine.PostID; fsxARTranRow.Mem_TableSource = docLine.SourceTable; SharedFunctions.CopyNotesAndFiles(Base.Transactions.Cache, arTranRow, docLine, fsSrvOrdTypeRow); fsPostDocRow.DocLineRef = arTranRow = Base.Transactions.Update(arTranRow); if (fsAppointmentRow != null && !string.IsNullOrEmpty(docLine.LotSerialNbr)) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.lotSerialNbr>(arTranRow, docLine.LotSerialNbr); } else if (fsSODetSplitRow != null && fsSODetSplitRow.SplitLineNbr > 0 && !string.IsNullOrEmpty(fsSODetSplitRow.LotSerialNbr)) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.lotSerialNbr>(arTranRow, fsSODetSplitRow.LotSerialNbr); } if (PXAccess.FeatureInstalled <FeaturesSet.equipmentManagementModule>()) { if (docLine.EquipmentAction != null) { Base.Transactions.Cache.SetValueExtIfDifferent <FSxARTran.equipmentAction>(arTranRow, docLine.EquipmentAction); Base.Transactions.Cache.SetValueExtIfDifferent <FSxARTran.sMEquipmentID>(arTranRow, docLine.SMEquipmentID); Base.Transactions.Cache.SetValueExtIfDifferent <FSxARTran.equipmentLineRef>(arTranRow, docLine.EquipmentLineRef); fsxARTranRow.Comment = docLine.Comment; if (docLine.EquipmentAction == ID.Equipment_Action.SELLING_TARGET_EQUIPMENT || ((docLine.EquipmentAction == ID.Equipment_Action.CREATING_COMPONENT || docLine.EquipmentAction == ID.Equipment_Action.UPGRADING_COMPONENT || docLine.EquipmentAction == ID.Equipment_Action.NONE) && string.IsNullOrEmpty(docLine.NewTargetEquipmentLineNbr) == false)) { componentList.Add(new SharedClasses.SOARLineEquipmentComponent(docLine, arTranRow, fsxARTranRow)); } else { fsxARTranRow.ComponentID = docLine.ComponentID; } } } if (onTransactionInserted != null) { onTransactionInserted(Base, arTranRow); } } if (componentList.Count > 0) { //Assigning the NewTargetEquipmentLineNbr field value for the component type records foreach (SharedClasses.SOARLineEquipmentComponent currLineModel in componentList.Where(x => x.equipmentAction == ID.Equipment_Action.SELLING_TARGET_EQUIPMENT)) { foreach (SharedClasses.SOARLineEquipmentComponent currLineComponent in componentList.Where(x => (x.equipmentAction == ID.Equipment_Action.CREATING_COMPONENT || x.equipmentAction == ID.Equipment_Action.UPGRADING_COMPONENT || x.equipmentAction == ID.Equipment_Action.NONE))) { if (currLineComponent.sourceNewTargetEquipmentLineNbr == currLineModel.sourceLineRef) { currLineComponent.fsxARTranRow.ComponentID = currLineComponent.componentID; currLineComponent.fsxARTranRow.NewTargetEquipmentLineNbr = currLineModel.currentLineRef; } } } } arInvoiceRow = Base.Document.Update(arInvoiceRow); if (Base.ARSetup.Current.RequireControlTotal == true) { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.curyOrigDocAmt>(arInvoiceRow, arInvoiceRow.CuryDocBal); } if (initialHold != true || quickProcessFlow != PXQuickProcess.ActionFlow.NoFlow) { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.hold>(arInvoiceRow, false); } arInvoiceRow = Base.Document.Update(arInvoiceRow); }
public virtual FSContractPostDoc CreateInvoiceByContract(PXGraph graphProcess, DateTime?invoiceDate, string invoiceFinPeriodID, FSContractPostBatch fsContractPostBatchRow, FSServiceContract fsServiceContractRow, FSContractPeriod fsContractPeriodRow, List <ContractInvoiceLine> docLines) { if (docLines.Count == 0) { return(null); } FSSetup fsSetupRow = ServiceManagementSetup.GetServiceManagementSetup(graphProcess); ARInvoice arInvoiceRow = new ARInvoice(); arInvoiceRow.DocType = ARInvoiceType.Invoice; arInvoiceRow.DocDate = invoiceDate; arInvoiceRow.FinPeriodID = invoiceFinPeriodID; arInvoiceRow.Hold = true; arInvoiceRow = Base.Document.Insert(arInvoiceRow); Base.Document.Cache.SetValueExt <ARInvoice.customerID>(arInvoiceRow, fsServiceContractRow.BillCustomerID); Base.Document.Cache.SetValueExt <ARInvoice.customerLocationID>(arInvoiceRow, fsServiceContractRow.BillLocationID); Base.Document.Cache.SetValueExt <ARInvoice.branchID>(arInvoiceRow, fsServiceContractRow.BranchID); Base.Document.Cache.SetValueExt <ARInvoice.docDesc>(arInvoiceRow, "Contract Standardized Billing: " + fsServiceContractRow.RefNbr + " " + fsServiceContractRow.DocDesc); string termsID = InvoicingFunctions.GetTermsIDFromCustomerOrVendor(graphProcess, fsServiceContractRow.BillCustomerID, null); if (termsID != null) { Base.Document.Cache.SetValueExt <ARInvoice.termsID>(arInvoiceRow, termsID); } else { Base.Document.Cache.SetValueExt <ARInvoice.termsID>(arInvoiceRow, fsSetupRow.DfltContractTermIDARSO); } ARTran arTranRow = null; FSxARTran fsxARTranRow = null; int? acctID; foreach (ContractInvoiceLine docLine in docLines) { arTranRow = new ARTran(); arTranRow = Base.Transactions.Insert(arTranRow); Base.Transactions.Cache.SetValueExt <ARTran.inventoryID>(arTranRow, docLine.InventoryID); Base.Transactions.Cache.SetValueExt <ARTran.uOM>(arTranRow, docLine.UOM); Base.Transactions.Cache.SetValueExt <ARTran.salesPersonID>(arTranRow, docLine.SalesPersonID); arTranRow = Base.Transactions.Update(arTranRow); if (docLine.AcctID != null) { acctID = docLine.AcctID; } else { acctID = (int?)ServiceOrderCore.Get_INItemAcctID_DefaultValue( graphProcess, fsSetupRow.ContractSalesAcctSource, docLine.InventoryID, fsServiceContractRow); } Base.Transactions.Cache.SetValueExt <ARTran.accountID>(arTranRow, acctID); if (docLine.SubID != null) { try { Base.Transactions.Cache.SetValueExt <ARTran.subID>(arTranRow, docLine.SubID); } catch (PXException) { arTranRow.SubID = null; } } else { InvoicingFunctions.SetCombinedSubID( graphProcess, Base.Transactions.Cache, arTranRow, null, null, fsSetupRow, arTranRow.BranchID, arTranRow.InventoryID, arInvoiceRow.CustomerLocationID, fsServiceContractRow.BranchLocationID); } Base.Transactions.Cache.SetValueExt <ARTran.qty>(arTranRow, docLine.Qty); Base.Transactions.Cache.SetValueExt <ARTran.curyUnitPrice>(arTranRow, docLine.CuryUnitPrice); Base.Transactions.Cache.SetValueExt <ARTran.tranDesc>(arTranRow, docLine.TranDescPrefix + arTranRow.TranDesc); arTranRow = Base.Transactions.Update(arTranRow); Base.Transactions.Cache.SetValueExt <ARTran.commissionable>(arTranRow, docLine.Commissionable ?? false); fsxARTranRow = Base.Transactions.Cache.GetExtension <FSxARTran>(arTranRow); fsxARTranRow.Source = ID.Billing_By.CONTRACT; fsxARTranRow.ServiceContractID = fsServiceContractRow.ServiceContractID; fsxARTranRow.ContractPeriodID = fsContractPeriodRow.ContractPeriodID; fsxARTranRow.BillCustomerID = fsServiceContractRow.BillCustomerID; fsxARTranRow.CustomerLocationID = fsServiceContractRow.BillLocationID; arTranRow = Base.Transactions.Update(arTranRow); } if (Base.ARSetup.Current.RequireControlTotal == true) { Base.Document.Cache.SetValueExt <ARInvoice.curyOrigDocAmt>(arInvoiceRow, arInvoiceRow.CuryDocBal); } Base.Document.Cache.SetValueExt <ARInvoice.hold>(arInvoiceRow, false); Exception newException = null; try { Base.Save.Press(); } catch (Exception e) { List <ErrorInfo> errorList = this.GetErrorInfo(); var exceptionWithContextMessage = ExceptionHelper.GetExceptionWithContextMessage( PXMessages.Localize(TX.Messages.ERROR_CREATING_INVOICE_IN_POSTING_BATCH), e); newException = InvoicingFunctions.GetErrorInfoInLines(errorList, exceptionWithContextMessage); } if (newException != null) { throw newException; } arInvoiceRow = Base.Document.Current; FSContractPostDoc fsContractCreatedDocRow = new FSContractPostDoc() { ContractPeriodID = fsContractPeriodRow.ContractPeriodID, ContractPostBatchID = fsContractPostBatchRow.ContractPostBatchID, PostDocType = arInvoiceRow.DocType, PostedTO = ID.Batch_PostTo.AR, PostRefNbr = arInvoiceRow.RefNbr, ServiceContractID = fsServiceContractRow.ServiceContractID }; return(fsContractCreatedDocRow); }
public virtual void CreateInvoice(PXGraph graphProcess, List <DocLineExt> docLines, List <DocLineExt> docLinesGrouped, short invtMult, DateTime?invoiceDate, string invoiceFinPeriodID, OnDocumentHeaderInsertedDelegate onDocumentHeaderInserted, OnTransactionInsertedDelegate onTransactionInserted, PXQuickProcess.ActionFlow quickProcessFlow) { if (docLinesGrouped.Count == 0) { return; } bool?initialHold = false; FSServiceOrder fsServiceOrderRow = docLinesGrouped[0].fsServiceOrder; FSSrvOrdType fsSrvOrdTypeRow = docLinesGrouped[0].fsSrvOrdType; FSPostDoc fsPostDocRow = docLinesGrouped[0].fsPostDoc; FSAppointment fsAppointmentRow = docLinesGrouped[0].fsAppointment; Base.FieldDefaulting.AddHandler <ARInvoice.branchID>((sender, e) => { e.NewValue = fsServiceOrderRow.BranchID; e.Cancel = true; }); ARInvoice arInvoiceRow = new ARInvoice(); if (invtMult >= 0) { arInvoiceRow.DocType = ARInvoiceType.Invoice; } else { arInvoiceRow.DocType = ARInvoiceType.CreditMemo; } arInvoiceRow.DocDate = invoiceDate; arInvoiceRow.FinPeriodID = invoiceFinPeriodID; arInvoiceRow.InvoiceNbr = fsServiceOrderRow.CustPORefNbr; arInvoiceRow = Base.Document.Insert(arInvoiceRow); initialHold = arInvoiceRow.Hold; arInvoiceRow.NoteID = null; PXNoteAttribute.GetNoteIDNow(Base.Document.Cache, arInvoiceRow); Base.Document.Cache.SetValueExt <ARInvoice.hold>(arInvoiceRow, true); Base.Document.Cache.SetValueExt <ARInvoice.customerID>(arInvoiceRow, fsServiceOrderRow.BillCustomerID); Base.Document.Cache.SetValueExt <ARInvoice.customerLocationID>(arInvoiceRow, fsServiceOrderRow.BillLocationID); Base.Document.Cache.SetValueExt <ARInvoice.curyID>(arInvoiceRow, fsServiceOrderRow.CuryID); Base.Document.Cache.SetValueExt <ARInvoice.taxZoneID>(arInvoiceRow, fsAppointmentRow != null ? fsAppointmentRow.TaxZoneID : fsServiceOrderRow.TaxZoneID); string termsID = InvoicingFunctions.GetTermsIDFromCustomerOrVendor(graphProcess, fsServiceOrderRow.BillCustomerID, null); if (termsID != null) { Base.Document.Cache.SetValueExt <ARInvoice.termsID>(arInvoiceRow, termsID); } else { Base.Document.Cache.SetValueExt <ARInvoice.termsID>(arInvoiceRow, fsSrvOrdTypeRow.DfltTermIDARSO); } if (fsServiceOrderRow.ProjectID != null) { Base.Document.Cache.SetValueExt <ARInvoice.projectID>(arInvoiceRow, fsServiceOrderRow.ProjectID); } Base.Document.Cache.SetValueExt <ARInvoice.docDesc>(arInvoiceRow, fsServiceOrderRow.DocDesc); arInvoiceRow.FinPeriodID = invoiceFinPeriodID; arInvoiceRow = Base.Document.Update(arInvoiceRow); InvoicingFunctions.SetAddress(Base, fsServiceOrderRow); if (onDocumentHeaderInserted != null) { onDocumentHeaderInserted(Base, arInvoiceRow); } IDocLine docLine = null; ARTran arTranRow = null; FSxARTran fsxARTranRow = null; int? acctID; foreach (DocLineExt docLineExt in docLinesGrouped) { docLine = docLineExt.docLine; fsPostDocRow = docLineExt.fsPostDoc; fsServiceOrderRow = docLineExt.fsServiceOrder; fsSrvOrdTypeRow = docLineExt.fsSrvOrdType; fsAppointmentRow = docLineExt.fsAppointment; arTranRow = new ARTran(); arTranRow = Base.Transactions.Insert(arTranRow); Base.Transactions.Cache.SetValueExt <ARTran.inventoryID>(arTranRow, docLine.InventoryID); Base.Transactions.Cache.SetValueExt <ARTran.uOM>(arTranRow, docLine.UOM); if (docLine.ProjectID != null && docLine.ProjectTaskID != null) { PMTask pmTaskRow = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(graphProcess, docLine.ProjectTaskID); Base.Transactions.Cache.SetValueExt <ARTran.taskID>(arTranRow, pmTaskRow.TaskCD); } Base.Transactions.Cache.SetValueExt <ARTran.qty>(arTranRow, docLine.GetQty(FieldType.BillableField)); Base.Transactions.Cache.SetValueExt <ARTran.tranDesc>(arTranRow, docLine.TranDesc); fsPostDocRow.DocLineRef = arTranRow = Base.Transactions.Update(arTranRow); Base.Transactions.Cache.SetValueExt <ARTran.salesPersonID>(arTranRow, fsAppointmentRow == null ? fsServiceOrderRow.SalesPersonID : fsAppointmentRow.SalesPersonID); if (docLine.AcctID != null) { acctID = docLine.AcctID; } else { acctID = (int?)ServiceOrderCore.Get_TranAcctID_DefaultValue( graphProcess, fsSrvOrdTypeRow.SalesAcctSource, docLine.InventoryID, fsServiceOrderRow); } Base.Transactions.Cache.SetValueExt <ARTran.accountID>(arTranRow, acctID); if (docLine.SubID != null) { try { Base.Transactions.Cache.SetValueExt <ARTran.subID>(arTranRow, docLine.SubID); } catch (PXException) { arTranRow.SubID = null; } } else { InvoicingFunctions.SetCombinedSubID( graphProcess, Base.Transactions.Cache, arTranRow, null, null, fsSrvOrdTypeRow, arTranRow.BranchID, arTranRow.InventoryID, arInvoiceRow.CustomerLocationID, fsServiceOrderRow.BranchLocationID, fsServiceOrderRow.SalesPersonID, docLine.IsService); } Base.Transactions.Cache.SetValueExt <ARTran.curyUnitPrice>(arTranRow, docLine.CuryUnitPrice * invtMult); Base.Transactions.Cache.SetValueExt <ARTran.taxCategoryID>(arTranRow, docLine.TaxCategoryID); //Base.Transactions.Cache.SetValueExt<ARTran.curyExtPrice>(arTranRow, docLine.GetTranAmt(FieldType.BillableField) * invtMult); Base.Transactions.Cache.SetValueExt <ARTran.commissionable>(arTranRow, fsAppointmentRow?.Commissionable ?? fsServiceOrderRow.Commissionable ?? false); Base.Transactions.Cache.SetValueExt <ARTran.costCodeID>(arTranRow, docLine.CostCodeID); fsxARTranRow = Base.Transactions.Cache.GetExtension <FSxARTran>(arTranRow); fsxARTranRow.Source = docLine.BillingBy; fsxARTranRow.SOID = fsServiceOrderRow.SOID; fsxARTranRow.ServiceOrderDate = fsServiceOrderRow.OrderDate; fsxARTranRow.BillCustomerID = fsServiceOrderRow.BillCustomerID; fsxARTranRow.CustomerLocationID = fsServiceOrderRow.BillLocationID; fsxARTranRow.SODetID = docLine.PostSODetID; fsxARTranRow.AppointmentID = docLine.PostAppointmentID; fsxARTranRow.AppointmentDate = fsAppointmentRow?.ExecutionDate; fsxARTranRow.AppDetID = docLine.PostAppDetID; fsxARTranRow.Mem_PreviousPostID = docLine.PostID; fsxARTranRow.Mem_TableSource = docLine.SourceTable; SharedFunctions.CopyNotesAndFiles(Base.Transactions.Cache, arTranRow, docLine, fsSrvOrdTypeRow); fsPostDocRow.DocLineRef = arTranRow = Base.Transactions.Update(arTranRow); if (onTransactionInserted != null) { onTransactionInserted(Base, arTranRow); } } arInvoiceRow = Base.Document.Update(arInvoiceRow); if (Base.ARSetup.Current.RequireControlTotal == true) { Base.Document.Cache.SetValueExt <ARInvoice.curyOrigDocAmt>(arInvoiceRow, arInvoiceRow.CuryDocBal); } if (initialHold != true) { Base.Document.Cache.SetValueExt <ARInvoice.hold>(arInvoiceRow, false); } arInvoiceRow = Base.Document.Update(arInvoiceRow); }
public virtual void DeletePostingBatch(FSPostBatch fsPostBatchRow) { if (fsPostBatchRow.BatchID < 0) { return; } PostBatchRecords.Current = PostBatchRecords.Search <FSPostBatch.batchID>(fsPostBatchRow.BatchID); if (PostBatchRecords.Current == null || PostBatchRecords.Current.BatchID != fsPostBatchRow.BatchID) { return; } IInvoiceGraph invoiceGraph = InvoicingFunctions.CreateInvoiceGraph(fsPostBatchRow.PostTo); var tempGraph = new PXGraph(); using (var ts = new PXTransactionScope()) { PXResultset <FSCreatedDoc> fsCreatedDocSet = PXSelect <FSCreatedDoc, Where < FSCreatedDoc.batchID, Equal <Required <FSCreatedDoc.batchID> > > > .Select(tempGraph, fsPostBatchRow.BatchID); foreach (FSCreatedDoc fsCreatedDocRow in fsCreatedDocSet) { if (fsCreatedDocRow.PostTo != fsPostBatchRow.PostTo) { throw new PXException(TX.Error.DOCUMENT_MODULE_DIFERENT_T0_BATCH_MODULE, fsCreatedDocRow.PostTo, fsPostBatchRow.PostTo); } invoiceGraph.DeleteDocument(fsCreatedDocRow); } PXDatabase.Delete <FSCreatedDoc>( new PXDataFieldRestrict <FSCreatedDoc.batchID>(fsPostBatchRow.BatchID)); PXResultset <FSPostDet> fsPostDetSet = PXSelect <FSPostDet, Where < FSPostDet.batchID, Equal <Required <FSPostDet.batchID> > > > .Select(tempGraph, fsPostBatchRow.BatchID); foreach (FSPostDet fsPostDetRow in fsPostDetSet) { invoiceGraph.CleanPostInfo(tempGraph, fsPostDetRow); int?sOID = InvoicingFunctions.GetServiceOrderFromSOPostID(tempGraph, fsPostDetRow.PostID); if (InvoicingFunctions.AreAppointmentsPostedInSO(tempGraph, sOID) == false) { PXUpdateJoin < Set <FSServiceOrder.finPeriodID, Null, Set <FSServiceOrder.postedBy, Null, Set <FSServiceOrder.pendingAPARSOPost, True> > >, FSServiceOrder, InnerJoin <FSSODet, On < FSSODet.sOID, Equal <FSServiceOrder.sOID> > >, Where < FSSODet.postID, Equal <Required <FSSODet.postID> >, And <FSServiceOrder.pendingAPARSOPost, Equal <False> > > > .Update(tempGraph, fsPostDetRow.PostID); } } PXDatabase.Delete <FSPostDet>( new PXDataFieldRestrict <FSPostDet.batchID>(fsPostBatchRow.BatchID)); PXDatabase.Delete <FSPostDoc>( new PXDataFieldRestrict <FSPostDoc.batchID>(fsPostBatchRow.BatchID)); PXDatabase.Delete <FSPostRegister>( new PXDataFieldRestrict <FSPostRegister.batchID>(fsPostBatchRow.BatchID)); PostBatchRecords.Delete(fsPostBatchRow); Save.Press(); ts.Complete(); } }
public virtual FSContractPostDoc CreateInvoiceByContract(PXGraph graphProcess, DateTime?invoiceDate, string invoiceFinPeriodID, FSContractPostBatch fsContractPostBatchRow, FSServiceContract fsServiceContractRow, FSContractPeriod fsContractPeriodRow, List <ContractInvoiceLine> docLines) { if (docLines.Count == 0) { return(null); } FSSetup fsSetupRow = ServiceManagementSetup.GetServiceManagementSetup(graphProcess); ARInvoice arInvoiceRow = new ARInvoice(); arInvoiceRow.DocType = ARInvoiceType.Invoice; AutoNumberHelper.CheckAutoNumbering(Base, Base.ARSetup.SelectSingle().InvoiceNumberingID); arInvoiceRow.DocDate = invoiceDate; arInvoiceRow.FinPeriodID = invoiceFinPeriodID; arInvoiceRow.Hold = true; arInvoiceRow = Base.Document.Insert(arInvoiceRow); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.customerID>(arInvoiceRow, fsServiceContractRow.BillCustomerID); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.customerLocationID>(arInvoiceRow, fsServiceContractRow.BillLocationID); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.branchID>(arInvoiceRow, fsServiceContractRow.BranchID); Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.docDesc>(arInvoiceRow, (PXMessages.LocalizeFormatNoPrefix(TX.Messages.CONTRACT_WITH_STANDARDIZED_BILLING, fsServiceContractRow.RefNbr, (string.IsNullOrEmpty(fsServiceContractRow.DocDesc) ? string.Empty : fsServiceContractRow.DocDesc)))); string termsID = InvoicingFunctions.GetTermsIDFromCustomerOrVendor(graphProcess, fsServiceContractRow.BillCustomerID, null); if (termsID != null) { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.termsID>(arInvoiceRow, termsID); } else { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.termsID>(arInvoiceRow, fsSetupRow.DfltContractTermIDARSO); } Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.projectID>(arInvoiceRow, fsServiceContractRow.ProjectID); ARTran arTranRow = null; FSxARTran fsxARTranRow = null; int? acctID; foreach (ContractInvoiceLine docLine in docLines) { arTranRow = new ARTran(); arTranRow = Base.Transactions.Insert(arTranRow); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.inventoryID>(arTranRow, docLine.InventoryID); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.uOM>(arTranRow, docLine.UOM); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.salesPersonID>(arTranRow, docLine.SalesPersonID); arTranRow = Base.Transactions.Update(arTranRow); if (docLine.AcctID != null) { acctID = docLine.AcctID; } else { acctID = (int?)ServiceOrderCore.Get_INItemAcctID_DefaultValue(graphProcess, fsSetupRow.ContractSalesAcctSource, docLine.InventoryID, fsServiceContractRow); } Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.accountID>(arTranRow, acctID); if (docLine.SubID != null) { try { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.subID>(arTranRow, docLine.SubID); } catch (PXException) { arTranRow.SubID = null; } } else { InvoicingFunctions.SetCombinedSubID(graphProcess, Base.Transactions.Cache, arTranRow, null, null, fsSetupRow, arTranRow.BranchID, arTranRow.InventoryID, arInvoiceRow.CustomerLocationID, fsServiceContractRow.BranchLocationID); } Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.qty>(arTranRow, docLine.Qty); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.curyUnitPrice>(arTranRow, docLine.CuryUnitPrice); if (docLine.ServiceContractID != null && docLine.ContractRelated == false && (docLine.SODetID != null || docLine.AppDetID != null)) { Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.curyExtPrice>(arTranRow, docLine.CuryBillableExtPrice); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.discPct>(arTranRow, docLine.DiscPct); } Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.tranDesc>(arTranRow, docLine.TranDescPrefix + arTranRow.TranDesc); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.taskID>(arTranRow, docLine.ProjectTaskID); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.costCodeID>(arTranRow, docLine.CostCodeID); arTranRow = Base.Transactions.Update(arTranRow); Base.Transactions.Cache.SetValueExtIfDifferent <ARTran.commissionable>(arTranRow, docLine.Commissionable ?? false); fsxARTranRow = Base.Transactions.Cache.GetExtension <FSxARTran>(arTranRow); fsxARTranRow.Source = ID.DocumentSource.INVOICE_FROM_SERVICECONTRACT; fsxARTranRow.ServiceContractID = fsServiceContractRow.ServiceContractID; fsxARTranRow.ContractPeriodID = fsContractPeriodRow.ContractPeriodID; fsxARTranRow.BillCustomerID = fsServiceContractRow.CustomerID; fsxARTranRow.CustomerLocationID = fsServiceContractRow.CustomerLocationID; arTranRow = Base.Transactions.Update(arTranRow); } if (Base.ARSetup.Current.RequireControlTotal == true) { Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.curyOrigDocAmt>(arInvoiceRow, arInvoiceRow.CuryDocBal); } Base.Document.Cache.SetValueExtIfDifferent <ARInvoice.hold>(arInvoiceRow, false); Exception newException = null; try { Base.Save.Press(); } catch (Exception e) { List <ErrorInfo> errorList = this.GetErrorInfo(); newException = InvoicingFunctions.GetErrorInfoInLines(errorList, e); } if (newException != null) { throw newException; } arInvoiceRow = Base.Document.Current; FSContractPostDoc fsContractCreatedDocRow = new FSContractPostDoc() { ContractPeriodID = fsContractPeriodRow.ContractPeriodID, ContractPostBatchID = fsContractPostBatchRow.ContractPostBatchID, PostDocType = arInvoiceRow.DocType, PostedTO = ID.Batch_PostTo.AR, PostRefNbr = arInvoiceRow.RefNbr, ServiceContractID = fsServiceContractRow.ServiceContractID }; return(fsContractCreatedDocRow); }