예제 #1
0
        /// <summary>
        /// Exports the specified entities.
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <param name="quantity">The quantity.</param>
        /// <param name="closingBatch">if set to <c>true</c> the batch is to be closed.</param>
        /// <param name="invoiceContent">Content of the invoice.</param>
        /// <param name="sadConsignmentNumber">The sad consignment number.</param>
        /// <param name="reCalculate">The recalculate delegate is used to adjust VAT, duty and value for last started disposal.</param>
        /// <exception cref="ApplicationError">if any internal exception has to be cough.</exception>
        internal void Export(Entities entities, ref decimal quantity, bool closingBatch, InvoiceContent invoiceContent, int sadConsignmentNumber, Action <Disposal> reCalculate)
        {
            string _at = "Starting";

            try
            {
                if (!closingBatch)
                {
                    if (quantity < this.SettledQuantityDec)
                    {
                        _at = "_newDisposal";
                        Disposal _newDisposal = new Disposal(Disposal2IPRIndex, DisposalStatus.Value, this.SettledQuantityDec - quantity);
                        _newDisposal.Material   = this.Disposal2MaterialIndex;
                        this.SettledQuantityDec = quantity;
                        quantity = 0;
                        _at      = "InsertOnSubmit";
                        entities.Disposal.InsertOnSubmit(_newDisposal);
                        reCalculate = x => { };
                    }
                    else
                    {
                        quantity -= this.SettledQuantityDec;
                    }
                }
                _at = "ClearThroughCustom";
                this.ClearThroughCustom(invoiceContent, reCalculate);
                this.SadConsignmentNo = SADConsignment.DocumentNumber(entities, sadConsignmentNumber);
            }
            catch (Exception _ex)
            {
                throw new ApplicationError(@"CAS.SmartFactory.IPR.WebsiteModel.Linq.Disposal.Export", _at, _ex.Message, _ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Insert on submit the disposal.
        /// </summary>
        /// <param name="edc">The _edc.</param>
        /// <param name="quantity">The quantity.</param>
        /// <param name="clearance">The clearance.</param>
        /// <exception cref="CAS">CAS.SmartFactory.IPR.WebsiteModel.Linq.AddDisposal;_qunt > 0;null</exception>
        public void AddDisposal(Entities edc, decimal quantity, Clearence clearance)
        {
            Disposal _dsp = AddDisposal(edc, DisposalEnum.Tobacco, ref quantity);

            _dsp.Clearance = clearance;
            if (quantity > 0)
            {
                string _msg = String.Format("Cannot add Disposal to IPR  {0} because there is not material on the IPR.", this.Id.Value);
                throw CAS.SharePoint.Web.GenericStateMachineEngine.ActionResult.Exception
                          (new CAS.SharePoint.ApplicationError("CAS.SmartFactory.IPR.WebsiteModel.Linq.AddDisposal", "_qunt > 0", _msg, null), _msg);
            }
        }
예제 #3
0
        internal void AddDisposal(Entities edc, DisposalEnum kind, ref decimal toDispose, Material material, InvoiceContent invoiceContent, NamedTraceLogger.TraceAction trace)
        {
            trace("Entering IPR.AddDisposal", 421, TraceSeverity.Verbose);
            Disposal _dsp = AddDisposal(edc, kind, ref toDispose);

            _dsp.Material = material;
            _dsp.ClearThroughCustom(invoiceContent, _x => { });
            SADGood _sg = invoiceContent.InvoiceIndex.ClearenceIndex.Clearence2SadGoodID;

            if (_sg != null)
            {
                _dsp.FinishClearingThroughCustoms(edc, _sg, trace);
            }
        }
예제 #4
0
        /// <summary>
        /// Contains calculated data required to create IPR account
        /// </summary>
        private Disposal AddDisposal(Entities edc, DisposalEnum status, ref decimal quantity)
        {
            Linq.DisposalStatus _typeOfDisposal = Entities.GetDisposalStatus(status);
            decimal             _toDispose      = 0;

            if (status == DisposalEnum.Cartons)
            {
                _toDispose = quantity;
                quantity   = 0;
            }
            else
            {
                _toDispose = Withdraw(ref quantity, 0);
            }
            Disposal _newDisposal = new Disposal(this, _typeOfDisposal, _toDispose);

            edc.Disposal.InsertOnSubmit(_newDisposal);
            return(_newDisposal);
        }
예제 #5
0
        internal void UpdateExportedDisposals(Entities edc, NamedTraceLogger.TraceAction trace)
        {
            trace("Entering InvoiceContent.UpdateExportedDisposals", 48, TraceSeverity.Verbose);
            IEnumerable <IGrouping <int, Disposal> > _dspslsGroups = from _dsx in this.Disposal(edc)
                                                                     let _midx = _dsx.Disposal2MaterialIndex.Id.Value
                                                                                 group _dsx by _midx;

            foreach (IGrouping <int, Disposal> _gx in _dspslsGroups)
            {
                Disposal _dsp = _gx.FirstOrDefault <Disposal>();
                if (_dsp == null)
                {
                    continue;
                }
                Material _mtrl = _dsp.Disposal2MaterialIndex;
                decimal  _2Add = _mtrl.CalculatedQuantity(this) - _gx.Sum <Disposal>(v => v.SettledQuantityDec);
                //TODO it could cause that the closed IPR accounts will have account balance != 0
                //TODO if current settled quantity < previous value it could also cause that old account will have holes that makes them difficult to be closed.
                IEnumerable <Disposal> _sorted = from _dx in _gx
                                                 orderby _dx.SettledQuantityDec ascending
                                                 select _dx;
                foreach (Disposal _dx in _sorted)
                {
                    _dx.Adjust(edc, ref _2Add, trace);
                    if (_2Add <= 0)
                    {
                        break;
                    }
                }
                if (_2Add <= 0)
                {
                    continue;
                }
                _mtrl.AddNewDisposals(edc, DisposalEnum.TobaccoInCigaretess, ref _2Add, this, trace);
            }
        }
예제 #6
0
        internal void AddDisposal(Entities edc, DisposalEnum _kind, ref decimal _toDispose, Material material)
        {
            Disposal _dsp = AddDisposal(edc, _kind, ref _toDispose);

            _dsp.Material = material;
        }