use of org.estatio.dom.geography.Country 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.Country 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);
}
use of org.estatio.dom.geography.Country in project estatio by estatio.
the class Api method putProperty.
// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putProperty(@Named("reference") final String reference, @Named("name") final String name, @Named("countryCode") final String countryCode, @Named("city") final String city, @Named("type") final String type, @Named("acquireDate") @Optional final LocalDate acquireDate, @Named("disposalDate") @Optional final LocalDate disposalDate, @Named("openingDate") @Optional final LocalDate openingDate, @Named("ownerReference") @Optional final String ownerReference, @Named("numeratorFormat") @Optional final String numeratorFormat, @Named("externalReference") @Optional final String externalReference, @Named("atPath") final String countryAtPath) {
final Party owner = fetchParty(ownerReference);
final Country country = fetchCountry(countryCode);
final ApplicationTenancy countryAppTenancy = fetchApplicationTenancy(countryAtPath);
final Property property = fetchProperty(reference, countryAppTenancy, true);
property.setName(name);
property.setCountry(country);
property.setCity(city);
property.setType(PropertyType.valueOf(type));
property.setAcquireDate(acquireDate);
property.setDisposalDate(disposalDate);
property.setOpeningDate(openingDate);
property.setExternalReference(externalReference);
property.addRoleIfDoesNotExist(owner, FixedAssetRoleType.PROPERTY_OWNER, null, null);
if (numeratorFormat != null)
collectionNumerators.createInvoiceNumberNumerator(property, numeratorFormat, BigInteger.ZERO);
}
use of org.estatio.dom.geography.Country in project estatio by estatio.
the class Api method putPartyCommunicationChannels.
// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putPartyCommunicationChannels(@Named("reference") final String partyReference, @Named("reference") @Optional final String reference, @Named("address1") @Optional final String address1, @Named("address2") @Optional final String address2, @Named("address3") @Optional final String address3, @Named("city") @Optional final String city, @Named("postalCode") @Optional final String postalCode, @Named("stateCode") @Optional final String stateCode, @Named("countryCode") @Optional final String countryCode, @Named("phoneNumber") @Optional final String phoneNumber, @Named("faxNumber") @Optional final String faxNumber, @Named("emailAddress") @Optional final String emailAddress, @Named("legal") @Optional final Boolean legal) {
final Party party = fetchParty(partyReference);
if (party == null)
throw new ApplicationException(String.format("Party with reference [%s] not found", partyReference));
// Address
if (address1 != null) {
final Country country = fetchCountry(countryCode);
PostalAddress comm = (PostalAddress) postalAddresses.findByAddress(party, address1, postalCode, city, country);
if (comm == null) {
comm = communicationChannels.newPostal(party, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, null, postalCode, city, states.findState(stateCode), countries.findCountry(countryCode));
comm.setReference(reference);
}
if (legal) {
comm.setLegal(true);
}
}
// Phone
if (phoneNumber != null) {
CommunicationChannel comm = phoneOrFaxNumbers.findByPhoneOrFaxNumber(party, phoneNumber);
if (comm == null) {
comm = communicationChannels.newPhoneOrFax(party, CommunicationChannelType.PHONE_NUMBER, phoneNumber);
comm.setReference(reference);
}
}
// Fax
if (faxNumber != null) {
CommunicationChannel comm = phoneOrFaxNumbers.findByPhoneOrFaxNumber(party, faxNumber);
if (comm == null) {
comm = communicationChannels.newPhoneOrFax(party, CommunicationChannelType.FAX_NUMBER, faxNumber);
comm.setReference(reference);
}
}
// Email
if (emailAddress != null) {
CommunicationChannel comm = emailAddresses.findByEmailAddress(party, emailAddress);
if (comm == null) {
comm = communicationChannels.newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
comm.setReference(reference);
}
}
}
Aggregations