Esempio n. 1
0
        private async Task ProfileFundingLineValues(PublishedProviderVersion newPublishedProviderVersion, ProfilePatternKey profilePatternKey)
        {
            string fundingLineCode = profilePatternKey.FundingLineCode;

            FundingLine fundingLine = newPublishedProviderVersion.FundingLines.SingleOrDefault(_ => _.FundingLineCode == fundingLineCode);

            if (fundingLine == null)
            {
                string error = $"Did not locate a funding line with code {fundingLineCode} on published provider version {newPublishedProviderVersion.PublishedProviderId}";

                _logger.Error(error);

                throw new InvalidOperationException(error);
            }

            ApiResponse <IEnumerable <ProfileVariationPointer> > variationPointersResponse =
                await _specificationResiliencePolicy.ExecuteAsync(() =>
                                                                  _specificationsApiClient.GetProfileVariationPointers(newPublishedProviderVersion.SpecificationId));

            IEnumerable <ProfileVariationPointer> profileVariationPointers = variationPointersResponse?
                                                                             .Content?
                                                                             .Where(_ =>
                                                                                    _.FundingLineId == fundingLineCode &&
                                                                                    _.FundingStreamId == newPublishedProviderVersion.FundingStreamId);

            if (ThereArePaidProfilePeriodsOnTheFundingLine(profileVariationPointers))
            {
                await ReProfileFundingLine(newPublishedProviderVersion, profilePatternKey, fundingLineCode, fundingLine);
            }
            else
            {
                await ProfileFundingLine(fundingLine, newPublishedProviderVersion, profilePatternKey);
            }
        }
Esempio n. 2
0
        private bool HasNoPaidPeriods(ProviderVariationContext providerVariationContext,
                                      PublishedProviderVersion priorState)
        {
            foreach (ProfileVariationPointer variationPointer in providerVariationContext.VariationPointers ?? ArraySegment <ProfileVariationPointer> .Empty)
            {
                FundingLine fundingLine = priorState?.FundingLines.SingleOrDefault(_ => _.FundingLineCode == variationPointer.FundingLineId);

                if (fundingLine == null)
                {
                    continue;
                }

                YearMonthOrderedProfilePeriods periods = new YearMonthOrderedProfilePeriods(fundingLine);

                int variationPointerIndex = periods.IndexOf(_ => _.Occurrence == variationPointer.Occurrence &&
                                                            _.Type.ToString() == variationPointer.PeriodType &&
                                                            _.Year == variationPointer.Year &&
                                                            _.TypeValue == variationPointer.TypeValue);

                if (variationPointerIndex > 0)
                {
                    return(false);
                }
            }

            return(true);
        }
        protected override void MakeAdjustmentsFromProfileVariationPointer(ProfileVariationPointer variationPointer)
        {
            FundingLine closedFundingLine = RefreshState.FundingLines?
                                            .SingleOrDefault(_ => _.FundingLineCode == variationPointer.FundingLineId);
            FundingLine successorFundingLine = SuccessorRefreshState?.FundingLines?
                                               .SingleOrDefault(_ => _.FundingLineCode == variationPointer.FundingLineId);

            if (closedFundingLine == null || successorFundingLine == null)
            {
                throw new ArgumentOutOfRangeException(nameof(variationPointer),
                                                      $"Did not locate a funding line for variation pointer with fundingLineId {variationPointer.FundingLineId}");
            }

            ProfilePeriod[] orderedClosedProfilePeriods = new YearMonthOrderedProfilePeriods(closedFundingLine)
                                                          .ToArray();
            ProfilePeriod[] orderedSuccessorProfilePeriods = new YearMonthOrderedProfilePeriods(successorFundingLine)
                                                             .ToArray();

            int variationPointerIndex = GetProfilePeriodIndexForVariationPoint(variationPointer, orderedClosedProfilePeriods);

            for (int profilePeriod = variationPointerIndex; profilePeriod < orderedClosedProfilePeriods.Length; profilePeriod++)
            {
                ProfilePeriod successorProfilePeriod = orderedSuccessorProfilePeriods[profilePeriod];

                successorProfilePeriod.ProfiledValue = successorProfilePeriod.ProfiledValue + orderedClosedProfilePeriods[profilePeriod].ProfiledValue;
            }
        }
