use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class BudgetAssignmentService_Test method before.
@Before
public void before() throws Exception {
budgetAssignmentService = new BudgetAssignmentService();
o1 = new Occupancy();
leaseWith1ActiveOccupancy = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o1));
}
};
o2 = new Occupancy();
o3 = new Occupancy();
leaseWith2ActiveOccupancies = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o2, o3));
}
};
o4 = new Occupancy();
leaseWithNoActiveOccupancies = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o4));
}
};
o5 = new Occupancy();
leaseTerminated = new Lease() {
@Override
public SortedSet<Occupancy> getOccupancies() {
return new TreeSet<>(Arrays.asList(o5));
}
};
budget = new Budget();
LocalDate startDate = new LocalDate(2015, 01, 01);
LocalDate endDate = new LocalDate(2015, 12, 31);
budget.setStartDate(startDate);
budget.setEndDate(endDate);
LeaseRepository leaseRepository = new LeaseRepository() {
@Override
public List<Lease> findLeasesByProperty(final Property property) {
return Arrays.asList(leaseWith1ActiveOccupancy, leaseWith2ActiveOccupancies, leaseWithNoActiveOccupancies, leaseTerminated);
}
};
budgetAssignmentService.leaseRepository = leaseRepository;
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class BudgetItemValueRepository_IntegTest method updateOrCreateTest_Create.
@Test
public void updateOrCreateTest_Create() {
// given
LocalDate budgetStart = new LocalDate(2015, 1, 1);
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.ACTUAL);
transactionService.flushTransaction();
// then
assertThat(budgetItem.getValues().size()).isEqualTo(2);
assertThat(result.getValue()).isEqualTo(new BigDecimal("33333.00"));
assertThat(result.getType()).isEqualTo(BudgetCalculationType.ACTUAL);
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class BudgetItemValueRepository_IntegTest method findByBudgetItemAndType.
@Test
public void findByBudgetItemAndType() {
// given
Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
Budget budget = budgetRepository.findByPropertyAndStartDate(property, new LocalDate(2015, 01, 01));
BudgetItem budgetItem = budget.getItems().first();
assertThat(budgetItem.getValues().size()).isEqualTo(1);
assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
// when
List<BudgetItemValue> results = budgetItemValueRepository.findByBudgetItemAndType(budgetItem, BudgetCalculationType.BUDGETED);
// then
assertThat(results.size()).isEqualTo(1);
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class DebtorBankAccountService method uniqueDebtorAccountToPay.
@Programmatic
public BankAccount uniqueDebtorAccountToPay(final IncomingInvoice invoice) {
final Party buyer = invoice.getBuyer();
List<BankAccount> bankAccountsForBuyer = bankAccountRepository.findBankAccountsByOwner(buyer);
final Property propertyIfAny = invoice.getProperty();
if (propertyIfAny != null) {
List<FixedAssetFinancialAccount> fafrList = fixedAssetFinancialAccountRepository.findByFixedAsset(propertyIfAny);
List<FinancialAccount> bankAccountsForProperty = fafrList.stream().map(FixedAssetFinancialAccount::getFinancialAccount).filter(BankAccount.class::isInstance).map(BankAccount.class::cast).collect(Collectors.toList());
bankAccountsForBuyer.retainAll(bankAccountsForProperty);
}
// original implementation ... see if we already have a unique bank account
int numBankAccounts = bankAccountsForBuyer.size();
switch(numBankAccounts) {
case 0:
return null;
case 1:
return bankAccountsForBuyer.get(0);
default:
}
// see if removing non-preferred helps
bankAccountsForBuyer.removeIf(x -> (x.getPreferred() == null || !x.getPreferred()));
numBankAccounts = bankAccountsForBuyer.size();
switch(numBankAccounts) {
case 0:
return null;
case 1:
return bankAccountsForBuyer.get(0);
default:
// give up, still non-duplicate
return null;
}
}
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_normal_run_works.
@Test
public void in_arrears_and_in_advance_in_one_normal_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.NORMAL_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(2);
InvoiceItemForLease rentItem010 = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForRent);
assertThat(rentItem010.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
InvoiceItemForLease depositItem010Advance = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForDeposit);
assertThat(depositItem010Advance.getNetAmount()).isEqualTo(depositValueAfterIndexation);
InvoiceForLease invoiceFor011Arrears = invoiceForLeaseRepository.findByLease(poisonLease011Arrears).get(0);
assertThat(invoiceFor011Arrears.getItems().size()).isEqualTo(2);
InvoiceItemForLease rentItem011 = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForRent);
assertThat(rentItem011.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
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);
}
Aggregations