Search in sources :

Example 1 with CCalcDocument

use of eu.ggnet.lucidcalc.CCalcDocument 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;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat)

Example 2 with CCalcDocument

use of eu.ggnet.lucidcalc.CCalcDocument 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);
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) CBorder(eu.ggnet.lucidcalc.CBorder) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with CCalcDocument

use of eu.ggnet.lucidcalc.CCalcDocument 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);
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) CBorder(eu.ggnet.lucidcalc.CBorder) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Example 4 with CCalcDocument

use of eu.ggnet.lucidcalc.CCalcDocument in project dwoss by gg-net.

the class SFormulaTest method testFormulaError.

@Test
public void testFormulaError() {
    SFormula[] formulas = { new SFormula(33, "+", 22, "//"), new SFormula(33, "+", 2, "/", 0), new SFormula(33, "+", 22, "/", Double.NaN), new SFormula(33, "+", 22), new SFormula(33, "+", 22) };
    STable newTable = new STable();
    newTable.add(new STableColumn("TestFormula", 10));
    newTable.setModel(new STableModelList<>(formulas));
    SBlock block = new SBlock();
    block.add(new SFormula("SUMME(", newTable.getCellFirstRow(0), ":", newTable.getCellLastRow(0), ")"));
    CCalcDocument cdoc = new TempCalcDocument();
    cdoc.add(new CSheet("Sheet1", newTable, block));
    File f = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    f.delete();
// System.out.println(f.toURI());
// No assert needed. If Anything goes wrong in the write process, an exception would be thrown.
}
Also used : STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) SFormula(eu.ggnet.lucidcalc.SFormula) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) SBlock(eu.ggnet.lucidcalc.SBlock) File(java.io.File) Test(org.junit.Test)

Example 5 with CCalcDocument

use of eu.ggnet.lucidcalc.CCalcDocument in project dwoss by gg-net.

the class DebitorsReporterOperation method toXls.

/**
 * Creates the Report
 *
 * @param monitor
 * @return a ByteArray represeting the content of an xls file.
 */
@Override
public FileJacket toXls(Date start, Date end) {
    SubMonitor m = monitorFactory.newSubMonitor("DebitorenReport", 25);
    m.message("loading Dossiers");
    DocumentEao documentEao = new DocumentEao(redTapeEm);
    List<Document> documents = new ArrayList<>();
    documents.addAll(documentEao.findDocumentsBetweenDates(start, end, DocumentType.INVOICE));
    m.worked(10, "preparing Data");
    List<Object[]> rows = new ArrayList<>();
    for (Document document : documents) {
        UiCustomer c = customerService.asUiCustomer(document.getDossier().getCustomerId());
        rows.add(new Object[] { c.getId(), document.getDossier().getIdentifier(), c.getCompany(), c.toNameLine(), document.getDossier().getCrucialDirective().getName(), document.getDossier().getComment(), document.getActual(), document.getIdentifier(), document.getPrice(), document.toAfterTaxPrice(), document.getDossier().getPaymentMethod().getNote() });
    }
    m.worked(10, "building Report");
    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("Kid", 8, new CFormat(RIGHT))).add(new STableColumn("AiD", 10, new CFormat(RIGHT))).add(new STableColumn("Firma", 20));
    table.add(new STableColumn("Nachname", 20)).add(new STableColumn("Letzer Status", 20));
    table.add(new STableColumn("Bemerkung", 10)).add(new STableColumn("Datum", 10, new CFormat(RIGHT, SHORT_DATE)));
    table.add(new STableColumn("RE_Nr", 10, new CFormat(RIGHT))).add(new STableColumn("Netto", 15, new CFormat(RIGHT, CURRENCY_EURO))).add(new STableColumn("Brutto", 10, new CFormat(RIGHT, CURRENCY_EURO)));
    table.add(new STableColumn("ZahlungsModalität", 10, new CFormat(RIGHT)));
    table.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument("Debitoren_");
    cdoc.add(new CSheet("DebitorenReport", table));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    FileJacket result = new FileJacket("Debitoren", ".xls", file);
    m.finish();
    return result;
}
Also used : DocumentEao(eu.ggnet.dwoss.redtape.ee.eao.DocumentEao) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) UiCustomer(eu.ggnet.dwoss.customer.opi.UiCustomer) CBorder(eu.ggnet.lucidcalc.CBorder) File(java.io.File)

Aggregations

CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)9 CSheet (eu.ggnet.lucidcalc.CSheet)9 STable (eu.ggnet.lucidcalc.STable)9 STableColumn (eu.ggnet.lucidcalc.STableColumn)9 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)9 FileJacket (eu.ggnet.dwoss.util.FileJacket)7 CFormat (eu.ggnet.lucidcalc.CFormat)7 STableModelList (eu.ggnet.lucidcalc.STableModelList)7 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)6 CBorder (eu.ggnet.lucidcalc.CBorder)6 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)5 File (java.io.File)5 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)4 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)3 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)3 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)3 ArrayList (java.util.ArrayList)3 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)2 SBlock (eu.ggnet.lucidcalc.SBlock)2 SimpleDateFormat (java.text.SimpleDateFormat)2