Esempio n. 4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                _fundingLine.Name      = textBoxFundingLineCode.Text;
                _fundingLine.Purpose   = textBoxFundingLineName.Text;
                _fundingLine.StartDate = dateTimePickerFundingLineBeginDate.Value;
                _fundingLine.EndDate   = dateTimePickerFundingLineEndDate.Value;
                _fundingLine.Currency  = comboBoxCurrencies.SelectedItem as Currency;
                if (_fundingLine.Id != 0)
                {
                    ServicesProvider.GetInstance().GetFundingLinesServices().UpdateFundingLine(_fundingLine);
                }
                else
                {
                    _fundingLine = ServicesProvider.GetInstance().GetFundingLinesServices().Create(_fundingLine);
                }

                InitializeFundingLines();
                InitializeTabPageFundingLineDetails(_fundingLine);
                btnSave.Text = GetString("update");
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
        public void DeleteFundinLine()
        {
            FundingLineManager fundingLineManager = (FundingLineManager)container["FundingLineManager"];
            FundingLine        fund = new FundingLine
            {
                Purpose   = "Microsoft financement",
                Name      = "XXX",
                Deleted   = false,
                StartDate = DateTime.Now,
                EndDate   = DateTime.Now,
                Currency  = new Currency {
                    Id = 1
                }
            };

            fundingLineManager.AddFundingLine(fund);

            FundingLine fundingLineInitial = fundingLineManager.SelectFundingLineById(fund.Id, false);

            Assert.AreEqual("XXX", fundingLineInitial.Name);
            fundingLineManager.DeleteFundingLine(fundingLineInitial);
            FundingLine fundingLineFinal = fundingLineManager.SelectFundingLineById(fundingLineInitial.Id, false);

            Assert.IsNull(fundingLineFinal);
        }
