Search in sources :

Example 31 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class DocumentTest method testRemove.

@Test
public void testRemove() {
    Document doc = new Document();
    Position p1 = doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    assertEquals("Document.posistion.size", 1, doc.getPositions().size());
    doc.remove(p1);
    assertEquals("Document.posistion.size", 0, doc.getPositions().size());
    p1 = doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    Position p3 = doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
    assertEquals("Document.posistion.size", 4, doc.getPositions().size());
    assertEquals("Postions order", Arrays.asList(1, 2, 3, 4), new ArrayList<>(doc.getPositions().keySet()));
    doc.remove(p1);
    assertEquals("Document.posistion.size", 3, doc.getPositions().size());
    assertEquals("Postions order", Arrays.asList(1, 2, 3), new ArrayList<>(doc.getPositions().keySet()));
    assertEquals("Position p3 should have id 2", 2, p3.getId());
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 32 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class DossierTest method testGetRelevantPositionsCapitalReturns.

@Test
public void testGetRelevantPositionsCapitalReturns() {
    final int UNIQUE_UNIT_ID = 1;
    Dossier dos1 = new Dossier();
    Document dos1CapitalAsset = new Document(DocumentType.RETURNS, Document.Directive.HAND_OVER_GOODS, null);
    dos1CapitalAsset.setActive(true);
    Position p1 = new Position();
    p1.setUniqueUnitId(UNIQUE_UNIT_ID);
    p1.setType(PositionType.UNIT);
    Position p2 = new Position();
    p2.setType(PositionType.COMMENT);
    dos1CapitalAsset.appendAll(p1, p2);
    dos1.add(dos1CapitalAsset);
    assertEquals(1, dos1.getRelevantUniqueUnitIds().size());
    assertEquals(UNIQUE_UNIT_ID, (int) dos1.getRelevantUniqueUnitIds().iterator().next());
    dos1CapitalAsset.add(Document.Condition.CANCELED);
    assertTrue("Should have no relevant UniqueUnit ids, but there are:  " + dos1.getRelevantUniqueUnitIds(), dos1.getRelevantUniqueUnitIds().isEmpty());
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 33 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class DossierTest method testGetRelevantPositionsCapitalAsset.

@Test
public void testGetRelevantPositionsCapitalAsset() {
    final int UNIQUE_UNIT_ID = 1;
    Dossier dos1 = new Dossier();
    Document dos1CapitalAsset = new Document(DocumentType.CAPITAL_ASSET, Document.Directive.HAND_OVER_GOODS, null);
    dos1CapitalAsset.setActive(true);
    Position p1 = new Position();
    p1.setUniqueUnitId(UNIQUE_UNIT_ID);
    p1.setType(PositionType.UNIT);
    Position p2 = new Position();
    p2.setType(PositionType.COMMENT);
    dos1CapitalAsset.appendAll(p1, p2);
    dos1.add(dos1CapitalAsset);
    assertEquals(1, dos1.getRelevantUniqueUnitIds().size());
    assertEquals(UNIQUE_UNIT_ID, (int) dos1.getRelevantUniqueUnitIds().iterator().next());
    dos1CapitalAsset.add(Document.Condition.CANCELED);
    assertTrue("Should have no relevant UniqueUnit ids, but there are:  " + dos1.getRelevantUniqueUnitIds(), dos1.getRelevantUniqueUnitIds().isEmpty());
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) Test(org.junit.Test)

Example 34 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class PositionFormater method main.

public static void main(String[] args) {
    Position p = new Position();
    p.setType(PositionType.UNIT);
    p.setName("Acer Aspire Stein (AA.BBBBB.CCC) SopoNr:12345 SN:AAAABBBBAVAFDADFDASFD");
    p.setPrice(10);
    System.out.println(PositionFormater.toHtmlShort(p, "250px"));
    p = new Position();
    p.setType(PositionType.PRODUCT_BATCH);
    p.setName("Acer Aspire Stein (AA.BBBBB.CCC)");
    p.setAmount(1.25);
    p.setDescription("Eine Tolle Beschreibung");
    p.setPrice(10);
    System.out.println(PositionFormater.toHtmlShort(p, "250px"));
}
Also used : Position(eu.ggnet.dwoss.redtape.ee.entity.Position)

Example 35 with Position

use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.

the class ResolveRepaymentBeanIT method testResolve.

@Test
public void testResolve() throws UserInfoException {
    List<Stock> allStocks = stockGenerator.makeStocksAndLocations(2);
    assertThat(allStocks).isNotEmpty().hasSize(2);
    Stock activeStock = allStocks.get(0);
    assertThat(customerGenerator.makeCustomers(10)).isNotEmpty();
    assertThat(receiptGenerator.makeUniqueUnits(200, true, true)).isNotEmpty();
    assertThat(redTapeGenerator.makeSalesDossiers(30)).isNotEmpty();
    final TradeName TRADE_NAME = ACER;
    assertThat(TRADE_NAME.isManufacturer()).isTrue();
    long customerId = customerGenerator.makeCustomer();
    List<UniqueUnit> uus = receiptGenerator.makeUniqueUnits(1, true, true);
    UniqueUnit uu = uus.get(0);
    uu = helper.changeContractors(uu.getId(), TRADE_NAME);
    String refurbishId = uu.getRefurbishId();
    Dossier dos = redTapeWorker.create(customerId, true, "Me");
    // order oder direct invoice
    Document doc = dos.getActiveDocuments(DocumentType.ORDER).get(0);
    // Create Positions
    doc.append(Position.builder().type(UNIT).amount(1).uniqueUnitId(uu.getId()).uniqueUnitProductId(uu.getProduct().getId()).price(uu.getPrice(CUSTOMER)).tax(doc.getSingleTax()).name(uu.getProduct().getName() + " | SN:" + uu.getSerial()).description(uu.getProduct().getDescription()).refurbishedId(refurbishId).build());
    // add units to LogicTransaction
    unitOverseer.lockStockUnit(dos.getId(), uu.getRefurbishId());
    doc.add(Document.Condition.PAID);
    doc.add(Document.Condition.PICKED_UP);
    doc.setType(DocumentType.INVOICE);
    doc = redTapeWorker.update(doc, null, "JUnit");
    // Now create an annulation Invoice
    doc.setType(ANNULATION_INVOICE);
    // ArrayList<Position> positions = new ArrayList<>();
    for (Position value : doc.getPositions().values()) {
        // if ( value.getType() == UNIT ) positions.add(value);
        value.setPrice(value.getPrice() * -1);
    }
    redTapeWorker.update(doc, activeStock.getId(), "JUnit Test");
    // Closing the Day. Creating report lines.
    redTapeCloser.executeManual("JUnitTest");
    // Ensure, that we have a Mirror Dossier on the repaymentcustomers.
    List<Dossier> repaymentDossiers = redTapeAgent.findDossiersOpenByCustomerIdEager(repaymentCustomers.get(TRADE_NAME).get());
    assertThat(repaymentDossiers).as("RepaymentDossiers").isNotEmpty();
    Dossier repaymentDossier = repaymentDossiers.get(0);
    List<Document> activeDocuments = repaymentDossier.getActiveDocuments(BLOCK);
    assertThat(activeDocuments).isNotEmpty();
    assertThat(activeDocuments.get(0).getPositions(UNIT)).isNotEmpty();
    Report report = new Report("Test", TRADE_NAME, new Date(), new Date());
    List<ReportLine> reportLines = reportLineEao.findAll();
    List<Storeable> arrayList = new ArrayList<>();
    reportLines.stream().filter((line) -> (line.getDocumentType() == INVOICE)).forEach((line) -> {
        arrayList.add(line.toStorable());
    });
    report = reportAgent.store(report, arrayList);
    assertThat(report).isNotNull();
    assertThat(report.getLines()).isNotEmpty();
    List<ReportLine> notReported = report.getLines().stream().filter((l) -> reportLines.contains(l)).collect(Collectors.toList());
    final int uuId = uu.getId();
    ReportLine lineToUniqueUnit = notReported.stream().filter((line) -> line.getUniqueUnitId() == uuId).collect(Collectors.toList()).get(0);
    assertThat(lineToUniqueUnit).isNotNull();
    List<ReportLine> repaymentLines = bean.getRepaymentLines(lineToUniqueUnit.getContractor());
    ReportLine repaymentLine = repaymentLines.stream().filter((l) -> l.getRefurbishId().equals(refurbishId)).collect(Collectors.toList()).get(0);
    assertThat(stockAgent.findStockUnitsByRefurbishIdEager(Arrays.asList(refurbishId))).isNotEmpty();
    // Resolving of the Unit.
    bean.resolveUnit(refurbishId, TRADE_NAME, "JUnit", "JUnit");
    List<Report> reports = reportAgent.findAll(Report.class);
    assertThat(reports).hasSize(2);
    Report repaymentReport = null;
    // Try to get Report with the Name that is generated in a Static method inside the ResolveRepaymentBean.
    if (reports.get(0).getName().equals(ResolveRepaymentBean.toReportName(TRADE_NAME)))
        repaymentReport = reports.get(0);
    else
        repaymentReport = reports.get(1);
    repaymentReport = reportAgent.findByIdEager(Report.class, repaymentReport.getId());
    assertThat(repaymentReport.getLines()).hasSize(1);
    assertThat(repaymentLines).contains(repaymentLine);
    // Ensure, that we the mirror Dossier has be cleared of the unit
    repaymentDossiers = redTapeAgent.findDossiersOpenByCustomerIdEager(repaymentCustomers.get(TRADE_NAME).get());
    assertThat(repaymentDossiers).isNotEmpty();
    repaymentDossier = repaymentDossiers.get(0);
    activeDocuments = repaymentDossier.getActiveDocuments(BLOCK);
    assertThat(activeDocuments).isNotEmpty();
    assertThat(activeDocuments.get(0).getPositions(UNIT)).isEmpty();
    // We still should have comments there.
    assertThat(activeDocuments.get(0).getPositions(PositionType.COMMENT)).isNotEmpty();
    assertThat(stockAgent.findStockUnitsByRefurbishIdEager(Arrays.asList(refurbishId))).isNullOrEmpty();
}
Also used : java.util(java.util) StockGeneratorOperation(eu.ggnet.dwoss.stock.ee.assist.gen.StockGeneratorOperation) Arquillian(org.jboss.arquillian.junit.Arquillian) ReportLineEao(eu.ggnet.dwoss.report.ee.eao.ReportLineEao) CustomerGeneratorOperation(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGeneratorOperation) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) RedTapeWorker(eu.ggnet.dwoss.redtapext.ee.RedTapeWorker) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) UnitOverseer(eu.ggnet.dwoss.redtapext.ee.UnitOverseer) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) CUSTOMER(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType.CUSTOMER) RedTapeCloser(eu.ggnet.dwoss.redtapext.ee.reporting.RedTapeCloser) Inject(javax.inject.Inject) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) ResolveRepayment(eu.ggnet.dwoss.misc.ee.ResolveRepayment) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) DocumentType(eu.ggnet.dwoss.rules.DocumentType) Report(eu.ggnet.dwoss.report.ee.entity.Report) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) RedTapeGeneratorOperation(eu.ggnet.dwoss.redtapext.ee.gen.RedTapeGeneratorOperation) EJB(javax.ejb.EJB) Storeable(eu.ggnet.dwoss.report.ee.entity.ReportLine.Storeable) RepaymentCustomers(eu.ggnet.dwoss.mandator.api.value.RepaymentCustomers) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) UNIT(eu.ggnet.dwoss.rules.PositionType.UNIT) ACER(eu.ggnet.dwoss.rules.TradeName.ACER) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) RedTapeAgent(eu.ggnet.dwoss.redtape.ee.RedTapeAgent) ResolveRepaymentBean(eu.ggnet.dwoss.misc.ee.ResolveRepaymentBean) ReceiptGeneratorOperation(eu.ggnet.dwoss.receipt.ee.gen.ReceiptGeneratorOperation) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) Position(eu.ggnet.dwoss.redtape.ee.entity.Position) Report(eu.ggnet.dwoss.report.ee.entity.Report) Storeable(eu.ggnet.dwoss.report.ee.entity.ReportLine.Storeable) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) Test(org.junit.Test)

Aggregations

Position (eu.ggnet.dwoss.redtape.ee.entity.Position)37 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)23 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)11 Test (org.junit.Test)8 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)6 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)5 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)5 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)5 OkCancelDialog (eu.ggnet.dwoss.util.OkCancelDialog)5 RedTapeWorker (eu.ggnet.dwoss.redtapext.ee.RedTapeWorker)4 AfterInvoicePosition (eu.ggnet.dwoss.redtapext.ui.cao.document.AfterInvoicePosition)4 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)4 CreditMemoView (eu.ggnet.dwoss.redtapext.ui.cao.document.annulation.CreditMemoView)3 ReportLineEao (eu.ggnet.dwoss.report.ee.eao.ReportLineEao)3 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)3 UNIT (eu.ggnet.dwoss.rules.PositionType.UNIT)3 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)3 Logger (org.slf4j.Logger)3 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)2