use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class Lease method existingBankMandatesForTenant.
@SuppressWarnings({ "unchecked", "rawtypes" })
private List<BankMandate> existingBankMandatesForTenant() {
final AgreementRole tenantRole = getSecondaryAgreementRole();
if (tenantRole == null || !tenantRole.isCurrent()) {
return Collections.emptyList();
}
final Party tenant = partyOf(tenantRole);
final AgreementType bankMandateAgreementType = bankMandateAgreementType();
final AgreementRoleType debtorRoleType = debtorRoleType();
return (List) agreementRepository.findByAgreementTypeAndRoleTypeAndParty(bankMandateAgreementType, debtorRoleType, tenant);
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class InvoiceMenu method newInvoiceForLease.
@ActionLayout(contributed = Contributed.AS_NEITHER)
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@MemberOrder(sequence = "1")
public Invoice newInvoiceForLease(final Lease lease, final LocalDate dueDate, @Parameter(optionality = Optionality.OPTIONAL) final PaymentMethod paymentMethod, final Currency currency) {
final Property propertyIfAny = lease.getProperty();
final Party seller = lease.getPrimaryParty();
final Party buyer = lease.getSecondaryParty();
final ApplicationTenancy propertySellerTenancy = estatioApplicationTenancyRepositoryForLease.findOrCreateTenancyFor(propertyIfAny, seller);
return invoiceForLeaseRepository.newInvoice(propertySellerTenancy, seller, buyer, paymentMethod == null ? lease.defaultPaymentMethod() : paymentMethod, currency, dueDate, lease, null);
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_Test method notification_BuyerBarcodeMatchValidation_works.
@Test
public void notification_BuyerBarcodeMatchValidation_works() {
String notification;
// given
IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel();
Party buyerDerived = new Organisation();
BuyerFinder buyerFinder = new BuyerFinder() {
@Override
public Party buyerDerivedFromDocumentName(final IncomingInvoice incomingInvoice) {
return buyerDerived;
}
};
IncomingInvoice invoice = new IncomingInvoice();
Party buyerOnViewmodel = new Organisation();
viewModel.setDomainObject(invoice);
viewModel.buyerFinder = buyerFinder;
viewModel.setBuyer(buyerOnViewmodel);
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isEqualTo("Buyer does not match barcode (document name); ");
// and given (buyers matching)
viewModel.setBuyer(buyerDerived);
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isNull();
// and given (no buyer derived)
BuyerFinder buyerFinderReturningNull = new BuyerFinder() {
@Override
public Party buyerDerivedFromDocumentName(final IncomingInvoice incomingInvoice) {
return null;
}
};
viewModel.buyerFinder = buyerFinderReturningNull;
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isNull();
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property.
@Test
public void unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
service.fixedAssetFinancialAccountRepository = mockFixedAssetFinancialAccountRepository;
BankAccount bankAccount = new BankAccount();
BankAccount bankAccountForProperty = new BankAccount();
FixedAssetFinancialAccount fixedAssetFinancialAccount = new FixedAssetFinancialAccount();
fixedAssetFinancialAccount.setFinancialAccount(bankAccountForProperty);
List<BankAccount> bankAccounts = new ArrayList<>();
bankAccounts.add(bankAccount);
bankAccounts.add(bankAccountForProperty);
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
Property property = new Property();
invoice.setProperty(property);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
will(returnValue(bankAccounts));
oneOf(mockFixedAssetFinancialAccountRepository).findByFixedAsset(property);
will(returnValue(Arrays.asList(fixedAssetFinancialAccount)));
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccountForProperty);
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_one_bankaccount_and_no_property.
@Test
public void unique_Debtor_Account_To_Pay_works_when_one_bankaccount_and_no_property() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
BankAccount bankAccount = new BankAccount();
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
will(returnValue(Arrays.asList(bankAccount)));
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccount);
}
Aggregations