private void Update()
        {
            if (CurrentClearance == null)
            {
                throw GenericStateMachineEngine.ActionResult.Exception(null, "Internal error - ClearanceID is null or empty at Update");
            }
            Entities _edc = m_DataContextManagement.DataContext;

            CurrentClearance.UpdateClerance(_edc, m_SelectGroupRadioButtonList.SelectedValue, SelectedClearenceProcedure);
            //remove from clearance
            foreach (Selection.SelectionTableRow _row in m_ControlState.AvailableItems.SelectionTable.OnlyAdded)
            {
                Disposal _dspsl = Element.GetAtIndex <Disposal>(_edc.Disposal, _row.Id);
                RemoveDisposalFromClearance(_edc, _dspsl);
            }
            //add to clearance
            foreach (Selection.SelectionTableRow _row in m_ControlState.AssignedItems.SelectionTable.OnlyAdded)
            {
                if (_row.Disposal)
                {
                    Disposal _dspsl = Element.GetAtIndex <Disposal>(_edc.Disposal, _row.Id);
                    _dspsl.Disposal2ClearenceIndex = CurrentClearance;
                }
                else
                {
                    IPRClass _ipr = Element.GetAtIndex <IPRClass>(_edc.IPR, _row.Id);
                    _ipr.AddDisposal(_edc, Convert.ToDecimal(_row.Quantity), CurrentClearance);
                }
            }
            CurrentClearance.UpdateTitle(_edc);
            m_DataContextManagement.DataContext.SubmitChanges();
        }
        /// <summary>
        /// Creates the IPR account.
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <param name="clearance">The clearance.</param>
        /// <param name="messageType">Type of the _message.</param>
        /// <param name="comments">The _comments.</param>
        /// <param name="warnings">The list of warnings.</param>
        /// <param name="trace">The trace action.</param>
        private static void CreateIPRAccount(Entities entities, Clearence clearance, CustomsDocument.DocumentType messageType, out string comments, List <Warnning> warnings, NamedTraceLogger.TraceAction trace)
        {
            trace("Entering ClearenceHelpers.CreateIPRAccount", 169, TraceSeverity.Verbose);
            comments = "IPR account creation error";
            string          _referenceNumber = String.Empty;
            SADDocumentType declaration      = clearance.Clearence2SadGoodID.SADDocumentIndex;

            _referenceNumber = declaration.ReferenceNumber;
            if (WebsiteModel.Linq.IPR.RecordExist(entities, clearance.DocumentNo))
            {
                string _msg = "IPR record with the same SAD document number: {0} exist";
                _msg = String.Format(_msg, clearance.DocumentNo);
                trace("Exception at ClearenceHelpers.CreateIPRAccount: " + _msg, 199, TraceSeverity.Verbose);
                throw GenericStateMachineEngine.ActionResult.NotValidated(_msg);
            }
            comments = "Inconsistent or incomplete data to create IPR account";
            IPRAccountData _iprdata = new IPRAccountData(clearance.Id.Value);

            _iprdata.GetAccountData(entities, clearance, ImportXMLCommon.Convert2MessageType(messageType), warnings, trace);
            comments = "Consent lookup filed";
            IPRClass _ipr = new IPRClass(entities, _iprdata, clearance, declaration);

            entities.IPR.InsertOnSubmit(_ipr);
            clearance.SPStatus = true;
            trace("ClearenceHelpers.CreateIPRAccount at SubmitChanges", 209, TraceSeverity.Verbose);
            entities.SubmitChanges();
            _ipr.UpdateTitle();
            comments = "IPR account created";
            trace("ClearenceHelpers.Create - IPRAccount comments", 213, TraceSeverity.Verbose);
        }
        internal static IPRIngredient GetIPRIngredient(Disposal disposal)
        {
            IPRIngredient _ret = new IPRIngredient(disposal.Disposal2IPRIndex.Batch, disposal.Disposal2IPRIndex.SKU, disposal.SettledQuantity.Value);

            CAS.SmartFactory.IPR.WebsiteModel.Linq.IPR _ipr = disposal.Disposal2IPRIndex;
            _ret.Currency        = _ipr.Currency;
            _ret.Date            = _ipr.CustomsDebtDate.Value;
            _ret.DocumentNoumber = _ipr.DocumentNo;
            _ret.Duty            = disposal.DutyPerSettledAmount.Value;
            switch (disposal.ClearingType.Value)
            {
            case CAS.SmartFactory.IPR.WebsiteModel.Linq.ClearingType.PartialWindingUp:
                _ret.ItemClearingType = xml.DocumentsFactory.CigaretteExportForm.ClearingType.PartialWindingUp;
                break;

            case CAS.SmartFactory.IPR.WebsiteModel.Linq.ClearingType.TotalWindingUp:
                _ret.ItemClearingType = xml.DocumentsFactory.CigaretteExportForm.ClearingType.PartialWindingUp;
                break;

            default:
                throw new ApplicationError("InvoiceLib.IPRIngredient", "ItemClearingType", "Wrong Clearing Type", null);
            }
            _ret.TobaccoUnitPrice = _ipr.IPRUnitPrice.Value;
            _ret.TobaccoValue     = disposal.TobaccoValue.Value;
            _ret.VAT = disposal.VATPerSettledAmount.Value;
            return(_ret);
        }
