/// <summary> /// Update a Posting Batch that will be used in every Posting Process. /// </summary> public virtual FSPostBatch UpdateFSPostBatch(FSPostBatch fsPostBatchRow) { graphUpdatePostBatchMaint.BatchRecords.Current = graphUpdatePostBatchMaint.BatchRecords.Search <FSPostBatch.batchID>(fsPostBatchRow.BatchID); graphUpdatePostBatchMaint.BatchRecords.Update(fsPostBatchRow); graphUpdatePostBatchMaint.Save.Press(); return(graphUpdatePostBatchMaint.BatchRecords.Current); }
public override void UpdateSourcePostDoc(PXCache <FSPostDet> cacheFSPostDet, FSPostBatch fsPostBatchRow, FSPostDoc fsPostDocRow) { PXUpdate < Set <FSServiceOrder.finPeriodID, Required <FSServiceOrder.finPeriodID>, Set <FSServiceOrder.postedBy, Required <FSServiceOrder.postedBy>, Set <FSServiceOrder.pendingAPARSOPost, False> > >, FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> >, And <FSServiceOrder.pendingAPARSOPost, Equal <True> > > > .Update(cacheFSPostDet.Graph, fsPostBatchRow.FinPeriodID, ID.Billing_By.SERVICE_ORDER, fsPostDocRow.SOID); }
/// <summary> /// Creates a Posting Batch that will be used in every Posting Process. /// </summary> public virtual FSPostBatch CreateFSPostBatch(int qtyDoc, string postTo, DateTime?cutOffDate, string invoicePeriodID = null, DateTime?invoiceDate = null, int?billingCycleID = null, DateTime?upToDate = null) { FSPostBatch fsPostBatchRow = new FSPostBatch(); fsPostBatchRow.QtyDoc = qtyDoc; fsPostBatchRow.BillingCycleID = billingCycleID; fsPostBatchRow.InvoiceDate = invoiceDate.HasValue == true ? new DateTime(invoiceDate.Value.Year, invoiceDate.Value.Month, invoiceDate.Value.Day, 0, 0, 0) : invoiceDate; fsPostBatchRow.PostTo = postTo; fsPostBatchRow.UpToDate = upToDate.HasValue == true ? new DateTime(upToDate.Value.Year, upToDate.Value.Month, upToDate.Value.Day, 0, 0, 0) : upToDate; fsPostBatchRow.CutOffDate = new DateTime(cutOffDate.Value.Year, cutOffDate.Value.Month, cutOffDate.Value.Day, 0, 0, 0); fsPostBatchRow.FinPeriodID = invoicePeriodID; graphUpdatePostBatchMaint.BatchRecords.Insert(fsPostBatchRow); graphUpdatePostBatchMaint.Save.Press(); return(graphUpdatePostBatchMaint.BatchRecords.Current); }
/// <summary> /// Defines where the AppointmentInventoryItems are going to be posted, depending of the ServiceType (Pickup or Delivery). /// </summary> /// <param name="fsAppointmentInventoryItemRows"> Items to be posted (Original List in the screen).</param> /// <param name="listGroupToInvoice"> Items to be posted (Groups to be posted after grouping rules).</param> /// <param name="filter"> Header of the screen (Filters).</param> public virtual void CreateDocumentByGroup(List <FSAppointmentDet> fsAppointmentInventoryItemRows, List <SharedClasses.AppointmentInventoryItemGroup> listGroupToInvoice, UpdateInventoryFilter filter) { FSPostBatch fsPostBatchRow = CreateFSPostBatch(fsAppointmentInventoryItemRows.Count, ID.Batch_PostTo.IN, filter.CutOffDate, filter.FinPeriodID, filter.DocumentDate); int documentsPosted = 0; documentsPosted = CreateDocumentsInIN(fsPostBatchRow, fsAppointmentInventoryItemRows, listGroupToInvoice, filter); if (documentsPosted > 0) { fsPostBatchRow.QtyDoc = documentsPosted; UpdateFSPostBatch(fsPostBatchRow); } else { DeleteFSPostBatch(fsPostBatchRow); } }
public override void UpdateSourcePostDoc(PXCache <FSPostDet> cacheFSPostDet, FSPostBatch fsPostBatchRow, FSPostDoc fsPostDocRow) { PXUpdate < Set <FSAppointment.finPeriodID, Required <FSAppointment.finPeriodID>, Set <FSAppointment.pendingAPARSOPost, False, Set <FSAppointment.postingStatusAPARSO, ListField_Status_Posting.Posted> > >, FSAppointment, Where < FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > > .Update(cacheFSPostDet.Graph, fsPostBatchRow.FinPeriodID, fsPostDocRow.AppointmentID); PXUpdate < Set <FSServiceOrder.finPeriodID, Required <FSServiceOrder.finPeriodID>, Set <FSServiceOrder.postedBy, Required <FSServiceOrder.postedBy>, Set <FSServiceOrder.pendingAPARSOPost, False> > >, FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> >, And <FSServiceOrder.pendingAPARSOPost, Equal <True> > > > .Update(cacheFSPostDet.Graph, fsPostBatchRow.FinPeriodID, ID.Billing_By.APPOINTMENT, fsPostDocRow.SOID); }
/// <summary> /// Update the references in <c>FSPostInfo</c> and <c>FSPostDet</c> when the posting process of every AppointmentInventoryItem is complete in IN. /// </summary> public virtual void UpdateIssuePostInfo(INIssueEntry graphINIssueEntry, InventoryPostBatchMaint graphInventoryPostBatchMaint, PostInfoEntry graphPostInfoEntry, FSAppointmentDet fsAppointmentInventoryItemRow, SharedClasses.AppointmentInventoryItemInfo appointmentInventoryItemInfoRow, FSPostBatch fsPostBatchRow) { //Create | Update Post info FSPostInfo fsPostInfoRow; FSPostDet fsPostDet; fsPostBatchRow = graphInventoryPostBatchMaint.BatchRecords.Current = graphInventoryPostBatchMaint.BatchRecords.Search <FSPostBatch.batchID>(fsPostBatchRow.BatchID); fsPostInfoRow = PXSelect <FSPostInfo, Where < FSPostInfo.postID, Equal <Required <FSPostInfo.postID> > > > .Select(this, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.PostID); if (fsPostInfoRow == null || fsPostInfoRow.PostID == null) { fsPostInfoRow = new FSPostInfo(); fsPostInfoRow = graphPostInfoEntry.PostInfoRecords.Current = graphPostInfoEntry.PostInfoRecords.Insert(fsPostInfoRow); } else { fsPostInfoRow = graphPostInfoEntry.PostInfoRecords.Current = graphPostInfoEntry.PostInfoRecords.Search <FSPostInfo.postID>(fsPostInfoRow.PostID); } fsPostInfoRow.INPosted = true; fsPostInfoRow.INDocType = graphINIssueEntry.issue.Current.DocType; fsPostInfoRow.INRefNbr = graphINIssueEntry.issue.Current.RefNbr; foreach (INTran inTranRowLocal in graphINIssueEntry.transactions.Select()) { FSxINTran fsxINTranRow = graphINIssueEntry.transactions.Cache.GetExtension <FSxINTran>(inTranRowLocal); if (fsxINTranRow != null && appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.AppDetID == fsxINTranRow.AppDetID) { fsPostInfoRow.INLineNbr = inTranRowLocal.LineNbr; break; } } fsPostInfoRow.AppointmentID = appointmentInventoryItemInfoRow.FSAppointmentRow.AppointmentID; fsPostInfoRow.SOID = appointmentInventoryItemInfoRow.FSAppointmentRow.SOID; fsPostInfoRow = graphPostInfoEntry.PostInfoRecords.Update(fsPostInfoRow); graphPostInfoEntry.Save.Press(); fsPostInfoRow = graphPostInfoEntry.PostInfoRecords.Current; fsPostDet = new FSPostDet(); fsPostDet.PostID = fsPostInfoRow.PostID; fsPostDet.INPosted = fsPostInfoRow.INPosted; fsPostDet.INDocType = fsPostInfoRow.INDocType; fsPostDet.INRefNbr = fsPostInfoRow.INRefNbr; fsPostDet.INLineNbr = fsPostInfoRow.INLineNbr; graphInventoryPostBatchMaint.BatchDetails.Insert(fsPostDet); graphInventoryPostBatchMaint.Save.Press(); fsAppointmentInventoryItemRow.Mem_BatchNbr = fsPostBatchRow.BatchNbr; fsPostInfoRow = graphPostInfoEntry.PostInfoRecords.Current; PXUpdate < Set <FSAppointmentDet.postID, Required <FSAppointmentDet.postID> >, FSAppointmentDet, Where < FSAppointmentDet.appDetID, Equal <Required <FSAppointmentDet.appDetID> > > > .Update(this, fsPostInfoRow.PostID, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.AppDetID); }
/// <summary> /// Creates an Issue document using the parameters <c>fsAppointmentRow</c>, <c>fsServiceOrderRow</c>, <c>fsServiceOrderTypeRow</c> and its posting information. /// </summary> protected virtual void CreateDocumentIssue(INIssueEntry graphINIssueEntry, SharedClasses.AppointmentInventoryItemInfo appointmentInventoryItemInfoRow, FSAppointmentDet fsAppointmentInventoryItemRow, DateTime?documentDate, string documentPeriod, FSPostBatch fsPostBatchRow, ref string inRefNbr, ref string inDocType) { if (appointmentInventoryItemInfoRow != null) { INRegister inRegisterRow; #region IN Issue Header if (string.IsNullOrEmpty(inRefNbr)) { inRegisterRow = new INRegister(); inRegisterRow.DocType = INDocType.Issue; inRegisterRow.TranDate = documentDate; inRegisterRow.FinPeriodID = documentPeriod; inRegisterRow.TranDesc = appointmentInventoryItemInfoRow.FSAppointmentRow.DocDesc; inRegisterRow.Hold = false; inRegisterRow = graphINIssueEntry.issue.Current = graphINIssueEntry.issue.Insert(inRegisterRow); inRegisterRow = graphINIssueEntry.issue.Update(inRegisterRow); } else { inRegisterRow = graphINIssueEntry.issue.Current = graphINIssueEntry.issue.Search <INRegister.refNbr>(inRefNbr); } #endregion INTran inTranRow; inTranRow = new INTran(); inTranRow.TranType = INTranType.Issue; inTranRow = graphINIssueEntry.transactions.Current = graphINIssueEntry.transactions.Insert(inTranRow); graphINIssueEntry.transactions.Cache.SetValueExt <INTran.inventoryID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.InventoryID); if (PXAccess.FeatureInstalled <FeaturesSet.subItem>()) { graphINIssueEntry.transactions.Cache.SetValueExt <INTran.subItemID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.SubItemID); } graphINIssueEntry.transactions.Cache.SetValueExt <INTran.siteID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.SiteID); graphINIssueEntry.transactions.Cache.SetValueExt <INTran.qty>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.Qty); graphINIssueEntry.transactions.Cache.SetValueExt <INTran.unitPrice>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.UnitPrice); graphINIssueEntry.transactions.Cache.SetValueExt <INTran.tranAmt>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.TranAmt); graphINIssueEntry.transactions.Cache.SetValueExt <INTran.projectID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.ProjectID); graphINIssueEntry.transactions.Cache.SetValueExt <INTran.taskID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.ProjectTaskID); FSxINTran fsxINTranRow = graphINIssueEntry.transactions.Cache.GetExtension <FSxINTran>(graphINIssueEntry.transactions.Current); fsxINTranRow.Source = ID.Billing_By.APPOINTMENT; fsxINTranRow.SOID = appointmentInventoryItemInfoRow.FSAppointmentRow.SOID; fsxINTranRow.BillCustomerID = appointmentInventoryItemInfoRow.FSServiceOrderRow.BillCustomerID; fsxINTranRow.CustomerLocationID = appointmentInventoryItemInfoRow.FSServiceOrderRow.BillLocationID; fsxINTranRow.AppointmentID = appointmentInventoryItemInfoRow.FSAppointmentRow.AppointmentID; fsxINTranRow.AppointmentDate = new DateTime(appointmentInventoryItemInfoRow.FSAppointmentRow.ActualDateTimeBegin.Value.Year, appointmentInventoryItemInfoRow.FSAppointmentRow.ActualDateTimeBegin.Value.Month, appointmentInventoryItemInfoRow.FSAppointmentRow.ActualDateTimeBegin.Value.Day, 0, 0, 0); fsxINTranRow.AppDetID = (int)appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.AppDetID; inTranRow = graphINIssueEntry.transactions.Update(inTranRow); graphINIssueEntry.Save.Press(); if (string.IsNullOrEmpty(inRefNbr)) { inRefNbr = graphINIssueEntry.issue.Current.RefNbr; inDocType = graphINIssueEntry.issue.Current.DocType; } UpdateIssuePostInfo(graphINIssueEntry, graphUpdatePostBatchMaint, graphPostInfoEntry, fsAppointmentInventoryItemRow, appointmentInventoryItemInfoRow, fsPostBatchRow); } else { throw new PXException(TX.Error.NOTHING_TO_BE_POSTED); } }
/// <summary> /// Creates one or more documents in Inventory depending of the number of FSAppointmentInventoryItem in the list [fsAppointmentInventoryItemRows]. /// </summary> public virtual int CreateDocumentsInIN(FSPostBatch fsPostBatchRow, List <FSAppointmentDet> fsAppointmentInventoryItemRows, List <SharedClasses.AppointmentInventoryItemGroup> listGroupToUpdateInInventory, UpdateInventoryFilter filter) { INReceiptEntry graphINReceiptEntry = PXGraph.CreateInstance <INReceiptEntry>(); INIssueEntry graphINIssueEntry = PXGraph.CreateInstance <INIssueEntry>(); int linesPosted = 0; foreach (SharedClasses.AppointmentInventoryItemGroup groupToUpdateInInventory in listGroupToUpdateInInventory) { string iNRefNbr = null; string iNDocType = null; foreach (SharedClasses.AppointmentInventoryItemInfo appointmentInventoryItemInfoRow in groupToUpdateInInventory.AppointmentInventoryItems) { using (var ts_GroupToUpdateInInventory = new PXTransactionScope()) { try { if (groupToUpdateInInventory.ServiceType == ID.Service_Action_Type.PICKED_UP_ITEMS) { // create receipt CreateDocumentReceipt(graphINReceiptEntry, appointmentInventoryItemInfoRow, fsAppointmentInventoryItemRows[appointmentInventoryItemInfoRow.Index], filter.DocumentDate, filter.FinPeriodID, fsPostBatchRow, ref iNRefNbr, ref iNDocType); } else if (groupToUpdateInInventory.ServiceType == ID.Service_Action_Type.DELIVERED_ITEMS) { // create issue CreateDocumentIssue(graphINIssueEntry, appointmentInventoryItemInfoRow, fsAppointmentInventoryItemRows[appointmentInventoryItemInfoRow.Index], filter.DocumentDate, filter.FinPeriodID, fsPostBatchRow, ref iNRefNbr, ref iNDocType); } else if (groupToUpdateInInventory.ServiceType == ID.Service_Action_Type.NO_ITEMS_RELATED) { PXProcessing <FSAppointmentDet> .SetError(appointmentInventoryItemInfoRow.Index, TX.Error.APPOINTMENT_ITEM_CANNOT_BE_POSTED_TO_IN_NO_ITEMS_RELATED); } PXProcessing <FSAppointmentDet> .SetInfo(appointmentInventoryItemInfoRow.Index, TX.Messages.RECORD_PROCESSED_SUCCESSFULLY); linesPosted++; ts_GroupToUpdateInInventory.Complete(); } catch (Exception e) { Exception latestException = ExceptionHelper.GetExceptionWithContextMessage(PXMessages.Localize(TX.Messages.COULD_NOT_PROCESS_RECORD), e); PXProcessing <FSAppointmentDet> .SetError(appointmentInventoryItemInfoRow.Index, latestException); ts_GroupToUpdateInInventory.Dispose(); graphINReceiptEntry.Actions.PressCancel(); } } } } return(linesPosted); }
/// <summary> /// Deletes a Posting Batch record. /// </summary> private void DeleteFSPostBatch(FSPostBatch fsPostBatchRow) { graphUpdatePostBatchMaint.BatchRecords.Current = graphUpdatePostBatchMaint.BatchRecords.Search <FSPostBatch.batchID>(fsPostBatchRow.BatchID); graphUpdatePostBatchMaint.BatchRecords.Delete(fsPostBatchRow); graphUpdatePostBatchMaint.Save.Press(); }