use of org.estatio.module.asset.dom.FixedAsset in project estatio by estatio.
the class PartyRoleMemberInferenceServiceForFixedAssetRoleAndIncomingInvoice method doInferMembersOf.
@Override
protected List<Person> doInferMembersOf(final FixedAssetRoleTypeEnum partyRoleType, final IncomingInvoice incomingInvoice) {
final FixedAsset fixedAsset = incomingInvoice.getProperty();
if (fixedAsset == null) {
// can't go any further
return null;
}
final List<FixedAssetRole> fixedAssetRoles = fixedAssetRoleRepository.findByAssetAndType(fixedAsset, partyRoleType);
return currentPersonsFrom(fixedAssetRoles);
}
use of org.estatio.module.asset.dom.FixedAsset in project estatio by estatio.
the class FixedAssetRegistration method remove.
// //////////////////////////////////////
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
public FixedAsset remove() {
FixedAsset fixedAsset = getSubject();
getContainer().remove(this);
getContainer().flush();
return fixedAsset;
}
use of org.estatio.module.asset.dom.FixedAsset in project estatio by estatio.
the class FixedAssetRole method delete.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
public FixedAsset delete() {
FixedAsset fa = getAsset();
remove(this);
return fa;
}
use of org.estatio.module.asset.dom.FixedAsset in project estatio by estatio.
the class InvoiceForLeaseDtoFactory method newDto.
@Programmatic
public InvoiceDto newDto(final InvoiceForLease invoiceForLease) {
InvoiceDto dto = new InvoiceDto();
dto.setSelf(mappingHelper.oidDtoFor(invoiceForLease));
dto.setAtPath(invoiceForLease.getApplicationTenancyPath());
dto.setBuyerParty(mappingHelper.oidDtoFor(invoiceForLease.getBuyer()));
dto.setSellerParty(mappingHelper.oidDtoFor(invoiceForLease.getSeller()));
dto.setDueDate(asXMLGregorianCalendar(invoiceForLease.getDueDate()));
dto.setInvoiceDate(asXMLGregorianCalendar(invoiceForLease.getInvoiceDate()));
dto.setInvoiceNumber(invoiceForLease.getInvoiceNumber());
dto.setPaymentMethod(toDto(invoiceForLease.getPaymentMethod()));
dto.setCollectionNumber(invoiceForLease.getCollectionNumber());
final Lease lease = invoiceForLease.getLease();
if (lease != null) {
dto.setAgreementReference(lease.getReference());
final BankMandate paidBy = lease.getPaidBy();
if (paidBy != null) {
dto.setPaidByMandate(mappingHelper.oidDtoFor(paidBy));
dto.setBuyerBankAccount(mappingHelper.oidDtoFor(paidBy.getBankAccount()));
}
}
final Optional<FixedAsset> fixedAssetIfAny = Optional.ofNullable(invoiceForLease.getFixedAsset());
if (fixedAssetIfAny.isPresent()) {
final FixedAsset fixedAsset = fixedAssetIfAny.get();
dto.setFixedAssetReference(fixedAsset.getReference());
dto.setFixedAssetExternalReference(fixedAsset.getExternalReference());
// there should be only one
dto.setSellerBankAccount(mappingHelper.oidDtoFor(invoiceForLease.getSellerBankAccount()));
}
invoiceForLease.getItems().stream().forEach(item -> dto.getItems().add(invoiceItemForLeaseDtoFactory.newDto(item)));
dto.setNetAmount(dto.getItems().stream().map(x -> valueElseZero(x.getNetAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
dto.setGrossAmount(dto.getItems().stream().map(x -> valueElseZero(x.getGrossAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
dto.setVatAmount(dto.getItems().stream().map(x -> valueElseZero(x.getVatAmount())).reduce(BigDecimal.ZERO, BigDecimal::add));
return dto;
}
use of org.estatio.module.asset.dom.FixedAsset in project estatio by estatio.
the class InvoiceItemForLeaseDtoFactory method newDto.
@Programmatic
public InvoiceItemDto newDto(final InvoiceItem item) {
InvoiceItemDto dto = new InvoiceItemDto();
if (item instanceof InvoiceItemForLease) {
InvoiceItemForLease invoiceItemForLease = (InvoiceItemForLease) item;
final Lease lease = invoiceItemForLease.getLease();
if (lease != null) {
dto.setAgreementReference(lease.getReference());
}
final FixedAsset fixedAsset = invoiceItemForLease.getFixedAsset();
if (fixedAsset != null) {
dto.setFixedAssetReference(fixedAsset.getReference());
dto.setFixedAssetExternalReference(fixedAsset.getExternalReference());
}
}
final Charge charge = item.getCharge();
dto.setChargeReference(charge.getReference());
dto.setChargeDescription(charge.getDescription());
dto.setChargeExternalReference(charge.getExternalReference());
dto.setChargeName(charge.getName());
final ChargeGroup group = charge.getGroup();
dto.setChargeGroupReference(group.getReference());
dto.setChargeGroupName(group.getName());
final Tax tax = item.getTax();
final TaxRate rate = item.getTaxRate();
dto.setTaxReference(tax.getReference());
dto.setTaxName(tax.getName());
dto.setTaxDescription(tax.getDescription());
dto.setTaxExternalReference(rate == null || rate.getExternalReference() == null ? tax.getExternalReference() : rate.getExternalReference());
dto.setNetAmount(item.getNetAmount());
dto.setGrossAmount(item.getGrossAmount());
dto.setVatAmount(item.getVatAmount());
dto.setDescription(item.getDescription());
dto.setStartDate(asXMLGregorianCalendar(item.getStartDate()));
dto.setEndDate(asXMLGregorianCalendar(item.getEndDate()));
dto.setEffectiveStartDate(asXMLGregorianCalendar(firstNonNull(item.getEffectiveStartDate(), item.getStartDate())));
dto.setEffectiveEndDate(asXMLGregorianCalendar(firstNonNull(item.getEffectiveEndDate(), item.getEndDate())));
if (item instanceof InvoiceItemForLease) {
final InvoiceItemForLease invoiceItemForLease = (InvoiceItemForLease) item;
final InvoiceForLease invoice = (InvoiceForLease) invoiceItemForLease.getInvoice();
final Lease leaseIfAny = invoice.getLease();
if (leaseIfAny != null) {
final SortedSet<Occupancy> occupancies = leaseIfAny.getOccupancies();
if (!occupancies.isEmpty()) {
// final Optional<Occupancy> occupancyIfAny =
// occupancies.stream().filter(x -> x.getInterval().overlaps(item.getEffectiveInterval())).findFirst();
final Optional<Occupancy> occupancyIfAny = Optional.ofNullable(occupancies.first());
if (occupancyIfAny.isPresent()) {
final Occupancy occupancy = occupancyIfAny.orElse(occupancies.last());
final Brand brand = occupancy.getBrand();
dto.setOccupancyBrand(brand == null ? null : brand.getName());
if (dto.getFixedAssetReference() == null) {
// the unit was not retrieved through the invoice item, so get it from the occupancy then.
dto.setFixedAssetReference(occupancy.getUnit().getReference());
dto.setFixedAssetExternalReference(occupancy.getUnit().getExternalReference());
}
} else {
// throw new IllegalArgumentException("Invoice has an effective date range outside the scope of the occupanies");
throw new IllegalArgumentException("No Occupancy Found");
}
}
}
}
return dto;
}
Aggregations