Beispiel #1
0
        protected virtual IEnumerable dummyCustomAction(PXAdapter adapter)
        {
            SOShipment      shipment        = Base.Document.Current;
            SOOrderShipment soOrderShipment = PXSelect <SOOrderShipment,
                                                        Where <SOOrderShipment.shipmentNbr, Equal <Required <SOOrderShipment.shipmentNbr> > > > .
                                              Select(Base, shipment.ShipmentNbr);

            ARInvoice arInvoice = PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARInvoice.refNbr> >,
                                                              And <ARInvoice.docType, Equal <Required <ARInvoice.docType> > > > > .
                                  Select(Base, soOrderShipment.InvoiceNbr, "INV");

            PXLongOperation.StartOperation(Base, delegate()
            {
                SOInvoiceEntry soInvoiceGraph   = PXGraph.CreateInstance <SOInvoiceEntry>();
                SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance <SOShipmentEntry>();
                //Release Sales Invoice
                soInvoiceGraph.Clear();
                soInvoiceGraph.Document.Current = soInvoiceGraph.Document.Search <ARInvoice.docType, ARInvoice.refNbr>(arInvoice.DocType, arInvoice.RefNbr);
                soInvoiceGraph.release.Press();
                //Update IN on Shipment
                soShipmentGraph.Clear();
                soShipmentGraph.Document.Current = soShipmentGraph.Document.Search <SOShipment.shipmentNbr>(shipment.ShipmentNbr);
                soShipmentGraph.UpdateIN.Press();
            });
            return(adapter.Get());
        }
Beispiel #2
0
        public bool CheckData(SOOrderShipment orderShipment, DateTime?dateFrom, DateTime?dateTo)
        {
            bool isBiggerThan = dateFrom.GetValueOrDefault() == default ? true : orderShipment.CreatedDateTime.GetValueOrDefault().BiggerThan(dateFrom.GetValueOrDefault());
            bool isLessThan   = dateTo.GetValueOrDefault() == default ? true : orderShipment.CreatedDateTime.GetValueOrDefault().LessThan(dateTo.GetValueOrDefault());

            return(isBiggerThan && isLessThan);
        }