Esempio n. 6
0
 public CorporateUserControl(FundingLine pFundingLine)
 {
     _fundingLine = pFundingLine;
     InitializeComponent();
     InitializeUserControlsAddress();
     _corporate = new Corporate();
 }
        private bool FundingLinesMatches(IEnumerable <FundingLine> fundingLines)
        {
            FundingLine fundingLine = fundingLines.FirstOrDefault();

            if (fundingLine == null)
            {
                return(false);
            }

            ProfilePeriod firstProfilePeriod = fundingLine.DistributionPeriods?.SingleOrDefault(_ => _.DistributionPeriodId == _distributionPeriod1Id)?.ProfilePeriods.FirstOrDefault();
            ProfilePeriod lastProfilePeriod  = fundingLine.DistributionPeriods?.SingleOrDefault(_ => _.DistributionPeriodId == _distributionPeriod2Id)?.ProfilePeriods.FirstOrDefault();

            if (firstProfilePeriod == null || lastProfilePeriod == null)
            {
                return(false);
            }

            return(firstProfilePeriod.ProfiledValue == _profilePeriod1ProfiledAmount &&
                   firstProfilePeriod.Occurrence == _profilePeriod1Occurence &&
                   firstProfilePeriod.Type == _profilePeriod1Type &&
                   firstProfilePeriod.TypeValue == _profilePeriod1TypeValue &&
                   firstProfilePeriod.Year == _profilePeriod1Year &&
                   lastProfilePeriod.ProfiledValue == _profilePeriod2ProfiledAmount &&
                   lastProfilePeriod.Occurrence == _profilePeriod2Occurence &&
                   lastProfilePeriod.Type == _profilePeriod2Type &&
                   lastProfilePeriod.TypeValue == _profilePeriod2TypeValue &&
                   lastProfilePeriod.Year == _profilePeriod2Year);
        }
        public CorporateUserControl(Corporate corporate, Form pMdiParent, IApplicationController applicationController)
        {
            _applicationController = applicationController;
            _mdifrom     = pMdiParent;
            _corporate   = corporate;
            _fundingLine = null;
            InitializeComponent();
            InitializeUserControlsAddress();
            InitializeCorporate();
            PicturesServices ps = ServicesProvider.GetInstance().GetPicturesServices();

            if (ps.IsEnabled())
            {
                pictureBox1.Image    = ps.GetPicture("CORPORATE", corporate.Id, true, 0);
                pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                pictureBox2.Image    = ps.GetPicture("CORPORATE", corporate.Id, true, 1);
                pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
            }
            else
            {
                pictureBox1.Visible           = false;
                pictureBox2.Visible           = false;
                linkLabelChangePhoto.Visible  = false;
                linkLabelChangePhoto2.Visible = false;
            }
        }
        public void ProjectsDistributionPeriodsAndProfilePeriodsOrderedByYearThenProfilePeriodMonthThenOccurence_ExampleOne()
        {
            ProfilePeriod lastPeriod   = NewProfilePeriod(2, 2021, "December");
            ProfilePeriod firstPeriod  = NewProfilePeriod(0, 2020, "December");
            ProfilePeriod secondPeriod = NewProfilePeriod(1, 2020, "December");
            ProfilePeriod thirdPeriod  = NewProfilePeriod(0, 2021, "January");

            FundingLine fundingLine = NewFundingLine(_ => _.WithDistributionPeriods(NewDistributionPeriod(
                                                                                        dp => dp.WithProfilePeriods(thirdPeriod, secondPeriod)),
                                                                                    NewDistributionPeriod(dp => dp.WithProfilePeriods(lastPeriod, firstPeriod))));

            ProfilePeriod[] orderedProfilePeriods = new YearMonthOrderedProfilePeriods(fundingLine)
                                                    .ToArray();

            orderedProfilePeriods[0]
            .Should()
            .BeSameAs(firstPeriod);

            orderedProfilePeriods[1]
            .Should()
            .BeSameAs(secondPeriod);

            orderedProfilePeriods[2]
            .Should()
            .BeSameAs(thirdPeriod);

            orderedProfilePeriods[3]
            .Should()
            .BeSameAs(lastPeriod);
        }
 private void AndTheCustomProfilePeriodsWereUsedOn(FundingLine fundingLine, IEnumerable <ProfilePeriod> profilePeriods)
 {
     fundingLine
     .DistributionPeriods.SelectMany(_ => _.ProfilePeriods)
     .Should()
     .BeEquivalentTo(profilePeriods);
 }
Esempio n. 11
0
        public async Task GetAllEntities_GivenEntities_ExpectedMethodsCalled()
        {
            string FundingLineId = NewRandomString();

            FundingLine FundingLine1 = NewFundingLine();
            Calculation calculation2 = NewCalculation();

            Entity <FundingLine> entity = new Entity <FundingLine> {
                Node = FundingLine1, Relationships = new[] { new Relationship {
                                                                 One = calculation2, Two = FundingLine1, Type = AttributeConstants.CalculationFundingLineRelationshipId
                                                             } }
            };

            GivenAllEntitities(new[] { AttributeConstants.FundingLineCalculationRelationshipId, AttributeConstants.CalculationFundingLineRelationshipId }, AttributeConstants.FundingLineId, FundingLineId, entity);

            IEnumerable <Entity <FundingLine, IRelationship> > entities = await _FundingLineRepository.GetAllEntities(FundingLineId);

            entities
            .Should()
            .HaveCount(1);

            entities
            .FirstOrDefault()
            .Node
            .Should()
            .BeEquivalentTo(FundingLine1);

            entities
            .FirstOrDefault()
            .Relationships
            .Should()
            .HaveCount(1);
        }
