Exemplo n.º 1
0
 public GeneralLedgerEntryNotInPeriodException(GeneralLedgerEntryNumber number, LocalDateTime createdOn,
                                               AccountingPeriod accountingPeriod) : base(
         $"General ledger entry {number} had a creation date of {createdOn}, but the current period is {accountingPeriod}")
 {
     Number           = number;
     CreatedOn        = createdOn;
     AccountingPeriod = accountingPeriod;
 }
Exemplo n.º 2
0
 internal GeneralLedgerEntry(GeneralLedgerEntryIdentifier identifier,
                             GeneralLedgerEntryNumber number, Period period, DateTimeOffset createdOn) : this()
 {
     Apply(new GeneralLedgerEntryCreated {
         GeneralLedgerEntryId = identifier.ToGuid(),
         Number    = number.ToString(),
         CreatedOn = createdOn,
         Period    = period.ToString()
     });
 }
Exemplo n.º 3
0
        internal GeneralLedgerEntry(GeneralLedgerEntryIdentifier identifier,
                                    GeneralLedgerEntryNumber number, AccountingPeriod accountingPeriod, LocalDateTime createdOn) : this()
        {
            if (!accountingPeriod.Contains(createdOn.Date))
            {
                throw new GeneralLedgerEntryNotInPeriodException(number, createdOn, accountingPeriod);
            }

            Apply(new GeneralLedgerEntryCreated {
                GeneralLedgerEntryId = identifier.ToGuid(),
                Number    = number.ToString(),
                CreatedOn = Time.Format.LocalDateTime(createdOn),
                Period    = accountingPeriod.ToString()
            });
        }
Exemplo n.º 4
0
        internal GeneralLedgerEntry(GeneralLedgerEntryIdentifier identifier,
                                    GeneralLedgerEntryNumber number, Period period, DateTimeOffset createdOn) : this()
        {
            if (!period.Contains(createdOn))
            {
                throw new GeneralLedgerEntryNotInPeriodException(number, createdOn, period);
            }

            Apply(new GeneralLedgerEntryCreated {
                GeneralLedgerEntryId = identifier.ToGuid(),
                Number    = number.ToString(),
                CreatedOn = createdOn,
                Period    = period.ToString()
            });
        }
 public void TryParseValidValueReturnsExpectedResult(GeneralLedgerEntryNumber number)
 {
     Assert.True(GeneralLedgerEntryNumber.TryParse(number.ToString(), out var sut));
     Assert.Equal(number, sut);
 }
        public void Equality(GeneralLedgerEntryNumber sut)
        {
            var copy = new GeneralLedgerEntryNumber(sut.Prefix, sut.SequenceNumber);

            Assert.Equal(sut, copy);
        }
        public void ParseValidValueReturnsExpectedResult(GeneralLedgerEntryNumber number)
        {
            var sut = GeneralLedgerEntryNumber.Parse(number.ToString());

            Assert.Equal(number, sut);
        }
 public void InequalityOperator(GeneralLedgerEntryNumber left, GeneralLedgerEntryNumber right)
 {
     Assert.True(left != right);
 }
        public void EqualityOperator(GeneralLedgerEntryNumber sut)
        {
            var copy = new GeneralLedgerEntryNumber(sut.Prefix, sut.SequenceNumber);

            Assert.True(sut == copy);
        }
 public void TryParseInvalidValueReturnsExpectedResult(string value)
 {
     Assert.False(GeneralLedgerEntryNumber.TryParse(value, out var sut));
     Assert.Equal(default, sut);
 public void ParseInvalidValueReturnsExpectedResult(string value)
 {
     Assert.Throws <FormatException>(() => GeneralLedgerEntryNumber.Parse(value));
 }
 public GeneralLedgerEntryNotInPeriodException(GeneralLedgerEntryNumber number, DateTimeOffset createdOn,
                                               Period period) : base(
         $"General ledger entry {number} had a creation date of {createdOn}, but the current period is {period}")
 {
 }
Exemplo n.º 13
0
 private static GeneralLedgerEntry Create(GeneralLedgerEntryIdentifier identifier,
                                          GeneralLedgerEntryNumber number, DateTimeOffset createdOn, Period period) =>
 new GeneralLedgerEntry(identifier, number, period, createdOn);
Exemplo n.º 14
0
 public GeneralLedgerEntry Create(GeneralLedgerEntryIdentifier identifier, GeneralLedgerEntryNumber number,
                                  DateTimeOffset createdOn) => _periodClosing
                 ? Create(identifier, number, createdOn, _period.Next())
                 : Create(identifier, number, createdOn, _period.Contains(createdOn) ? _period : _period.Next());