use of org.estatio.module.lease.dom.LeaseTermForServiceCharge in project estatio by estatio.
the class InvoiceCalculationService_normalRun_IntegTest method invoiceItemsForServiceChargeCreated.
@Test
public void invoiceItemsForServiceChargeCreated() throws Exception {
leaseInvoicingSettingsService.updateEpochDate(VT.ld(1980, 1, 1));
LeaseTermForServiceCharge leaseTopModelServiceChargeTerm0 = (LeaseTermForServiceCharge) leaseTopModelServiceChargeItem.getTerms().first();
leaseTopModelServiceChargeTerm0.approve();
// partial period
calculateNormalRunAndAssert(leaseTopModelServiceChargeTerm0, VT.ld(2010, 7, 1), VT.ld(2010, 10, 1), VT.ldi("2010-07-01/2010-10-01"), 1271.74, false, null);
// full period
calculateNormalRunAndAssert(leaseTopModelServiceChargeTerm0, VT.ld(2010, 1, 10), VT.ld(2010, 10, 2), VT.ldi("2010-10-01/2011-01-01"), 1500.00, false, null);
// restore epochdate for other integ tests
leaseInvoicingSettingsService.updateEpochDate(VT.ld(2010, 1, 1));
}
use of org.estatio.module.lease.dom.LeaseTermForServiceCharge in project estatio by estatio.
the class LeaseItemForMarketingBuilder method execute.
@Override
protected void execute(final ExecutionContext ec) {
defaultParam("charge", ec, Charge_enum.GbMarketing.findUsing(serviceRegistry));
final ChargeGroup group = getCharge().getGroup();
final ChargeGroup_enum expectedGroup = ChargeGroup_enum.Marketing;
if (group != expectedGroup.findUsing(serviceRegistry)) {
throw new IllegalArgumentException("Charge's group must be " + expectedGroup.getRef());
}
LeaseItem leaseItem = new LeaseItemBuilder().setLease(lease).setCharge(charge).setLeaseItemType(LEASE_ITEM_TYPE).setInvoicingFrequency(INVOICING_FREQUENCY).setInvoicedBy(invoicedBy).setPaymentMethod(paymentMethod).setStatus(status).setSequence(sequence).build(this, ec).getObject();
for (LeaseTermForServiceChargeBuilder.TermSpec termSpec : termSpecs) {
final LeaseTermForServiceCharge term = new LeaseTermForServiceChargeBuilder().setLeaseItem(leaseItem).setStartDate(termSpec.startDate).setEndDate(termSpec.endDate).setLeaseTermFrequency(termSpec.leaseTermFrequency).setBudgetedValue(termSpec.budgetedValue).build(this, ec).getObject();
terms.add(term);
}
object = leaseItem;
}
use of org.estatio.module.lease.dom.LeaseTermForServiceCharge in project estatio by estatio.
the class LeaseTermForServiceChargeImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
// find or create leaseItem
final Lease lease = fetchLease(leaseReference);
final ApplicationTenancy leaseItemApplicationTenancy = ObjectUtils.firstNonNull(securityApplicationTenancyRepository.findByPath(leaseItemAtPath), lease.getApplicationTenancy());
final Charge charge = fetchCharge(itemChargeReference);
final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
final LocalDate itemStartDateToUse = itemStartDate == null ? lease.getStartDate() : itemStartDate;
final LeaseAgreementRoleTypeEnum invoicedByToUse = this.invoicedBy == null ? LeaseAgreementRoleTypeEnum.LANDLORD : LeaseAgreementRoleTypeEnum.valueOf(this.invoicedBy);
final PaymentMethod paymentMethodToUse = itemPaymentMethod == null ? lease.defaultPaymentMethod() : PaymentMethod.valueOf(itemPaymentMethod);
LeaseItem item = lease.findItem(itemType, charge, itemStartDateToUse, invoicedByToUse);
if (item == null) {
item = lease.newItem(itemType, invoicedByToUse, charge, InvoicingFrequency.valueOf(itemInvoicingFrequency), paymentMethodToUse, itemStartDateToUse);
item.setSequence(itemSequence);
}
item.setEpochDate(itemEpochDate);
item.setNextDueDate(itemNextDueDate);
final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(itemStatus, LeaseItemStatus.ACTIVE);
item.setStatus(leaseItemStatus);
// create term
LeaseTermForServiceCharge term = (LeaseTermForServiceCharge) item.findTermWithSequence(sequence);
if (term == null) {
if (startDate == null) {
throw new IllegalArgumentException("startDate cannot be empty");
}
if (sequence.equals(BigInteger.ONE)) {
term = (LeaseTermForServiceCharge) item.newTerm(startDate, endDate);
} else {
final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
if (previousTerm == null) {
throw new IllegalArgumentException(String.format("Previous term not found %s", lease.getReference()));
}
term = (LeaseTermForServiceCharge) previousTerm.createNext(startDate, endDate);
}
term.setSequence(sequence);
}
term.setStatus(LeaseTermStatus.valueOf(status));
// set service charge term values
term.setBudgetedValue(budgetedValue);
term.setAuditedValue(auditedValue);
return Lists.newArrayList(term);
}
Aggregations