Esempio n. 12
0
        private void SetFundingLineOnPublishedProvider(string fundingLineCode, Table table, PublishedProvider publishedProvider)
        {
            publishedProvider
            .Should()
            .NotBeNull();

            FundingLine fundingLine =
                publishedProvider.Current.FundingLines.SingleOrDefault(f =>
                                                                       f.FundingLineCode == fundingLineCode && f.Type == FundingLineType.Payment);

            fundingLine
            .Should()
            .NotBeNull($"funding line should exist with code '{fundingLineCode}'");

            List <DistributionPeriod> distributionPeriods = new List <DistributionPeriod>();

            if (fundingLine.DistributionPeriods.AnyWithNullCheck())
            {
                distributionPeriods.AddRange(fundingLine.DistributionPeriods);
            }

            distributionPeriods.AddRange(table.CreateSet <DistributionPeriod>());

            fundingLine.DistributionPeriods = distributionPeriods;
        }
        public async Task ZerosAllProfiles()
        {
            ProfilePeriod[] fundingLineOnePeriods   = CreateProfilePeriods(2, 2, 2973864M).ToArray();
            ProfilePeriod[] fundingLineTwoPeriods   = CreateProfilePeriods(1, 2, 2973864M).ToArray();
            ProfilePeriod[] fundingLineThreePeriods = CreateProfilePeriods(2, 3, 2973864M).ToArray();

            FundingLine fundingLineOne = NewFundingLine(_ => _.WithFundingLineCode(NewRandomString())
                                                        .WithFundingLineType(FundingLineType.Payment)
                                                        .WithDistributionPeriods(NewDistributionPeriod(dp => dp.WithProfilePeriods(fundingLineOnePeriods))));

            FundingLine fundingLineTwo = NewFundingLine(_ => _.WithFundingLineCode(NewRandomString())
                                                        .WithFundingLineType(FundingLineType.Payment)
                                                        .WithDistributionPeriods(NewDistributionPeriod(dp => dp.WithProfilePeriods(fundingLineTwoPeriods))));

            FundingLine fundingLineThree = NewFundingLine(_ => _.WithFundingLineCode(NewRandomString())
                                                          .WithFundingLineType(FundingLineType.Information)
                                                          .WithDistributionPeriods(NewDistributionPeriod(dp => dp.WithProfilePeriods(fundingLineThreePeriods)))
                                                          .WithValue(decimal.Multiply(decimal.Multiply(2, 3), 2973864M)));

            AndTheFundingLines(fundingLineOne,
                               fundingLineTwo,
                               fundingLineThree);

            await Change.Apply(VariationsApplication);

            ThenProfilePeriodsShouldBeZeroAmount(fundingLineOnePeriods);
            AndTheProfilePeriodsShouldBeZeroAmount(fundingLineTwoPeriods);
            AndFundingLinesValuesShouldBeZeroAmount(fundingLineOne, fundingLineTwo);
            AndTheProfilePeriodsAmountShouldBe(fundingLineThreePeriods, 2973864M);

            fundingLineThree.Value
            .Should()
            .Be(17843184M);
        }
        private async Task <ProfilePeriod[]> GetOrderedProfilePeriodsForFundingLine(string fundingStreamId,
                                                                                    string fundingPeriodId,
                                                                                    string providerId,
                                                                                    string fundingLineCode)
        {
            PublishedProvider publishedProvider = await _publishedFundingResilience.ExecuteAsync(() => _publishedFunding.GetPublishedProvider(fundingStreamId,
                                                                                                                                              fundingPeriodId,
                                                                                                                                              providerId));

            if (publishedProvider == null)
            {
                throw new InvalidOperationException($"Did not locate a published provider for {fundingStreamId} {fundingPeriodId} {providerId}");
            }

            FundingLine fundingLine = publishedProvider.Current?.FundingLines?.SingleOrDefault(_ => _.FundingLineCode == fundingLineCode);

            if (fundingLine == null)
            {
                throw new InvalidOperationException(
                          $"Did not locate a funding line {fundingLineCode} on published provider for {fundingStreamId} {fundingPeriodId} {providerId}");
            }

            return(new YearMonthOrderedProfilePeriods(fundingLine)
                   .ToArray());
        }
        public async Task AssignProfilePatternKeyReturnsBadRequestIfNewPublishedProviderVersionCreationFailed()
        {
            string fundingLineCode            = NewRandomString();
            string existingProfilePatternKey  = NewRandomString();
            string newProfilePatterFundingKey = NewRandomString();

            GivenTheFundingConfiguration(true);
            ProfilePatternKey profilePatternKey = NewProfilePatternKey(_ => _.WithFundingLineCode(fundingLineCode).WithKey(newProfilePatterFundingKey));

            FundingLine fundingLine = NewFundingLine(_ => _.WithFundingLineCode(fundingLineCode));
            PublishedProviderVersion existingPublishedProviderVersion =
                NewPublishedProviderVersion(ppv => ppv
                                            .WithFundingStreamId(_fundingStreamId)
                                            .WithFundingPeriodId(_fundingPeriodId)
                                            .WithProfilePatternKeys(
                                                NewProfilePatternKey(_ => _.WithFundingLineCode(fundingLineCode).WithKey(existingProfilePatternKey)))
                                            .WithFundingLines(fundingLine)
                                            );

            PublishedProvider publishedProvider = NewPublishedProvider(_ => _.WithCurrent(existingPublishedProviderVersion));

            GivenThePublishedProvider(publishedProvider);

            IActionResult result = await WhenProfilePatternKeyIsAssigned(_fundingStreamId, _fundingPeriodId, _providerId, profilePatternKey);

            ThenResultShouldBe(result, HttpStatusCode.BadRequest);
        }
