Search in sources :

Example 6 with AgreementRoleType

use of org.estatio.module.agreement.dom.role.AgreementRoleType 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 7 with AgreementRoleType

use of org.estatio.module.agreement.dom.role.AgreementRoleType in project estatio by estatio.

the class BankMandateRepository method newBankMandate.

// //////////////////////////////////////
public BankMandate newBankMandate(final String reference, final String name, final LocalDate startDate, final LocalDate endDate, final Party debtor, final Party creditor, final BankAccount bankAccount, final SequenceType sequenceType, final Scheme scheme, final LocalDate signatureDate) {
    BankMandate mandate = newTransientInstance();
    mandate.setType(agreementTypeRepository.find(BankMandateAgreementTypeEnum.MANDATE));
    mandate.setReference(reference);
    mandate.setName(name);
    mandate.setStartDate(startDate);
    mandate.setEndDate(endDate);
    mandate.setBankAccount(bankAccount);
    mandate.setSequenceType(sequenceType);
    mandate.setScheme(scheme);
    mandate.setSignatureDate(signatureDate);
    // app tenancy derived from the debtor
    mandate.setApplicationTenancyPath(debtor.getApplicationTenancy().getPath());
    persistIfNotAlready(mandate);
    final AgreementRoleType artCreditor = agreementRoleTypeRepository.find(BankMandateAgreementRoleTypeEnum.CREDITOR);
    mandate.newRole(artCreditor, creditor, null, null);
    final AgreementRoleType artDebtor = agreementRoleTypeRepository.find(BankMandateAgreementRoleTypeEnum.DEBTOR);
    mandate.newRole(artDebtor, debtor, null, null);
    return mandate;
}
Also used : AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType)

Example 8 with AgreementRoleType

use of org.estatio.module.agreement.dom.role.AgreementRoleType 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)

Example 9 with AgreementRoleType

use of org.estatio.module.agreement.dom.role.AgreementRoleType in project estatio by estatio.

the class AgreementRepository_Test method setup.

@Before
public void setup() {
    agreementType = new AgreementType();
    agreementRoleType = new AgreementRoleType();
    party = new PartyForTesting();
    agreementRepository = new AgreementRepository() {

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

        @Override
        protected List<Agreement> 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;
        }
    };
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) List(java.util.List) PartyForTesting(org.estatio.module.party.dom.PartyForTesting) FinderInteraction(org.incode.module.unittestsupport.dom.repo.FinderInteraction) Before(org.junit.Before)

Example 10 with AgreementRoleType

use of org.estatio.module.agreement.dom.role.AgreementRoleType in project estatio by estatio.

the class GuaranteeBuilder method execute.

@Override
protected void execute(ExecutionContext ec) {
    checkParam("lease", ec, Lease.class);
    checkParam("reference", ec, String.class);
    defaultParam("name", ec, getReference());
    checkParam("guaranteeType", ec, GuaranteeType.class);
    checkParam("startDate", ec, LocalDate.class);
    checkParam("endDate", ec, LocalDate.class);
    checkParam("description", ec, String.class);
    checkParam("contractualAmount", ec, BigDecimal.class);
    final Guarantee guarantee = guaranteeRepository.newGuarantee(lease, reference, name, guaranteeType, startDate, endDate, description, contractualAmount, startAmount);
    ec.addResult(this, guarantee);
    object = guarantee;
    final AgreementRoleType bankRoleType = agreementRoleTypeRepository.find(GuaranteeAgreementRoleTypeEnum.BANK);
    this.bankRole = guarantee.createRole(bankRoleType, bank, bankRoleStartDate, bankRoleEndDate);
}
Also used : AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) Guarantee(org.estatio.module.guarantee.dom.Guarantee)

Aggregations

AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)13 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)7 Party (org.estatio.module.party.dom.Party)7 Programmatic (org.apache.isis.applib.annotation.Programmatic)6 AgreementType (org.estatio.module.agreement.dom.type.AgreementType)5 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)5 List (java.util.List)4 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)4 ArrayList (java.util.ArrayList)2 Inject (javax.inject.Inject)2 AgreementRoleCommunicationChannel (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel)2 IAgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType)2 AgreementRoleTypeRepository (org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository)2 BankMandate (org.estatio.module.bankmandate.dom.BankMandate)2 FinancialAccount (org.estatio.module.financial.dom.FinancialAccount)2 FinancialAccountType (org.estatio.module.financial.dom.FinancialAccountType)2 Lease (org.estatio.module.lease.dom.Lease)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Optional (java.util.Optional)1