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); } }
/// <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 UpdateReceiptPostInfo(INReceiptEntry graphINReceiptEntry, 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 = graphINReceiptEntry.receipt.Current.DocType; fsPostInfoRow.INRefNbr = graphINReceiptEntry.receipt.Current.RefNbr; foreach (INTran inTranRowLocal in graphINReceiptEntry.transactions.Select()) { FSxINTran fsxINTranRow = graphINReceiptEntry.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 a Receipt document using the parameters [fsAppointmentRow], [fsServiceOrderRow], [fsServiceOrderTypeRow] and its posting information. /// </summary> public virtual void CreateDocumentReceipt(INReceiptEntry graphINReceiptEntry, SharedClasses.AppointmentInventoryItemInfo appointmentInventoryItemInfoRow, FSAppointmentDet fsAppointmentInventoryItemRow, DateTime?documentDate, string documentPeriod, FSPostBatch fsPostBatchRow, ref string inRefNbr, ref string inDocType) { if (appointmentInventoryItemInfoRow != null) { INRegister inRegisterRow; #region IN Receipt Header if (string.IsNullOrEmpty(inRefNbr)) { inRegisterRow = new INRegister(); inRegisterRow.DocType = INDocType.Receipt; inRegisterRow.TranDate = documentDate; inRegisterRow.FinPeriodID = documentPeriod; inRegisterRow.TranDesc = appointmentInventoryItemInfoRow.FSAppointmentRow.DocDesc; inRegisterRow.Hold = false; inRegisterRow.BranchID = appointmentInventoryItemInfoRow.FSServiceOrderRow.BranchID; inRegisterRow = graphINReceiptEntry.receipt.Current = graphINReceiptEntry.receipt.Insert(inRegisterRow); inRegisterRow = graphINReceiptEntry.receipt.Update(inRegisterRow); } else { inRegisterRow = graphINReceiptEntry.receipt.Current = graphINReceiptEntry.receipt.Search <INRegister.refNbr>(inRefNbr); } #endregion INTran inTranRow; inTranRow = new INTran(); inTranRow.TranType = INTranType.Receipt; inTranRow = graphINReceiptEntry.transactions.Current = graphINReceiptEntry.transactions.Insert(inTranRow); graphINReceiptEntry.transactions.Cache.SetValueExt <INTran.inventoryID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.InventoryID); if (PXAccess.FeatureInstalled <FeaturesSet.subItem>()) { graphINReceiptEntry.transactions.Cache.SetValueExt <INTran.subItemID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.SubItemID); } graphINReceiptEntry.transactions.Cache.SetValueExt <INTran.siteID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.SiteID); graphINReceiptEntry.transactions.Cache.SetValueExt <INTran.qty>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.Qty); graphINReceiptEntry.transactions.Cache.SetValueExt <INTran.unitCost>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.UnitPrice); graphINReceiptEntry.transactions.Cache.SetValueExt <INTran.projectID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.ProjectID); graphINReceiptEntry.transactions.Cache.SetValueExt <INTran.taskID>(inTranRow, appointmentInventoryItemInfoRow.FSAppointmentInventoryItem.ProjectTaskID); FSxINTran fsxINTranRow = graphINReceiptEntry.transactions.Cache.GetExtension <FSxINTran>(graphINReceiptEntry.transactions.Current); fsxINTranRow.Source = ID.Billing_By.APPOINTMENT; fsxINTranRow.SOID = appointmentInventoryItemInfoRow.FSAppointmentRow.SOID; 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 = graphINReceiptEntry.transactions.Update(inTranRow); graphINReceiptEntry.Save.Press(); if (string.IsNullOrEmpty(inRefNbr)) { inRefNbr = graphINReceiptEntry.receipt.Current.RefNbr; inDocType = graphINReceiptEntry.receipt.Current.DocType; } UpdateReceiptPostInfo(graphINReceiptEntry, 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); }
private INTranSplit addReceiptSplitLine(INReceiptEntry receiptEntry, INLocationStatus2 stat, INTransitLineLotSerialStatus lotstat, INTransitLine transitline, INTran tran, InventoryItem item, Decimal qty, string location) { INTranSplit newsplit; decimal newsplitqty; if (lotstat.QtyOnHand == null) { newsplit = new INTranSplit(); newsplit.InventoryID = stat.InventoryID; newsplit.IsStockItem = true; newsplit.FromSiteID = transitline.SiteID; newsplit.SubItemID = stat.SubItemID; newsplit.LotSerialNbr = null; newsplitqty = qty; } else { newsplit = new INTranSplit(); newsplit.InventoryID = lotstat.InventoryID; newsplit.IsStockItem = true; newsplit.FromSiteID = lotstat.FromSiteID; newsplit.SubItemID = lotstat.SubItemID; newsplit.LotSerialNbr = lotstat.LotSerialNbr; newsplitqty = qty; } newsplit.DocType = receiptEntry.receipt.Current.DocType; newsplit.RefNbr = receiptEntry.receipt.Current.RefNbr; newsplit.LineNbr = tran.LineNbr; newsplit.SplitLineNbr = (int)PXLineNbrAttribute.NewLineNbr <INTranSplit.splitLineNbr>(receiptEntry.splits.Cache, receiptEntry.receipt.Current); newsplit.UnitCost = 0m; newsplit.InvtMult = (short)1; newsplit.SiteID = transitline.ToSiteID; newsplit.PlanID = null; newsplit.Released = false; newsplit.ProjectID = null; newsplit.TaskID = null; if (location == null) { newsplit.LocationID = lotstat.ToLocationID ?? transitline.ToLocationID; } else { receiptEntry.splits.SetValueExt <INTranSplit.locationID>(newsplit, location); } newsplit = receiptEntry.splits.Insert(newsplit); newsplit.MaxTransferBaseQty = newsplitqty; newsplit.BaseQty = newsplitqty; newsplit.Qty = newsplit.BaseQty.Value; receiptEntry.UpdateCostSubItemID(newsplit, item); receiptEntry.SetCostAttributes(tran, newsplit, item, tran.OrigRefNbr); newsplit.UnitCost = PXCurrencyAttribute.BaseRound(receiptEntry, newsplit.UnitCost); receiptEntry.splits.Update(newsplit); return(newsplit); }