Esempio n. 16
0
        private static decimal?GetFundingLinesTotalValueRecursive(FundingLine fundingLine)
        {
            decimal?cashCalculationsSum = GetCashCalculationsSum(fundingLine);

            decimal?subFundingLinesTotalValue = null;

            if (fundingLine.FundingLines != null)
            {
                subFundingLinesTotalValue = fundingLine.FundingLines.Select(GetFundingLinesTotalValueRecursive)
                                            .Where(fundingLineTotal => fundingLineTotal != null)
                                            .Aggregate(
                    subFundingLinesTotalValue,
                    (current, fundingLineTotal) => current.AddValueIfNotNull(fundingLineTotal));
            }

            if (cashCalculationsSum != null && subFundingLinesTotalValue == null)
            {
                fundingLine.Value = cashCalculationsSum;
            }
            else if (cashCalculationsSum == null && subFundingLinesTotalValue != null)
            {
                fundingLine.Value = subFundingLinesTotalValue;
            }
            else if (cashCalculationsSum != null)
            {
                fundingLine.Value = cashCalculationsSum + subFundingLinesTotalValue;
            }

            return(fundingLine.Value);
        }
Esempio n. 17
0
        private void _DisplayAmounts(FundingLine fl)
        {
            bool useCents = null == fl.Currency ? true : fl.Currency.UseCents;

            tbInitialAmt.Text     = fl.Amount.GetFormatedValue(useCents);
            tbRealAmt.Text        = fl.RealRemainingAmount.GetFormatedValue(useCents);
            tbAnticipatedAmt.Text = fl.AnticipatedRemainingAmount.GetFormatedValue(useCents);
        }
Esempio n. 18
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     tabControlFundingLines.TabPages.Remove(tabPageFundingLineDetails);
     tabControlFundingLines.TabPages.Add(tabPageFundingLineDetails);
     tabControlFundingLines.SelectedTab = tabPageFundingLineDetails;
     _fundingLine = new FundingLine();
     InitializeTabPageFundingLineDetails(_fundingLine);
 }
Esempio n. 19
0
 public FrmFundingLineEvent(FundingLine pFundingLine, FundingLineEvent pFundingLineEvent)
 {
     InitializeComponent();
     _FundingLine      = pFundingLine;
     _fundingLineEvent = pFundingLineEvent;
     InitializeComboBoxDirections();
     dateTimePickerEvent.Value = TimeProvider.Now;
 }
Esempio n. 20
0
 public CorporateUserControl(Form pMdiParent)
 {
     _mdifrom = pMdiParent;
     InitializeComponent();
     _corporate   = new Corporate();
     _fundingLine = null;
     InitializeUserControlsAddress();
 }
