use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class ImageIdHandlerOperation method exportMissing.
/**
* Returns a FileJacket of XLS, which contains all Products with missing ImageIds.
* <p/>
* Acitve Filters are:
* <ul>
* <li>If SalesChannel is supplied, only Products, which have units in the SalesChannel.</li>
* <li>Only Products, which don't have an image id.</li>
* <li>Only Products, which have Unit in stock.</li>
* </ul>
* <p/>
* @param salesChannel
* @return
*/
@Override
public FileJacket exportMissing(SalesChannel salesChannel) {
SubMonitor m = monitorFactory.newSubMonitor("Fehlende Image Ids exportieren", 100);
m.message("Loading Missing IDs");
m.start();
List<Integer> uniqueUnitIds = new StockUnitEao(stockEm).findByNoLogicTransactionAsUniqueUnitId();
List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(uniqueUnitIds);
SortedSet<Product> products = new TreeSet<>();
for (UniqueUnit uniqueUnit : uniqueUnits) {
if (uniqueUnit.getProduct() == null)
continue;
if (salesChannel != null && uniqueUnit.getSalesChannel() != salesChannel)
continue;
if (uniqueUnit.getProduct().getImageId() > 0)
continue;
products.add(uniqueUnit.getProduct());
}
STable table = new STable();
table.setHeadlineFormat(new CFormat(BOLD, BLACK, LIGHT_GRAY, CENTER, MIDDLE));
table.add(new STableColumn("ArtikelNr", 15).setAction(SUtil.getBeanProperty("partNo")));
table.add(new STableColumn("Warengruppe", 22).setAction(SUtil.getBeanProperty("group.name")));
table.add(new STableColumn("Hersteller", 16).setAction(SUtil.getBeanProperty("tradeName.name")));
table.add(new STableColumn("Bezeichnung", 45).setAction(SUtil.getBeanProperty("name")));
table.add(new STableColumn("Image Id", 10).setAction(SUtil.getNull()));
table.setModel(new STableModelList(products));
CCalcDocument doc = new TempCalcDocument("ImageIds");
doc.add(new CSheet("ImageIds", table));
FileJacket fj = new FileJacket("MissingImageIds", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(doc));
m.finish();
return fj;
}
use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class PersistenceValidatorOperation method createFileJacket.
/**
* This Method create a XLS Document with the given list of errors.
* First it sort the erros by his level and put them into different sheets.
* <p/>
* @param errors
* @return an optional of filejacket, if empty no errors are found.
*/
private Optional<FileJacket> createFileJacket(List<Vm> errors) {
if (errors.isEmpty())
return Optional.empty();
List<Object[]> rows = new ArrayList<>();
for (Vm vm : errors) {
rows.add(new Object[] { vm.getLevel(), vm.getMessage() });
}
CSheet sheet = new CSheet("Fehler");
STable table = new STable();
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, RED, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("Level", 12, new CFormat(RED, BLUE))).add(new STableColumn("Nachricht", 60));
table.setModel(new STableModelList(rows));
sheet.addBelow(table);
CCalcDocument document = new TempCalcDocument();
document.add(sheet);
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document);
FileJacket result = new FileJacket("Datenbank_Errors", ".xls", file);
return Optional.of(result);
}
use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class CreditMemoReporterOperation method toOptimizedXls.
@Override
public FileJacket toOptimizedXls(Date start, Date end) {
SubMonitor m = monitorFactory.newSubMonitor("Generating Report", 25);
m.message("Loading Credit Memos");
UniqueUnitEao unitEao = new UniqueUnitEao(uuEm);
List<Object[]> rows = new ArrayList<>();
List<Document> documents = new DocumentEao(redTapeEm).findDocumentsBetweenDates(start, end, DocumentType.CREDIT_MEMO, DocumentType.ANNULATION_INVOICE);
m.setWorkRemaining(documents.size());
for (Document document : documents) {
String salesDate = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT, Locale.GERMANY).format(document.getActual());
UiCustomer customer = customerService.asUiCustomer(document.getDossier().getCustomerId());
double price = 0;
double afterTaxPrice = 0;
boolean full = true;
String sopos = "";
for (Position position : document.getPositions().values()) {
if (position.getType() == PositionType.COMMENT)
continue;
if (position.getType() == PositionType.UNIT || position.getType() == PositionType.UNIT_ANNEX) {
full = position.getType() == PositionType.UNIT;
String refurbishId = unitEao.findById(position.getUniqueUnitId()).getRefurbishId();
sopos += (sopos.isEmpty()) ? refurbishId : " ," + refurbishId;
} else if (position.getType() == PositionType.SHIPPING_COST) {
Document invoice = document.getDossier().getActiveDocuments(DocumentType.INVOICE).get(0);
SortedMap<Integer, Position> positions = invoice.getPositions(PositionType.SHIPPING_COST);
if (positions.size() > 0) {
Position get = positions.get(positions.firstKey());
if (Math.abs(Math.abs(get.getPrice()) - Math.abs(position.getPrice())) > 0.001)
full = false;
}
}
price += position.getPrice();
afterTaxPrice += position.toAfterTaxPrice();
}
rows.add(new Object[] { document.getDossier().getIdentifier(), customer.getId(), salesDate, document.getIdentifier(), (full) ? "V" : "T", price, afterTaxPrice, customer.getCompany(), customer.toNameLine(), sopos });
m.worked(1);
}
m.message("Generating Document");
m.setWorkRemaining(10);
STable table = new STable();
table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
table.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.LEFT, CFormat.VerticalAlignment.BOTTOM, CFormat.Representation.DEFAULT));
table.add(new STableColumn("DossierId", 15)).add(new STableColumn("Kid", 10)).add(new STableColumn("Belegdatum", 10));
table.add(new STableColumn("DokumentId", 15)).add(new STableColumn("Voll/Teil", 10));
table.add(new STableColumn("Netto", 10, new CFormat(CFormat.HorizontalAlignment.RIGHT, CFormat.Representation.CURRENCY_EURO)));
table.add(new STableColumn("Brutto", 10, new CFormat(CFormat.HorizontalAlignment.RIGHT, CFormat.Representation.CURRENCY_EURO)));
table.add(new STableColumn("Firma", 25)).add(new STableColumn("Name", 25)).add(new STableColumn("SopoNr.", 10));
table.setModel(new STableModelList(rows));
CCalcDocument cdoc = new TempCalcDocument("Gutschriften_");
cdoc.add(new CSheet("Sheet1", table));
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
m.finish();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd_MM_yyy");
return new FileJacket("Gutschriften_" + dateFormat.format(start) + "-" + dateFormat.format(end), ".xls", file);
}
use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class CreditMemoReporterOperation method toXls.
@Override
public FileJacket toXls(Date start, Date end) {
SubMonitor m = monitorFactory.newSubMonitor("Generating Report", 25);
m.message("Loading Credit Memos");
List<Position> creditMemoPositions = new ArrayList<>();
for (Document document : new DocumentEao(redTapeEm).findDocumentsBetweenDates(start, end, DocumentType.COMPLAINT, DocumentType.CREDIT_MEMO, DocumentType.ANNULATION_INVOICE)) {
for (Position position : document.getPositions().values()) {
creditMemoPositions.add(position);
}
}
m.setWorkRemaining(creditMemoPositions.size() * 2);
UniqueUnitEao unitEao = new UniqueUnitEao(uuEm);
m.message(null);
List<Object[]> rows = new ArrayList<>();
for (Position position : creditMemoPositions) {
if (position.getType() == PositionType.COMMENT)
continue;
Document doc = position.getDocument();
UiCustomer customer = customerService.asUiCustomer(position.getDocument().getDossier().getCustomerId());
UniqueUnit unit = unitEao.findById(position.getUniqueUnitId());
String error = "ERROR FINDING UNIT";
String sopoNr = "-";
String serial = "-";
String contractor = "-";
String fullOrPartial = "-";
double customerPrice = 0;
double retailerPrice = 0;
if (position.getType() == PositionType.UNIT || position.getType() == PositionType.UNIT_ANNEX) {
if (unit == null) {
sopoNr = error;
serial = error;
contractor = error;
} else {
sopoNr = unit.getIdentifier(UniqueUnit.Identifier.REFURBISHED_ID);
serial = unit.getIdentifier(UniqueUnit.Identifier.SERIAL);
contractor = unit.getContractor().getName();
customerPrice = unit.getPrice(PriceType.CUSTOMER);
retailerPrice = unit.getPrice(PriceType.RETAILER);
fullOrPartial = (position.getType() == PositionType.UNIT ? "V" : "T");
if (position.getDocument().getType() == DocumentType.COMPLAINT)
fullOrPartial = "Rekla";
}
}
rows.add(new Object[] { sopoNr, serial, position.getName(), contractor, fullOrPartial, position.getPrice(), position.toAfterTaxPrice(), position.getDocument().getDossier().getIdentifier(), doc.getActual(), position.getDocument().getIdentifier(), customer.getId(), customer.toNameCompanyLine(), customerPrice, retailerPrice });
m.worked(5);
}
Collections.sort(rows, comperator);
m.message("Generating Document");
m.setWorkRemaining(10);
STable table = new STable();
table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
table.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.LEFT, CFormat.VerticalAlignment.BOTTOM, CFormat.Representation.DEFAULT));
table.add(new STableColumn("SopoNr", 15)).add(new STableColumn("Seriennummer", 30)).add(new STableColumn("Name", 50)).add(new STableColumn("Contractor", 15)).add(new STableColumn("Voll/Teil", 10)).add(new STableColumn("Netto", 10, EURO)).add(new STableColumn("Brutto", 10, EURO)).add(new STableColumn("DossierId", 15)).add(new STableColumn("Belegdatum", 10, new CFormat(SHORT_DATE))).add(new STableColumn("DokumentId", 15)).add(new STableColumn("Kid", 10)).add(new STableColumn("Kunde", 50)).add(new STableColumn("Endkundenpreis(Netto)", 25, EURO)).add(new STableColumn("Händlerpreis(Netto)", 25, EURO));
table.setModel(new STableModelList(rows));
CCalcDocument cdoc = new TempCalcDocument("Gutschriften_");
cdoc.add(new CSheet("Sheet1", table));
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
m.finish();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd_MM_yyy");
return new FileJacket("Gutschriften_" + dateFormat.format(start) + "-" + dateFormat.format(end), ".xls", file);
}
use of eu.ggnet.dwoss.util.FileJacket in project dwoss by gg-net.
the class DirectDebitReporterOperation method toXls.
/**
* Creates the Report
* <p/>
* @return a ByteArray represeting the content of an xls file.
*/
@Override
public FileJacket toXls() {
SubMonitor m = monitorFactory.newSubMonitor("Lastschriften", 25);
m.worked(10);
DocumentEao docEao = new DocumentEao(redTapeEm);
List<Document> documents = docEao.findInvoiceUnpaid(DIRECT_DEBIT);
Set<Long> customers = new HashSet<>();
for (Document document : documents) {
customers.add(document.getDossier().getCustomerId());
}
for (Long customerId : customers) {
documents.addAll(docEao.findUnBalancedAnulation(customerId, DIRECT_DEBIT));
}
List<Object[]> rows = new ArrayList<>();
for (Document doc : documents) {
UiCustomer customer = customerService.asUiCustomer(doc.getDossier().getCustomerId());
rows.add(new Object[] { doc.getDossier().getIdentifier(), customer.getId(), customer.toNameCompanyLine(), doc.getDirective().getName(), DocumentFormater.toConditions(doc), doc.getIdentifier(), doc.getActual(), doc.getPrice(), doc.toAfterTaxPrice(), doc.getDossier().getComment(), customerService.asCustomerMetaData(customer.getId()).getEmail() });
}
m.worked(10);
STable table = new STable();
table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
table.setHeadlineFormat(new CFormat(BOLD_ITALIC, WHITE, BLUE, CENTER, new CBorder(BLACK)));
table.add(new STableColumn("Vorgang", 10)).add(new STableColumn("KID", 8)).add(new STableColumn("Kunde", 40));
table.add(new STableColumn("Anweisung", 35)).add(new STableColumn("Status", 20)).add(new STableColumn("Dokument", 15)).add(new STableColumn("Datum", 15, new CFormat(SHORT_DATE)));
table.add(new STableColumn("Netto", 15, new CFormat(RIGHT, CURRENCY_EURO))).add(new STableColumn("Brutto", 15, new CFormat(RIGHT, CURRENCY_EURO)));
table.add(new STableColumn("Bemerkung", 50)).add(new STableColumn("eMail", 50));
table.setModel(new STableModelList(rows));
CCalcDocument cdoc = new TempCalcDocument("Lastschriften");
cdoc.add(new CSheet("Sheet1", table));
File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
FileJacket result = new FileJacket("Lastschriften", ".xls", file);
m.finish();
return result;
}
Aggregations