Search in sources :

Example 6 with InvoiceItem

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;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) ArrayList(java.util.ArrayList) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) DomainObject(org.apache.isis.applib.annotation.DomainObject) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 7 with InvoiceItem

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;
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Months(org.joda.time.Months) LocalDate(org.joda.time.LocalDate)

Example 8 with InvoiceItem

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;
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) FixedAsset(org.estatio.module.asset.dom.FixedAsset) Unit(org.estatio.module.asset.dom.Unit) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 9 with InvoiceItem

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();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)9 Programmatic (org.apache.isis.applib.annotation.Programmatic)7 ArrayList (java.util.ArrayList)3 DomainObject (org.apache.isis.applib.annotation.DomainObject)2 FixedAsset (org.estatio.module.asset.dom.FixedAsset)1 Property (org.estatio.module.asset.dom.Property)1 Unit (org.estatio.module.asset.dom.Unit)1 ReasonBuffer2 (org.estatio.module.base.platform.applib.ReasonBuffer2)1 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)1 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)1 Project (org.estatio.module.capex.dom.project.Project)1 Charge (org.estatio.module.charge.dom.Charge)1 Invoice (org.estatio.module.invoice.dom.Invoice)1 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)1 Lease (org.estatio.module.lease.dom.Lease)1 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)1 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)1 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)1 LocalDate (org.joda.time.LocalDate)1 Months (org.joda.time.Months)1