Exemple #4
0
 internal SelectionTableRowWraper(IPRClass _iprx)
 {
     InitializeDisposal(_iprx);
     Disposal = false;
     Quantity = _iprx.TobaccoNotAllocated.Value;
     Status   = "IPR Material";
     Created  = _iprx.CustomsDebtDate.Value;
     ID       = _iprx.Id.Value.ToString();
 }
Exemple #5
0
        /// <summary>
        /// Gets the current situation.
        /// </summary>
        /// <param name="edc">The edc.</param>
        /// <returns></returns>
        public static decimal GetCurrentSituationData(Entities edc)
        {
            decimal _ret = 0;

            foreach (IPR _iprx in IPR.GetAllOpen4JSOX(edc))
            {
                _ret += _iprx.AccountBalanceDec;
            }
            return(_ret);
        }
Exemple #6
0
 private void InitializeDisposal(IPRClass _ipr)
 {
     DocumentNo = _ipr.DocumentNo;
     DebtDate   = _ipr.CustomsDebtDate.Value;
     ValidTo    = _ipr.OGLValidTo.Value;
     SKU        = _ipr.SKU;
     Batch      = _ipr.Batch;
     UnitPrice  = _ipr.IPRUnitPrice.Value;
     Currency   = _ipr.Currency;
 }
 private void onWhileLogToHistory(object sender, EventArgs e)
 {
     TraceEvent("Entering CloseManyIPRAccounts.onWhileLogToHistory", 74, TraceSeverity.Verbose);
     WhileLogToHistory_HistoryOutcome = "Closing account";
     using (IPRLinq.Entities _entities = new IPRLinq.Entities(workflowProperties.WebUrl))
     {
         IPRLinq.IPR _ipr = IPRLinq.Element.GetAtIndex <IPRLinq.IPR>(_entities.IPR, m_InitializationData.AccountsArray[m_LoopCounter]);
         WhileLogToHistory_HistoryDescription = String.Format("Closing account: {0} - Item: {1}/{2}", _ipr.Title, m_LoopCounter + 1, m_InitializationData.AccountsArray.Length);
         TraceEvent("CloseManyIPRAccounts.onWhileLogToHistory: " + WhileLogToHistory_HistoryDescription, 79, TraceSeverity.Verbose);
     }
 }
        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);
        }
