Search in sources :

Example 1 with AgreementType

use of org.estatio.module.agreement.dom.type.AgreementType in project estatio by estatio.

the class AgreementRoleTypeRepository_Test method setup.

@Before
public void setup() {
    agreementType = new AgreementType();
    agreementRoleTypeRepository = new AgreementRoleTypeRepository() {

        @Override
        protected <T> T firstMatch(Query<T> query) {
            finderInteraction = new FinderInteraction(query, FinderMethod.FIRST_MATCH);
            return null;
        }

        @Override
        protected List<AgreementRoleType> allInstances() {
            finderInteraction = new FinderInteraction(null, FinderMethod.ALL_INSTANCES);
            return null;
        }

        @Override
        protected <T> List<T> allMatches(Query<T> query) {
            finderInteraction = new FinderInteraction(query, FinderMethod.ALL_MATCHES);
            return null;
        }
    };
    QueryResultsCache.Control control = new QueryResultsCache.Control();
    control.on(new FixturesInstallingEvent(new FixtureScriptsDefault()));
    final QueryResultsCache queryResultsCache = new QueryResultsCache() {

        {
            control = new Control();
        }
    };
    agreementRoleTypeRepository.queryResultsCache = queryResultsCache;
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) FixturesInstallingEvent(org.apache.isis.applib.events.system.FixturesInstallingEvent) List(java.util.List) FixtureScriptsDefault(org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault) QueryResultsCache(org.apache.isis.applib.services.queryresultscache.QueryResultsCache) FinderInteraction(org.incode.module.unittestsupport.dom.repo.FinderInteraction) Before(org.junit.Before)

Example 2 with AgreementType

use of org.estatio.module.agreement.dom.type.AgreementType in project estatio by estatio.

the class AgreementRoleCommunicationChannelTypeRepository method findOrCreate.

public AgreementRoleCommunicationChannelType findOrCreate(final IAgreementRoleCommunicationChannelType data, final IAgreementType IAgreementType) {
    final String title = data.getTitle();
    final AgreementType agreementType = agreementTypeRepository.findOrCreate(IAgreementType);
    AgreementRoleCommunicationChannelType arcct = findByAgreementTypeAndTitle(agreementType, title);
    if (arcct == null) {
        arcct = getContainer().newTransientInstance(AgreementRoleCommunicationChannelType.class);
        arcct.setTitle(title);
        arcct.setAppliesTo(agreementType);
        getContainer().persist(arcct);
    }
    return arcct;
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) IAgreementType(org.estatio.module.agreement.dom.type.IAgreementType) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType)

Example 3 with AgreementType

use of org.estatio.module.agreement.dom.type.AgreementType in project estatio by estatio.

the class GuaranteeRepository method newGuarantee.

@Programmatic
public Guarantee newGuarantee(final Lease lease, @Parameter(regexPattern = ReferenceType.Meta.REGEX, regexPatternReplacement = ReferenceType.Meta.REGEX_DESCRIPTION) final String reference, final String name, final GuaranteeType guaranteeType, final LocalDate startDate, final LocalDate endDate, final String description, final BigDecimal contractualAmount, final BigDecimal startAmount) {
    AgreementRoleType artGuarantee = agreementRoleTypeRepository.find(GuaranteeAgreementRoleTypeEnum.GUARANTEE);
    Party leasePrimaryParty = lease.getPrimaryParty();
    AgreementRoleType artGuarantor = agreementRoleTypeRepository.find(GuaranteeAgreementRoleTypeEnum.GUARANTOR);
    Party leaseSecondaryParty = lease.getSecondaryParty();
    Guarantee guarantee = newTransientInstance(Guarantee.class);
    final AgreementType at = agreementTypeRepository.find(GuaranteeAgreementTypeEnum.GUARANTEE);
    guarantee.setType(at);
    guarantee.setReference(reference);
    guarantee.setDescription(description);
    guarantee.setName(name);
    guarantee.setStartDate(startDate);
    guarantee.setEndDate(endDate);
    guarantee.setGuaranteeType(guaranteeType);
    guarantee.setLease(lease);
    guarantee.setContractualAmount(contractualAmount);
    guarantee.newRole(artGuarantee, leasePrimaryParty, null, null);
    guarantee.newRole(artGuarantor, leaseSecondaryParty, null, null);
    FinancialAccountType financialAccountType = guaranteeType.getFinancialAccountType();
    if (financialAccountType != null) {
        FinancialAccount financialAccount = financialAccountRepository.newFinancialAccount(financialAccountType, reference, name, leaseSecondaryParty);
        guarantee.setFinancialAccount(financialAccount);
        if (ObjectUtils.compare(startAmount, BigDecimal.ZERO) > 0) {
            financialAccountTransactionRepository.newTransaction(guarantee.getFinancialAccount(), startDate, null, startAmount);
        }
    }
    persistIfNotAlready(guarantee);
    return guarantee;
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) FinancialAccountType(org.estatio.module.financial.dom.FinancialAccountType) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with AgreementType

