Search in sources :

Example 16 with Party

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);
}
Also used : AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) List(java.util.List) ArrayList(java.util.ArrayList)

Example 17 with Party

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);
}
Also used : Party(org.estatio.module.party.dom.Party) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 18 with Party

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();
}
Also used : Party(org.estatio.module.party.dom.Party) BuyerFinder(org.estatio.module.capex.dom.documents.BuyerFinder) Organisation(org.estatio.module.party.dom.Organisation) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Test(org.junit.Test)

Example 19 with Party

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);
}
Also used : Expectations(org.jmock.Expectations) FixedAssetFinancialAccount(org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) ArrayList(java.util.ArrayList) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 20 with Party

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);
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Aggregations

Party (org.estatio.module.party.dom.Party)51 Programmatic (org.apache.isis.applib.annotation.Programmatic)22 Test (org.junit.Test)15 Property (org.estatio.module.asset.dom.Property)13 BankAccount (org.estatio.module.financial.dom.BankAccount)13 Organisation (org.estatio.module.party.dom.Organisation)13 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)10 Expectations (org.jmock.Expectations)10 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)8 ArrayList (java.util.ArrayList)7 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)7 Lease (org.estatio.module.lease.dom.Lease)6 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)6 List (java.util.List)5 Inject (javax.inject.Inject)4 Action (org.apache.isis.applib.annotation.Action)4 Country (org.incode.module.country.dom.impl.Country)4 LocalDate (org.joda.time.LocalDate)4 Optional (java.util.Optional)3 SortedSet (java.util.SortedSet)3