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;
}
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);
}
}
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);
}
Aggregations