Beispiel #1
0
        internal static CloseAccountResult CloseAccount(SPWeb Web, string WebUrl, int ItemId)
        {
            CloseAccountResult _ret = CloseAccountResult.Closed;

            using (Entities _edc = new Entities(WebUrl))
            {
                IPRClass _iprItem = Element.GetAtIndex <WebsiteModel.Linq.IPR>(_edc.IPR, ItemId);
                if (_iprItem.AccountClosed.GetValueOrDefault(false))
                {
                    throw new CAS.SharePoint.ApplicationError("CloseAccount", "AccountClosed", "The account has been already closed.", null);
                }
                if (_iprItem.AccountBalance != 0)
                {
                    _ret = CloseAccountResult.AccountBalanceError;
                }
                else if (!_iprItem.AllEntriesClosed(_edc, (x, y, z) => TraceEvent(x, y, z)))
                {
                    _ret = CloseAccountResult.AccountBalanceError;
                }
                string          _documentName = Settings.RequestForAccountClearenceDocumentName(_edc, _iprItem.Id.Value);
                List <Disposal> _Disposals    = _iprItem.Disposals(_edc, (x, y, z) => TraceEvent(x, y, z)).Where <Disposal>(x => x.CustomsStatus == CustomsStatus.Finished).ToList <Disposal>();
                RequestContent  _content      = DocumentsFactory.AccountClearanceFactory.CreateRequestContent(_Disposals, _iprItem, _documentName);
                if (_iprItem.IPRLibraryIndex != null)
                {
                    File.WriteXmlFile <RequestContent>(Web, _iprItem.IPRLibraryIndex.Id.Value, Entities.IPRLibraryName, _content, DocumentNames.RequestForAccountClearenceName);
                }
                else
                {
                    SPFile _docFile = File.CreateXmlFile <RequestContent>(Web, _content, _documentName, Entities.IPRLibraryName, DocumentNames.RequestForAccountClearenceName);
                    WebsiteModel.Linq.IPRLib _document = Element.GetAtIndex <WebsiteModel.Linq.IPRLib>(_edc.IPRLibrary, _docFile.Item.ID);
                    _document.DocumentNo     = _iprItem.Title;
                    _iprItem.IPRLibraryIndex = _document;
                }
                if (_ret == CloseAccountResult.Closed)
                {
                    _iprItem.AccountClosed = true;
                    _iprItem.ClosingDate   = DateTime.Today.Date;
                }
                _edc.SubmitChanges();
            }
            return(_ret);
        }
Beispiel #2
0
            internal Balance(Entities edc, IPR record, NamedTraceLogger.TraceAction trace)
            {
                trace("Entering IPR.Balance", 421, TraceSeverity.Verbose);
                foreach (ValueKey _vkx in Enum.GetValues(typeof(ValueKey)))
                {
                    base[_vkx] = 0;
                }
                #region totals
                foreach (Disposal _dspx in record.Disposals(edc, trace))
                {
                    switch (_dspx.CustomsStatus.Value)
                    {
                    case CustomsStatus.NotStarted:
                        switch (_dspx.DisposalStatus.Value)
                        {
                        case DisposalStatus.Dust:
                            base[ValueKey.DustCSNotStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.SHMenthol:
                            base[ValueKey.SHMentholCSNotStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Waste:
                            base[ValueKey.WasteCSNotStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Overuse:
                            base[ValueKey.OveruseCSNotStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Tobacco:
                            base[ValueKey.PureTobaccoCSNotStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.TobaccoInCigaretes:
                            base[ValueKey.TobaccoInFGCSNotStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Cartons:
                        case DisposalStatus.TobaccoInCigaretesDestinationEU:
                        case DisposalStatus.TobaccoInCigaretesProduction:
                        case DisposalStatus.TobaccoInCutfiller:
                        case DisposalStatus.TobaccoInCutfillerDestinationEU:
                        case DisposalStatus.TobaccoInCutfillerProduction:
                            break;
                        }
                        break;

                    case CustomsStatus.Started:
                        switch (_dspx.DisposalStatus.Value)
                        {
                        case DisposalStatus.Dust:
                            base[ValueKey.DustCSStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.SHMenthol:
                            base[ValueKey.SHMentholCSStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Waste:
                            base[ValueKey.WasteCSStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Overuse:
                            base[ValueKey.OveruseCSStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Tobacco:
                            base[ValueKey.PureTobaccoCSStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.TobaccoInCigaretes:
                            base[ValueKey.TobaccoInFGCSStarted] += _dspx.SettledQuantityDec;
                            break;

                        case DisposalStatus.Cartons:
                        case DisposalStatus.TobaccoInCigaretesDestinationEU:
                        case DisposalStatus.TobaccoInCigaretesProduction:
                        case DisposalStatus.TobaccoInCutfiller:
                        case DisposalStatus.TobaccoInCutfillerDestinationEU:
                        case DisposalStatus.TobaccoInCutfillerProduction:
                            break;
                        }
                        break;

                    case CustomsStatus.Finished:
                        switch (_dspx.DisposalStatus.Value)
                        {
                        case DisposalStatus.Cartons:
                            break;

                        case DisposalStatus.Dust:
                        case DisposalStatus.SHMenthol:
                        case DisposalStatus.Waste:
                        case DisposalStatus.Overuse:
                        case DisposalStatus.Tobacco:
                        case DisposalStatus.TobaccoInCigaretes:
                        case DisposalStatus.TobaccoInCigaretesDestinationEU:
                        case DisposalStatus.TobaccoInCigaretesProduction:
                        case DisposalStatus.TobaccoInCutfiller:
                        case DisposalStatus.TobaccoInCutfillerDestinationEU:
                        case DisposalStatus.TobaccoInCutfillerProduction:
                            base[ValueKey.TobaccoCSFinished] += _dspx.SettledQuantityDec;
                            break;
                        }
                        break;
                    }
                }
                #endregion
                base[ValueKey.TobaccoEnteredIntoIPR] = record.NetMassDec;
                base[ValueKey.IPRBook]                        = IPRBook;
                base[ValueKey.TobaccoStarted]                 = TobaccoStarted;
                base[ValueKey.SHWasteOveruseCSNotStarted]     = SHWasteOveruseCSNotStarted;
                base[ValueKey.TobaccoAvailable]               = TobaccoAvailable;
                base[ValueKey.TobaccoUsedInTheProduction]     = TobaccoUsedInTheProduction;
                base[ValueKey.TobaccoToBeUsedInTheProduction] = base[ValueKey.TobaccoEnteredIntoIPR] - base[ValueKey.TobaccoUsedInTheProduction];
            }