protected int?GetSOIDRelated(ARTran tran)
        {
            int?SOID;

            FSxARTran fsxARTranRow = PXCache <ARTran> .GetExtension <FSxARTran>(tran);

            SOID = fsxARTranRow?.SOID;

            if (SOID == null)
            {
                var soLine = PXSelect <SOLine,
                                       Where <SOLine.orderType, Equal <Required <ARTran.sOOrderType> >,
                                              And <SOLine.orderNbr, Equal <Required <ARTran.sOOrderNbr> >,
                                                   And <SOLine.lineNbr, Equal <Required <ARTran.sOOrderLineNbr> > > > > >
                             .Select(Base, tran.SOOrderType, tran.SOOrderNbr, tran.SOOrderLineNbr)
                             .RowCast <SOLine>()
                             .FirstOrDefault();

                if (soLine != null)
                {
                    FSxSOLine fsxSOLineRow = PXCache <SOLine> .GetExtension <FSxSOLine>(soLine);

                    SOID = fsxSOLineRow?.SOID;
                }
            }

            return(SOID);
        }
 public SOLineEquipmentComponent(ContractInvoiceLine docLine, SOLine sOLineRow, FSxSOLine fSxSOLineRow)
 {
     this.componentID     = docLine.ComponentID;
     this.currentLineRef  = sOLineRow.LineNbr;
     this.equipmentAction = docLine.EquipmentAction;
     this.sourceLineRef   = docLine.LineRef;
     this.sourceNewTargetEquipmentLineNbr = docLine.NewTargetEquipmentLineNbr;
     this.fsxSOLineRow = fSxSOLineRow;
 }
Ejemplo n.º 3
0
 public SOPrepaymentBySO(SOLine soLineRow, FSxSOLine fsxSOLineRow, decimal soTaxLine)
 {
     SOID           = fsxSOLineRow.SOID;
     unpaidAmount   = 0;
     unpaidAmount  += (soLineRow.CuryLineAmt ?? 0m) + soTaxLine;
     originalAmount = unpaidAmount;
     fsxSOLineList  = new List <FSxSOLine>();
     fsxSOLineList.Add(fsxSOLineRow);
 }
Ejemplo n.º 4
0
 public SOARLineEquipmentComponent(IDocLine docLine, ARTran arTranRow, FSxARTran fsxARTranRow)
 {
     this.componentID     = docLine.ComponentID;
     this.currentLineRef  = arTranRow.LineNbr;
     this.equipmentAction = docLine.EquipmentAction;
     this.sourceLineRef   = docLine.LineRef;
     this.sourceNewTargetEquipmentLineNbr = docLine.NewTargetEquipmentLineNbr;
     this.fsxARTranRow = fsxARTranRow;
     this.fsxSOLineRow = null;
 }
