コード例 #1
0
        public void AddBooking_BookingWithoutCurrentAccount_AccountJournalUnchanged()
        {
            var sut = CreateSut();

            sut.ProjectData.Load(Samples.SampleProject);
            var booking = new AccountingDataJournalBooking
            {
                Date   = Samples.BaseDate + 401,
                ID     = 4567,
                Credit = new List <BookingValue> {
                    new BookingValue {
                        Account = 990, Text = "Init", Value = 42
                    }
                },
                Debit = new List <BookingValue> {
                    new BookingValue {
                        Account = 100, Text = "Init", Value = 42
                    }
                }
            };

            sut.Accounts.SelectedAccount = sut.Accounts.AccountList.Last();

            using var monitor1 = sut.AccountJournal.Monitor();
            using var monitor2 = sut.AccountJournal.Items.Monitor();
            sut.ProjectData.AddBooking(booking, updateJournal: true);

            using var _ = new AssertionScope();
            monitor1.Should().NotRaisePropertyChangeFor(x => x.SelectedItem);
            monitor2.Should().NotRaise(nameof(sut.AccountJournal.Items.CollectionChanged));
        }
コード例 #2
0
        public void AddBooking_FirstBooking_JournalsUpdated()
        {
            var sut = CreateSut();

            sut.ProjectData.Load(Samples.SampleProject);
            var booking = new AccountingDataJournalBooking
            {
                Date   = Samples.BaseDate + 401,
                ID     = 4567,
                Credit = new List <BookingValue> {
                    new BookingValue {
                        Account = 990, Text = "Init", Value = 42
                    }
                },
                Debit = new List <BookingValue> {
                    new BookingValue {
                        Account = 100, Text = "Init", Value = 42
                    }
                }
            };

            using var fullJournalMonitor    = sut.FullJournal.Monitor();
            using var accountJournalMonitor = sut.AccountJournal.Monitor();
            sut.ProjectData.AddBooking(booking, updateJournal: true);

            using var _ = new AssertionScope();
            sut.FullJournal.Items.Should().BeEquivalentTo(
                new[]
            {
                new
                {
                    Identifier    = 4567,
                    Date          = new DateTime(DateTime.Now.Year, 4, 1),
                    Text          = "Init",
                    Value         = 0.42,
                    CreditAccount = "990 (Carryforward)",
                    DebitAccount  = "100 (Bank account)"
                }
            });
            fullJournalMonitor.Should().RaisePropertyChangeFor(x => x.SelectedItem);
            sut.FullJournal.SelectedItem.Should().BeEquivalentTo(new { Identifier = 4567 });
            sut.AccountJournal.Items.Should().BeEquivalentTo(
                new object[]
            {
                new
                {
                    Identifier    = 4567,
                    Date          = new DateTime(DateTime.Now.Year, 4, 1),
                    Text          = "Init",
                    CreditValue   = 0.0,
                    DebitValue    = 0.42,
                    RemoteAccount = "990 (Carryforward)"
                },
                new { Text = "Total", IsSummary = true, CreditValue = 0.0, DebitValue = 0.42 },
                new { Text = "Balance", IsSummary = true, CreditValue = 0.0, DebitValue = 0.42 }
            });
            accountJournalMonitor.Should().RaisePropertyChangeFor(x => x.SelectedItem);
            sut.AccountJournal.SelectedItem.Should().BeEquivalentTo(new { Identifier = 4567 });
        }
コード例 #3
0
        private void AddBookingEntries(AccountingDataJournalBooking entry, ulong accountIdentifier, XmlNode dataNode)
        {
            XmlNode lineTemplate = this.PrintDocument.CreateElement("tr");

            lineTemplate.SetAttribute("topLine", true);
            lineTemplate.AddTableNode(entry.Date.ToDateTime().ToString("d", CultureInfo.CurrentCulture));
            lineTemplate.AddTableNode(entry.ID.ToString(CultureInfo.InvariantCulture));

            var debitEntries = entry.Debit.Where(x => x.Account == accountIdentifier);

            foreach (var debitEntry in debitEntries)
            {
                var lineNode = lineTemplate.Clone();
                lineNode.AddTableNode(debitEntry.Text);
                double debitValue = Convert.ToDouble(debitEntry.Value) / 100;
                lineNode.AddTableNode(debitValue.FormatCurrency());
                this.debitTotal += debitValue;
                lineNode.AddTableNode(string.Empty);
                lineNode.AddTableNode(
                    entry.Credit.Count == 1
                        ? entry.Credit[0].Account.ToString(CultureInfo.InvariantCulture)
                        : Resources.Word_Various);
                dataNode.AppendChild(lineNode);
            }

            var creditEntries = entry.Credit.Where(x => x.Account == accountIdentifier);

            foreach (var creditEntry in creditEntries)
            {
                var lineNode = lineTemplate.Clone();
                lineNode.AddTableNode(creditEntry.Text);
                lineNode.AddTableNode(string.Empty);
                double creditValue = Convert.ToDouble(creditEntry.Value) / 100;
                lineNode.AddTableNode(creditValue.FormatCurrency());
                this.creditTotal += creditValue;
                lineNode.AddTableNode(
                    entry.Debit.Count == 1
                        ? entry.Debit[0].Account.ToString(CultureInfo.InvariantCulture)
                        : Resources.Word_Various);
                dataNode.AppendChild(lineNode);
            }
        }