コード例 #1
0
        public Transition_SponsorWindow(Sponsor s, FundType ft)
        {
            InitializeComponent();
            txtSponsorName.Text = s.Name;
            var i = new Invoice();

            i.AddTransition();
            i.Transitions[0].LeftAccount = s.Account;

            if (ft == FundType.GeneralHidden)
            {
                i.Transitions[0].IsHidden = true;
                txtHeader.Text           += " (ايداع مخفي)";
            }

            if (ft == FundType.Private)
            {
                cmboAccounts.ItemsSource = BaseDataBase._Tabling("select Id, Name from Account where Id between 2 and 4").DefaultView;
            }
            else
            {
                cmboAccounts.ItemsSource   = BaseDataBase._Tabling("select Id, Name from Account where Id = 1").DefaultView;
                cmboAccounts.SelectedIndex = 0;
                GetCurrentBalance(s.Account.Id.Value, 1);
            }

            this.DataContext = i;
        }
コード例 #2
0
        public Transition_Expenses(FundType ft)
        {
            InitializeComponent();
            var i = new Invoice();
            var t = i.AddTransition();

            t.LeftAccount = new Account {
                Id = 1
            };                                          //1 is general fund account id
            t.RightAccount = new Account {
                Id = 5
            };                                          //5 is expenses account id

            if (ft == FundType.GeneralHidden)
            {
                t.IsHidden         = true;
                txtMsg1.Visibility = Visibility.Visible;
                txtMsg2.Visibility = Visibility.Collapsed;
                var r = BaseDataBase._Scalar($@"select dbo.fn_GetHiddenBalance()");
                txtBalance.Text = r;
            }
            else
            {
                var r = BaseDataBase._Scalar($@"(select
			        (select isnull(sum(Value),0) from Transition where IsHidden = 0 and RightAccount = 1 - 
			        (select isnull(sum(Value),0) from Transition where IsHidden = 0 and LeftAccount = 1))"            );
                txtBalance.Text = r;
            }
            this.DataContext = i;
        }
コード例 #3
0
        public Result Add(string description, double amount, DateTime date, string note, PaymentType paymentType,
                          BudgetType budgetType, FundType fundType, bool?giftAid = false)
        {
            Result <Note> incomeNote = Note.Create(note);
            Result <TransactionDescription> incomeDescription = TransactionDescription.Create(description);

            var incomeGiftAid = giftAid == null ?
                                GiftAidStatus.NotSet :
                                (bool)giftAid ?
                                GiftAidStatus.GiftAid :
                                GiftAidStatus.NotGiftAid;

            var result = Result.Combine(incomeNote, incomeDescription);

            if (result.IsSuccess)
            {
                var income = Income.Create(
                    incomeDescription.Value, date, paymentType,
                    amount, budgetType, incomeNote.Value, fundType);

                Add(income);

                return(Result.Ok());
            }

            return(result);
        }
コード例 #4
0
 public Fund(int id, string name, int externalId, FundType type)
 {
     Id         = id;
     Name       = name;
     ExternalId = externalId;
     Type       = type;
 }
コード例 #5
0
        public Fund GetFundByNameAndDate(FundType fundType, DateTime date)
        {
            var balance = GetIncomeByFundType(fundType).Where(t => t.Date <= date).Sum(i => i.Amount) -
                          GetPaymentByFundType(fundType).Where(t => t.Date <= date).Sum(p => p.Amount);

            fund = new Fund(fundType.ToString(), balance);

            return(fund);
        }
コード例 #6
0
        public Fund GetFundByName(FundType fundType)
        {
            var balance = GetIncomeByFundType(fundType).Sum(i => i.Amount) -
                          GetPaymentByFundType(fundType).Sum(p => p.Amount);

            fund = new Fund(fundType.ToString(), balance);

            return(fund);
        }
コード例 #7
0
        private void CreateTransactionTypeRows()
        {
            var paymentTypeId = paymentTypeRepository.Add(PAYMENTTYPE_TOADD);
            var fundTypeId    = fundTypeRepository.Add(FUNDTYPE_TOADD);
            var budgetTypeId  = budgetTypeRepository.Add(BUDGETTYPE_TOADD);

            PAYMENTTYPE = paymentTypeRepository.GetById(paymentTypeId);
            BUDGETTYPE  = budgetTypeRepository.GetById(budgetTypeId);
            FUNDTYPE    = fundTypeRepository.GetById(fundTypeId);
        }
コード例 #8
0
        private void GetByID(Guid id)
        {
            // Act
            FundType fundType = repo.GetById(id);

            // Assert
            Assert.IsNotNull(fundType.Description, "GetByID returned null.");
            Assert.AreEqual(id, fundType.Id);
            Assert.AreEqual(DESCRIPTION, fundType.Description);
            Assert.AreEqual(LONG_DESCRIPTION, fundType.LongDescription);
        }
コード例 #9
0
 public void Setup()
 {
     payment = Payment.Create(
         (TransactionDescription)"Council Tax",
         DateTime.Parse("03/06/2018"),
         PaymentType.Create("DDR", "Direct Debit").Value,
         210.00,
         BudgetType.Create("CTAX", "Council Tax"),
         SpendType.Create("Revenue", "Revenue"),
         (Note)string.Empty, "",
         FundType.Create("Revenue", "Revenue"));
 }
コード例 #10
0
        private void Delete(Guid id)
        {
            // Arrange
            FundType fundType = repo.GetById(id);

            // Act
            repo.Remove(fundType);
            fundType = repo.GetById(id);

            // Assert
            Assert.IsNull(fundType, "Record is not deleted.");
        }
コード例 #11
0
 private void InitialiseParameters()
 {
     DATERECIEVED      = new DateTime(2018, 8, 7);
     DESCRIPTION       = (TransactionDescription)"Offering 7/8/2018";
     AMOUNT            = 230.00;
     PAYMENTTYPE_TOADD = PaymentType.Create("CSH", "Cash").Value;
     BUDGETTYPE_TOADD  = BudgetType.Create("GeneralIncome", "General Income");
     FUNDTYPE_TOADD    = FundType.Create("Revenue", "Revenue");
     GIFTAIDSTATUS     = GiftAidStatus.NotGiftAid;
     PAYINGINSLIP      = "000124";
     NOTE        = (Note)"Offering taken in the evening";
     BANKCLEARED = false;
 }
コード例 #12
0
 private void InitialiseParameters()
 {
     DATERECIEVED      = new DateTime(2018, 8, 7);
     DESCRIPTION       = (TransactionDescription)"Builder and Sons";
     AMOUNT            = 520.00;
     PAYMENTTYPE_TOADD = PaymentType.Create("CHQ", "Cheque").Value;
     BUDGETTYPE_TOADD  = BudgetType.Create("Building", "Building Maintenance");
     FUNDTYPE_TOADD    = FundType.Create("Building", "Building Fund");
     SPENDTYPE_TOADD   = SpendType.Create("Capital", "Capital");
     NOTE         = (Note)string.Empty;
     BANKCLEARED  = false;
     CHEQUENUMBER = "000123";
 }
コード例 #13
0
        private Guid Create()
        {
            //Arrange
            FundType fundType = FundType.Create(DESCRIPTION, LONG_DESCRIPTION);

            //Act
            fundType.Id = repo.Add(fundType);

            //Assert
            Assert.AreNotEqual(0, fundType.Id, "Creating new record does not return id");

            return(fundType.Id);
        }
コード例 #14
0
        public void Setup()
        {
            income = Income.Create(
                (TransactionDescription)"Offering 20/05/18",
                DateTime.Parse("22/05/2018"),
                PaymentType.Create("CSH", "Cash").Value,
                230.00,
                BudgetType.Create("GeneralIncome", "General Income"),
                (Note)string.Empty,
                FundType.Create("Revenue", "Revenue")
                );

            income.GiftAidStatus = GiftAidStatus.NotGiftAid;
        }
コード例 #15
0
        private void Update(Guid id)
        {
            // Arrange
            FundType fundType = repo.GetById(id);

            fundType.LongDescription = "Test Change";

            // Act
            repo.Update(fundType);

            FundType updatedFundType = repo.GetById(id);

            // Assert
            Assert.AreEqual("Test Change", updatedFundType.LongDescription, "Record is not updated.");
        }
コード例 #16
0
 private IEnumerable <Income> GetIncomeByFundType(FundType fundType)
 {
     return(incomes.Where(t => t.FundType == fundType));
 }
コード例 #17
0
 private IEnumerable <Payment> GetPaymentByFundType(FundType fundType)
 {
     return(payments.Where(t => t.FundType == fundType));
 }