use of org.estatio.module.charge.dom.Charge in project estatio by estatio.
the class BudgetImportExport method findOrCreatePartitionItem.
private PartitionItem findOrCreatePartitionItem(final BudgetItem budgetItem) {
Charge targetCharge = fetchCharge(getOutgoingChargeReference());
KeyTable keyTable = findOrCreateKeyTable(budgetItem.getBudget(), getKeyTableName(), getFoundationValueType(), getKeyValueMethod());
return budgetItem.updateOrCreatePartitionItem(targetCharge, keyTable, getPercentage());
}
use of org.estatio.module.charge.dom.Charge in project estatio by estatio.
the class BudgetImportExport method importData.
@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
if (previousRow == null) {
removeExistingBudgetItemsIfNotLinked();
}
Charge incomingCharge = fetchCharge(getIncomingChargeReference());
BudgetItem budgetItem = findOrCreateBudgetAndBudgetItem(incomingCharge);
if (getOutgoingChargeReference() != null && getKeyTableName() != null && getFoundationValueType() != null && getKeyValueMethod() != null && percentage != null) {
findOrCreatePartitionItem(budgetItem);
}
return Lists.newArrayList(budgetItem.getBudget());
}
use of org.estatio.module.charge.dom.Charge 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);
}
use of org.estatio.module.charge.dom.Charge in project estatio by estatio.
the class IncomingInvoice method copyWithLinks.
private IncomingInvoiceItem copyWithLinks(final IncomingInvoiceItem itemToReverse, final Sort sort) {
final IncomingInvoiceType type = itemToReverse.getIncomingInvoiceType();
final String description = itemToReverse.getDescription();
final Charge charge = itemToReverse.getCharge();
final BigDecimal netAmount = itemToReverse.getNetAmount();
final BigDecimal vatAmount = itemToReverse.getVatAmount();
final BigDecimal grossAmount = itemToReverse.getGrossAmount();
final Tax tax = itemToReverse.getTax();
final LocalDate dueDate = itemToReverse.getDueDate();
final String period = itemToReverse.getPeriod();
final FixedAsset fixedAsset = itemToReverse.getFixedAsset();
final Project project = itemToReverse.getProject();
final BudgetItem budgetItem = itemToReverse.getBudgetItem();
final IncomingInvoiceItem copyItem = addItemToThis(type, charge, sort.prefixTo(description), sort.adjust(netAmount), sort.adjust(vatAmount), sort.adjust(grossAmount), tax, dueDate, period, fixedAsset, project, budgetItem);
if (sort == Sort.REVERSAL) {
copyItem.setReversalOf(itemToReverse);
}
final Optional<OrderItemInvoiceItemLink> linkIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(itemToReverse);
linkIfAny.ifPresent(link -> {
orderItemInvoiceItemLinkRepository.createLink(link.getOrderItem(), copyItem, sort.adjust(link.getNetAmount()));
});
return copyItem;
}
use of org.estatio.module.charge.dom.Charge in project estatio by estatio.
the class IncomingInvoiceItemRepository_IntegTest method findByInvoiceAndChargeAndSequence_works.
@Test
public void findByInvoiceAndChargeAndSequence_works() throws Exception {
// given
IncomingInvoice invoice = createIncomingInvoiceAndTwoItemsWithSameCharge();
// when
Charge chargeToFindOnItem = charge;
IncomingInvoiceItem item1 = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeToFindOnItem, BigInteger.valueOf(1L));
IncomingInvoiceItem item2 = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeToFindOnItem, BigInteger.valueOf(2L));
// then
assertThat(item1.getInvoice()).isEqualTo(invoice);
assertThat(item1.getCharge()).isEqualTo(charge);
assertThat(item1.getSequence()).isEqualTo(BigInteger.valueOf(1L));
assertThat(item2.getInvoice()).isEqualTo(invoice);
assertThat(item2.getCharge()).isEqualTo(charge);
assertThat(item2.getSequence()).isEqualTo(BigInteger.valueOf(2L));
// and when
Charge chargeNotToBeFoundOnItem = chargeRepository.findByReference("OTHER");
IncomingInvoiceItem itemNotToBeFound = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeNotToBeFoundOnItem, BigInteger.valueOf(1L));
// then
assertThat(itemNotToBeFound).isNull();
}
Aggregations