Search in sources :

Example 1 with FinancialAccountType

use of org.estatio.module.financial.dom.FinancialAccountType 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 2 with FinancialAccountType

use of org.estatio.module.financial.dom.FinancialAccountType in project estatio by estatio.

the class FinancialAccountRepository_create_IntegTest method when_bankAccount.

@Test
public void when_bankAccount() throws Exception {
    final FinancialAccountType[] financialAccountTypes = FinancialAccountType.values();
    for (final FinancialAccountType financialAccountType : financialAccountTypes) {
        final String someRef = fakeDataService.strings().fixed(4);
        final String someName = fakeDataService.strings().upper(20);
        // given
        final List<FinancialAccount> before = financialAccountRepository.allAccounts();
        // when
        final FinancialAccount financialAccount = financialAccountRepository.newFinancialAccount(financialAccountType, someRef, someName, party);
        // then
        assertThat(financialAccount.getType()).isEqualTo(financialAccountType);
        assertThat(financialAccount.getReference()).isEqualTo(someRef);
        assertThat(financialAccount.getName()).isEqualTo(someName);
        final List<FinancialAccount> after = financialAccountRepository.allAccounts();
        assertThat(after).contains(financialAccount);
        assertThat(after.size()).isEqualTo(before.size() + 1);
    }
}
Also used : FinancialAccountType(org.estatio.module.financial.dom.FinancialAccountType) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) Test(org.junit.Test)

Example 3 with FinancialAccountType

use of org.estatio.module.financial.dom.FinancialAccountType in project estatio by estatio.

the class Guarantee method changeGuaranteeType.

public void changeGuaranteeType(GuaranteeType guaranteeType) {
    FinancialAccountType financialAccountType = guaranteeType.getFinancialAccountType();
    if (financialAccountType != null) {
        FinancialAccount financialAccount = financialAccountRepository.newFinancialAccount(financialAccountType, this.getReference(), this.getName(), this.getSecondaryParty());
        this.setFinancialAccount(financialAccount);
    }
    this.setGuaranteeType(guaranteeType);
}
Also used : FinancialAccountType(org.estatio.module.financial.dom.FinancialAccountType) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount)

Aggregations

FinancialAccount (org.estatio.module.financial.dom.FinancialAccount)3 FinancialAccountType (org.estatio.module.financial.dom.FinancialAccountType)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)1 AgreementType (org.estatio.module.agreement.dom.type.AgreementType)1 Party (org.estatio.module.party.dom.Party)1 Test (org.junit.Test)1