use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class BudgetAssignmentService_Test method findOrCreateLeaseItemForServiceChargeBudgeted_works_when_item_to_copy_from_found.
@Test
public void findOrCreateLeaseItemForServiceChargeBudgeted_works_when_item_to_copy_from_found() throws Exception {
// given
LeaseItem leaseItemToCopyFrom = new LeaseItem();
leaseItemToCopyFrom.setInvoicingFrequency(InvoicingFrequency.QUARTERLY_IN_ADVANCE);
leaseItemToCopyFrom.setPaymentMethod(PaymentMethod.CHEQUE);
BudgetAssignmentService budgetAssignmentService = new BudgetAssignmentService() {
@Override
LeaseItem findItemToCopyFrom(final Lease lease) {
return leaseItemToCopyFrom;
}
};
Charge charge = new Charge();
BudgetCalculationResult budgetCalculationResult = new BudgetCalculationResult();
budgetCalculationResult.setInvoiceCharge(charge);
LocalDate termStartDate = new LocalDate(2018, 1, 1);
// expect
context.checking(new Expectations() {
{
oneOf(mockLease).findFirstActiveItemOfTypeAndChargeOnDate(LeaseItemType.SERVICE_CHARGE, charge, termStartDate);
will(returnValue(null));
oneOf(mockLease).newItem(LeaseItemType.SERVICE_CHARGE, LeaseAgreementRoleTypeEnum.LANDLORD, budgetCalculationResult.getInvoiceCharge(), leaseItemToCopyFrom.getInvoicingFrequency(), leaseItemToCopyFrom.getPaymentMethod(), termStartDate);
}
});
// when
budgetAssignmentService.findOrCreateLeaseItemForServiceChargeBudgeted(mockLease, budgetCalculationResult, termStartDate);
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class BudgetAssignmentService method findOrCreateLeaseItemForServiceChargeBudgeted.
LeaseItem findOrCreateLeaseItemForServiceChargeBudgeted(final Lease lease, final BudgetCalculationResult calculationResult, final LocalDate startDate) {
LeaseItem leaseItem = lease.findFirstActiveItemOfTypeAndChargeOnDate(LeaseItemType.SERVICE_CHARGE, calculationResult.getInvoiceCharge(), startDate);
if (leaseItem == null) {
// try to copy invoice frequency and payment method from another lease item
LeaseItem itemToCopyFrom = findItemToCopyFrom(lease);
leaseItem = lease.newItem(LeaseItemType.SERVICE_CHARGE, LeaseAgreementRoleTypeEnum.LANDLORD, calculationResult.getInvoiceCharge(), itemToCopyFrom != null ? itemToCopyFrom.getInvoicingFrequency() : InvoicingFrequency.QUARTERLY_IN_ADVANCE, itemToCopyFrom != null ? itemToCopyFrom.getPaymentMethod() : PaymentMethod.DIRECT_DEBIT, startDate);
}
return leaseItem;
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class InvoiceCalculationForDeposit_IntegTest method setUpDepositItem.
private LeaseItem setUpDepositItem(final Lease lease, final LeaseItem source, final InvoicingFrequency invoicingFrequency) {
LeaseItem depositItem = wrap(lease).newItem(LeaseItemType.DEPOSIT, LeaseAgreementRoleTypeEnum.LANDLORD, chargeForDeposit, invoicingFrequency, PaymentMethod.DIRECT_DEBIT, startDateForItems);
wrap(depositItem).newSourceItem(source);
LeaseTermForDeposit term = (LeaseTermForDeposit) wrap(depositItem).newTerm(startDateForItems, null);
wrap(term).changeParameters(Fraction.M6, null, false);
return depositItem;
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class LeaseStatusService_Test method tester.
void tester(LeaseStatus expectedStatus, LocalDate tenancyStartDate, LocalDate tenancyEndDate, LeaseItem... items) {
lease.setTenancyStartDate(tenancyStartDate);
lease.setTenancyEndDate(tenancyEndDate);
int seq = 1;
for (LeaseItem item : items) {
item.setSequence(BigInteger.valueOf(seq));
lease.getItems().add(item);
seq++;
}
assertThat(lease.getItems()).hasSize(items.length);
assertThat(service.statusOf(lease)).isEqualTo(expectedStatus);
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class LeaseMenu method verifyLeasesUntil.
@Action(semantics = SemanticsOf.IDEMPOTENT)
@MemberOrder(sequence = "4")
public String verifyLeasesUntil(final LeaseItemType leaseItemType, final LocalDate untilDate) {
DateTime start = DateTime.now();
List<Lease> leases = allLeases();
for (Lease lease : leases) {
for (LeaseItem leaseItem : lease.getItems()) {
if (leaseItem.getType().equals(leaseItemType)) {
leaseItem.verifyUntil(untilDate);
}
}
}
Period p = new Period(start, DateTime.now());
return String.format("Verified %d leases in %s", leases.size(), JodaPeriodUtils.asString(p));
}
Aggregations