use of eu.ggnet.dwoss.report.ee.entity.ReportLine in project dwoss by gg-net.
the class ReportUtilTest method annulationForInvoice.
/**
* Create an annulation invoice reportline referenced to a invoice report line.
* <p>
* @param invoiceLine the referenced report line
* @param partialRepayment does the annulation represent a partial repayment (UNIT/UNIT_ANNEX)
* @return an annulation invoice reportline referenced to a invoice report line
*/
private ReportLine annulationForInvoice(ReportLine invoiceLine, boolean partialRepayment) {
if (invoiceLine == null || DocumentType.INVOICE != invoiceLine.getDocumentType())
return null;
ReportLine annulationLine = ReportLine.builder().mfgDate(invoiceLine.getMfgDate()).dossierId(invoiceLine.getDossierId()).dossierIdentifier("DW" + format.format(invoiceLine.getDossierId())).documentType(ANNULATION_INVOICE).positionType(partialRepayment ? UNIT_ANNEX : invoiceLine.getPositionType()).build();
invoiceLine.add(annulationLine);
return annulationLine;
}
use of eu.ggnet.dwoss.report.ee.entity.ReportLine in project dwoss by gg-net.
the class ReportUtilTest method makeUnitReportLine.
/**
* Generates a invoice report line for a unit.
* <p>
* @param mfgDate the manufavcturing date from the unit
* @param lastDossierId the last used dossier id
* @param dType the document type of the reportline
* @return a invoice report line for a unit.
*/
private ReportLine makeUnitReportLine(Date mfgDate, long lastDossierId, DocumentType dType) {
ReportLine build = ReportLine.builder().mfgDate(mfgDate).dossierId(lastDossierId + 1).dossierIdentifier("DW" + format.format(lastDossierId + 1)).documentType(dType).positionType(UNIT).build();
build.setReportingDate(now);
build.setContractor(HP);
return build;
}
use of eu.ggnet.dwoss.report.ee.entity.ReportLine in project dwoss by gg-net.
the class ReportUtil method filterActiveInfo.
/**
* Returns a set containing only non reportable lines that are not of the RETURNS type.
* It's not allowed to have a null value in the collection.
* <p>
* @param allLines
* @param reportAble
* @return
*/
public static NavigableSet<ReportLine> filterActiveInfo(Collection<ReportLine> allLines, Collection<ReportLine> reportAble) {
TreeSet<ReportLine> treeSet = new TreeSet<>(allLines);
treeSet.removeAll(reportAble);
for (Iterator<ReportLine> it = treeSet.iterator(); it.hasNext(); ) {
ReportLine reportLine = it.next();
if (reportLine.getDocumentType() == DocumentType.RETURNS)
it.remove();
}
return treeSet;
}
use of eu.ggnet.dwoss.report.ee.entity.ReportLine in project dwoss by gg-net.
the class ReportUtil method filterInvoicedSplit.
/**
* Returns all Lines of the Report for Category Invoiced, split by mfgDate - startOfReport < 1 year and the rest.
* This consists of:
* <ul>
* <li>Position of Type Invoice, with no References</li>
* <li>Position of Type UNIT_ANNEX in DocumentType CREDIT_MEMO/ANNULATIION_INVOICE and a Referencing Invoice in the same report.</li>
* </ul>
* <p>
* It's not allowed to have a null value in the collection.
* <p>
* @param lines
* @param startingDate
* @return all Lines of the Report for Category Invoiced.
*/
public static YearSplit filterInvoicedSplit(Collection<ReportLine> lines, Date startingDate) {
NavigableSet<ReportLine> pastSplit = new TreeSet<>();
NavigableSet<ReportLine> preSplit = new TreeSet<>();
Date splitter = DateUtils.addYears(startingDate, -1);
for (ReportLine line : filterInvoiced(lines)) {
if (splitter.before(line.getMfgDate())) {
preSplit.add(line);
} else {
pastSplit.add(line);
}
}
return new YearSplit(startingDate, preSplit, pastSplit);
}
use of eu.ggnet.dwoss.report.ee.entity.ReportLine in project dwoss by gg-net.
the class ReportLineGenerator method makeReportLine.
public ReportLine makeReportLine() {
ReportLine reportLine = new ReportLine();
Date pastFiveYears = DateUtils.setYears(new Date(), 2009);
reportLine.setActual(new Date());
reportLine.setName("ReportLine-" + getRandomInt());
reportLine.setDescription("desription-" + getRandomInt());
reportLine.setDossierId(getRandomLong());
reportLine.setDocumentIdentifier("dossierIdentifier-" + getRandomInt());
reportLine.setDocumentId(getRandomLong());
reportLine.setDocumentIdentifier("documentIdentifier-" + getRandomInt());
reportLine.setPositionType(PositionType.values()[R.nextInt(PositionType.values().length)]);
reportLine.setDocumentType(DocumentType.values()[R.nextInt(DocumentType.values().length)]);
reportLine.setCustomerId(getRandomLong());
reportLine.setAmount(getRandomLong());
double tax = GlobalConfig.DEFAULT_TAX.getTax();
double price = Math.abs(R.nextDouble() * R.nextInt(1500));
reportLine.setManufacturerCostPrice(price + 15);
reportLine.setPrice(price);
reportLine.setTax(tax);
reportLine.setBookingAccount(getRandomInt());
GeneratedAddress makeAddress = new NameGenerator().makeAddress();
Name makeName = new NameGenerator().makeName();
String invoiceAdress = makeName.getFirst() + " " + makeName.getLast() + ", " + makeAddress.getStreet() + " " + makeAddress.getNumber() + ", " + makeAddress.getPostalCode() + " " + makeAddress.getTown();
reportLine.setInvoiceAddress(invoiceAdress);
reportLine.setRefurbishId("" + R.nextInt(100000));
reportLine.setUniqueUnitId(getRandomLong());
reportLine.setSerial("serial" + getRandomInt());
reportLine.setProductId(getRandomLong());
reportLine.setPartNo("partNo" + getRandomInt());
List<TradeName> names = new ArrayList<>();
names.addAll(Arrays.asList(TradeName.ACER, TradeName.APPLE, TradeName.DELL, TradeName.HP));
reportLine.setContractor(names.get(R.nextInt(names.size())));
reportLine.setProductBrand(names.get(R.nextInt(names.size())));
reportLine.setMfgDate(DateUtils.addDays(pastFiveYears, R.nextInt(2000)));
reportLine.setReportingDate(DateUtils.addDays(reportLine.getMfgDate(), R.nextInt(400)));
return reportLine;
}
Aggregations