Exemple #9
0
        /// <summary>
        /// Gets the introducing quantity.
        /// </summary>
        /// <param name="edc">The edc.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="dateStart">The date start.</param>
        /// <param name="dateEnd">The date end.</param>
        /// <returns></returns>
        public static decimal GetIntroducingData(Entities edc, JSOXLib parent, out DateTime dateStart, out DateTime dateEnd)
        {
            decimal _ret = 0;

            dateEnd   = LinqIPRExtensions.DateTimeMinValue;
            dateStart = LinqIPRExtensions.DateTimeMaxValue;
            foreach (IPR _iprx in parent.IPR(edc))
            {
                _ret     += _iprx.NetMassDec;
                dateEnd   = LinqIPRExtensions.Max(_iprx.CustomsDebtDate.Value.Date, dateEnd);
                dateStart = LinqIPRExtensions.Min(_iprx.CustomsDebtDate.Value.Date, dateStart);
            }
            foreach (IPR _iprx in IPR.GetAllNew4JSOX(edc))
            {
                _iprx.IPR2JSOXIndex = parent;
                _ret     += _iprx.NetMassDec;
                dateEnd   = LinqIPRExtensions.Max(_iprx.CustomsDebtDate.Value.Date, dateEnd);
                dateStart = LinqIPRExtensions.Min(_iprx.CustomsDebtDate.Value.Date, dateStart);
            }
            return(_ret);
        }
Exemple #10
0
        internal static IPR.Balance Create(Entities edc, IPR _iprAccount, BalanceBatch parent, JSOXLib masterReport, List <BalanceIPR> iprCollection, NamedTraceLogger.TraceAction trace)
        {
            trace("Entering BalanceIPR.Create", 30, TraceSeverity.Verbose);
            BalanceIPR _newItem = new BalanceIPR()
            {
                Archival             = false,
                Balance              = -1,
                BalanceBatchIndex    = parent,
                BalanceIPR2JSOXIndex = masterReport,
                Batch            = _iprAccount.Batch,
                CustomsProcedure = _iprAccount.ClearenceIndex.ClearenceProcedure.ToString(),
                DocumentNo       = _iprAccount.DocumentNo,
                InvoiceNo        = _iprAccount.InvoiceNo,
                IPRIndex         = _iprAccount,
                OGLIntroduction  = _iprAccount.DocumentNo,
                SKU   = _iprAccount.SKU,
                Title = "Creating",
            };

            edc.BalanceIPR.InsertOnSubmit(_newItem);
            iprCollection.Add(_newItem);
            return(_newItem.Update(edc, trace));
        }
