Search in sources :

Example 1 with BankMandate

use of org.estatio.module.bankmandate.dom.BankMandate in project estatio by estatio.

the class BankMandateBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("agreement", ec, Agreement.class);
    checkParam("bankAccount", ec, BankAccount.class);
    checkParam("sequence", ec, Integer.class);
    // these are optional in the domain, so perhaps don't need to be mandatory
    checkParam("sequenceType", ec, Integer.class);
    checkParam("scheme", ec, Scheme.class);
    checkParam("leaseDate", ec, LocalDate.class);
    final AgreementRoleType agreementRoleType = agreementRoleTypeRepository.findByTitle(LeaseAgreementRoleTypeEnum.TENANT.getTitle());
    final AgreementRole role = agreementRoleRepository.findByAgreementAndTypeAndContainsDate(agreement, agreementRoleType, leaseDate);
    final Party owner = role.getParty();
    final BankMandate bankMandate = bankMandateRepository.newBankMandate(referenceFrom(owner, sequence), owner.getReference(), agreement.getStartDate(), agreement.getEndDate(), agreement.getSecondaryParty(), agreement.getPrimaryParty(), bankAccount, sequenceType, scheme, agreement.getStartDate());
    ec.addResult(this, bankMandate.getReference(), bankMandate);
    object = bankMandate;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) BankMandate(org.estatio.module.bankmandate.dom.BankMandate)

Example 2 with BankMandate

use of org.estatio.module.bankmandate.dom.BankMandate 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 3 with BankMandate

use of org.estatio.module.bankmandate.dom.BankMandate in project estatio by estatio.

the class InvoiceForLeaseDtoFactory method newDto.

