Exemple #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());
        }
Exemple #2
0
        protected void _(Events.FieldUpdated <SOShipLineExt.usrCartonQty> e)
        {
            SOShipLine    row    = e.Row as SOShipLine;
            SOShipLineExt rowExt = row.GetExtension <SOShipLineExt>();

            rowExt.UsrDimWeight = rowExt.UsrCartonQty * rowExt.UsrBaseItemVolume * 1000000M / 5000M;
        }