Search in sources :

Example 1 with Numerator

use of org.estatio.module.numerator.dom.Numerator in project estatio by estatio.

the class OrderRepository method create.

@Programmatic
public Order create(final Property property, final String orderNumber, final String sellerOrderReference, final LocalDate entryDate, final LocalDate orderDate, final Party seller, final Party buyer, final String atPath, final OrderApprovalState approvalStateIfAny) {
    final Numerator numerator = numeratorRepository.findOrCreateNumerator("Order number", null, "%05d", BigInteger.ZERO, applicationTenancyRepository.findByPath(atPath));
    final Order order = new Order(property, orderNumber == null ? numerator.nextIncrementStr() : orderNumber, sellerOrderReference, entryDate, orderDate, seller, buyer, atPath, approvalStateIfAny);
    serviceRegistry2.injectServicesInto(order);
    repositoryService.persistAndFlush(order);
    return order;
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with Numerator

use of org.estatio.module.numerator.dom.Numerator in project estatio by estatio.

the class CreateInvoiceNumerators method execute.

@Override
protected void execute(ExecutionContext ec) {
    final List<FixedAssetRoleTypeEnum> roleTypes = Arrays.asList(FixedAssetRoleTypeEnum.PROPERTY_OWNER, FixedAssetRoleTypeEnum.TENANTS_ASSOCIATION);
    for (final Property property : propertyRepository.allProperties()) {
        for (final FixedAssetRole fixedAssetRole : fixedAssetRoleRepository.findAllForProperty(property)) {
            if (roleTypes.contains(fixedAssetRole.getType())) {
                ApplicationTenancy applicationTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(property, fixedAssetRole.getParty());
                final Numerator numerator = estatioNumeratorRepository.createInvoiceNumberNumerator(property, PropertyOwnerBuilder.numeratorReferenceFor(property), bi(0), applicationTenancy);
                ec.addResult(this, property.getReference(), numerator);
            }
        }
    }
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator) FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) FixedAssetRoleTypeEnum(org.estatio.module.asset.dom.role.FixedAssetRoleTypeEnum) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 3 with Numerator

use of org.estatio.module.numerator.dom.Numerator in project estatio by estatio.

the class InvoiceNumeratorImport method importData.

@Override
public List<Object> importData(Object previousRow) {
    // find or create app tenancy (because of use wildcards)
    ApplicationTenancy applicationTenancy = securityApplicationTenancyRepository.newTenancy(atPath, atPath, securityApplicationTenancyRepository.findByPath(atPath.split("/%/")[0]));
    Property property = propertyRepository.findPropertyByReference(propertyReference);
    Numerator numerator;
    if (atPath.contains("/%/")) {
        numerator = numeratorRepository.findScopedNumeratorIncludeWildCardMatching(Constants.NumeratorName.INVOICE_NUMBER, property, applicationTenancy);
    } else {
        numerator = numeratorRepository.findNumerator(Constants.NumeratorName.INVOICE_NUMBER, property, applicationTenancy);
    }
    if (numerator == null) {
        numerator = numeratorRepository.createScopedNumerator(Constants.NumeratorName.INVOICE_NUMBER, property, formatStr, lastIncrement, applicationTenancy);
    }
    return Lists.newArrayList(numerator);
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 4 with Numerator

use of org.estatio.module.numerator.dom.Numerator in project estatio by estatio.

the class NumeratorForOrganisationBuilder method execute.

@Override
protected void execute(ExecutionContext executionContext) {
    checkParam("country", executionContext, Country.class);
    checkParam("format", executionContext, String.class);
    defaultParam("name", executionContext, PartyConstants.ORGANISATION_REFERENCE_NUMERATOR_NAME);
    Numerator numerator = numeratorRepository.createGlobalNumerator(name, format, BigInteger.ZERO, estatioApplicationTenancyRepository.findOrCreateTenancyFor(country));
    executionContext.addResult(this, name, numerator);
    object = numerator;
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator)

Example 5 with Numerator

use of org.estatio.module.numerator.dom.Numerator 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()));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) Numerator(org.estatio.module.numerator.dom.Numerator) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Before(org.junit.Before)

Aggregations

Numerator (org.estatio.module.numerator.dom.Numerator)5 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)3 Property (org.estatio.module.asset.dom.Property)2 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 FixedAssetRole (org.estatio.module.asset.dom.role.FixedAssetRole)1 FixedAssetRoleTypeEnum (org.estatio.module.asset.dom.role.FixedAssetRoleTypeEnum)1 Expectations (org.jmock.Expectations)1 Before (org.junit.Before)1