Ejemplo n.º 5
0
            public void Add(SOLine soLineRow, FSxSOLine fsxSOLineRow, decimal soTaxLine)
            {
                if (fsxSOLineRow.SOID == null)
                {
                    return;
                }

                SOPrepaymentBySO row = SOPrepaymentList.Find(x => x.SOID.Equals(fsxSOLineRow.SOID));

                if (row != null)
                {
                    row.unpaidAmount += (soLineRow.CuryLineAmt ?? 0m) + soTaxLine;
                    row.fsxSOLineList.Add(fsxSOLineRow);
                }
                else
                {
                    SOPrepaymentBySO newRow = new SOPrepaymentBySO(soLineRow, fsxSOLineRow, soTaxLine);
                    SOPrepaymentList.Add(newRow);
                }
            }
        public virtual void FillEquipmentFields(PXCache cache, ARTran arTranRow)
        {
            if (arTranRow.SOOrderType != null &&
                arTranRow.SOOrderNbr != null &&
                arTranRow.SOOrderLineNbr != null)
            {
                PXResult <SOLine, SOOrder, FSServiceOrder, FSAppointment> bqlResult = (PXResult <SOLine, SOOrder, FSServiceOrder, FSAppointment>)
                                                                                      PXSelectJoin <SOLine,
                                                                                                    InnerJoin <SOOrder,
                                                                                                               On <SOOrder.orderNbr, Equal <SOLine.orderNbr>,
                                                                                                                   And <SOOrder.orderType, Equal <SOLine.orderType> > >,
                                                                                                               LeftJoin <FSServiceOrder,
                                                                                                                         On <
                                                                                                                             Where2 <
                                                                                                                                 Where <
                                                                                                                                     FSServiceOrder.refNbr, Equal <FSxSOOrder.soRefNbr>,
                                                                                                                                     And <FSServiceOrder.srvOrdType, Equal <FSxSOOrder.srvOrdType> > >,
                                                                                                                                 Or <FSServiceOrder.sOID, Equal <FSxSOLine.sOID> > > >,
                                                                                                                         LeftJoin <FSAppointment,
                                                                                                                                   On <FSAppointment.appointmentID, Equal <FSxSOLine.appointmentID> > > > >,
                                                                                                    Where <
                                                                                                        SOLine.orderType, Equal <Required <SOLine.orderType> >,
                                                                                                        And <
                                                                                                            SOLine.orderNbr, Equal <Required <SOLine.orderNbr> >,
                                                                                                            And <
                                                                                                                SOLine.lineNbr, Equal <Required <SOLine.lineNbr> > > > > >
                                                                                      .Select(cache.Graph, arTranRow.SOOrderType, arTranRow.SOOrderNbr, arTranRow.SOOrderLineNbr);

                SOLine         soLineRow         = (SOLine)bqlResult;
                SOOrder        soOrderRow        = (SOOrder)bqlResult;
                FSServiceOrder fsServiceOrderRow = (FSServiceOrder)bqlResult;
                FSAppointment  fsAppointmentRow  = (FSAppointment)bqlResult;

                if (soLineRow != null)
                {
                    FSxSOOrder fsxSOOrderRow = PXCache <SOOrder> .GetExtension <FSxSOOrder>(soOrderRow);

                    FSxSOLine fsxSOLineRow = PXCache <SOLine> .GetExtension <FSxSOLine>(soLineRow);

                    FSxARTran fsxARTranRow = cache.GetExtension <FSxARTran>(arTranRow);

                    if (fsxSOLineRow.EquipmentAction == ID.Equipment_Action.CREATING_COMPONENT ||
                        fsxSOLineRow.EquipmentAction == ID.Equipment_Action.REPLACING_COMPONENT)
                    {
                        fsxARTranRow.SMEquipmentID = fsxSOLineRow.SMEquipmentID;
                    }
                    else
                    {
                        fsxARTranRow.SuspendedSMEquipmentID = fsxSOLineRow.SMEquipmentID;
                    }

                    fsxARTranRow.NewTargetEquipmentLineNbr = fsxSOLineRow.NewTargetEquipmentLineNbr;
                    fsxARTranRow.ComponentID = fsxSOLineRow.ComponentID;

                    if (fsxSOOrderRow.SDEnabled == true ||
                        fsServiceOrderRow.SOID != null)
                    {
                        fsxARTranRow.SOID               = fsServiceOrderRow.SOID;
                        fsxARTranRow.BillCustomerID     = fsServiceOrderRow.BillCustomerID;
                        fsxARTranRow.CustomerLocationID = fsServiceOrderRow.BillLocationID;
                    }

                    if (fsAppointmentRow?.AppointmentID != null)
                    {
                        fsxARTranRow.AppointmentID   = fsAppointmentRow.AppointmentID;
                        fsxARTranRow.AppointmentDate = fsAppointmentRow.ScheduledDateTimeBegin;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 8
0
        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();
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public virtual void FillEquipmentFields(PXCache cache, ARTran arTranRow)
        {
            if (arTranRow.SOOrderType != null &&
                arTranRow.SOOrderNbr != null &&
                arTranRow.SOOrderLineNbr != null)
            {
                PXResult <SOLine, SOOrder, FSServiceOrder, FSAppointment> bqlResult = (PXResult <SOLine, SOOrder, FSServiceOrder, FSAppointment>)
                                                                                      PXSelectJoin <SOLine,
                                                                                                    InnerJoin <SOOrder,
                                                                                                               On <
                                                                                                                   SOOrder.orderNbr, Equal <SOLine.orderNbr>,
                                                                                                                   And <SOOrder.orderType, Equal <SOLine.orderType> > >,
                                                                                                               LeftJoin <FSServiceOrder,
                                                                                                                         On <
                                                                                                                             Where2 <
                                                                                                                                 Where <
                                                                                                                                     FSServiceOrder.refNbr, Equal <FSxSOOrder.soRefNbr>,
                                                                                                                                     And <FSServiceOrder.srvOrdType, Equal <FSxSOOrder.srvOrdType> > >,
                                                                                                                                 Or <FSServiceOrder.sOID, Equal <FSxSOLine.sOID> > > >,
                                                                                                                         LeftJoin <FSAppointment,
                                                                                                                                   On <
                                                                                                                                       FSAppointment.appointmentID, Equal <FSxSOLine.appointmentID> > > > >,
                                                                                                    Where <
                                                                                                        SOLine.orderType, Equal <Required <SOLine.orderType> >,
                                                                                                        And <
                                                                                                            SOLine.orderNbr, Equal <Required <SOLine.orderNbr> >,
                                                                                                            And <
                                                                                                                SOLine.lineNbr, Equal <Required <SOLine.lineNbr> > > > > >
                                                                                      .Select(cache.Graph, arTranRow.SOOrderType, arTranRow.SOOrderNbr, arTranRow.SOOrderLineNbr);

                SOLine         soLineRow         = (SOLine)bqlResult;
                SOOrder        soOrderRow        = (SOOrder)bqlResult;
                FSServiceOrder fsServiceOrderRow = (FSServiceOrder)bqlResult;
                FSAppointment  fsAppointmentRow  = (FSAppointment)bqlResult;

                if (soLineRow != null)
                {
                    FSxSOOrder fsxSOOrderRow = PXCache <SOOrder> .GetExtension <FSxSOOrder>(soOrderRow);

                    FSxSOLine fsxSOLineRow = PXCache <SOLine> .GetExtension <FSxSOLine>(soLineRow);

                    FSxARTran fsxARTranRow = cache.GetExtension <FSxARTran>(arTranRow);

                    fsxARTranRow.SMEquipmentID    = fsxSOLineRow.SMEquipmentID;
                    fsxARTranRow.ComponentID      = fsxSOLineRow.ComponentID;
                    fsxARTranRow.EquipmentLineRef = fsxSOLineRow.EquipmentLineRef;
                    fsxARTranRow.EquipmentAction  = fsxSOLineRow.EquipmentAction;
                    fsxARTranRow.Comment          = fsxSOLineRow.Comment;

                    SOLine soLineRow2 = PXSelect <SOLine,
                                                  Where <
                                                      SOLine.orderType, Equal <Required <SOLine.orderType> >,
                                                      And <SOLine.orderNbr, Equal <Required <SOLine.orderNbr> >,
                                                           And <SOLine.lineNbr, Equal <Required <SOLine.lineNbr> > > > > >
                                        .Select(cache.Graph, arTranRow.SOOrderType, arTranRow.SOOrderNbr, fsxSOLineRow.NewTargetEquipmentLineNbr);

                    if (soLineRow2 != null)
                    {
                        ARTran arTranRow2 = Base.Transactions.Select().Where(x => ((ARTran)x).SOOrderType == arTranRow.SOOrderType &&
                                                                             ((ARTran)x).SOOrderNbr == arTranRow.SOOrderNbr &&
                                                                             ((ARTran)x).SOOrderLineNbr == soLineRow2.LineNbr).RowCast <ARTran>().FirstOrDefault();

                        fsxARTranRow.NewTargetEquipmentLineNbr = arTranRow2?.LineNbr;
                    }

                    if (fsxSOOrderRow.SDEnabled == true ||
                        fsServiceOrderRow.SOID != null)
                    {
                        fsxARTranRow.SOID = fsServiceOrderRow.SOID;

                        fsxARTranRow.BillCustomerID     = fsServiceOrderRow.CustomerID;
                        fsxARTranRow.CustomerLocationID = fsServiceOrderRow.LocationID;
                    }

                    if (fsAppointmentRow?.AppointmentID != null)
                    {
                        fsxARTranRow.AppointmentID   = fsAppointmentRow.AppointmentID;
                        fsxARTranRow.AppointmentDate = fsAppointmentRow.ScheduledDateTimeBegin;
                    }
                }
            }
        }
        protected int?GetSOIDRelated(SOLine line)
        {
            FSxSOLine row = PXCache <SOLine> .GetExtension <FSxSOLine>(line);

            return(row?.SOID);
        }