Exemple #11
0
        internal Disposal(IPR ipr, Linq.DisposalStatus _typeOfDisposal, decimal _toDispose)
            : this()
        {
            Archival                = false;
            ClearingType            = Linq.ClearingType.PartialWindingUp;
            CustomsProcedure        = String.Empty.NotAvailable();
            CustomsStatus           = Linq.CustomsStatus.NotStarted;
            Disposal2IPRIndex       = ipr;
            DisposalStatus          = _typeOfDisposal;
            Disposal2PCNID          = null;                        //will be assigned during clearing through custom
            DutyPerSettledAmount    = new Nullable <double>();     // calculated in SetUpCalculatedColumns,
            InvoiceNo               = String.Empty.NotAvailable(); //To be assigned during finished goods export.
            IPRDocumentNo           = String.Empty.NotAvailable();
            JSOXCustomsSummaryIndex = null;
            SPNo = new Nullable <double>();
            RemainingQuantity  = new Nullable <double>(); //To be set during sad processing
            SADDate            = Extensions.SPMinimum;
            SADDocumentNo      = String.Empty.NotAvailable();
            SettledQuantityDec = _toDispose;
            string _titleTmplt = "Disposal: {0} of material {1}";

            Title = String.Format(_titleTmplt, this.DisposalStatus.Value.ToString(), this.Disposal2IPRIndex.Batch);
        }
        internal static BalanceBatchWrapper Create(Entities edc, IGrouping <string, IPR> iprGroups, JSOXLib parent, StockDictionary.BalanceStock balanceStock, NamedTraceLogger.TraceAction trace)
        {
            trace("Entering BalanceBatch.Create", 34, TraceSeverity.Verbose);
            BalanceBatchWrapper _ret;

            try
            {
                IPR          _firsTIPR = iprGroups.FirstOrDefault <IPR>();
                BalanceBatch _newBB    = new BalanceBatch()
                {
                    Archival = false,
                    Balance2JSOXLibraryIndex = parent,
                    Batch = iprGroups.Key,
                    Title = "creating",
                    SKU   = _firsTIPR == null ? "NA" : _firsTIPR.SKU,
                };
                edc.BalanceBatch.InsertOnSubmit(_newBB);
                List <BalanceIPR> _is = new List <BalanceIPR>();
                _newBB.Update(edc, iprGroups, balanceStock, _is, trace);
                _ret = new BalanceBatchWrapper()
                {
                    iprCollection = _is.ToArray <BalanceIPR>(), batch = _newBB
                };
            }
            catch (CAS.SharePoint.ApplicationError)
            {
                throw;
            }
            catch (Exception ex)
            {
                trace("ApplicationError at BalanceBatch.Create", 58, TraceSeverity.High);
                throw new SharePoint.ApplicationError("BalanceBatch.Create", "Body", ex.Message, ex);
            }
            trace("Finished BalanceBatch.Create", 61, TraceSeverity.Verbose);
            return(_ret);
        }
        internal static RequestContent CreateRequestContent(List <Disposal> _Disposals, IPRClass ipr, string documentName)
        {
            int documentNo = ipr.Id.Value;

            ProductCodeNumberDesscription[]  _pcnArray           = CreateArrayOfProductCodeNumberDesscription(_Disposals);
            ArrayOfDIsposalsDisposalsArray[] _disposalsColection = CreateArrayOfDIsposalsDisposalsArray(_Disposals);
            RequestContent _ret = new RequestContent()
            {
                Batch              = ipr.Batch,
                Cartons            = ipr.Cartons.Value,
                ConsentDate        = ipr.IPR2ConsentTitle.ValidFromDate.Value,
                ConsentNo          = ipr.IPR2ConsentTitle.Title,
                ConsentPeriod      = ipr.ConsentPeriod.Value,
                CustomsDebtDate    = ipr.CustomsDebtDate.Value,
                DisposalsColection = _disposalsColection,
                DocumentDate       = DateTime.Today.Date,
                DocumentName       = documentName,
                DocumentNo         = documentNo,
                Duty                = ipr.Duty.Value,
                DutyName            = ipr.DutyName,
                DutyPerUnit         = ipr.IPRDutyPerUnit.Value,
                EntryDocumentNo     = ipr.DocumentNo,
                Grade               = ipr.Grade,
                GrossMass           = ipr.GrossMass.Value,
                InvoiceNo           = ipr.InvoiceNo,
                NetMass             = ipr.NetMass.Value,
                PCN                 = ipr.IPR2PCNPCN.ProductCodeNumber,
                PCNRecord           = _pcnArray,
                ProductivityRateMax = ipr.ProductivityRateMax.GetValueOrDefault(-1),
                ProductivityRateMin = ipr.ProductivityRateMin.GetValueOrDefault(-1),
                SKU                 = ipr.SKU,
                TobaccoName         = ipr.TobaccoName,
                ValidFromDate       = ipr.ValidFromDate.Value,
                ValidToDate         = ipr.ValidToDate.Value,
                VAT                 = ipr.VAT.Value,
                VATName             = ipr.VATName,
                VATPerUnit          = ipr.IPRVATPerUnit.Value,
                VATDutyTotal        = ipr.VATDec + ipr.DutyDec
            };

            return(_ret);
        }
Exemple #14
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];
            }