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));
}
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);
}
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;
}
Aggregations