private void Recalculate()
 {
     AutoCalculation            = false;
     QuantityyToClearSum        = DeclaredNetMass + AddedKg;
     PackagesToDispose          = CustomsWarehouse.Packages(QuantityyToClearSum, this.MassPerPackage);
     QuantityyToClearSumRounded = PackagesToDispose * this.MassPerPackage;
 }
Beispiel #2
0
        /// <summary>
        /// Compares two instances of the <see cref="CustomsWarehouse " /> type and returns an integer that indicates
        /// whether the first instance is earlier than, the same as, or later than the second instance.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of x and y, as shown in the following table.
        /// Value Condition Less than 0 x is less than y.
        /// 0 x equals y.
        /// Greater than 0 x is greater than y.
        /// </returns>
        internal static int CompareCustomsWarehouse(CustomsWarehouse x, CustomsWarehouse y)
        {
            int _ret = DateTime.Compare(x.CustomsDebtDate.Value, y.CustomsDebtDate.Value);

            if (_ret == 0)
            {
                _ret = String.Compare(x.DocumentNo, y.DocumentNo);
            }
            return(_ret);
        }
Beispiel #3
0
        internal void CreateDisposalRequest(List <CustomsWarehouse> list, double toDispose, string customsProcedure)
        {
            if (list.Count == 0)
            {
                throw new AggregateException("list must contain at least one element");
            }
            CustomsWarehouse _fcw     = list.First <CustomsWarehouse>();
            DisposalRequest  _fDspRqs = this.FirstOrDefault <DisposalRequest>((x) => { return(x.Batch == _fcw.Batch); });

            if (_fDspRqs != null)
            {
                _fDspRqs.AddedKg += toDispose;
            }
            else
            {
                DisposalRequest _dr = DisposalRequest.Create(list, customsProcedure, (x, y) => RaisePropertyChanged(y));
                this.Add(_dr);
                _dr.AutoCalculation = true;
                _dr.AddedKg        += toDispose;
            }
        }
 private static DisposalRequest CreateDisposalRequest(CustomsWarehouse account, string skuDescription, string customsProcedure, Action <DisposalRequest, PropertyChangedEventArgs> notify)
 {
     return(new DisposalRequest()
     {
         AddedKg = 0,
         DeclaredNetMass = 0,
         CustomsProcedure = customsProcedure,
         Batch = account.Batch,
         MassPerPackage = account.CW_MassPerPackage.Value,
         PackagesToDispose = 0,
         QuantityyToClearSum = 0,
         QuantityyToClearSumRounded = 0,
         RemainingOnStock = 0,
         SKUDescription = skuDescription,
         Title = "Title TBD",
         TotalStock = 0,
         Units = account.Units,
         SKU = account.SKU,
         m_ParentNotify = notify
     });
 }
        private static DisposalRequest Create
            (List <CustomsWarehouse> listOfAccounts, IGrouping <string, CustomsWarehouseDisposal> disposals, string description, string procedure, Action <DisposalRequest, PropertyChangedEventArgs> notify)
        {
            CustomsWarehouse _firstAccount = listOfAccounts.First <CustomsWarehouse>();
            DisposalRequest  _newRequest   = CreateDisposalRequest(_firstAccount, description, procedure, notify);

            listOfAccounts.Sort(new Comparison <CustomsWarehouse>(CustomsWarehouse.CompareCustomsWarehouse));
            List <DisposalRequestDetails> _newCollection = new List <DisposalRequestDetails>();
            int _sequenceNumber = 0;
            List <CustomsWarehouse> _copylistOfAccounts = new List <CustomsWarehouse>(listOfAccounts);

            if (disposals != null)
            {
                foreach (CustomsWarehouseDisposal _cwdx in disposals)
                {
                    DisposalRequestDetails _newDisposalRequestDetails = new DisposalRequestDetails(_newRequest, _cwdx, ref _sequenceNumber);
                    _copylistOfAccounts.Remove(_cwdx.CWL_CWDisposal2CustomsWarehouseID);
                    _newCollection.Add(_newDisposalRequestDetails);
                    _newRequest.GetDataContext(_newDisposalRequestDetails);
                    if (_cwdx.CustomsStatus.GetValueOrDefault(CustomsStatus.NotStarted) != CustomsStatus.NotStarted)
                    {
                        _newRequest.ReadOnly = true;
                    }
                }
            }
            foreach (CustomsWarehouse _cwx in _copylistOfAccounts)
            {
                if (_cwx.TobaccoNotAllocated == 0)
                {
                    continue;
                }
                DisposalRequestDetails _newDisposalRequestDetails = new DisposalRequestDetails(_newRequest, _cwx, ref _sequenceNumber);
                _newCollection.Add(_newDisposalRequestDetails);
            }
            _newRequest.RemainingOnStock = _newCollection.Sum(x => x.RemainingOnStock);
            _newRequest.UpdateOnInit(_newCollection);
            return(_newRequest);
        }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisposalRequestDetails" /> class. Used to add new position of the requests list.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="account">The account without disposal created for the relevant request.</param>
 /// <param name="sequenceNumber">The sequence number that will be incremented each time new instance is created.</param>
 internal DisposalRequestDetails(DisposalRequest parent, CustomsWarehouse account, ref int sequenceNumber)
 {
     m_Parent                   = parent;
     m_Disposal                 = null;
     m_Account                  = account;
     AddedKg                    = 0;
     Batch                      = account.Batch;
     CustomsProcedure           = parent.CustomsProcedure;
     DeclaredNetMass            = 0;
     DocumentNumber             = account.DocumentNo;
     MassPerPackage             = account.CW_MassPerPackage.Value;
     PackagesToDispose          = 0;
     QuantityyToClearSum        = 0;
     QuantityyToClearSumRounded = 0;
     RemainingOnStock           = account.TobaccoNotAllocated.Value;
     SequenceNumber             = sequenceNumber++;
     SKU            = account.SKU;
     SKUDescription = string.Empty;
     TotalStock     = account.TobaccoNotAllocated.Value;
     Units          = account.Units;
     MoveDown       = new SynchronousCommandBase <Nullable <int> >(x => parent.GoDown(SequenceNumber), y => !parent.IsBottomActive(SequenceNumber));
     MoveUp         = new SynchronousCommandBase <Nullable <int> >(x => parent.GoUp(SequenceNumber), y => !parent.IsTopActive(SequenceNumber));
 }
        internal static CustomsWarehouseDisposal Create(DisposalRequestDetails disposalRequestDetails, int disposalRequestLibId, CustomsWarehouse account, string customsProcedure)
        {
            Debug.Assert(account != null, "Disposal have to has account assigned.");
            CustomsWarehouseDisposal _newItem = new CustomsWarehouseDisposal()
            {
                Archival            = false,
                CNIDId              = account.CNIDId,
                ClearingType        = Linq.ClearingType.PartialWindingUp,
                CustomsStatus       = Linq.CustomsStatus.NotStarted,
                CustomsProcedure    = customsProcedure,
                CW_AddedKg          = 0, //Assigned in Recalculate
                CW_DeclaredNetMass  = 0,
                CW_SettledNetMass   = 0, //Assigned in Recalculate
                CW_SettledGrossMass = 0, //Assigned in Recalculate
                CW_PackageToClear   = 0, //Assigned in Recalculate
                TobaccoValue        = 0, //Assigned in Recalculate
                DisposalRequestId   = disposalRequestLibId,
                CWL_CWDisposal2CustomsWarehouseID = account,
                SKUDescription = "N/A",
                Title          = "ToDo",
                SADDate        = Extensions.SPMinimum,
            };

            _newItem.Recalculate(disposalRequestDetails);
            _newItem.Title = String.Format("CW-{0:D4}-{1}", DateTime.Today.Year, "XXXXXX"); //TODO Id.Value);
            return(_newItem);
        }