public void ReleaseDocProc(JournalEntry je, INRegister doc, INReleaseProcess_Extension.ReleaseDocProcDelegate baseMethod) { baseMethod(je, doc); foreach (INTranSplit row in this.Base.intransplit.Cache.Cached) { INTranSplit tranSplit = SelectINTranRcpSplit(Base, row.LotSerialNbr, row.InventoryID, row.SubItemID, row.SiteID, row.LocationID); if (tranSplit != null && row.DocType != INDocType.Receipt) { INTranSplitExt tranSplitExt = tranSplit.GetExtension <INTranSplitExt>(); Base.intransplit.Cache.SetValue <INTranSplitExt.usrCOO>(row, tranSplitExt.UsrCOO); Base.intransplit.Cache.SetValue <INTranSplitExt.usrDateCode>(row, tranSplitExt.UsrDateCode); } else { SOShipLineSplit lineSplit = SelectSOShipLineSplit(Base, row.LotSerialNbr, row.InventoryID, row.SubItemID, row.SiteID, row.LocationID); if (lineSplit == null) { continue; } SOShipLineSplitExt lineSplitExt = lineSplit.GetExtension <SOShipLineSplitExt>(); Base.intransplit.Cache.SetValue <INTranSplitExt.usrCOO>(row, lineSplitExt.UsrCOO); Base.intransplit.Cache.SetValue <INTranSplitExt.usrDateCode>(row, lineSplitExt.UsrDateCode); } Base.Caches[typeof(INTranSplit)].PersistUpdated(this.Base.Caches[typeof(INTranSplit)].Update(row)); PXTimeStampScope.PutPersisted(this.Base.Caches[typeof(INTranSplit)], row, PXDatabase.SelectTimeStamp()); } }
private void UpgradeEquipmentComponents( SMEquipmentMaint graphSMEquipmentMaint, ARRegister arRegisterRow, Dictionary <int?, int?> newEquiments) { var inventoryItemSet = PXSelectJoin <InventoryItem, InnerJoin <ARTran, On <ARTran.inventoryID, Equal <InventoryItem.inventoryID>, And <ARTran.tranType, Equal <ARDocType.invoice> > >, InnerJoin <SOLineSplit, On <SOLineSplit.orderType, Equal <ARTran.sOOrderType>, And <SOLineSplit.orderNbr, Equal <ARTran.sOOrderNbr>, And <SOLineSplit.lineNbr, Equal <ARTran.sOOrderLineNbr>, And <SOLineSplit.qty, Greater <Zero> > > > >, InnerJoin <SOLine, On <SOLine.orderType, Equal <SOLineSplit.orderType>, And <SOLine.orderNbr, Equal <SOLineSplit.orderNbr>, And <SOLine.lineNbr, Equal <SOLineSplit.lineNbr> > > >, LeftJoin <SOShipLineSplit, On <SOShipLineSplit.origOrderType, Equal <SOLineSplit.orderType>, And <SOShipLineSplit.origOrderNbr, Equal <SOLineSplit.orderNbr>, And <SOShipLineSplit.origLineNbr, Equal <SOLineSplit.lineNbr>, And <SOShipLineSplit.origSplitLineNbr, Equal <SOLineSplit.splitLineNbr> > > > > > > > >, Where < ARTran.tranType, Equal <Required <ARInvoice.docType> >, And <ARTran.refNbr, Equal <Required <ARInvoice.refNbr> >, And <FSxSOLine.equipmentAction, Equal <ListField_EquipmentAction.UpgradingComponent>, And <FSxSOLine.sMEquipmentID, IsNull, And <FSxSOLine.newTargetEquipmentLineNbr, IsNotNull, And <FSxSOLine.componentID, IsNotNull, And <FSxSOLine.equipmentLineRef, IsNull, And <SOLineSplit.pOCreate, Equal <False> > > > > > > > >, OrderBy < Asc <ARTran.tranType, Asc <ARTran.refNbr, Asc <ARTran.lineNbr> > > > > .Select(Base, arRegisterRow.DocType, arRegisterRow.RefNbr); foreach (PXResult <InventoryItem, ARTran, SOLineSplit, SOLine, SOShipLineSplit> bqlResult in inventoryItemSet) { ARTran arTranRow = (ARTran)bqlResult; InventoryItem inventoryItemRow = (InventoryItem)bqlResult; SOLine soLineRow = (SOLine)bqlResult; SOLineSplit soLineSplitRow = (SOLineSplit)bqlResult; SOShipLineSplit soShipLineSplitRow = (SOShipLineSplit)bqlResult; FSxSOLine fsxSOLineRow = PXCache <SOLine> .GetExtension <FSxSOLine>(soLineRow); FSxARTran fsxARTranRow = PXCache <ARTran> .GetExtension <FSxARTran>(arTranRow); int?smEquipmentID = -1; if (newEquiments.TryGetValue(fsxSOLineRow.NewTargetEquipmentLineNbr, out smEquipmentID)) { graphSMEquipmentMaint.EquipmentRecords.Current = graphSMEquipmentMaint.EquipmentRecords.Search <FSEquipment.SMequipmentID>(smEquipmentID); FSEquipmentComponent fsEquipmentComponentRow = graphSMEquipmentMaint.EquipmentWarranties.Select().Where(x => ((FSEquipmentComponent)x).ComponentID == fsxSOLineRow.ComponentID).FirstOrDefault(); if (fsEquipmentComponentRow != null) { fsEquipmentComponentRow.SalesOrderNbr = soLineRow.OrderNbr; fsEquipmentComponentRow.SalesOrderType = soLineRow.OrderType; fsEquipmentComponentRow.LongDescr = soLineRow.TranDesc; fsEquipmentComponentRow.InvoiceRefNbr = arTranRow.RefNbr; fsEquipmentComponentRow.InstallationDate = arTranRow.TranDate != null ? arTranRow.TranDate : arRegisterRow.DocDate; if (fsxSOLineRow != null) { if (fsxSOLineRow.AppointmentID != null) { fsEquipmentComponentRow.InstAppointmentID = fsxSOLineRow.AppointmentID; fsEquipmentComponentRow.InstallationDate = fsxSOLineRow.AppointmentDate; } else if (fsxSOLineRow.SOID != null) { fsEquipmentComponentRow.InstServiceOrderID = fsxSOLineRow.SOID; fsEquipmentComponentRow.InstallationDate = fsxSOLineRow.ServiceOrderDate; } fsEquipmentComponentRow.Comment = fsxSOLineRow.Comment; } if (soLineSplitRow != null) { fsEquipmentComponentRow.SerialNumber = soLineSplitRow.LotSerialNbr; } if (fsEquipmentComponentRow.SerialNumber == null && soShipLineSplitRow != null) { fsEquipmentComponentRow.SerialNumber = soShipLineSplitRow.LotSerialNbr; } fsEquipmentComponentRow = graphSMEquipmentMaint.EquipmentWarranties.Update(fsEquipmentComponentRow); graphSMEquipmentMaint.EquipmentWarranties.SetValueExt <FSEquipmentComponent.inventoryID>(fsEquipmentComponentRow, soLineRow.InventoryID); graphSMEquipmentMaint.EquipmentWarranties.SetValueExt <FSEquipmentComponent.salesDate>(fsEquipmentComponentRow, soLineRow.OrderDate); graphSMEquipmentMaint.Save.Press(); } } } }
private void Create_Replace_Equipments( SMEquipmentMaint graphSMEquipmentMaint, PXResultset <InventoryItem> inventoryItemSet, ARRegister arRegisterRow, Dictionary <int?, int?> newEquiments, string action) { foreach (PXResult <InventoryItem, ARTran, SOLineSplit, SOLine, SOShipLineSplit> bqlResult in inventoryItemSet) { ARTran arTranRow = (ARTran)bqlResult; InventoryItem inventoryItemRow = (InventoryItem)bqlResult; SOLine soLineRow = (SOLine)bqlResult; SOLineSplit soLineSplitRow = (SOLineSplit)bqlResult; SOShipLineSplit soShipLineSplitRow = (SOShipLineSplit)bqlResult; FSEquipment fsEquipmentRow = null; FSxSOLine fsxSOLineRow = PXCache <SOLine> .GetExtension <FSxSOLine>(soLineRow); FSxARTran fsxARTranRow = PXCache <ARTran> .GetExtension <FSxARTran>(arTranRow); FSxEquipmentModel fsxEquipmentModelRow = PXCache <InventoryItem> .GetExtension <FSxEquipmentModel>(inventoryItemRow); int?iteratorMax = (int?)(soShipLineSplitRow == null || soShipLineSplitRow.Qty == null ? soLineSplitRow.Qty : soShipLineSplitRow.Qty); for (int i = 0; i < iteratorMax; i++) { SoldInventoryItem soldInventoryItemRow = new SoldInventoryItem(); soldInventoryItemRow.CustomerID = arRegisterRow.CustomerID; soldInventoryItemRow.CustomerLocationID = arRegisterRow.CustomerLocationID; soldInventoryItemRow.InventoryID = inventoryItemRow.InventoryID; soldInventoryItemRow.InventoryCD = inventoryItemRow.InventoryCD; soldInventoryItemRow.InvoiceRefNbr = arTranRow.RefNbr; soldInventoryItemRow.InvoiceLineNbr = arTranRow.LineNbr; soldInventoryItemRow.DocType = arRegisterRow.DocType; soldInventoryItemRow.DocDate = arTranRow.TranDate != null ? arTranRow.TranDate : arRegisterRow.DocDate; if (fsxSOLineRow != null) { if (fsxSOLineRow.AppointmentID != null) { soldInventoryItemRow.DocDate = fsxSOLineRow.AppointmentDate; } else if (fsxSOLineRow.SOID != null) { soldInventoryItemRow.DocDate = fsxSOLineRow.ServiceOrderDate; } } soldInventoryItemRow.Descr = inventoryItemRow.Descr; soldInventoryItemRow.SiteID = arTranRow.SiteID; soldInventoryItemRow.ItemClassID = inventoryItemRow.ItemClassID; soldInventoryItemRow.SOOrderType = soLineRow.OrderType; soldInventoryItemRow.SOOrderNbr = soLineRow.OrderNbr; soldInventoryItemRow.SOOrderDate = soLineRow.OrderDate; soldInventoryItemRow.EquipmentTypeID = fsxEquipmentModelRow.EquipmentTypeID; if (soLineSplitRow != null) { soldInventoryItemRow.LotSerialNumber = soLineSplitRow.LotSerialNbr; } if (soldInventoryItemRow.LotSerialNumber == null && soShipLineSplitRow != null) { soldInventoryItemRow.LotSerialNumber = soShipLineSplitRow.LotSerialNbr; } fsEquipmentRow = SharedFunctions.CreateSoldEquipment(graphSMEquipmentMaint, soldInventoryItemRow, soLineRow, fsxSOLineRow, action, inventoryItemRow); } if (fsEquipmentRow != null) { fsxARTranRow.SMEquipmentID = fsEquipmentRow.SMEquipmentID; Base.ARTran_TranType_RefNbr.Update(arTranRow); if (action == ID.Equipment_Action.SELLING_TARGET_EQUIPMENT) { int?smEquipmentID = -1; if (newEquiments.TryGetValue(soLineRow.LineNbr, out smEquipmentID) == false) { newEquiments.Add( soLineRow.LineNbr, fsEquipmentRow.SMEquipmentID); } } else if (action == ID.Equipment_Action.REPLACING_TARGET_EQUIPMENT) { if (fsxSOLineRow != null) { graphSMEquipmentMaint.EquipmentRecords.Current = graphSMEquipmentMaint.EquipmentRecords.Search <FSEquipment.SMequipmentID>(fsxSOLineRow.SMEquipmentID); graphSMEquipmentMaint.EquipmentRecords.Current.ReplaceEquipmentID = fsEquipmentRow.SMEquipmentID; graphSMEquipmentMaint.EquipmentRecords.Current.Status = ID.Equipment_Status.DISPOSED; graphSMEquipmentMaint.EquipmentRecords.Current.DisposalDate = soLineRow.OrderDate; graphSMEquipmentMaint.EquipmentRecords.Current.DispServiceOrderID = fsxSOLineRow.SOID; graphSMEquipmentMaint.EquipmentRecords.Current.DispAppointmentID = fsxSOLineRow.AppointmentID; graphSMEquipmentMaint.EquipmentRecords.Cache.SetStatus(graphSMEquipmentMaint.EquipmentRecords.Current, PXEntryStatus.Updated); graphSMEquipmentMaint.Save.Press(); } } } } }