use of eu.ggnet.dwoss.redtape.ee.entity.Document 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());
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DossierTest method sampleOpenDossierWithClosedInvoice.
private Dossier sampleOpenDossierWithClosedInvoice() {
Dossier dos = new Dossier(PaymentMethod.ADVANCE_PAYMENT, true, 1);
Document d1 = new Document(DocumentType.INVOICE, Document.Directive.NONE, null);
d1.setActive(true);
d1.setClosed(true);
dos.add(d1);
return dos;
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document 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());
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document 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());
}
use of eu.ggnet.dwoss.redtape.ee.entity.Document in project dwoss by gg-net.
the class DossierTest method sampleClosedDossier.
private Dossier sampleClosedDossier() {
Dossier dos = new Dossier(PaymentMethod.ADVANCE_PAYMENT, true, 1);
Document d1 = new Document(DocumentType.ORDER, Document.Directive.NONE, null);
d1.setClosed(true);
dos.add(d1);
dos.setClosed(true);
return dos;
}
Aggregations