use of org.estatio.module.tax.dom.Tax in project estatio by estatio.
the class ChargeImport method importData.
@Override
@Programmatic
public List<Object> importData(Object previousRow) {
ChargeGroup chargeGroup = null;
if (getChargeGroupReference() != null) {
chargeGroup = findOrCreateChargeGroup(chargeGroupReference, chargeGroupName);
}
final ApplicationTenancy applicationTenancy = securityApplicationTenancyRepository.findByPath(atPath);
final Applicability applicability = this.applicability != null ? Applicability.valueOf(this.applicability) : Applicability.IN_AND_OUT;
Tax tax = null;
if (getTaxReference() != null) {
tax = taxRepository.findOrCreate(taxReference, taxReference, applicationTenancy);
}
if (getReference() == null) {
setReference(getName());
}
final Charge charge = chargeRepository.upsert(getReference(), getName(), getDescription(), applicationTenancy, applicability, tax, chargeGroup);
if (getParent() != null) {
Charge parentCharge = chargeRepository.findByReference(getParent());
if (parentCharge != null) {
charge.setParent(parentCharge);
}
}
if (externalReference != null) {
charge.setExternalReference(externalReference);
}
if (sortOrder != null) {
charge.setSortOrder(sortOrder);
}
return Lists.newArrayList(charge);
}
use of org.estatio.module.tax.dom.Tax in project estatio by estatio.
the class InvoiceForLeaseDtoFactory_Test method newItem.
private static InvoiceItemForTesting newItem(final Invoice invoice, final String netAmt, final String grossAmt, final String vatAmt) {
final InvoiceItemForTesting invoiceItem = new InvoiceItemForTesting(invoice);
invoiceItem.setInvoice(invoice);
final ChargeGroup chargeGroup = new ChargeGroup();
final Charge charge = new Charge();
charge.setGroup(chargeGroup);
invoiceItem.setCharge(charge);
final Tax tax = new Tax();
invoiceItem.setTax(tax);
invoiceItem.setNetAmount(new BigDecimal(netAmt));
invoiceItem.setGrossAmount(new BigDecimal(grossAmt));
invoiceItem.setVatAmount(new BigDecimal(vatAmt));
return invoiceItem;
}
use of org.estatio.module.tax.dom.Tax in project estatio by estatio.
the class IncomingInvoiceItemRepository_Test method upsert_works.
@Test
public void upsert_works() throws Exception {
// given
IncomingInvoiceItemRepository incomingInvoiceItemRepository = new IncomingInvoiceItemRepository() {
@Override
public IncomingInvoiceItem findByInvoiceAndChargeAndSequence(final IncomingInvoice invoice, final Charge charge, final BigInteger sequence) {
return invoiceItem;
}
};
BigInteger sequence = new BigInteger("1");
String description = "";
Tax tax = new Tax();
LocalDate dueDate = new LocalDate(2017, 1, 1);
LocalDate startDate = new LocalDate(2017, 1, 2);
LocalDate endDate = new LocalDate(2017, 1, 3);
Property property = new Property();
Project project = new Project();
BudgetItem budgetItem = new BudgetItem();
IncomingInvoiceType type = IncomingInvoiceType.CORPORATE_EXPENSES;
invoiceItem.setInvoice(mockInvoice);
assertThat(invoiceItem.getInvoice()).isEqualTo(mockInvoice);
assertThat(invoiceItem.getIncomingInvoiceType()).isNull();
assertThat(invoiceItem.getCharge()).isNull();
assertThat(invoiceItem.getSequence()).isNull();
assertThat(invoiceItem.getDescription()).isNull();
assertThat(invoiceItem.getNetAmount()).isNull();
assertThat(invoiceItem.getVatAmount()).isNull();
assertThat(invoiceItem.getGrossAmount()).isNull();
assertThat(invoiceItem.getTax()).isNull();
assertThat(invoiceItem.getDueDate()).isNull();
assertThat(invoiceItem.getStartDate()).isNull();
assertThat(invoiceItem.getEndDate()).isNull();
assertThat(invoiceItem.getFixedAsset()).isNull();
assertThat(invoiceItem.getProject()).isNull();
// when
incomingInvoiceItemRepository.upsert(sequence, mockInvoice, type, mockCharge, description, BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN, tax, dueDate, startDate, endDate, property, project, budgetItem);
// then
// should not updated
assertThat(invoiceItem.getInvoice()).isEqualTo(mockInvoice);
// should not updated
assertThat(invoiceItem.getCharge()).isNull();
// should not be updated
assertThat(invoiceItem.getIncomingInvoiceType()).isNull();
assertThat(invoiceItem.getSequence()).isEqualTo(sequence);
assertThat(invoiceItem.getDescription()).isEqualTo(description);
assertThat(invoiceItem.getNetAmount()).isEqualTo(BigDecimal.ZERO);
assertThat(invoiceItem.getVatAmount()).isEqualTo(BigDecimal.ONE);
assertThat(invoiceItem.getGrossAmount()).isEqualTo(BigDecimal.TEN);
assertThat(invoiceItem.getTax()).isEqualTo(tax);
assertThat(invoiceItem.getDueDate()).isEqualTo(dueDate);
assertThat(invoiceItem.getStartDate()).isEqualTo(startDate);
assertThat(invoiceItem.getEndDate()).isEqualTo(endDate);
assertThat(invoiceItem.getFixedAsset()).isEqualTo(property);
assertThat(invoiceItem.getProject()).isEqualTo(project);
}
use of org.estatio.module.tax.dom.Tax in project estatio by estatio.
the class OrderItemRepository_Test method upsert_works.
@Test
public void upsert_works() throws Exception {
// given
OrderItemRepository orderItemRepository = new OrderItemRepository() {
@Override
public OrderItem findByOrderAndCharge(final Order order, final Charge charge) {
return orderItem;
}
};
String description = new String("some description");
BigDecimal netAmount = BigDecimal.ZERO;
BigDecimal vatAmount = BigDecimal.ONE;
BigDecimal grossAmount = BigDecimal.TEN;
Tax tax = new Tax();
LocalDate startDate = new LocalDate(2017, 1, 1);
LocalDate endDate = new LocalDate(2017, 1, 2);
Property property = new Property();
Project project = new Project();
BudgetItem budgetItem = new BudgetItem();
assertThat(orderItem.getOrdr()).isNull();
assertThat(orderItem.getCharge()).isNull();
// when
orderItemRepository.upsert(mockOrder, mockCharge, description, netAmount, vatAmount, grossAmount, tax, startDate, endDate, property, project, budgetItem);
// then
assertThat(orderItem.getOrdr()).isNull();
assertThat(orderItem.getCharge()).isNull();
assertThat(orderItem.getDescription()).isEqualTo(description);
assertThat(orderItem.getNetAmount()).isEqualTo(netAmount);
assertThat(orderItem.getVatAmount()).isEqualTo(vatAmount);
assertThat(orderItem.getGrossAmount()).isEqualTo(grossAmount);
assertThat(orderItem.getTax()).isEqualTo(tax);
assertThat(orderItem.getStartDate()).isEqualTo(startDate);
assertThat(orderItem.getEndDate()).isEqualTo(endDate);
assertThat(orderItem.getProperty()).isEqualTo(property);
assertThat(orderItem.getProject()).isEqualTo(project);
assertThat(orderItem.getBudgetItem()).isEqualTo(budgetItem);
}
use of org.estatio.module.tax.dom.Tax in project estatio by estatio.
the class Order_withLinks_IntegTest method can_update_amounts_even_when_has_linked_items.
@Test
public void can_update_amounts_even_when_has_linked_items() throws Exception {
// when
final BigDecimal newNetAmt = fakeDataService.bigDecimals().any(13, 2).abs();
final BigDecimal newVatAmt = fakeDataService.bigDecimals().any(13, 2).abs();
final BigDecimal newGrossAmt = fakeDataService.bigDecimals().any(13, 2).abs();
final Tax tax = fakeDataService.collections().anyOf(taxRepository.allTaxes());
wrap(orderItem).updateAmounts(newNetAmt, newVatAmt, newGrossAmt, tax);
// then
assertThat(orderItem.getNetAmount()).isEqualTo(newNetAmt);
assertThat(orderItem.getVatAmount()).isEqualTo(newVatAmt);
assertThat(orderItem.getGrossAmount()).isEqualTo(newGrossAmt);
assertThat(orderItem.getTax()).isEqualTo(tax);
}
Aggregations