Beispiel #1
0
 protected void ClearTotals(ref SupplierProduct pendingProduct, ref Supplier pendingSupplier,
                            ref int supplierCount, List <string> countries)
 {
     pendingProduct  = null;
     pendingSupplier = null;
     supplierCount   = 0;
     countries.Clear();
 }
Beispiel #2
0
        protected virtual void viewProduct()
        {
            SupplierProduct row   = SupplierProducts.Current;
            ProductMaint    graph = PXGraph.CreateInstance <ProductMaint>();

            graph.Products.Current = graph.Products.Search <Product.productID>(row.ProductID);
            if (graph.Products.Current != null)
            {
                throw new PXRedirectRequiredException(graph, true, "Product Details");
            }
        }
Beispiel #3
0
        protected virtual IEnumerable supplierProducts()
        {
            PXSelectBase <SupplierProduct> query =
                new PXSelectReadonly3 <SupplierProduct,
                                       InnerJoin <Supplier, On <Supplier.supplierID, Equal <SupplierProduct.supplierID> > >,
                                       OrderBy <Asc <SupplierProduct.productID, Asc <SupplierProduct.supplierID> > > >(this);

            SupplierFilter filter = Filter.Current;

            if (filter.CountryCD != null)
            {
                query.WhereAnd <Where <Supplier.countryCD, Equal <Current <SupplierFilter.countryCD> > > >();
            }
            if (filter.MinOrderQty != null)
            {
                query.WhereAnd <Where <SupplierProduct.minOrderQty, GreaterEqual <Current <SupplierFilter.minOrderQty> > > >();
            }

            if (filter.GroupBySupplier != true)
            {
                return(query.Select());
            }

            PXResultset <SupplierProduct, Supplier> result = new PXResultset <SupplierProduct, Supplier>();
            SupplierProduct pendingProduct  = null;
            Supplier        pendingSupplier = null;
            int             supplierCount   = 0;
            List <string>   countries       = new List <string>();

            foreach (PXResult <SupplierProduct, Supplier> record in query.Select())
            {
                SupplierProduct supplierProduct = (SupplierProduct)record;
                Supplier        supplier        = (Supplier)record;
                if (pendingProduct != null && supplierProduct.ProductID != pendingProduct.ProductID)
                {
                    CalcAggregates(ref pendingProduct, ref pendingSupplier, ref supplierCount, countries);
                    result.Add(new PXResult <SupplierProduct, Supplier>(pendingProduct, pendingSupplier));
                    ClearTotals(ref pendingProduct, ref pendingSupplier, ref supplierCount, countries);
                }
                CalcTotals(supplierProduct, supplier, ref pendingProduct, ref pendingSupplier,
                           ref supplierCount, countries);
            }

            if (pendingProduct != null && pendingSupplier != null)
            {
                CalcAggregates(ref pendingProduct, ref pendingSupplier, ref supplierCount, countries);
                result.Add(new PXResult <SupplierProduct, Supplier>(pendingProduct, pendingSupplier));
            }

            return(result);
        }
Beispiel #4
0
        protected virtual void DocTransaction_ProductID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            DocTransaction  line         = (DocTransaction)e.Row;
            Product         product      = null;
            SupplierProduct supplierData = null;

            if (line.ProductID != null)
            {
                product = PXSelectorAttribute.Select <DocTransaction.productID>(sender, line) as Product;
                if (product != null)
                {
                    line.Description = product.ProductName;
                    line.StockUnit   = product.StockUnit;

                    supplierData = PXSelect <SupplierProduct,
                                             Where <SupplierProduct.supplierID, Equal <Current <Document.supplierID> >,
                                                    And <SupplierProduct.productID, Equal <Required <Product.productID> > > > >
                                   .Select(this, product.ProductID);

                    if (supplierData != null)
                    {
                        line.Unit             = supplierData.SupplierUnit;
                        line.ConversionFactor = supplierData.ConversionFactor;
                        line.UnitPrice        = supplierData.SupplierPrice;
                    }
                }
            }

            if (product == null)
            {
                sender.SetDefaultExt <DocTransaction.tranQty>(line);
                line.Description = null;
                line.StockUnit   = null;
            }
            if (supplierData == null)
            {
                line.Unit = null;
                sender.SetDefaultExt <DocTransaction.conversionFactor>(line);
                line.UnitPrice = null;
            }
        }
Beispiel #5
0
 protected void CalcTotals(SupplierProduct supplierProduct, Supplier supplier,
                           ref SupplierProduct pendingProduct, ref Supplier pendingSupplier, ref int supplierCount, List <string> countries)
 {
     if (pendingProduct == null || pendingSupplier == null)
     {
         pendingProduct = supplierProduct;
         supplierCount++;
         pendingSupplier = supplier;
         if (!string.IsNullOrEmpty(supplier.CountryCD))
         {
             countries.Add(supplier.CountryCD);
         }
     }
     else
     {
         pendingProduct.SupplierID     = supplierProduct.SupplierID;
         pendingProduct.ProductID      = supplierProduct.ProductID;
         pendingProduct.SupplierPrice += supplierProduct.SupplierPrice;
         if (pendingProduct.LastPurchaseDate == null)
         {
             pendingProduct.LastPurchaseDate = supplierProduct.LastPurchaseDate;
         }
         else if (supplierProduct.LastPurchaseDate > pendingProduct.LastPurchaseDate)
         {
             pendingProduct.LastPurchaseDate = supplierProduct.LastPurchaseDate;
         }
         if (supplierProduct.MinOrderQty < pendingProduct.MinOrderQty)
         {
             pendingProduct.MinOrderQty = supplierProduct.MinOrderQty;
         }
         supplierCount++;
         if (!string.IsNullOrEmpty(supplier.CountryCD) && !countries.Contains(supplier.CountryCD))
         {
             countries.Add(supplier.CountryCD);
         }
     }
 }
Beispiel #6
0
 protected void CalcAggregates(ref SupplierProduct pendingProduct, ref Supplier pendingSupplier,
                               ref int supplierCount, List <string> countries)
 {
     pendingProduct.SupplierPrice = pendingProduct.SupplierPrice / supplierCount;
     pendingSupplier.CountryCD    = countries.Count.ToString();
 }