public void GivenCashPaymentMethodForInternalOrganisationThatDoesAccounting_WhenDeriving_ThenEitherGeneralLedgerAccountOrJournalMustExist() { var supplier = new OrganisationBuilder(this.DatabaseSession) .WithName("supplier") .WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain) .Build(); var internalOrganisation = new InternalOrganisations(this.DatabaseSession).FindBy(InternalOrganisations.Meta.Name, "internalOrganisation"); var supplierRelationship = new SupplierRelationshipBuilder(this.DatabaseSession) .WithSupplier(supplier) .WithInternalOrganisation(internalOrganisation) .WithFromDate(DateTime.UtcNow) .Build(); var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.DatabaseSession) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.DatabaseSession) .WithInternalOrganisation(internalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.DatabaseSession).WithDescription("journal").Build(); this.DatabaseSession.Commit(); var cash = new CashBuilder(this.DatabaseSession) .WithDescription("description") .WithCreditor(supplierRelationship) .Build(); internalOrganisation.RemovePaymentMethods(); internalOrganisation.AddPaymentMethod(cash); internalOrganisation.DoAccounting = true; Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); cash.Journal = journal; Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); cash.RemoveJournal(); cash.GeneralLedgerAccount = internalOrganisationGlAccount; Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); }
public void GivenCashPaymentMethodForInternalOrganisationThatDoesAccounting_WhenDeriving_ThenCreditorIsRequired() { var cash = new CashBuilder(this.DatabaseSession) .WithDescription("description") .Build(); var internalOrganisation = Singleton.Instance(this.DatabaseSession).DefaultInternalOrganisation; internalOrganisation.RemovePaymentMethods(); internalOrganisation.AddPaymentMethod(cash); internalOrganisation.DoAccounting = false; Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); internalOrganisation.DoAccounting = true; Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); }
public void GivenCashPaymentMethodForSingletonThatDoesAccounting_WhenDeriving_ThenEitherGeneralLedgerAccountOrJournalMustExist() { var internalOrganisation = this.InternalOrganisation; var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithInternalOrganisation(this.InternalOrganisation) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session) .WithDescription("journal") .Build(); this.Session.Commit(); var cash = new CashBuilder(this.Session) .WithDescription("description") .Build(); internalOrganisation.DoAccounting = true; ((OrganisationDerivedRoles)internalOrganisation).AddActiveCollectionMethod(cash); Assert.True(this.Session.Derive(false).HasErrors); cash.Journal = journal; Assert.False(this.Session.Derive(false).HasErrors); cash.RemoveJournal(); cash.GeneralLedgerAccount = internalOrganisationGlAccount; Assert.False(this.Session.Derive(false).HasErrors); }
public void GivenCashPaymentMethod_WhenDeriving_ThenGeneralLedgerAccountAndJournalAtMostOne() { var generalLedgerAccount = new GeneralLedgerAccountBuilder(this.Session) .WithAccountNumber("0001") .WithName("GeneralLedgerAccount") .WithBalanceSheetAccount(true) .Build(); var internalOrganisationGlAccount = new OrganisationGlAccountBuilder(this.Session) .WithGeneralLedgerAccount(generalLedgerAccount) .Build(); var journal = new JournalBuilder(this.Session).WithDescription("journal").Build(); this.Session.Commit(); var cash = new CashBuilder(this.Session) .WithDescription("description") .WithGeneralLedgerAccount(internalOrganisationGlAccount) .Build(); var internalOrganisation = this.InternalOrganisation; internalOrganisation.DoAccounting = true; internalOrganisation.DefaultCollectionMethod = cash; Assert.False(this.Session.Derive(false).HasErrors); cash.Journal = journal; Assert.True(this.Session.Derive(false).HasErrors); cash.RemoveGeneralLedgerAccount(); Assert.False(this.Session.Derive(false).HasErrors); }