use of org.estatio.dom.geography.State 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.geography.State in project estatio by estatio.
the class Api method putState.
// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putState(@Named("code") final String reference, @Named("name") final String name, @Named("countryCode") final String countryCode) {
final Country country = fetchCountry(countryCode);
State state = states.findState(countryCode);
if (state == null) {
state = states.newState(reference, name, country);
}
state.setName(name);
state.setCountry(country);
}