use of org.estatio.module.agreement.dom.type.AgreementType in project estatio by estatio.

the class Lease method existingBankMandatesForTenant.

@SuppressWarnings({ "unchecked", "rawtypes" })
private List<BankMandate> existingBankMandatesForTenant() {
    final AgreementRole tenantRole = getSecondaryAgreementRole();
    if (tenantRole == null || !tenantRole.isCurrent()) {
        return Collections.emptyList();
    }
    final Party tenant = partyOf(tenantRole);
    final AgreementType bankMandateAgreementType = bankMandateAgreementType();
    final AgreementRoleType debtorRoleType = debtorRoleType();
    return (List) agreementRepository.findByAgreementTypeAndRoleTypeAndParty(bankMandateAgreementType, debtorRoleType, tenant);
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with AgreementType

use of org.estatio.module.agreement.dom.type.AgreementType in project estatio by estatio.

the class PartyBankAccountsAndMandatesDtoFactory method newDto.

@Programmatic
public BankAccountsAndMandatesDto newDto(final Party party) {
    final BankAccountsAndMandatesDto dto = new BankAccountsAndMandatesDto();
    final List<FinancialAccount> financialAccountList = financialAccountRepository.findAccountsByTypeOwner(FinancialAccountType.BANK_ACCOUNT, party);
    final List<BankAccountDto> bankAccountDtos = financialAccountList.stream().map(x -> bankAccountDtoFactory.newDto((BankAccount) x)).collect(Collectors.toList());
    dto.setBankAccounts(bankAccountDtos);
    final AgreementType bankMandateAt = agreementTypeRepository.find(BankMandateAgreementTypeEnum.MANDATE);
    final AgreementRoleType debtorOfMandate = agreementRoleTypeRepository.findByAgreementTypeAndTitle(bankMandateAt, BankMandateAgreementRoleTypeEnum.DEBTOR.getTitle());
    final List<AgreementRole> agreementRoles = agreementRoleRepository.findByPartyAndType(party, debtorOfMandate);
    final List<BankMandateDto> mandateDtos = agreementRoles.stream().map(x -> x.getAgreement()).map(x -> bankMandateDtoFactory.newDto((BankMandate) x)).collect(Collectors.toList());
    dto.setBankMandates(mandateDtos);
    return dto;
}
Also used : BankAccountsAndMandatesDto(org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto) BankAccountDto(org.estatio.canonical.financial.v1.BankAccountDto) DtoFactoryAbstract(org.estatio.module.base.platform.applib.DtoFactoryAbstract) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) BankMandateDto(org.estatio.canonical.bankmandate.v1.BankMandateDto) AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementTypeRepository(org.estatio.module.agreement.dom.type.AgreementTypeRepository) DomainService(org.apache.isis.applib.annotation.DomainService) BankAccountDto(org.estatio.canonical.financial.v1.BankAccountDto) FinancialAccountRepository(org.estatio.module.financial.dom.FinancialAccountRepository) Programmatic(org.apache.isis.applib.annotation.Programmatic) Inject(javax.inject.Inject) BankMandateAgreementRoleTypeEnum(org.estatio.module.bankmandate.dom.BankMandateAgreementRoleTypeEnum) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) BankAccountsAndMandatesDto(org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto) BankAccount(org.estatio.module.financial.dom.BankAccount) NatureOfService(org.apache.isis.applib.annotation.NatureOfService) BankMandateAgreementTypeEnum(org.estatio.module.bankmandate.dom.BankMandateAgreementTypeEnum) Party(org.estatio.module.party.dom.Party) AgreementRoleTypeRepository(org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository) Collectors(java.util.stream.Collectors) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) List(java.util.List) BankAccountDtoFactory(org.estatio.module.financial.canonical.v1.BankAccountDtoFactory) AgreementRoleRepository(org.estatio.module.agreement.dom.AgreementRoleRepository) BankMandate(org.estatio.module.bankmandate.dom.BankMandate) FinancialAccountType(org.estatio.module.financial.dom.FinancialAccountType) AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) BankMandateDto(org.estatio.canonical.bankmandate.v1.BankMandateDto) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

AgreementType (org.estatio.module.agreement.dom.type.AgreementType)7 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)5 List (java.util.List)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 Party (org.estatio.module.party.dom.Party)3 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)2 FinancialAccount (org.estatio.module.financial.dom.FinancialAccount)2 FinancialAccountType (org.estatio.module.financial.dom.FinancialAccountType)2 FinderInteraction (org.incode.module.unittestsupport.dom.repo.FinderInteraction)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 DomainService (org.apache.isis.applib.annotation.DomainService)1 NatureOfService (org.apache.isis.applib.annotation.NatureOfService)1 FixturesInstallingEvent (org.apache.isis.applib.events.system.FixturesInstallingEvent)1 FixtureScriptsDefault (org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault)1 QueryResultsCache (org.apache.isis.applib.services.queryresultscache.QueryResultsCache)1 BankAccountsAndMandatesDto (org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto)1 BankMandateDto (org.estatio.canonical.bankmandate.v1.BankMandateDto)1