use of org.estatio.module.asset.dom.Unit in project estatio by estatio.
the class Occupancy_Test method validateNewOccupancy_Passes_Test.
@Test
public void validateNewOccupancy_Passes_Test() {
// given
Lease lease = new Lease();
LocalDate occStartDate = new LocalDate();
// when
Unit unit = new Unit() {
@Override
public boolean isActiveOn(final LocalDate date) {
return true;
}
};
// then
assertThat(lease.validateNewOccupancy(occStartDate, unit)).isNull();
}
use of org.estatio.module.asset.dom.Unit in project estatio by estatio.
the class OccupancyRepository_Test method setup.
@Before
public void setup() {
lease = new Lease();
unit = new Unit();
startDate = new LocalDate(2013, 4, 1);
occupancyRepository = new OccupancyRepository() {
@Override
protected <T> T firstMatch(Query<T> query) {
finderInteraction = new FinderInteraction(query, FinderMethod.FIRST_MATCH);
return null;
}
@Override
protected List<Occupancy> allInstances() {
finderInteraction = new FinderInteraction(null, FinderMethod.ALL_INSTANCES);
return null;
}
@Override
protected <T> List<T> allMatches(Query<T> query) {
finderInteraction = new FinderInteraction(query, FinderMethod.ALL_MATCHES);
return null;
}
};
}
use of org.estatio.module.asset.dom.Unit in project estatio by estatio.
the class KeyTable method generateItems.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
public KeyTable generateItems() {
// delete old items
for (Iterator<KeyItem> it = this.getItems().iterator(); it.hasNext(); ) {
it.next().deleteBudgetKeyItem();
}
/*
create list of input pairs: identifier - sourcevalue
sourcevalue is determined by FoundationValueType
*/
List<Distributable> input = new ArrayList<>();
for (Unit unit : unitRepository.findByProperty(this.getBudget().getProperty())) {
if (unitIntervalValidForThisKeyTable(unit)) {
BigDecimal sourceValue;
if (getFoundationValueType().valueOf(unit) != null) {
sourceValue = getFoundationValueType().valueOf(unit);
} else {
sourceValue = BigDecimal.ZERO;
}
KeyItem newItem = new KeyItem();
newItem.setSourceValue(sourceValue);
newItem.setValue(BigDecimal.ZERO);
newItem.setUnit(unit);
newItem.setKeyTable(this);
persistIfNotAlready(newItem);
input.add(newItem);
}
}
/*
call distribute method
*/
DistributionService distributionService = new DistributionService();
distributionService.distribute(input, getKeyValueMethod().divider(this), getPrecision());
return this;
}
use of org.estatio.module.asset.dom.Unit in project estatio by estatio.
the class InvoiceItemForLeaseRepository method newInvoiceItem.
@Programmatic
public InvoiceItemForLease newInvoiceItem(final LeaseTerm leaseTerm, final LocalDateInterval interval, final LocalDateInterval calculationInterval, final LocalDateInterval effectiveInterval, final LocalDate dueDate, final String interactionId) {
final Lease lease = leaseTerm.getLeaseItem().getLease();
final InvoiceForLease invoice = invoiceRepository.findOrCreateMatchingInvoice(leaseTerm.getApplicationTenancy(), leaseTerm.getLeaseItem().getPaymentMethod(), lease, InvoiceStatus.NEW, dueDate, interactionId);
final InvoiceItemForLease invoiceItem = newItem(invoice, dueDate);
invoiceItem.setLeaseTerm(leaseTerm);
invoiceItem.setStartDate(interval.startDate());
invoiceItem.setEndDate(interval.endDate());
invoiceItem.setEffectiveStartDate(effectiveInterval.startDate());
invoiceItem.setEffectiveEndDate(effectiveInterval.endDate());
invoiceItem.setCalculationStartDate(calculationInterval.startDate());
invoiceItem.setCalculationEndDate(calculationInterval.endDate());
// redundantly persist, these are immutable
// assumes only one occupancy per lease...
invoiceItem.setLease(lease);
final Optional<Occupancy> occupancyIfAny = lease.primaryOccupancy();
occupancyIfAny.ifPresent(occupancy -> {
Unit unit = occupancy.getUnit();
invoiceItem.setFixedAsset(unit);
});
persistIfNotAlready(invoiceItem);
return invoiceItem;
}
use of org.estatio.module.asset.dom.Unit in project estatio by estatio.
the class KeyItemRepository_Test method negativeSourceValue.
@Test
public void negativeSourceValue() {
// given
KeyTable keyTable = new KeyTable();
Unit unit = new Unit();
BigDecimal sourcevalue = BigDecimal.valueOf(-0.001);
BigDecimal keyValue = new BigDecimal(10);
// when
String validateNewBudgetKeyItem = keyItemRepository.validateNewItem(keyTable, unit, sourcevalue, keyValue);
// then
assertThat(validateNewBudgetKeyItem).isEqualTo("sourceValue cannot be zero or less than zero");
}
Aggregations