@Programmatic
public InvoiceDto newDto(final InvoiceForLease invoiceForLease) {
    InvoiceDto dto = new InvoiceDto();
    dto.setSelf(mappingHelper.oidDtoFor(invoiceForLease));
    dto.setAtPath(invoiceForLease.getApplicationTenancyPath());
    dto.setBuyerParty(mappingHelper.oidDtoFor(invoiceForLease.getBuyer()));
    dto.setSellerParty(mappingHelper.oidDtoFor(invoiceForLease.getSeller()));
    dto.setDueDate(asXMLGregorianCalendar(invoiceForLease.getDueDate()));
    dto.setInvoiceDate(asXMLGregorianCalendar(invoiceForLease.getInvoiceDate()));
    dto.setInvoiceNumber(invoiceForLease.getInvoiceNumber());
    dto.setPaymentMethod(toDto(invoiceForLease.getPaymentMethod()));
    dto.setCollectionNumber(invoiceForLease.getCollectionNumber());
    final Lease lease = invoiceForLease.getLease();
    if (lease != null) {
        dto.setAgreementReference(lease.getReference());
        final BankMandate paidBy = lease.getPaidBy();
        if (paidBy != null) {
            dto.setPaidByMandate(mappingHelper.oidDtoFor(paidBy));
            dto.setBuyerBankAccount(mappingHelper.oidDtoFor(paidBy.getBankAccount()));
        }
    }
    final Optional<FixedAsset> fixedAssetIfAny = Optional.ofNullable(invoiceForLease.getFixedAsset());
    if (fixedAssetIfAny.isPresent()) {
        final FixedAsset fixedAsset = fixedAssetIfAny.get();
        dto.setFixedAssetReference(fixedAsset.getReference());
        dto.setFixedAssetExternalReference(fixedAsset.getExternalReference());
        // there should be only one
        dto.setSellerBankAccount(mappingHelper.oidDtoFor(invoiceForLease.getSellerBankAccount()));
    }
    invoiceForLease.getItems().stream().forEach(item -> dto.getItems().add(invoiceItemForLeaseDtoFactory.newDto(item)));
    dto.setNetAmount(dto.getItems().stream().map(x -> valueElseZero(x.getNetAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
    dto.setGrossAmount(dto.getItems().stream().map(x -> valueElseZero(x.getGrossAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
    dto.setVatAmount(dto.getItems().stream().map(x -> valueElseZero(x.getVatAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
    return dto;
}
Also used : InvoiceDto(org.estatio.canonical.invoice.v1.InvoiceDto) Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) FixedAsset(org.estatio.module.asset.dom.FixedAsset) BankMandate(org.estatio.module.bankmandate.dom.BankMandate) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with BankMandate

use of org.estatio.module.bankmandate.dom.BankMandate in project estatio by estatio.

the class Lease method newMandate.

// //////////////////////////////////////
public Lease newMandate(final BankAccount bankAccount, @Parameter(regexPattern = org.incode.module.base.dom.types.ReferenceType.Meta.REGEX, regexPatternReplacement = org.incode.module.base.dom.types.ReferenceType.Meta.REGEX_DESCRIPTION) final String reference, final LocalDate startDate, @Parameter(optionality = Optionality.OPTIONAL) final LocalDate endDate, final SequenceType sequenceType, final Scheme scheme, final LocalDate signatureDate) {
    final Party creditor = getPrimaryParty();
    final Party debtor = getSecondaryParty();
    final BankMandate bankMandate = bankMandateRepository.newBankMandate(reference, reference, startDate, endDate, debtor, creditor, bankAccount, sequenceType, scheme, signatureDate);
    paidBy(bankMandate);
    return this;
}
Also used : Party(org.estatio.module.party.dom.Party) BankMandate(org.estatio.module.bankmandate.dom.BankMandate)

Example 5 with BankMandate

use of org.estatio.module.bankmandate.dom.BankMandate in project estatio by estatio.

the class BankMandateImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Lease lease = fetchLease(leaseReference);
    BankAccount bankAccount;
    BankMandate bankMandate = null;
    // find or create bank account
    final Party owner = lease.getSecondaryParty();
    bankAccount = (BankAccount) financialAccountRepository.findByOwnerAndReference(owner, bankAccountReference);
    if (bankAccount == null) {
        bankAccount = bankAccountRepository.newBankAccount(owner, bankAccountReference, null);
    }
    if (reference != null) {
        bankMandate = bankMandateRepository.findByReference(reference);
    }
    if (bankMandate == null) {
        lease.newMandate(bankAccount, reference, startDate, endDate, SequenceType.valueOf(sequenceType), Scheme.valueOf(scheme), signatureDate);
        bankMandate = lease.getPaidBy();
    }
    bankMandate.setBankAccount(bankAccount);
    bankMandate.setReference(reference);
    bankMandate.setName(name);
    bankMandate.setStartDate(startDate);
    bankMandate.setEndDate(endDate);
    bankMandate.setSepaMandateIdentifier(sepaMandateIdentifier);
    bankMandate.setSequenceType(SequenceType.valueOf(sequenceType));
    bankMandate.setScheme(Scheme.valueOf(scheme));
    bankMandate.setSignatureDate(signatureDate);
    lease.paidBy(bankMandate);
    return Lists.newArrayList(bankMandate);
}
Also used : Party(org.estatio.module.party.dom.Party) Lease(org.estatio.module.lease.dom.Lease) BankAccount(org.estatio.module.financial.dom.BankAccount) BankMandate(org.estatio.module.bankmandate.dom.BankMandate) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

BankMandate (org.estatio.module.bankmandate.dom.BankMandate)5 Party (org.estatio.module.party.dom.Party)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)2 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)2 BankAccount (org.estatio.module.financial.dom.BankAccount)2 Lease (org.estatio.module.lease.dom.Lease)2 List (java.util.List)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 BankAccountsAndMandatesDto (org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto)1 BankMandateDto (org.estatio.canonical.bankmandate.v1.BankMandateDto)1 BankAccountDto (org.estatio.canonical.financial.v1.BankAccountDto)1 InvoiceDto (org.estatio.canonical.invoice.v1.InvoiceDto)1 AgreementRoleRepository (org.estatio.module.agreement.dom.AgreementRoleRepository)1 AgreementRoleTypeRepository (org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository)1 AgreementType (org.estatio.module.agreement.dom.type.AgreementType)1 AgreementTypeRepository (org.estatio.module.agreement.dom.type.AgreementTypeRepository)1