use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.
the class DocumentSupporterIT method testCreate.
/**
* Test of create method, of class RedTapeOperation.
*/
@Test
public void testCreate() {
Dossier dos = new Dossier();
dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
dos.setDispatch(true);
dos.setCustomerId(1);
Document doc = new Document();
doc.setType(DocumentType.ORDER);
doc.setActive(true);
doc.setDirective(Document.Directive.WAIT_FOR_MONEY);
doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
Address a = new Address("Herr Muh\nMuhstrasse 7\n12345 Muhstadt");
doc.setInvoiceAddress(a);
doc.setShippingAddress(a);
dos.add(doc);
doc.append(NaivBuilderUtil.comment());
doc.append(NaivBuilderUtil.service());
doc.append(NaivBuilderUtil.shippingcost());
JasperPrint print = documentSupporter.render(doc, DocumentViewType.DEFAULT);
assertNotNull("A JasperPrint should not be null", print);
}
use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.
the class RedTapeUpdateOrderWorkflow method execute.
/**
* Executes the Workflow and returns a Document.
*
* @return a Document.
*/
@Override
public Document execute() {
Document previous = new DocumentEao(redTapeEm).findById(altered.getId(), LockModeType.PESSIMISTIC_WRITE);
if (noChanges(altered, previous))
return altered;
L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(altered), arranger);
validate(altered, previous);
// Must be asked here due to possible change on dossier
boolean isStillExactlyBriefed = altered.isStillExactlyBriefed(previous);
String comment = optionalUpdateDossier(previous.getDossier(), altered.getDossier().isDispatch(), altered.getDossier().getPaymentMethod());
Document newDocument = refreshAndPrepare(altered, previous);
if (altered.getConditions().contains(Document.Condition.CANCELED)) {
removeLogicTransaction(newDocument);
comment += "Auftrag storniert.";
} else {
equilibrateLogicTransaction(newDocument);
comment += "Auftrag geƤndert.";
}
if (!isStillExactlyBriefed) {
L.debug("Remove Flag CUSTOMER_EXACTLY_BRIEFED." + newDocument);
newDocument.remove(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
}
newDocument.setHistory(new DocumentHistory(arranger, comment));
redTapeEm.persist(newDocument);
// Writing new document an gennerating the id;
redTapeEm.flush();
L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
validateAfter(newDocument.getDossier());
return newDocument;
}
use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.
the class RedTapeUpdateRepaymentWorkflow method execute.
/**
* Executes the Workflow.
*
* @param alteredDocument
* @param destinationId
* @param aranger
* @return the updated Document.
*/
public Document execute(Document alteredDocument, Integer destinationId, String aranger) {
// TODO: don't do this in stateless, works for now.
this.arranger = aranger;
Document previousDoc = new DocumentEao(redTapeEm).findById(alteredDocument.getId(), LockModeType.PESSIMISTIC_WRITE);
validate(alteredDocument, previousDoc, destinationId);
if (alteredDocument.equalsContent(previousDoc))
return alteredDocument;
L.info("Workflow on {} by {}", DocumentFormater.toSimpleLine(alteredDocument), arranger);
Document newDocument = refreshAndPrepare(alteredDocument, previousDoc);
if (alteredDocument.getType() != previousDoc.getType()) {
// A Complaint is now complete.
if (previousDoc.getType() == DocumentType.COMPLAINT)
previousDoc.setDirective(Document.Directive.NONE);
generateIdentifier(newDocument);
}
if (!alteredDocument.isStillExactlyBriefed(previousDoc))
newDocument.remove(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
newDocument.setHistory(new DocumentHistory(arranger, "Update durch " + getClass().getSimpleName()));
redTapeEm.persist(newDocument);
// Writing new document an gennerating the id;
redTapeEm.flush();
L.debug("Returning {} with {}", newDocument, newDocument.getDossier());
validateAfter(newDocument.getDossier());
// Is this a first time change
if (alteredDocument.getType() == previousDoc.getType())
return newDocument;
// Is it a full CreditMemo on a Unit
if (!alteredDocument.containsPositionType(PositionType.UNIT))
return newDocument;
List<StockUnit> stockUnits = optionalRemoveFromLogicTransaction(newDocument);
List<StockUnit> stockUnits2 = rollInMissingStockUnits(newDocument.getDossier().getIdentifier(), newDocument.getPositions(PositionType.UNIT).values(), destinationId);
optionalTransferToDestination(stockUnits, destinationId);
Map<TradeName, List<Position>> contractorPositions = mapPositionsToContrator(newDocument.getPositions(PositionType.UNIT).values());
for (TradeName contractor : contractorPositions.keySet()) {
Document mirror = createMirrorDossier(repaymentCustomers.get(contractor).get()).getActiveDocuments().get(0);
updateMirrorPositions(newDocument.getDossier().getIdentifier(), mirror, contractorPositions.get(contractor));
equilibrateLogicTransaction(mirror);
}
return newDocument;
}
use of eu.ggnet.dwoss.redtape.ee.entity.DocumentHistory in project dwoss by gg-net.
the class DocumentRendererTryout method main.
public static void main(String[] args) {
DocumentSupporterOperation documentSupporter = new DocumentSupporterOperation();
documentSupporter.setMandator(Sample.MANDATOR);
Dossier dos = new Dossier();
dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
dos.setDispatch(true);
dos.setCustomerId(1);
Document doc = new Document();
doc.setTaxType(TaxType.GENERAL_SALES_TAX_DE_SINCE_2007);
doc.setType(DocumentType.ORDER);
doc.setActive(true);
doc.setDirective(Document.Directive.WAIT_FOR_MONEY);
doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
Address a = new Address("Herr Muh\nMuhstrasse 7\n12345 Muhstadt");
doc.setInvoiceAddress(a);
doc.setShippingAddress(a);
dos.add(doc);
NaivBuilderUtil.overwriteTax(doc.getTaxType());
doc.append(NaivBuilderUtil.comment());
doc.append(NaivBuilderUtil.service());
doc.append(NaivBuilderUtil.shippingcost());
System.out.println("Tax: " + doc.getSingleTax());
System.out.println("Netto " + doc.getPrice());
System.out.println("Brutto: " + doc.toAfterTaxPrice());
System.out.println("SumTax: " + (doc.toAfterTaxPrice() - doc.getPrice()));
JasperPrint print = documentSupporter.render(doc, DocumentViewType.DEFAULT);
JRViewer viewer = new JRViewer(print);
JFrame frame = new JFrame("Viewer");
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(viewer, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
Aggregations