use of org.estatio.module.lease.dom.Lease 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.Lease in project estatio by estatio.
the class BudgetOverrideRepository_IntegTest method findByLeaseAndInvoiceCharge.
@Test
public void findByLeaseAndInvoiceCharge() {
// given
Lease leaseTopModel = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
Charge invoiceCharge = Charge_enum.GbServiceCharge.findUsing(serviceRegistry);
BigDecimal overrideValue = new BigDecimal("1234.56");
String reason = "Some reason";
// when
BudgetOverrideForFixed budgetOverrideForFixed = wrap(budgetOverrideRepository).newBudgetOverrideForFixed(overrideValue, leaseTopModel, null, null, invoiceCharge, null, null, reason);
// then
assertThat(budgetOverrideRepository.findByLeaseAndInvoiceCharge(leaseTopModel, invoiceCharge).size()).isEqualTo(1);
assertThat(budgetOverrideRepository.findByLeaseAndInvoiceCharge(leaseTopModel, invoiceCharge).get(0)).isEqualTo(budgetOverrideForFixed);
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class Invoice_DocumentManagement_IntegTest method findInvoice.
Invoice findInvoice(final InvoiceStatus invoiceStatus) {
// clears out queryResultsCache
transactionService.nextTransaction();
final Party seller = InvoiceForLease_enum.OxfPoison003Gb.getSeller_d().findUsing(serviceRegistry);
final Party buyer = InvoiceForLease_enum.OxfPoison003Gb.getBuyer_d().findUsing(serviceRegistry);
final Lease lease = InvoiceForLease_enum.OxfPoison003Gb.getLease_d().findUsing(serviceRegistry);
final LocalDate invoiceStartDate = InvoiceForLease_enum.OxfPoison003Gb.getLease_d().getStartDate().plusYears(1);
List<InvoiceForLease> matchingInvoices = findMatchingInvoices(seller, buyer, lease, invoiceStartDate, invoiceStatus);
assertThat(matchingInvoices.size()).isLessThanOrEqualTo(1);
return matchingInvoices.isEmpty() ? null : matchingInvoices.get(0);
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class InvoiceForLeaseDtoFactory method newDto.
@Programmatic
public InvoiceDto newDto(final InvoiceForLease invoiceForLease) {
InvoiceDto dto = new InvoiceDto();
dto.setSelf(mappingHelper.oidDtoFor(invoiceForLease));
dto.setAtPath(invoiceForLease.getApplicationTenancyPath());
dto.setBuyerParty(mappingHelper.oidDtoFor(invoiceForLease.getBuyer()));
dto.setSellerParty(mappingHelper.oidDtoFor(invoiceForLease.getSeller()));
dto.setDueDate(asXMLGregorianCalendar(invoiceForLease.getDueDate()));
dto.setInvoiceDate(asXMLGregorianCalendar(invoiceForLease.getInvoiceDate()));
dto.setInvoiceNumber(invoiceForLease.getInvoiceNumber());
dto.setPaymentMethod(toDto(invoiceForLease.getPaymentMethod()));
dto.setCollectionNumber(invoiceForLease.getCollectionNumber());
final Lease lease = invoiceForLease.getLease();
if (lease != null) {
dto.setAgreementReference(lease.getReference());
final BankMandate paidBy = lease.getPaidBy();
if (paidBy != null) {
dto.setPaidByMandate(mappingHelper.oidDtoFor(paidBy));
dto.setBuyerBankAccount(mappingHelper.oidDtoFor(paidBy.getBankAccount()));
}
}
final Optional<FixedAsset> fixedAssetIfAny = Optional.ofNullable(invoiceForLease.getFixedAsset());
if (fixedAssetIfAny.isPresent()) {
final FixedAsset fixedAsset = fixedAssetIfAny.get();
dto.setFixedAssetReference(fixedAsset.getReference());
dto.setFixedAssetExternalReference(fixedAsset.getExternalReference());
// there should be only one
dto.setSellerBankAccount(mappingHelper.oidDtoFor(invoiceForLease.getSellerBankAccount()));
}
invoiceForLease.getItems().stream().forEach(item -> dto.getItems().add(invoiceItemForLeaseDtoFactory.newDto(item)));
dto.setNetAmount(dto.getItems().stream().map(x -> valueElseZero(x.getNetAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
dto.setGrossAmount(dto.getItems().stream().map(x -> valueElseZero(x.getGrossAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
dto.setVatAmount(dto.getItems().stream().map(x -> valueElseZero(x.getVatAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
return dto;
}
use of org.estatio.module.lease.dom.Lease 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