Search in sources :

Example 1 with ChargeGroup

use of org.estatio.dom.charge.ChargeGroup 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 ChargeGroup

use of org.estatio.dom.charge.ChargeGroup 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 ChargeGroup

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

the class Api method fetchOrCreateChargeGroup.

private ChargeGroup fetchOrCreateChargeGroup(final String reference, final String name) {
    ChargeGroup chargeGroup = chargeGroups.findChargeGroup(reference);
    if (chargeGroup == null) {
        chargeGroup = chargeGroups.createChargeGroup(reference, name);
    }
    chargeGroup.setName(name);
    return chargeGroup;
}
Also used : ChargeGroup(org.estatio.dom.charge.ChargeGroup)

Aggregations

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