Search in sources :

Example 36 with Charge

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());
}
Also used : Charge(org.estatio.module.charge.dom.Charge) KeyTable(org.estatio.module.budget.dom.keytable.KeyTable)

Example 37 with Charge

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());
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 38 with Charge

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);
}
Also used : LeaseAgreementRoleTypeEnum(org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum) Lease(org.estatio.module.lease.dom.Lease) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) Charge(org.estatio.module.charge.dom.Charge) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) LeaseItemStatus(org.estatio.module.lease.dom.LeaseItemStatus) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 39 with Charge

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;
}
Also used : Project(org.estatio.module.capex.dom.project.Project) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) FixedAsset(org.estatio.module.asset.dom.FixedAsset) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal)

Example 40 with Charge

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();
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Charge(org.estatio.module.charge.dom.Charge) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Test(org.junit.Test)

Aggregations

Charge (org.estatio.module.charge.dom.Charge)41 Test (org.junit.Test)18 BigDecimal (java.math.BigDecimal)14 LocalDate (org.joda.time.LocalDate)14 Lease (org.estatio.module.lease.dom.Lease)11 Programmatic (org.apache.isis.applib.annotation.Programmatic)10 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)9 Project (org.estatio.module.capex.dom.project.Project)9 Tax (org.estatio.module.tax.dom.Tax)9 Property (org.estatio.module.asset.dom.Property)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)6 ApplicationException (org.apache.isis.applib.ApplicationException)4 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)4 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)4 Action (org.apache.isis.applib.annotation.Action)3 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)3 Organisation (org.estatio.module.party.dom.Organisation)3 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)3 Expectations (org.jmock.Expectations)3 ArrayList (java.util.ArrayList)2