Beispiel #3
0
        public virtual void EnsureCanCancel(ARInvoice doc, bool isCorrection)
        {
            if (doc.DocType != ARDocType.Invoice)
            {
                throw new PXException(Messages.CantCancelDocType, doc.DocType);
            }

            if (doc.InstallmentCntr > 0)
            {
                throw new PXException(Messages.CantCancelMultipleInstallmentsInvoice);
            }

            var arAdjustGroups = PXSelectGroupBy <ARAdjust,
                                                  Where <ARAdjust.adjdDocType, Equal <Current <ARInvoice.docType> >, And <ARAdjust.adjdRefNbr, Equal <Current <ARInvoice.refNbr> > > >,
                                                  Aggregate <
                                                      GroupBy <ARAdjust.adjgDocType, GroupBy <ARAdjust.adjgRefNbr, GroupBy <ARAdjust.released,
                                                                                                                            Sum <ARAdjust.curyAdjdAmt> > > > > >
                                 .SelectMultiBound(Base, new[] { doc })
                                 .RowCast <ARAdjust>().ToList();

            if (arAdjustGroups.Any(a => a.Released == false))
            {
                throw new PXException(Messages.CantCancelInvoiceWithUnreleasedApplications);
            }

            var nonReversedCreditMemo = arAdjustGroups.FirstOrDefault(a => a.CuryAdjdAmt != 0m && a.AdjgDocType == ARDocType.CreditMemo);

            if (nonReversedCreditMemo != null)
            {
                throw new PXException(Messages.CantCancelInvoiceWithCM, nonReversedCreditMemo.AdjdRefNbr, nonReversedCreditMemo.AdjgRefNbr);
            }

            var nonReversedApplication = arAdjustGroups.FirstOrDefault(a => a.CuryAdjdAmt != 0m);

            if (nonReversedApplication != null)
            {
                throw new PXException(Messages.CantCancelInvoiceWithPayment, nonReversedApplication.AdjdRefNbr, nonReversedApplication.AdjgRefNbr);
            }

            ARTran directSale = PXSelectReadonly <ARTran,
                                                  Where <ARTran.tranType, Equal <Current <ARInvoice.docType> >, And <ARTran.refNbr, Equal <Current <ARInvoice.refNbr> >,
                                                                                                                     And <ARTran.invtMult, NotEqual <short0>, And <ARTran.lineType, Equal <SOLineType.inventory> > > > > >
                                .SelectSingleBound(Base, new[] { doc });

            if (directSale != null)
            {
                throw new PXException(Messages.CantCancelInvoiceWithDirectStockSales, doc.RefNbr);
            }

            SOOrderShipment notRequireShipment = PXSelectReadonly <SOOrderShipment,
                                                                   Where <SOOrderShipment.invoiceType, Equal <Current <ARInvoice.docType> >, And <SOOrderShipment.invoiceNbr, Equal <Current <ARInvoice.refNbr> >,
                                                                                                                                                  And <SOOrderShipment.shipmentNbr, Equal <Constants.noShipmentNbr> > > > >
                                                 .SelectSingleBound(Base, new[] { doc });

            if (notRequireShipment != null)
            {
                throw new PXException(Messages.CantCancelInvoiceWithOrdersNotRequiringShipments, doc.RefNbr);
            }
        }
        public virtual ARTran CreateTranFromMiscLine(SOOrderShipment orderShipment, SOMiscLine2 orderline, CreateTranFromMiscLineDelegate baseMethod)
        {
            ARTran tran = baseMethod(orderShipment, orderline);
            SOLine line = PXSelect <SOLine, Where <SOLine.orderType, Equal <Required <SOLine.orderType> >,
                                                   And <SOLine.orderNbr, Equal <Required <SOLine.orderNbr> >,
                                                        And <SOLine.lineNbr, Equal <Required <SOLine.lineNbr> > > > > > .Select(Base, orderline.OrderType, orderline.OrderNbr, orderline.LineNbr);

            SOLineRUTROT lineRR = PXCache <SOLine> .GetExtension <SOLineRUTROT>(line);

            ARTranRUTROT tranRR = PXCache <ARTran> .GetExtension <ARTranRUTROT>(tran);

            tranRR.IsRUTROTDeductible = lineRR.IsRUTROTDeductible;
            tranRR.RUTROTItemType     = lineRR.RUTROTItemType;
            tranRR.RUTROTWorkTypeID   = lineRR.RUTROTWorkTypeID;
            return(tran);
        }
        public void ConfirmShipment(SOOrderEntry docgraph, SOShipment shiporder, Action <SOOrderEntry, SOShipment> baseMethod)
        {
            baseMethod(docgraph, shiporder);

            SOPackageDetail TNbr = FirstTrackingNumber.Select(shiporder.ShipmentNbr);

            if (TNbr != null)
            {
                SOOrderShipment ShipNbr = OrderShipment.Select(shiporder.ShipmentType, shiporder.ShipmentNbr);
                if (ShipNbr != null)
                {
                    ShipNbr.GetExtension <SOOrderShipmentExt>().UsrShipmentTrackingNbr = TNbr.TrackNumber;
                    OrderShipment.Cache.Update(ShipNbr);
                    Base.Save.Press();
                }
            }
        }
        public static void GetTargetTypeAndKeys(SOOrderShipment row, out Type targetType, out object[] targetKeys)
        {
            targetType = null;
            targetKeys = null;

            if (row != null && row.ShipmentType.IsIn(INDocType.Issue, INDocType.Transfer) && !string.Equals(row.ShipmentNbr, Constants.NoShipmentNbr))
            {
                targetType = typeof(SOShipment);
                targetKeys = new object[] { row.ShipmentNbr };
            }
            else if (row != null && row.ShipmentType == INDocType.DropShip && !string.IsNullOrEmpty(row.ShipmentNbr))
            {
                targetType = typeof(POReceipt);
                targetKeys = new object[] { PO.POReceiptType.POReceipt, row.ShipmentNbr };
            }
            else if (row != null &&
                     (row.ShipmentType == INDocType.Issue && string.Equals(row.ShipmentNbr, Constants.NoShipmentNbr) || row.ShipmentType == INDocType.Invoice) &&
                     !string.IsNullOrEmpty(row.InvoiceType) && !string.IsNullOrEmpty(row.InvoiceNbr))
            {
                targetType = typeof(ARInvoice);
                targetKeys = new object[] { row.InvoiceType, row.InvoiceNbr };
            }
        }
        protected virtual void SOShipment_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
        {
            baseHandler?.Invoke(sender, e);

            if (e.Row == null)
            {
                return;
            }

            SOShipment      row           = (SOShipment)e.Row;
            KCSOShipmentExt rowKCExt      = row.GetExtension <KCSOShipmentExt>();
            SOOrderShipment orderShipment = PXSelect <SOOrderShipment, Where <SOOrderShipment.shipmentNbr,
                                                                              Equal <Required <SOOrderShipment.shipmentNbr> > > > .Select(Base, row.ShipmentNbr);

            if (orderShipment != null)
            {
                SOOrder order = PXSelect <SOOrder, Where <SOOrder.orderNbr,
                                                          Equal <Required <SOOrder.orderNbr> > > > .Select(Base, orderShipment.OrderNbr);

                bool?FBA         = order?.GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("/FBA");
                var  buttonMenus = (Base.Actions["action"].GetState(null) as PXButtonState)?.Menus;

                if (FBA == true)
                {
                    bool enable = Base.Accessinfo.ScreenID == "KC.50.10.00";

                    var reportMenus = (Base.report.GetState(null) as PXButtonState)?.Menus;

                    foreach (var action in reportMenus)
                    {
                        action.Enabled = enable;
                    }

                    foreach (var action in buttonMenus)
                    {
                        if (action.Text != "Prepare Invoice")
                        {
                            action.Enabled = enable;
                        }
                    }

                    Base.Actions["InventorySummary"].SetEnabled(enable);
                    Base.Actions["LSSOShipLine_binLotSerial"].SetEnabled(enable);
                    Base.CarrierRatesExt.recalculatePackages.SetEnabled(enable);
                    Base.UpdateIN.SetEnabled(enable);
                    Base.Delete.SetEnabled(enable);

                    sender.AllowUpdate = enable;

                    Base.Transactions.Cache.AllowInsert = enable;
                    Base.Transactions.Cache.AllowUpdate = enable;
                    Base.Transactions.Cache.AllowDelete = enable;

                    Base.OrderList.View.AllowInsert = enable;
                    Base.OrderList.View.AllowUpdate = enable;
                    Base.OrderList.View.AllowDelete = enable;
                }
                else if (rowKCExt?.UsrKCExported == true)
                {
                    foreach (var action in buttonMenus)
                    {
                        if (action.Text.Equals("Correct Shipment"))
                        {
                            action.Enabled = false;
                        }
                    }
                }
            }
        }