Esempio n. 21
0
 private async Task ProfileFundingLine(FundingLine fundingLine, PublishedProviderVersion newPublishedProviderVersion, ProfilePatternKey profilePatternKey)
 {
     await _profilingService.ProfileFundingLines(
         new[] { fundingLine },
         newPublishedProviderVersion.FundingStreamId,
         newPublishedProviderVersion.FundingPeriodId,
         new[] { profilePatternKey });
 }
Esempio n. 22
0
        private decimal?CalculateFundingTotal(FundingLine fundingLine)
        {
            decimal?paymentFundingLineValue       = fundingLine.Type == FundingLineType.Payment ? fundingLine.Value : null;
            decimal?subFundingLinesTotal          = fundingLine.FundingLines?.NullableSum(CalculateFundingTotal);
            decimal?nonPaymentFundingLineSubTotal = fundingLine.Type != FundingLineType.Payment ? (subFundingLinesTotal) : null;

            return(paymentFundingLineValue.AddValueIfNotNull(nonPaymentFundingLineSubTotal));
        }
Esempio n. 23
0
        private decimal?CalculateFundingTotal(FundingLine fundingLine)
        {
            decimal?paymentFundingLineValue       = fundingLine.Type == FundingLineType.Payment ? fundingLine.Value : 0;
            decimal?subFundingLinesTotal          = fundingLine.FundingLines?.Sum(CalculateFundingTotal);
            decimal?nonPaymentFundingLineSubTotal = fundingLine.Type != FundingLineType.Payment ? (subFundingLinesTotal) : 0;

            return(paymentFundingLineValue + nonPaymentFundingLineSubTotal);
        }
Esempio n. 24
0
        public void WhenGeneratingFundingLineValuesForACollectionOfFundingLinesUsingCashCalculations_ExpectedRoundingInHierachyBasedOnFundingLineTotals()
        {
            IEnumerable <FundingLine> fundingLines = JsonConvert.DeserializeObject <IEnumerable <FundingLine> >(GetResourceString($"CalculateFunding.Generators.Funding.UnitTests.Resources.exampleFundingLines-rounding.json"));

            FundingValue fundingValue = _generator.GenerateFundingValue(fundingLines, 2);

            fundingValue.TotalValue.Should().Be(60M);

            IEnumerable <FundingLine> allFundingLines = fundingValue.FundingLines.Flatten(_ => _.FundingLines);

            FundingLine aggregateFundingLine = allFundingLines.Single(_ => _.Name == "aggregate funding line");

            // This is important to check the total is rounded to sub funding lines, then the aggregate funding lines are summed.
            // If just the cash calculations are summed, then the aggregate would be 60.01, instead of 60.00.
            // This is because the cash calculations would be 5 lots of xx.001, which would equals xx.01, instead of the funding lines summed from xx.00
            aggregateFundingLine.Value.Should()
            .Be(60M);

            FundingLine fundingLine1 = allFundingLines.Single(_ => _.Name == "funding line 1");

            fundingLine1.Value.Should().Be(10M);

            FundingLine fundingLine2 = allFundingLines.Single(_ => _.Name == "funding line 2");

            fundingLine2.Value.Should().Be(10M);

            FundingLine fundingLine3 = allFundingLines.Single(_ => _.Name == "funding line 3");

            fundingLine3.Value.Should().Be(11M);

            FundingLine fundingLine4 = allFundingLines.Single(_ => _.Name == "funding line 4");

            fundingLine4.Value.Should().Be(11M);

            FundingLine fundingLine5 = allFundingLines.Single(_ => _.Name == "funding line 5");

            fundingLine5.Value.Should().Be(12M);

            FundingLine fundingLine6 = allFundingLines.Single(_ => _.Name == "funding line 6");

            fundingLine6.Value.Should().Be(12M);

            FundingLine fundingLine7 = allFundingLines.Single(_ => _.Name == "funding line 7");

            fundingLine7.Value.Should().Be(13M);

            FundingLine fundingLine8 = allFundingLines.Single(_ => _.Name == "funding line 8");

            fundingLine8.Value.Should().Be(13M);

            FundingLine fundingLine9 = allFundingLines.Single(_ => _.Name == "funding line 9");

            fundingLine9.Value.Should().Be(14M);

            FundingLine fundingLine10 = allFundingLines.Single(_ => _.Name == "funding line 10");

            fundingLine10.Value.Should().Be(14M);
        }
