public virtual void openDocument() { InventoryPostingBatchDetail inventoryPostingBatchDetailRow = BatchDetailsInfo.Current; FSPostDet fsPostDetRow = PXSelectJoin <FSPostDet, InnerJoin <FSPostInfo, On <FSPostInfo.postID, Equal <FSPostDet.postID> >, InnerJoin <FSAppointmentInventoryItem, On <FSAppointmentInventoryItem.postID, Equal <FSPostInfo.postID> > > >, Where < FSPostDet.batchID, Equal <Current <FSPostBatch.batchID> >, And <FSAppointmentInventoryItem.appDetID, Equal <Required <FSAppointmentInventoryItem.appDetID> > > > > .Select(this, inventoryPostingBatchDetailRow.AppointmentInventoryItemID); if (fsPostDetRow != null && fsPostDetRow.INPosted == true) { if (fsPostDetRow.INDocType.Trim() == INDocType.Receipt) { INReceiptEntry graphINReceiptEntry = PXGraph.CreateInstance <INReceiptEntry>(); graphINReceiptEntry.receipt.Current = graphINReceiptEntry.receipt.Search <INRegister.refNbr>(fsPostDetRow.INRefNbr); throw new PXRedirectRequiredException(graphINReceiptEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else { INIssueEntry graphINIssueEntry = PXGraph.CreateInstance <INIssueEntry>(); graphINIssueEntry.issue.Current = graphINIssueEntry.issue.Search <INRegister.refNbr>(fsPostDetRow.INRefNbr); throw new PXRedirectRequiredException(graphINIssueEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } }
public static void ReleaseDoc(List <POReceipt> list, bool aIsMassProcess) { POReceiptEntry docgraph = PXGraph.CreateInstance <POReceiptEntry>(); DocumentList <INRegister> created = new DocumentList <INRegister>(docgraph); DocumentList <APInvoice> invoicesCreated = new DocumentList <APInvoice>(docgraph); INReceiptEntry iRe = null; INIssueEntry iIe = null; AP.APInvoiceEntry apInvoiceGraph = PXGraph.CreateInstance <APInvoiceEntry>(); int iRow = 0; bool failed = false; foreach (POReceipt order in list) { try { switch (order.ReceiptType) { case POReceiptType.POReceipt: case POReceiptType.TransferReceipt: if (iRe == null) { iRe = docgraph.CreateReceiptEntry(); } docgraph.ReleaseReceipt(iRe, apInvoiceGraph, order, created, invoicesCreated, aIsMassProcess); break; case POReceiptType.POReturn: if (iIe == null) { iIe = docgraph.CreateIssueEntry(); } docgraph.ReleaseReturn(iIe, apInvoiceGraph, order, created, invoicesCreated, aIsMassProcess); break; } PXProcessing <POReceipt> .SetInfo(iRow, ActionsMessages.RecordProcessed); } catch (Exception e) { if (aIsMassProcess) { PXProcessing <POReceipt> .SetError(iRow, e); failed = true; } else { throw; } } iRow++; } if (failed) { throw new PXException(Messages.ReleaseOfOneOrMoreReceiptsHasFailed); } }
public static void PostOrder(SOPostShipmentFilter filter, List <SOOrder> list) { SOOrderEntry docgraph = PXGraph.CreateInstance <SOOrderEntry>(); DocumentList <INRegister> created = new DocumentList <INRegister>(docgraph); INIssueEntry ie = PXGraph.CreateInstance <INIssueEntry>(); ie.FieldVerifying.AddHandler <INTran.projectID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); ie.FieldVerifying.AddHandler <INTran.taskID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); foreach (SOOrder order in list) { docgraph.PostOrder(ie, order, created); } }
/// <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); }
public virtual void openDocument() { FSCreatedDoc postingBatchDetailRow = BatchDetailsInfo.Current; if (postingBatchDetailRow.PostTo == ID.Batch_PostTo.SO) { if (PXAccess.FeatureInstalled <FeaturesSet.distributionModule>()) { SOOrderEntry graphSOOrderEntry = PXGraph.CreateInstance <SOOrderEntry>(); graphSOOrderEntry.Document.Current = graphSOOrderEntry.Document.Search <SOOrder.orderNbr>(postingBatchDetailRow.CreatedRefNbr, postingBatchDetailRow.CreatedDocType); throw new PXRedirectRequiredException(graphSOOrderEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } else if (postingBatchDetailRow.PostTo == ID.Batch_PostTo.AR) { ARInvoiceEntry graphARInvoiceEntry = PXGraph.CreateInstance <ARInvoiceEntry>(); graphARInvoiceEntry.Document.Current = graphARInvoiceEntry.Document.Search <ARInvoice.refNbr>(postingBatchDetailRow.CreatedRefNbr, postingBatchDetailRow.CreatedDocType); throw new PXRedirectRequiredException(graphARInvoiceEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (postingBatchDetailRow.PostTo == ID.Batch_PostTo.SI) { SOInvoiceEntry graphSOInvoiceEntry = PXGraph.CreateInstance <SOInvoiceEntry>(); graphSOInvoiceEntry.Document.Current = graphSOInvoiceEntry.Document.Search <ARInvoice.refNbr>(postingBatchDetailRow.CreatedRefNbr, postingBatchDetailRow.CreatedDocType); throw new PXRedirectRequiredException(graphSOInvoiceEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (postingBatchDetailRow.PostTo == ID.Batch_PostTo.AP) { APInvoiceEntry graphAPInvoiceEntry = PXGraph.CreateInstance <APInvoiceEntry>(); graphAPInvoiceEntry.Document.Current = graphAPInvoiceEntry.Document.Search <APInvoice.refNbr>(postingBatchDetailRow.CreatedRefNbr, postingBatchDetailRow.CreatedDocType); throw new PXRedirectRequiredException(graphAPInvoiceEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (postingBatchDetailRow.PostTo == ID.Batch_PostTo.IN) { INIssueEntry graphINIssueEntry = PXGraph.CreateInstance <INIssueEntry>(); graphINIssueEntry.issue.Current = graphINIssueEntry.issue.Search <INRegister.refNbr>(postingBatchDetailRow.CreatedRefNbr, postingBatchDetailRow.CreatedDocType); throw new PXRedirectRequiredException(graphINIssueEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (postingBatchDetailRow.PostTo == ID.Batch_PostTo.PM) { RegisterEntry graphRegisterEntry = PXGraph.CreateInstance <RegisterEntry>(); graphRegisterEntry.Document.Current = graphRegisterEntry.Document.Search <PMRegister.refNbr>(postingBatchDetailRow.CreatedRefNbr, postingBatchDetailRow.CreatedDocType); throw new PXRedirectRequiredException(graphRegisterEntry, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } }
public virtual void PostInvoice(INIssueEntry docgraph, ARInvoice invoice, DocumentList<INRegister> list) { SOOrderEntry oe = null; SOShipmentEntry se = null; foreach (PXResult<SOOrderShipment, SOOrder> res in PXSelectJoin<SOOrderShipment, InnerJoin<SOOrder, On<SOOrder.orderType, Equal<SOOrderShipment.orderType>, And<SOOrder.orderNbr, Equal<SOOrderShipment.orderNbr>>>>, Where<SOOrderShipment.invoiceType, Equal<Current<ARInvoice.docType>>, And<SOOrderShipment.invoiceNbr, Equal<Current<ARInvoice.refNbr>>>>>.SelectMultiBound(this, new object[] { invoice })) { if (((SOOrderShipment)res).ShipmentType == SOShipmentType.DropShip) { if (se == null) { se = PXGraph.CreateInstance<SOShipmentEntry>(); } else { se.Clear(); } se.PostReceipt(docgraph, res, list); } else if (string.Equals(((SOOrderShipment)res).ShipmentNbr, Constants.NoShipmentNbr)) { if (oe == null) { oe = PXGraph.CreateInstance<SOOrderEntry>(); } else { oe.Clear(); } oe.PostOrder(docgraph, (SOOrder)res, list); } else { if (se == null) { se = PXGraph.CreateInstance<SOShipmentEntry>(); se.Caches[typeof(SiteStatus)] = docgraph.Caches[typeof(SiteStatus)]; se.Caches[typeof(LocationStatus)] = docgraph.Caches[typeof(LocationStatus)]; se.Caches[typeof(LotSerialStatus)] = docgraph.Caches[typeof(LotSerialStatus)]; se.Caches[typeof(ItemLotSerial)] = docgraph.Caches[typeof(ItemLotSerial)]; se.Views.Caches.Remove(typeof(SiteStatus)); se.Views.Caches.Remove(typeof(LocationStatus)); se.Views.Caches.Remove(typeof(LotSerialStatus)); se.Views.Caches.Remove(typeof(ItemLotSerial)); } else { se.Clear(); } se.PostShipment(docgraph, res, list); } } }