Search in sources :

Example 1 with PriceHistory

use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory in project dwoss by gg-net.

the class SalesListingProducerOperation method generateAllSalesListing.

@Override
public FileJacket generateAllSalesListing() {
    SubMonitor m = monitorFactory.newSubMonitor("All List", 5);
    m.message("loading Units");
    m.start();
    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransaction();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
    m.worked(3, "preparing Units");
    List<Object[]> retailers = new ArrayList<>(stockUnits.size());
    List<Object[]> customers = new ArrayList<>(stockUnits.size());
    for (Map.Entry<UniqueUnit, StockUnit> entry : toSortedMap(uniqueUnits, stockUnits, new UniqueUnitComparator()).entrySet()) {
        UniqueUnit uu = entry.getKey();
        StockUnit su = entry.getValue();
        Product p = uu.getProduct();
        Date firstPriced = null;
        for (PriceHistory priceHistory : uu.getPriceHistory()) {
            if (firstPriced == null || firstPriced.after(priceHistory.getDate()))
                firstPriced = priceHistory.getDate();
        }
        String source = "Automatisch";
        if (p != null && p.getFlags().contains(Product.Flag.PRICE_FIXED))
            source = "Manuell (Artikel)";
        else if (uu.getFlags().contains(UniqueUnit.Flag.PRICE_FIXED))
            source = "Manuell (Gerät)";
        Object[] row = { uu.getRefurbishId(), (p == null ? null : p.getPartNo()), (p == null ? null : p.getGroup().getNote()), (p == null ? null : p.getTradeName().getName()), (p == null ? null : p.getName()), (p == null ? null : p.getDescription()), uu.getWarranty().getName(), uu.getWarrentyValid(), UniqueUnitFormater.toSingleLineAccessories(uu), uu.getCondition().getNote(), UniqueUnitFormater.toSingleLineComment(uu), uu.getPrice(PriceType.RETAILER), uu.getPrice(PriceType.CUSTOMER), (!uu.hasPrice(PriceType.CUSTOMER) ? null : TwoDigits.roundedApply(uu.getPrice(PriceType.CUSTOMER), GlobalConfig.DEFAULT_TAX.getTax(), 0)), (su.getStock() == null ? su.getTransaction() : su.getStock().getName()), uu.getMfgDate(), uu.getInputDate(), firstPriced, source };
        if (uu.getSalesChannel() == SalesChannel.CUSTOMER && uu.hasPrice(PriceType.CUSTOMER))
            customers.add(row);
        else if (uu.getSalesChannel() == SalesChannel.RETAILER && (uu.hasPrice(PriceType.CUSTOMER) || uu.hasPrice(PriceType.RETAILER)))
            retailers.add(row);
    }
    m.worked(1, "creating File, Endkundengeräte: " + customers.size() + ", Händlergeräte: " + retailers.size());
    STable consumerTable = new STable();
    consumerTable.setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
    consumerTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
    consumerTable.setRowHeight(1000);
    consumerTable.add(new STableColumn("SopoNr", 12));
    consumerTable.add(new STableColumn("ArtikelNr", 15));
    consumerTable.add(new STableColumn("Warengruppe", 18));
    consumerTable.add(new STableColumn("Hersteller", 15));
    consumerTable.add(new STableColumn("Bezeichnung", 30));
    consumerTable.add(new STableColumn("Beschreibung", 60, LFT));
    consumerTable.add(new STableColumn("Garantie", 18, LFT));
    consumerTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Zubehör", 30, LFT));
    consumerTable.add(new STableColumn("optische Bewertung", 25));
    consumerTable.add(new STableColumn("Bemerkung", 50, LFT));
    consumerTable.add(new STableColumn("Händler", 15, EURO));
    consumerTable.add(new STableColumn("Endkunde", 15, EURO));
    consumerTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
    consumerTable.add(new STableColumn("Lager", 18));
    consumerTable.add(new STableColumn("Mfg Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Aufnahme Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Erstmalig Bepreist", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Preis Quelle", 18));
    consumerTable.setModel(new STableModelList(customers));
    STable retailerTable = new STable(consumerTable);
    retailerTable.setModel(new STableModelList(retailers));
    CCalcDocument cdoc = new TempCalcDocument();
    cdoc.add(new CSheet("Endkunde", consumerTable));
    cdoc.add(new CSheet("Händler", retailerTable));
    FileJacket fj = new FileJacket("All", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc));
    m.finish();
    return fj;
}
Also used : Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) PriceHistory(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 2 with PriceHistory

use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory in project dwoss by gg-net.

the class PriceCoreOperationIT method testStore.

@Test
public void testStore() {
    stockGenerator.makeStocksAndLocations(2);
    receiptGenerator.makeUniqueUnits(20, true, false);
    // Estimate all Units
    List<PriceEngineResult> pers = priceCore.loadAndCalculate(null);
    final double fixedUnitPrice = 100;
    final double fixedProductPrice = 50;
    String fixedPriceRefurbishId = pers.get(0).getRefurbishedId();
    pers.get(0).setCustomerPrice(100);
    pers.get(0).setRetailerPrice(100);
    pers.get(0).setUnitPriceFixed(PriceEngineResult.Change.SET);
    String fixedPartNo = pers.get(3).getManufacturerPartNo();
    pers.get(3).setCustomerPrice(50);
    pers.get(3).setRetailerPrice(50);
    pers.get(3).setManufacturerPartPriceFixed(PriceEngineResult.Change.SET);
    priceCore.store(pers, "via test", "testuser", null);
    UniqueUnit uniqueUnit = uniqueUnitAgent.findUnitByIdentifierEager(Identifier.REFURBISHED_ID, fixedPriceRefurbishId);
    assertEquals(fixedUnitPrice, uniqueUnit.getPrice(PriceType.CUSTOMER), 0.001);
    assertEquals(fixedUnitPrice, uniqueUnit.getPrice(PriceType.RETAILER), 0.001);
    assertTrue("Unit should contain Flage PriceFixed" + uniqueUnit.getFlags(), uniqueUnit.getFlags().contains(UniqueUnit.Flag.PRICE_FIXED));
    for (PriceHistory priceHistory : uniqueUnit.getPriceHistory()) {
        assertTrue(priceHistory.getComment().contains("unitfix"));
        assertEquals(fixedUnitPrice, priceHistory.getPrice(), 0.001);
        assertTrue(priceHistory.getType() == PriceType.CUSTOMER || priceHistory.getType() == PriceType.RETAILER);
    }
    Product product = uniqueUnitAgent.findProductByPartNoEager(fixedPartNo);
    assertEquals(fixedProductPrice, product.getPrice(PriceType.CUSTOMER), 0.001);
    assertEquals(fixedProductPrice, product.getPrice(PriceType.RETAILER), 0.001);
    assertTrue(product.getFlags().contains(Product.Flag.PRICE_FIXED));
    for (PriceHistory priceHistory : product.getPriceHistory()) {
        assertTrue(priceHistory.getComment().contains("productfix"));
        assertEquals(fixedProductPrice, priceHistory.getPrice(), 0.001);
        assertTrue(priceHistory.getType() == PriceType.CUSTOMER || priceHistory.getType() == PriceType.RETAILER);
    }
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) PriceEngineResult(eu.ggnet.dwoss.price.engine.PriceEngineResult) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) PriceHistory(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory) Test(org.junit.Test)

Aggregations

PriceHistory (eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory)2 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)2 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)2 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)1 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)1 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)1 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)1 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)1 Test (org.junit.Test)1