Esempio n. 25
0
 public CorporateUserControl(Corporate pCorporate, FundingLine pFundingLine)
 {
     InitializeComponent();
     _corporate   = pCorporate;
     _fundingLine = pFundingLine;
     InitializeUserControlsAddress();
     InitializeCorporate();
     InitializeCustomizableFields(_corporate.Id);
 }
        public string GetProfilePatternKey(FundingLine fundingLine)
        {
            if (ProfilePatternKeys.IsNullOrEmpty())
            {
                return(null);
            }

            return(ProfilePatternKeys.TryGetValue(fundingLine.FundingLineCode, out string key) ? key : null);
        }
Esempio n. 27
0
 public FrmFundingLineEvent(FundingLine pFundingLine)
 {
     InitializeComponent();
     _FundingLine      = pFundingLine;
     _exchangeRate     = null;
     _fundingLineEvent = new FundingLineEvent();
     InitializeComboBoxDirections();
     dateTimePickerEvent.Value = TimeProvider.Now;
 }
Esempio n. 28
0
        private void listViewFundingLine_DoubleClick(object sender, EventArgs e)
        {
            tabControlFundingLines.TabPages.Remove(tabPageFundingLineDetails);
            tabControlFundingLines.TabPages.Add(tabPageFundingLineDetails);
            tabControlFundingLines.SelectedTab = tabPageFundingLineDetails;

            _fundingLine = (FundingLine)listViewFundingLine.SelectedItems[0].Tag;
            InitializeTabPageFundingLineDetails(_fundingLine);
        }
        /// <summary>
        /// Select all events for selected Funding Line
        /// </summary>
        /// <param name="fundingLine">funding line </param>
        /// <returns>list of Funding Line events</returns>
        public List <FundingLineEvent> SelectFundingLineEvents(FundingLine fundingLine)
        {
            List <FundingLineEvent> list = new List <FundingLineEvent>();

            const string sqlText =
                @"SELECT 
                        [id],
                        [code],
                        [amount],
                        [direction],
                        [fundingline_id],
                        [deleted],
                        [creation_date],
                        [type] 
                  FROM [FundingLineEvents] 
                  WHERE fundingline_id = @fundingline_id 
                  ORDER BY creation_date DESC, id DESC";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, conn))
                {
                    cmd.AddParam("@fundingline_id", fundingLine.Id);

                    using (OpenCbsReader reader = cmd.ExecuteReader())
                    {
                        if (reader == null || reader.Empty)
                        {
                            return(list);
                        }
                        {
                            while (reader.Read())
                            {
                                FundingLineEvent fundingLineEvent = new FundingLineEvent
                                {
                                    Id       = reader.GetInt("id"),
                                    Code     = reader.GetString("code"),
                                    Amount   = reader.GetMoney("amount"),
                                    Movement =
                                        ((OBookingDirections)
                                         reader.GetSmallInt("direction")),
                                    IsDeleted =
                                        reader.GetBool("deleted"),
                                    CreationDate =
                                        reader.GetDateTime("creation_date"),
                                    Type =
                                        ((OFundingLineEventTypes)
                                         reader.GetSmallInt("type")),
                                    FundingLine = fundingLine
                                };
                                list.Add(fundingLineEvent);
                            }
                        }
                    }
                    return(list);
                }
        }
Esempio n. 30
0
 public CashPrevisionForm(FundingLine pfundingLine, bool pIncludeDeleted)
 {
     InitializeComponent();
     date = TimeProvider.Today;
     _cashForFundingLine = pfundingLine;
     forecastDays        = 5;
     includeDeleted      = pIncludeDeleted;
     checkBoxIncludeLateLoans.Checked = pIncludeDeleted;
     DrawZedGraphForCashPrevision();
 }