Search in sources :

Example 1 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class BudgetItemValueRepository_IntegTest method findUniqueTest.

@Test
public void findUniqueTest() {
    // given
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, new LocalDate(2015, 01, 01));
    BudgetItem budgetItem = budget.getItems().first();
    // when
    BudgetItemValue result = budgetItemValueRepository.findUnique(budgetItem, new LocalDate(2015, 01, 01), BudgetCalculationType.BUDGETED);
    // then
    assertThat(result.getDate()).isEqualTo(new LocalDate(2015, 01, 01));
    // and when
    result = budgetItemValueRepository.findUnique(budgetItem, new LocalDate(2015, 01, 02), BudgetCalculationType.BUDGETED);
    // then
    assertThat(result).isNull();
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) Property(org.estatio.module.asset.dom.Property) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 2 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class BudgetItemValueRepository_IntegTest method updateOrCreateTest_Update.

@Test
public void updateOrCreateTest_Update() {
    // given
    LocalDate budgetStart = new LocalDate(2015, 01, 01);
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, budgetStart);
    BudgetItem budgetItem = budget.getItems().first();
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    assertThat(budgetItem.getValues().first().getValue()).isEqualTo(new BigDecimal("30000.55"));
    // when
    BudgetItemValue result = wrap(budgetItemValueRepository).updateOrCreateBudgetItemValue(new BigDecimal("33333.00"), budgetItem, budgetStart, BudgetCalculationType.BUDGETED);
    // then
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(result.getValue()).isEqualTo(new BigDecimal("33333.00"));
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class InvoiceForLeaseBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("lease", ec, Lease.class);
    checkParam("seller", ec, Party.class);
    checkParam("buyer", ec, Party.class);
    checkParam("paymentMethod", ec, PaymentMethod.class);
    checkParam("currency", ec, Currency.class);
    checkParam("dueDate", ec, LocalDate.class);
    defaultParam("invoiceDate", ec, getDueDate());
    final String interactionId = null;
    final InvoiceForLease invoice = invoiceForLeaseRepository.newInvoice(applicationTenancy, seller, buyer, paymentMethod, currency, dueDate, lease, interactionId);
    invoice.setInvoiceDate(this.invoiceDate);
    ec.addResult(this, invoice);
    final Property property = lease.getProperty();
    final String format = property.getReference() + "-%06d";
    final BigInteger lastIncrement = BigInteger.ZERO;
    this.numerator = numeratorForCollectionRepository.createInvoiceNumberNumerator(property, format, lastIncrement, applicationTenancy);
    ec.addResult(this, numerator);
    for (ItemsSpec itemSpec : itemSpecs) {
        final List<InvoiceItemForLease> items = createInvoiceItemsForTermsOfFirstLeaseItemOfType(invoice, itemSpec.leaseItemType, itemSpec.startDate, itemSpec.interval, ec);
        this.items.addAll(items);
    }
    object = invoice;
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) BigInteger(java.math.BigInteger) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) ToString(lombok.ToString) Property(org.estatio.module.asset.dom.Property)

Example 4 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class InvoiceAttributesVM method getLeasePropertyName.

@Programmatic
public String getLeasePropertyName() {
    Lease lease = invoice.getLease();
    if (lease == null) {
        return null;
    }
    Property property = lease.getProperty();
    if (property == null) {
        return null;
    }
    return property.getName();
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class InvoiceCalculationForDeposit_IntegTest method in_arrears_and_in_advance_in_one_retro_run_works.

@Test
public void in_arrears_and_in_advance_in_one_retro_run_works() {
    // given
    setUpTheGiven();
    // EST-1750: to mimick behaviour through UI
    sessionManagementService.nextSession();
    // when
    LocalDate invoiceDueDate = VT.ld(2012, 1, 1);
    // NOTE: the user has to realize that the due date for invoices in arrears is the last date of the period
    LocalDate startDueDate = VT.ld(2011, 12, 31);
    LocalDate nextDueDate = VT.ld(2012, 1, 2);
    Property oxford = Property_enum.OxfGb.findUsing(serviceRegistry);
    final LocalDate dateOfInvoiceRun = VT.ld(2011, 12, 1);
    setFixtureClockDate(dateOfInvoiceRun);
    mixin(Property_calculateInvoices.class, oxford).exec(InvoiceRunType.RETRO_RUN, Arrays.asList(LeaseItemType.RENT, LeaseItemType.DEPOSIT), invoiceDueDate, startDueDate, nextDueDate);
    // EST-1750: to mimick behaviour through UI
    transactionService.nextTransaction();
    // TODO: manage extra boilerplate because of new session -> to be handled in new programming model?
    reloadObjectsForNewSession();
    assertThat(rentItem010.getTerms().size()).isEqualTo(2);
    assertThat(rentItem011.getTerms().size()).isEqualTo(2);
    // then
    InvoiceForLease invoiceFor010Advance = invoiceForLeaseRepository.findByLease(poisonLease010Advance).get(0);
    assertThat(invoiceFor010Advance.getItems().size()).isEqualTo(6);
    InvoiceItemForLease depositItem010Advance = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForDeposit);
    assertThat(depositItem010Advance.getNetAmount()).isEqualTo(depositValueAfterIndexation);
    InvoiceForLease invoiceFor011Arrears = invoiceForLeaseRepository.findByLease(poisonLease011Arrears).get(0);
    assertThat(invoiceFor011Arrears.getItems().size()).isEqualTo(6);
    InvoiceItemForLease depositItem011Arrears = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForDeposit);
    // The user expects that the indexation on 1-1-2012 - which is outside the quarter being invoiced in arrears - is NOT taken into account
    assertThat(depositItem011Arrears.getNetAmount()).isEqualTo(depositValueBeforeIndexation);
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property_calculateInvoices(org.estatio.module.lease.contributions.Property_calculateInvoices) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Aggregations

Property (org.estatio.module.asset.dom.Property)47 LocalDate (org.joda.time.LocalDate)19 Test (org.junit.Test)19 Party (org.estatio.module.party.dom.Party)12 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)11 Programmatic (org.apache.isis.applib.annotation.Programmatic)10 Budget (org.estatio.module.budget.dom.budget.Budget)8 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)8 BigDecimal (java.math.BigDecimal)7 List (java.util.List)6 Charge (org.estatio.module.charge.dom.Charge)6 Lease (org.estatio.module.lease.dom.Lease)6 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)6 Expectations (org.jmock.Expectations)6 Before (org.junit.Before)6 Unit (org.estatio.module.asset.dom.Unit)5 Project (org.estatio.module.capex.dom.project.Project)5 Organisation (org.estatio.module.party.dom.Organisation)5 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 BankAccount (org.estatio.module.financial.dom.BankAccount)4