Search in sources :

Example 1 with Charge

use of org.estatio.dom.charge.Charge in project estatio by estatio.

the class ApiIntegrationTest method t00_refData.

@Test
public void t00_refData() throws Exception {
    // country
    api.putCountry("NLD", "NL", "Netherlands");
    Country netherlands = countries.findCountry("NLD");
    Assert.assertNotNull(netherlands);
    assertThat(netherlands.getReference(), is("NLD"));
    assertThat(netherlands.getAlpha2Code(), is("NL"));
    assertThat(netherlands.getName(), is("Netherlands"));
    // state
    api.putState("NH", "North Holland", "NLD");
    State state = states.findState("NH");
    Assert.assertNotNull(state);
    assertThat(state.getReference(), is("NH"));
    assertThat(state.getName(), is("North Holland"));
    assertThat(state.getCountry(), is(netherlands));
    api.putTax("/NLD", "APITAXREF", "APITAX Name", "APITAXEXTREF", "APITAX Desc", BigDecimal.valueOf(21.0), dt(1980, 1, 1), "APITAXEXTRATEREF");
    api.putTax("/NLD", "APITAXREF", "APITAX Name", "APITAXEXTREF", "APITAX Desc", BigDecimal.valueOf(21), dt(1980, 1, 1), "APITAXEXTRATEREF");
    final Tax tax = taxes.findByReference("APITAXREF");
    Assert.assertNotNull(tax);
    assertThat(tax.getReference(), is("APITAXREF"));
    assertThat(tax.getName(), is("APITAX Name"));
    Assert.assertNotNull(tax.percentageFor(clockService.now()));
    api.putCharge("/NLD", "APICHARGEREF", "APICHARGENAME", "API CHARGE", "APITAXREF", "APISORTORDER", "APICHARGEGROUP", "APICHARGEGROUPNAME", "APICHARGEEXTREF");
    final ChargeGroup chargeGroup = chargeGroups.findChargeGroup("APICHARGEGROUP");
    Assert.assertNotNull(chargeGroup);
    assertThat(chargeGroup.getReference(), is("APICHARGEGROUP"));
    assertThat(chargeGroup.getName(), is("APICHARGEGROUPNAME"));
    final Charge charge = charges.findByReference("APICHARGEREF");
    Assert.assertNotNull(charge);
    assertThat(charge.getReference(), is("APICHARGEREF"));
    assertThat(charge.getName(), is("APICHARGENAME"));
    assertThat(charge.getDescription(), is("API CHARGE"));
    assertThat(charge.getTax(), is(tax));
    assertThat(charge.getGroup(), is(chargeGroup));
}
Also used : ChargeGroup(org.estatio.dom.charge.ChargeGroup) State(org.estatio.dom.geography.State) Charge(org.estatio.dom.charge.Charge) Country(org.estatio.dom.geography.Country) Tax(org.estatio.tax.dom.Tax) Test(org.junit.Test)

Example 2 with Charge

use of org.estatio.dom.charge.Charge in project estatio by estatio.

the class Api method putCharge.

// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putCharge(@Named("atPath") final String atPath, @Named("reference") final String reference, @Named("name") final String name, @Named("description") @Optional final String description, @Named("taxReference") final String taxReference, @Named("sortOrder") @Optional final String sortOrder, @Named("chargeGroupReference") final String chargeGroupReference, @Named("chargeGroupName") final String chargeGroupName, @Named("externalReference") @Optional final String externalReference) {
    final ChargeGroup chargeGroup = fetchOrCreateChargeGroup(chargeGroupReference, chargeGroupName);
    final ApplicationTenancy applicationTenancy = applicationTenancies.findTenancyByPath(atPath);
    final Tax tax = taxes.findOrCreate(taxReference, taxReference, applicationTenancy);
    final Charge charge = charges.newCharge(applicationTenancy, reference, name, description, tax, chargeGroup);
    charge.setExternalReference(externalReference);
    charge.setSortOrder(sortOrder);
}
Also used : ChargeGroup(org.estatio.dom.charge.ChargeGroup) Charge(org.estatio.dom.charge.Charge) Tax(org.estatio.tax.dom.Tax) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 3 with Charge

use of org.estatio.dom.charge.Charge in project estatio by estatio.

the class Api method putLeaseItem.

@ActionSemantics(Of.IDEMPOTENT)
public void putLeaseItem(@Named("leaseReference") final String leaseReference, @Named("tenantReference") final String tenantReference, @Named("unitReference") @Optional final String unitReference, @Named("type") @Optional final String leaseItemTypeName, @Named("sequence") final BigInteger sequence, @Named("startDate") @Optional final LocalDate startDate, @Named("endDate") @Optional final LocalDate endDate, @Named("chargeReference") @Optional final String chargeReference, @Named("nextDueDate") @Optional final LocalDate nextDueDate, @Named("invoicingFrequency") @Optional final String invoicingFrequency, @Named("paymentMethod") final String paymentMethod, @Named("status") @Optional final String status, @Named("atPath") final String leaseItemAtPath) {
    final Lease lease = fetchLease(leaseReference);
    final Unit unit = fetchUnit(unitReference);
    final ApplicationTenancy unitApplicationTenancy = unit.getApplicationTenancy();
    final ApplicationTenancy countryApplicationTenancy = unitApplicationTenancy.getParent();
    final Charge charge = fetchCharge(chargeReference);
    ApplicationTenancy leaseApplicationTenancy = lease.getApplicationTenancy();
    final ApplicationTenancy leaseItemApplicationTenancy = leaseApplicationTenancy;
    // TODO: removed fetchApplicationTenancy(leaseItemAtPath);
    // if(!leaseApplicationTenancy.getChildren().contains(leaseItemApplicationTenancy))
    // {
    // throw new ApplicationException(
    // String.format("Lease item's appTenancy '%s' not child of lease's appTenancy '%s'.",
    // leaseApplicationTenancy.getName(), leaseItemAtPath));
    // }
    // 
    final LeaseItemType itemType = fetchLeaseItemType(leaseItemTypeName);
    LeaseItem item = lease.findItem(itemType, startDate, sequence);
    if (item == null) {
        item = lease.newItem(itemType, charge, InvoicingFrequency.valueOf(invoicingFrequency), PaymentMethod.valueOf(paymentMethod), startDate, leaseItemApplicationTenancy);
        item.setSequence(sequence);
    }
    item.setNextDueDate(nextDueDate);
    final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(status, LeaseItemStatus.ACTIVE);
}
Also used : Charge(org.estatio.dom.charge.Charge) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Aggregations

Charge (org.estatio.dom.charge.Charge)3 ChargeGroup (org.estatio.dom.charge.ChargeGroup)2 Tax (org.estatio.tax.dom.Tax)2 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)2 Country (org.estatio.dom.geography.Country)1 State (org.estatio.dom.geography.State)1 Test (org.junit.Test)1