示例#1
0
        public static void ReleaseDocs(List <Document> list)
        {
            ReceiptEntry graph = PXGraph.CreateInstance <ReceiptEntry>();

            foreach (Document doc in list)
            {
                graph.Clear();
                graph.Receipts.Current = graph.Receipts.Search <Document.docNbr>(doc.DocNbr, doc.DocType);
                foreach (DocTransaction line in graph.ReceiptTransactions.Select())
                {
                    ProductQty productQty = new ProductQty();
                    productQty.ProductID = line.ProductID;
                    if (doc.DocType == DocTypes.Recpt)
                    {
                        productQty.AvailQty = line.TranQty * line.ConversionFactor;
                        SupplierData suppData = new SupplierData();
                        suppData.SupplierID        = doc.SupplierID;
                        suppData.ProductID         = line.ProductID;
                        suppData.LastPurchaseDate  = doc.DocDate;
                        suppData.LastSupplierPrice = line.UnitPrice;
                        suppData.ConversionFactor  = line.ConversionFactor;
                        suppData.SupplierUnit      = line.Unit;
                        graph.SupplierRecords.Insert(suppData);
                    }
                    else
                    {
                        productQty.AvailQty = -(line.TranQty * line.ConversionFactor);
                    }
                    graph.Stock.Insert(productQty);
                }
                doc.Released = true;
                graph.Receipts.Update(doc);
                graph.Persist();
            }
        }
示例#2
0
        protected override bool PrepareInsert(PXCache sender, object row, PXAccumulatorCollection columns)
        {
            if (!base.PrepareInsert(sender, row, columns))
            {
                return(false);
            }
            ProductQty newQty = (ProductQty)row;

            if (newQty.AvailQty < 0m)
            {
                columns.AppendException("Updating product quantity in stock will lead to a negative value.",
                                        new PXAccumulatorRestriction <ProductQty.availQty>(PXComp.GE, 0m));
            }
            columns.Update <ProductQty.availQty>(newQty.AvailQty, PXDataFieldAssign.AssignBehavior.Summarize);
            return(true);
        }
示例#3
0
        public static void ReleaseOrder(SalesOrder order)
        {
            SalesOrderEntry graph = PXGraph.CreateInstance <SalesOrderEntry>();

            graph.Orders.Current = order;

            foreach (OrderLine line in graph.OrderDetails.Select())
            {
                ProductQty productQty = new ProductQty();
                productQty.ProductID = line.ProductID;
                productQty.AvailQty  = -line.OrderQty;
                graph.Stock.Insert(productQty);
            }
            order.ShippedDate = graph.Accessinfo.BusinessDate;
            order.Status      = OrderStatus.Completed;
            graph.Orders.Update(order);

            graph.Persist();
        }