Search in sources :

Example 1 with BankAccount

use of org.estatio.dom.financial.bankaccount.BankAccount in project estatio by estatio.

the class Api method putBankMandate.

@ActionSemantics(Of.IDEMPOTENT)
public void putBankMandate(@Named("reference") final String reference, @Named("sepaMandateIdentifier") @Optional final String sepaMandateIdentifier, @Named("name") @Optional final String name, @Named("leaseReference") final String leaseReference, @Named("debtorReference") final String debtorReference, @Named("creditorReference") final String creditorReference, @Named("bankAccountReference") final String bankAccountReference, @Named("startDate") final LocalDate startDate, @Named("endDate") @Optional final LocalDate endDate) {
    BankMandate bankMandate = (BankMandate) agreements.findAgreementByReference(reference);
    final BankAccount bankAccount = (BankAccount) financialAccounts.findAccountByReference(bankAccountReference);
    if (bankAccount == null)
        throw new ApplicationException(String.format("BankAccount with reference %1$s not found", bankAccountReference));
    final Lease lease = fetchLease(leaseReference);
    final Party debtor = fetchParty(debtorReference);
    final Party creditor = fetchParty(creditorReference);
    if (bankMandate == null) {
        lease.newMandate(bankAccount, reference, startDate, endDate);
        bankMandate = lease.getPaidBy();
        bankMandate.setName(name);
    // EST-467, previously was:
    // bankMandate = bankMandates.newBankMandate(reference, name,
    // startDate, endDate, debtor, creditor, bankAccount);
    }
    // upsert
    bankMandate.setBankAccount(bankAccount);
    bankMandate.setName(name);
    bankMandate.setStartDate(startDate);
    bankMandate.setEndDate(endDate);
    bankMandate.setSepaMandateIdentifier(sepaMandateIdentifier);
    lease.paidBy(bankMandate);
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) BankAccount(org.estatio.dom.financial.bankaccount.BankAccount) BankMandate(org.estatio.dom.bankmandate.BankMandate)

Example 2 with BankAccount

use of org.estatio.dom.financial.bankaccount.BankAccount in project estatio by estatio.

the class Api method putBankAccount.

@ActionSemantics(Of.IDEMPOTENT)
public void putBankAccount(// start generic fields
@Named("reference") final String reference, @Named("name") @Optional final String name, @Named("ownerReference") final String ownerReference, @Named("bankAccountType") @Optional final String bankAccountType, @Named("propertyReference") @Optional final String propertyReference, @Named("iban") @Optional final String iban, @Named("countryCode") @Optional final String countryCode, @Named("nationalCheckCode") @Optional final String nationalCheckCode, @Named("nationalBankCode") @Optional final String nationalBankCode, @Named("branchCode") @Optional final String branchCode, @Named("accountNumber") @Optional final String accountNumber, @Named("externalReference") @Optional final String externalReference) {
    if (IBANValidator.valid(iban)) {
        BankAccount bankAccount = (BankAccount) financialAccounts.findAccountByReference(reference);
        final Party owner = parties.findPartyByReference(ownerReference);
        if (owner == null)
            return;
        if (bankAccount == null) {
            bankAccount = bankAccounts.newBankAccount(owner, reference, name == null ? reference : name);
        }
        bankAccount.setIban(iban);
        bankAccount.verifyIban();
        if (propertyReference != null) {
            final Property property = properties.findPropertyByReferenceElseNull(propertyReference);
            if (property == null) {
                throw new IllegalArgumentException(propertyReference.concat(" not found"));
            }
            fixedAssetFinancialAccounts.findOrCreate(property, bankAccount);
        }
    }
}
Also used : BankAccount(org.estatio.dom.financial.bankaccount.BankAccount) Property(org.estatio.dom.asset.Property)

Aggregations

BankAccount (org.estatio.dom.financial.bankaccount.BankAccount)2 ApplicationException (org.apache.isis.applib.ApplicationException)1 Property (org.estatio.dom.asset.Property)1 BankMandate (org.estatio.dom.bankmandate.BankMandate)1