use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.
the class InvoiceImportLine method importData.
@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
List<Object> result = new ArrayList<>();
Lease lease = fetchLease(getLeaseReference());
PaymentMethod paymentMethod = fetchPaymentMethod(getPaymentMethod());
String atPath = lease.getApplicationTenancyPath().concat("/").concat(lease.getPrimaryParty().getReference());
ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(atPath);
Invoice invoice = invoiceForLeaseRepository.newInvoice(applicationTenancy, lease.getPrimaryParty(), lease.getSecondaryParty(), paymentMethod, currencyRepository.findCurrency("EUR"), getDueDate(), lease, null);
InvoiceItem invoiceItem = factoryService.mixin(InvoiceForLease._newItem.class, invoice).$$(fetchCharge(getItemChargeReference()), BigDecimal.ONE, getItemNetAmount(), getItemStartDate(), getItemEndDate());
if (getItemDescription() != null) {
invoiceItem.setDescription(getItemDescription());
}
result.add(invoice);
return result;
}
use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.
the class InvoiceAttributesVM method getFrequencyElseNull.
private String getFrequencyElseNull() {
final SortedSet<InvoiceItem> items = invoice.getItems();
if (items.isEmpty()) {
return null;
}
final InvoiceItem item = items.first();
final LocalDate startDate = item.getStartDate();
final LocalDate endDate = item.getEndDate();
if (startDate == null || endDate == null) {
return null;
}
Months months = Months.monthsBetween(startDate, endDate.plusDays(1));
switch(months.getMonths()) {
case 12:
return "YEAR";
case 3:
return "QUARTER";
case 1:
return "MONTH";
}
return null;
}
use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.
the class InvoiceAttributesVM method getUnitName.
@Programmatic
public String getUnitName() {
final Optional<InvoiceItem> invoiceItemOptional = invoice.getItems().stream().findFirst();
if (invoiceItemOptional.isPresent()) {
final InvoiceItemForLease invoiceItem = (InvoiceItemForLease) invoiceItemOptional.get();
final FixedAsset fixedAsset = invoiceItem.getFixedAsset();
if (fixedAsset != null && fixedAsset instanceof Unit) {
return fixedAsset.getName();
}
}
return null;
}
use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.
the class IncomingInvoice method getDescriptionSummary.
@Programmatic
public String getDescriptionSummary() {
StringBuffer summary = new StringBuffer();
boolean first = true;
for (InvoiceItem item : getItems()) {
if (item.getDescription() != null && item.getDescription() != "") {
if (!first) {
summary.append(" | ");
}
summary.append(item.getDescription());
first = false;
}
}
return summary.toString();
}
Aggregations