Esempio n. 1
0
        public virtual IEnumerable AutoPackaging(PXAdapter adapter)
        {
            decimal    parseResult   = 0;
            var        _maxCartno    = GetMaxCartonNbr();
            SOShipLine _line         = (SOShipLine)Base.Transactions.Cache.Current;
            var        _QtyPerCarton = decimal.TryParse(_line.GetExtension <SOShipLineExt>().QtyPerCarton, out parseResult) ? parseResult : 0;

            // valid QtyPerCarton
            if (_QtyPerCarton == 0)
            {
                throw new PXException("Qty per carton Can not be null or 0");
            }

            var NumberOfPackages = Math.Floor((_line.GetExtension <SOShipLineExt>().RemainingQty.Value / _QtyPerCarton));

            PXLongOperation.StartOperation(Base, () =>
            {
                for (int i = 0; i < NumberOfPackages; i++)
                {
                    this._IsAutoPacking = true;
                    Base.Packages.Insert((SOPackageDetailEx)Base.Packages.Cache.CreateInstance());
                    SOPackageDetailEx _package = Base.Packages.Cache.Dirty.RowCast <SOPackageDetailEx>().ElementAt(i);
                    Base.Packages.Cache.SetValueExt <SOPackageDetail.shipmentNbr>(_package, _line.ShipmentNbr);
                    Base.Packages.Cache.SetValueExt <SOPackageDetailEx.customRefNbr1>(_package, (++_maxCartno).ToString().PadLeft(3, '0'));
                    Base.Packages.Cache.SetValueExt <SOPackageDetailExt.usrShipmentSplitLineNbr>(_package, _line.LineNbr);
                    Base.Packages.Cache.SetValueExt <SOPackageDetail.qty>(_package, _QtyPerCarton);
                }
                Base.Save.Press();
            });
            return(adapter.Get());
        }
Esempio n. 2
0
        public virtual IEnumerable ManualPackaging(PXAdapter adapter)
        {
            var _shipLines = Base.Transactions.Cache.Cached.RowCast <SOShipLine>();

            if (_shipLines.Where(x => x.GetExtension <SOShipLineExt>().RemainingQty < x.GetExtension <SOShipLineExt>().UsrPackingQty).Count() > 0)
            {
                throw new PXException("Packing Qty cannot exceed Remaining Qty");
            }
            PXLongOperation.StartOperation(Base, () =>
            {
                int pointer       = 0;
                var _maxCartonNbr = GetMaxCartonNbr() + 1;
                foreach (var _line in _shipLines.Where(x => x.GetExtension <SOShipLineExt>().UsrPackingQty > 0))
                {
                    this._IsAutoPacking = true;
                    Base.Packages.Insert((SOPackageDetailEx)Base.Packages.Cache.CreateInstance());
                    SOPackageDetailEx _package = Base.Packages.Cache.Dirty.RowCast <SOPackageDetailEx>().ElementAt(pointer++);
                    Base.Packages.Cache.SetValueExt <SOPackageDetail.shipmentNbr>(_package, _line.ShipmentNbr);
                    Base.Packages.Cache.SetValueExt <SOPackageDetailEx.customRefNbr1>(_package, _maxCartonNbr.ToString().PadLeft(3, '0'));
                    Base.Packages.Cache.SetValueExt <SOPackageDetailExt.usrShipmentSplitLineNbr>(_package, _line.LineNbr);
                    Base.Packages.Cache.SetValueExt <SOPackageDetail.qty>(_package, _line.GetExtension <SOShipLineExt>().UsrPackingQty);
                }
                Base.Save.Press();
            });
            return(adapter.Get());
        }
Esempio n. 3
0
        public virtual SOPackageDetailEx ToPackageDetail(string packageType)
        {
            var detail = new SOPackageDetailEx
            {
                BoxID         = BoxID,
                NetWeight     = Weight,
                Weight        = GrossWeight,
                WeightUOM     = WeightUOM,
                Qty           = Qty,
                QtyUOM        = QtyUOM,
                InventoryID   = InventoryID,
                DeclaredValue = DeclaredValue,
                COD           = COD == true ? (DeclaredValue ?? 1m) : (decimal?)null,
                PackageType   = packageType,

                BoxWeight      = BoxWeight,
                CarrierBox     = CarrierBox,
                BoxDescription = Description,
                Height         = Height,
                Length         = Length,
                Width          = Width,
                MaxWeight      = MaxWeight
            };

            return(detail);
        }