use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class InvoiceForLease_Test method setUp.
@Before
public void setUp() throws Exception {
numerator = new Numerator();
numerator.setFormat("XXX-%05d");
numerator.setLastIncrement(BigInteger.TEN);
applicationTenancy = new ApplicationTenancy();
applicationTenancy.setPath("/");
context.checking(new Expectations() {
{
allowing(mockClockService).now();
will(returnValue(LocalDate.now()));
}
});
}
use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class EstatioApplicationTenancyRepositoryForLease method findOrCreateTenancyFor.
public ApplicationTenancy findOrCreateTenancyFor(final Property property, final Party party) {
ApplicationTenancy propertyPartyTenancy = applicationTenancies.findByPath(pathFor(property, party));
if (propertyPartyTenancy != null) {
return propertyPartyTenancy;
}
final ApplicationTenancy propertyApplicationTenancy = estatioApplicationTenancyRepositoryForProperty.findOrCreateTenancyFor(property);
final String tenancyName = String.format("%s/%s ", propertyApplicationTenancy.getPath(), party.getReference());
return applicationTenancies.newTenancy(tenancyName, pathFor(property, party), propertyApplicationTenancy);
}
use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class InvoiceMenu method newInvoiceForLease.
@ActionLayout(contributed = Contributed.AS_NEITHER)
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@MemberOrder(sequence = "1")
public Invoice newInvoiceForLease(final Lease lease, final LocalDate dueDate, @Parameter(optionality = Optionality.OPTIONAL) final PaymentMethod paymentMethod, final Currency currency) {
final Property propertyIfAny = lease.getProperty();
final Party seller = lease.getPrimaryParty();
final Party buyer = lease.getSecondaryParty();
final ApplicationTenancy propertySellerTenancy = estatioApplicationTenancyRepositoryForLease.findOrCreateTenancyFor(propertyIfAny, seller);
return invoiceForLeaseRepository.newInvoice(propertySellerTenancy, seller, buyer, paymentMethod == null ? lease.defaultPaymentMethod() : paymentMethod, currency, dueDate, lease, null);
}
use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class EstatioApplicationTenancyRepositoryForCountry_Test method testFindOrCreateCountryTenancy_whenExists.
@Test
public void testFindOrCreateCountryTenancy_whenExists() throws Exception {
// given
Country country = new Country();
country.setReference("ITA");
// when
ApplicationTenancy countryTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(country);
// then
assertThat(countryTenancy).isEqualTo(italy);
}
use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class EstatioApplicationTenancyRepositoryForCountry_Test method testFindCountryTenancyFor.
@Test
public void testFindCountryTenancyFor() {
// given
ApplicationTenancy atGlobalLevel = new ApplicationTenancy();
atGlobalLevel.setPath("/");
ApplicationTenancy atGlobalLevel_ = new ApplicationTenancy();
atGlobalLevel_.setPath("/_");
ApplicationTenancy atCountryLevel = new ApplicationTenancy();
atCountryLevel.setPath("/ABC");
ApplicationTenancy atCountryLevel_ = new ApplicationTenancy();
atCountryLevel_.setPath("/ABC/_");
ApplicationTenancy atPropertyLevel = new ApplicationTenancy();
atPropertyLevel.setPath("/ABC/DEF");
atPropertyLevel.setParent(atCountryLevel);
ApplicationTenancy atLandLordLevel = new ApplicationTenancy();
atLandLordLevel.setPath("/ABC/DEF/GHI");
atLandLordLevel.setParent(atPropertyLevel);
// when, then
assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atGlobalLevel).getPath()).isEqualTo("/");
assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atGlobalLevel_).getPath()).isEqualTo("/_");
assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atCountryLevel).getPath()).isEqualTo("/ABC");
assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atCountryLevel_).getPath()).isEqualTo("/ABC/_");
assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atPropertyLevel).getPath()).isEqualTo("/ABC");
assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atLandLordLevel).getPath()).isEqualTo("/ABC");
}
Aggregations