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