Esempio n. 1
0
        /// <summary>
        /// Disposes goods for selected batch.
        /// </summary>
        /// <param name="entities">The entities representing SharePoint lists.</param>
        /// <param name="batch">The batch.</param>
        /// <param name="parentRequestLib">The parent request library.</param>
        /// <param name="xmlData">The XML data to be disposed.</param>
        /// <exception cref="CAS.SharePoint.ApplicationError">CustomsWarehouse.Dispose;ending;null</exception>
        public static void Dispose(Entities entities, string batch, DisposalRequestLib parentRequestLib, CustomsWarehouseDisposal.XmlData xmlData)
        {
            List <CustomsWarehouse> _available = GetOrderedQueryable4Batch(entities, batch);
            CustomsWarehouse        _noValue   = _available.FirstOrDefault <CustomsWarehouse>(x => !x.Value.HasValue);

            if (_noValue != null)
            {
                string _msg = String.Format("No Value assigned to the account {0} dept day: {1}", _noValue.DocumentNo, _noValue.CustomsDebtDate);
                throw new CAS.SharePoint.ApplicationError("CustomsWarehouse.Dispose", "No Value", _msg, null);
            }
            if (_available.Count == 0)
            {
                string _batchMsg = String.Format("I cannot find any account for the batch: {0}", batch);
                throw new CAS.SharePoint.ApplicationError("CustomsWarehouse.Dispose", "GetOrderedQueryable4Batch", _batchMsg, null);
            }
            foreach (CustomsWarehouse _cwx in _available)
            {
                _cwx.Dispose(entities, parentRequestLib, ref xmlData);
                if (xmlData.DeclaredQuantity + xmlData.AdditionalQuantity <= 0)
                {
                    return;
                }
            }
            string _msg2 = String.Format("there is not enough tobacco {0} to dispose the batch: {1}", xmlData.DeclaredQuantity + xmlData.AdditionalQuantity, batch);

            throw new CAS.SharePoint.ApplicationError("CustomsWarehouse.Dispose", "ending", _msg2, null);
        }
Esempio n. 2
0
        private void Dispose(Entities entities, DisposalRequestLib parent, ref CustomsWarehouseDisposal.XmlData xmlData)
        {
            decimal _2Dispose = xmlData.DeclaredQuantity + xmlData.AdditionalQuantity;

            if (this.TobaccoNotAllocated.DecimalValue() < _2Dispose)
            {
                _2Dispose = this.TobaccoNotAllocated.DecimalValue();
            }
            decimal _Boxes = Math.Round(_2Dispose / Convert.ToDecimal(this.CW_MassPerPackage.Value) + 0.49m, 0);

            _2Dispose = _Boxes * this.CW_MassPerPackage.DecimalValue();
            Debug.Assert(_2Dispose <= this.TobaccoNotAllocated.DecimalValue(), "Account overrun");
            if (Math.Abs(_2Dispose - this.TobaccoNotAllocated.DecimalValue()) < this.CW_MassPerPackage.DecimalValue())
            {
                _2Dispose = this.TobaccoNotAllocated.DecimalValue();
            }
            //DeclaredQntty
            decimal _DeclaredQntty = Math.Min(_2Dispose, xmlData.DeclaredQuantity);

            xmlData.DeclaredQuantity -= _DeclaredQntty;
            this.TobaccoNotAllocated  = Convert.ToDouble(this.TobaccoNotAllocated.DecimalValue() - _2Dispose);
            CustomsWarehouseDisposal _new = new CustomsWarehouseDisposal()
            {
                Archival            = false,
                ClearingType        = ClearingType.PartialWindingUp,
                CustomsStatus       = CustomsStatus.NotStarted,
                CustomsProcedure    = parent.ClearenceProcedure.Value.Convert2String(),
                CW_AddedKg          = 0, //Assigned in SettledNetMass
                CW_DeclaredNetMass  = _DeclaredQntty.DoubleValue(),
                CW_SettledNetMass   = 0, //Assigned in SettledNetMass
                CW_SettledGrossMass = 0, //Assigned in SettledNetMass
                CW_PackageToClear   = _Boxes.DoubleValue(),
                TobaccoValue        = 0, //Assigned in SettledNetMass
                CWL_CWDisposal2DisposalRequestLibraryID = parent,
                CWL_CWDisposal2PCNTID             = this.CWL_CW2PCNID,
                CWL_CWDisposal2CustomsWarehouseID = this,
                SADDate             = CAS.SharePoint.Extensions.SPMinimum,
                SKUDescription      = xmlData.SKUDescription,
                CW_WZNoSupplemented = false,
                Title = "ToDo",
            };

            _new.CalculateMassValu(_2Dispose.DoubleValue());
            xmlData.AdditionalQuantity -= Convert.ToDecimal(_new.CW_AddedKg.Value);
            entities.CustomsWarehouseDisposal.InsertOnSubmit(_new);
            _new.UpdateTitle();
        }