update
This commit is contained in:
parent
da9f4c7c0e
commit
15e0d86fb7
2 changed files with 214 additions and 201 deletions
|
|
@ -40,113 +40,126 @@ import org.imixs.workflow.faces.data.WorkflowEvent;
|
||||||
@ConversationScoped
|
@ConversationScoped
|
||||||
public class OPListController implements Serializable {
|
public class OPListController implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final int TASK_ERSTELLUNG = 1000;
|
public static final int TASK_ERSTELLUNG = 1000;
|
||||||
private static Logger logger = Logger.getLogger(OPListController.class.getName());
|
private static Logger logger = Logger.getLogger(OPListController.class.getName());
|
||||||
|
|
||||||
private String lastDbtrNumber = null;
|
private String lastDbtrNumber = null;
|
||||||
|
|
||||||
private List<ItemCollection> invoiceList = null;
|
private List<ItemCollection> invoiceList = null;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected WorkflowController workflowController;
|
protected WorkflowController workflowController;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected WorkflowService workflowService;
|
protected WorkflowService workflowService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ZahlungseingangService zahlungseingangService;
|
ZahlungseingangService zahlungseingangService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected DocumentService documentService;
|
protected DocumentService documentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese Methode liefert die Rechnungen zur gegebenen dbtrNumber. Die Methode
|
* Diese Methode liefert die Rechnungen zur gegebenen dbtrNumber. Die Methode
|
||||||
* nutzt einen lokalen cache um die Zugriffe zu beschleunigen.
|
* nutzt einen lokalen cache um die Zugriffe zu beschleunigen.
|
||||||
* <p>
|
* <p>
|
||||||
* Befindet sich der Zahlungseingang in Erstellung (Task=1000) werden alle
|
* Befindet sich der Zahlungseingang in Erstellung (Task=1000) werden alle
|
||||||
* offenen Rechnungen geholt
|
* offenen Rechnungen geholt. Zusätzlich werden auch alle diese Rechnungen
|
||||||
* <p>
|
* vorselektiert (Anforderung von Mary Mwangi). D.h. man muss ggf. Rechnungen
|
||||||
* Befindet sich der Zahlungseingang nicht mehr in erstellung werden nur die
|
* manuell delselktieren wenn man diese nicht im Mahnlauf haben will.
|
||||||
* Rechnugnen aus $workitemRef geholt!
|
* <p>
|
||||||
*
|
* Befindet sich der Zahlungseingang nicht mehr in erstellung werden nur die
|
||||||
* @param _dbtrNumber
|
* Rechnugnen aus $workitemRef geholt!
|
||||||
* @return
|
*
|
||||||
*/
|
* @param _dbtrNumber
|
||||||
@SuppressWarnings("unchecked")
|
* @return
|
||||||
public List<ItemCollection> getInvoices(String _dbtrNumber) {
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<ItemCollection> getInvoices(String _dbtrNumber) {
|
||||||
|
|
||||||
// Compute all open invoices if TASK_ERSTELLUNG....
|
// Compute all open invoices if TASK_ERSTELLUNG....
|
||||||
if (workflowController.getWorkitem().getTaskID() == TASK_ERSTELLUNG) {
|
if (workflowController.getWorkitem().getTaskID() == TASK_ERSTELLUNG) {
|
||||||
|
|
||||||
// return empty list if dbtr is not set
|
// return empty list if dbtr is not set
|
||||||
if (_dbtrNumber == null || _dbtrNumber.isEmpty()) {
|
if (_dbtrNumber == null || _dbtrNumber.isEmpty()) {
|
||||||
invoiceList = new ArrayList<ItemCollection>();
|
invoiceList = new ArrayList<ItemCollection>();
|
||||||
return invoiceList;
|
return invoiceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if last dbtr number is equal then return the current list....
|
// if last dbtr number is equal then return the current list....
|
||||||
if (invoiceList != null && lastDbtrNumber != null && lastDbtrNumber.equals(_dbtrNumber)) {
|
if (invoiceList != null && lastDbtrNumber != null && lastDbtrNumber.equals(_dbtrNumber)) {
|
||||||
return invoiceList;
|
return invoiceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load new invoice list....
|
// load new invoice list....
|
||||||
|
lastDbtrNumber = _dbtrNumber;
|
||||||
|
invoiceList = new ArrayList<ItemCollection>();
|
||||||
|
logger.info("....loading open Invoices for " + _dbtrNumber);
|
||||||
|
|
||||||
lastDbtrNumber = _dbtrNumber;
|
// Aus der dbtrNummer muss das führendde D entfernt werden
|
||||||
invoiceList = new ArrayList<ItemCollection>();
|
// wir speichern dieses zwar im Zahlungseingangs Workflow, aber eine
|
||||||
logger.info("....loading open Invoices for " + _dbtrNumber);
|
// Ausganksrechnung kennt das nicht
|
||||||
|
// Das ganze ist ein übles Relikt aus Cargosoft und kann nicht vermieden werden
|
||||||
|
if (_dbtrNumber.startsWith("D")) {
|
||||||
|
_dbtrNumber = _dbtrNumber.substring(1);
|
||||||
|
}
|
||||||
|
// (type:workitem OR type:workitemarchive)
|
||||||
|
String query = "(type:workitem) AND ($modelversion:rechnungsausgang-*) AND (dbtr.number:" + _dbtrNumber
|
||||||
|
+ ")";
|
||||||
|
|
||||||
// Aus der dbtrNummer muss das führendde D entfernt werden
|
try {
|
||||||
// wir speichern dieses zwar im Zahlungseingangs Workflow, aber eine
|
invoiceList = documentService.find(query, 999, 0, "$created", false);
|
||||||
// Ausganksrechnung kennt das nicht
|
} catch (QueryException e) {
|
||||||
// Das ganze ist ein übles Relikt aus Cargosoft und kann nicht vermieden werden
|
logger.severe("Failed to get op liste:" + e.getMessage());
|
||||||
if (_dbtrNumber.startsWith("D")) {
|
}
|
||||||
_dbtrNumber = _dbtrNumber.substring(1);
|
// wir selektieren hier alle Rechnungen vor, falls der Mahnlauf gerade erstellt
|
||||||
}
|
// wird.
|
||||||
// (type:workitem OR type:workitemarchive)
|
if (workflowController.getWorkitem().getItemValueInteger("$version") == 0
|
||||||
String query = "(type:workitem) AND ($modelversion:rechnungsausgang-*) AND (dbtr.number:" + _dbtrNumber
|
|| (workflowController.getWorkitem().getItemValueInteger("$version") == 1
|
||||||
+ ")";
|
&& workflowController.getWorkitem().getItemValueInteger("$lastevent") == 100)) {
|
||||||
|
List<String> intialSelection = new ArrayList<String>();
|
||||||
|
for (ItemCollection invoice : invoiceList) {
|
||||||
|
intialSelection.add(invoice.getUniqueID());
|
||||||
|
}
|
||||||
|
workflowController.getWorkitem().setItemValue("$workitemref", intialSelection);
|
||||||
|
|
||||||
try {
|
}
|
||||||
invoiceList = documentService.find(query, 999, 0, "$created", false);
|
|
||||||
} catch (QueryException e) {
|
|
||||||
logger.severe("Failed to get op liste:" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// We are no longer in TASK_ERSTELLUNG, so
|
// We are no longer in TASK_ERSTELLUNG, so
|
||||||
// fetch only selected invoices
|
// fetch only selected invoices
|
||||||
invoiceList = new ArrayList<ItemCollection>();
|
invoiceList = new ArrayList<ItemCollection>();
|
||||||
if (!workflowController.getWorkitem().isItemEmpty("$workitemref")) {
|
if (!workflowController.getWorkitem().isItemEmpty("$workitemref")) {
|
||||||
List<String> selection = workflowController.getWorkitem().getItemValue("$workitemref");
|
List<String> selection = workflowController.getWorkitem().getItemValue("$workitemref");
|
||||||
for (String id : selection) {
|
for (String id : selection) {
|
||||||
if (id != null && !id.isEmpty()) {
|
if (id != null && !id.isEmpty()) {
|
||||||
invoiceList.add(documentService.load(id));
|
invoiceList.add(documentService.load(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally we set the 'selection' item depending on the $workitemList
|
// finally we set the 'selection' item depending on the $workitemList
|
||||||
// and the payment amount form the 'payment.details'
|
// and the payment amount form the 'payment.details'
|
||||||
List<String> selection = workflowController.getWorkitem().getItemValue("$workitemref");
|
List<String> selection = workflowController.getWorkitem().getItemValue("$workitemref");
|
||||||
List<ItemCollection> paymentList = zahlungseingangService.loadPaymentDetails(workflowController.getWorkitem());
|
List<ItemCollection> paymentList = zahlungseingangService.loadPaymentDetails(workflowController.getWorkitem());
|
||||||
for (ItemCollection invoice : invoiceList) {
|
for (ItemCollection invoice : invoiceList) {
|
||||||
if (selection.contains(invoice.getUniqueID())) {
|
if (selection.contains(invoice.getUniqueID())) {
|
||||||
invoice.setItemValue("selected", true);
|
invoice.setItemValue("selected", true);
|
||||||
// set amount
|
// set amount
|
||||||
for (ItemCollection payment : paymentList) {
|
for (ItemCollection payment : paymentList) {
|
||||||
if (invoice.getUniqueID().equals(payment.getUniqueID())) {
|
if (invoice.getUniqueID().equals(payment.getUniqueID())) {
|
||||||
invoice.setItemValue("payment.amount", payment.getItemValue("payment.amount"));
|
invoice.setItemValue("payment.amount", payment.getItemValue("payment.amount"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return invoiceList;
|
return invoiceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Liefert die Payments die mit diesem workitem verbunden sind...
|
// * Liefert die Payments die mit diesem workitem verbunden sind...
|
||||||
|
|
@ -170,125 +183,125 @@ public class OPListController implements Serializable {
|
||||||
// return result;
|
// return result;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Before Process we store the selected invoices in $worktiemRef
|
* On Before Process we store the selected invoices in $worktiemRef
|
||||||
*
|
*
|
||||||
* @param workflowEvent
|
* @param workflowEvent
|
||||||
*/
|
*/
|
||||||
public void onWorkflowEvent(@Observes WorkflowEvent workflowEvent) {
|
public void onWorkflowEvent(@Observes WorkflowEvent workflowEvent) {
|
||||||
if (workflowEvent == null || workflowEvent.getWorkitem() == null) {
|
if (workflowEvent == null || workflowEvent.getWorkitem() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// store a collection of child items if you are in a Zahlungseingang
|
// store a collection of child items if you are in a Zahlungseingang
|
||||||
if (workflowEvent.getWorkitem().getModelVersion().startsWith("zahlungseingang")
|
if (workflowEvent.getWorkitem().getModelVersion().startsWith("zahlungseingang")
|
||||||
&& workflowEvent.getEventType() == WorkflowEvent.WORKITEM_BEFORE_PROCESS) {
|
&& workflowEvent.getEventType() == WorkflowEvent.WORKITEM_BEFORE_PROCESS) {
|
||||||
updateChildList(workflowEvent.getWorkitem());
|
updateChildList(workflowEvent.getWorkitem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemCollection loadInvoice(String id) {
|
public ItemCollection loadInvoice(String id) {
|
||||||
return documentService.load(id);
|
return documentService.load(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese Methode aktualisiert das item ChildWOrkitems mit allen selektierten
|
* Diese Methode aktualisiert das item ChildWOrkitems mit allen selektierten
|
||||||
* Invoices udn berechnet den payment total
|
* Invoices udn berechnet den payment total
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public void updateChildList(ItemCollection workitem) {
|
public void updateChildList(ItemCollection workitem) {
|
||||||
double paymentTotal = 0;
|
double paymentTotal = 0;
|
||||||
List<Map> mapInvoiceItems = new ArrayList<Map>();
|
List<Map> mapInvoiceItems = new ArrayList<Map>();
|
||||||
// convert the child ItemCollection elements into a List of Map
|
// convert the child ItemCollection elements into a List of Map
|
||||||
logger.info("Convert child items into Map...");
|
logger.info("Convert child items into Map...");
|
||||||
// iterate over all order items..
|
// iterate over all order items..
|
||||||
List<String> selectionList = new ArrayList<String>();
|
List<String> selectionList = new ArrayList<String>();
|
||||||
for (ItemCollection invoice : invoiceList) {
|
for (ItemCollection invoice : invoiceList) {
|
||||||
if (invoice.getItemValueBoolean("selected")) {
|
if (invoice.getItemValueBoolean("selected")) {
|
||||||
logger.info("calculate - " + invoice.getUniqueID());
|
logger.info("calculate - " + invoice.getUniqueID());
|
||||||
selectionList.add(invoice.getUniqueID());
|
selectionList.add(invoice.getUniqueID());
|
||||||
paymentTotal = paymentTotal + invoice.getItemValueDouble("payment.amount");
|
paymentTotal = paymentTotal + invoice.getItemValueDouble("payment.amount");
|
||||||
ItemCollection invoiceStub = new ItemCollection();
|
ItemCollection invoiceStub = new ItemCollection();
|
||||||
invoiceStub.setItemValue(WorkflowKernel.UNIQUEID, invoice.getUniqueID());
|
invoiceStub.setItemValue(WorkflowKernel.UNIQUEID, invoice.getUniqueID());
|
||||||
invoiceStub.setItemValue("payment.amount", invoice.getItemValue("payment.amount"));
|
invoiceStub.setItemValue("payment.amount", invoice.getItemValue("payment.amount"));
|
||||||
mapInvoiceItems.add(invoiceStub.getAllItems());
|
mapInvoiceItems.add(invoiceStub.getAllItems());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rond with 2 digits
|
// rond with 2 digits
|
||||||
workitem.replaceItemValue("payment.total", Math.round(paymentTotal * 100.0) / 100.0);
|
workitem.replaceItemValue("payment.total", Math.round(paymentTotal * 100.0) / 100.0);
|
||||||
// update childitems
|
// update childitems
|
||||||
workitem.replaceItemValue(ZahlungseingangService.ITEM_PAYMENT_DETAILS, mapInvoiceItems);
|
workitem.replaceItemValue(ZahlungseingangService.ITEM_PAYMENT_DETAILS, mapInvoiceItems);
|
||||||
// Update $workitemref
|
// Update $workitemref
|
||||||
workitem.setItemValue("$workitemref", selectionList);
|
workitem.setItemValue("$workitemref", selectionList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This JSF backing method is called by cargosft-debitor-serach.xhtml after the
|
* This JSF backing method is called by cargosft-debitor-serach.xhtml after the
|
||||||
* user has selected a new debitor.
|
* user has selected a new debitor.
|
||||||
* <p>
|
* <p>
|
||||||
* The new dbtrNumber is slected form the curren ajax request param 'dbtrNumber'
|
* The new dbtrNumber is slected form the curren ajax request param 'dbtrNumber'
|
||||||
* <p>
|
* <p>
|
||||||
* The method just updates the dbtr.number of the current workitem. The form
|
* The method just updates the dbtr.number of the current workitem. The form
|
||||||
* will than rerender the opList section.
|
* will than rerender the opList section.
|
||||||
*/
|
*/
|
||||||
public void updateDbtrNumber() {
|
public void updateDbtrNumber() {
|
||||||
FacesContext fc = FacesContext.getCurrentInstance();
|
FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
String dbtrNumber = fc.getExternalContext().getRequestParameterMap().get("dbtrNumber");
|
String dbtrNumber = fc.getExternalContext().getRequestParameterMap().get("dbtrNumber");
|
||||||
logger.fine(".........dbtrNumber = " + dbtrNumber);
|
logger.fine(".........dbtrNumber = " + dbtrNumber);
|
||||||
workflowController.getWorkitem().setItemValue("dbtr.number", dbtrNumber);
|
workflowController.getWorkitem().setItemValue("dbtr.number", dbtrNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hilfsmethode delegates to ZahlungseingangServcie
|
* Hilfsmethode delegates to ZahlungseingangServcie
|
||||||
*
|
*
|
||||||
* @param payment
|
* @param payment
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<ItemCollection> loadPaymentDetails(ItemCollection payment) {
|
public List<ItemCollection> loadPaymentDetails(ItemCollection payment) {
|
||||||
return zahlungseingangService.loadPaymentDetails(payment);
|
return zahlungseingangService.loadPaymentDetails(payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Berechnet den gesammten OP Saldo
|
* Berechnet den gesammten OP Saldo
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double calculateInvoiceTotal() {
|
public double calculateInvoiceTotal() {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (ItemCollection invoice : invoiceList) {
|
for (ItemCollection invoice : invoiceList) {
|
||||||
result = result + invoice.getItemValueDouble("invoice.total");
|
result = result + invoice.getItemValueDouble("invoice.total");
|
||||||
}
|
}
|
||||||
// rond with 2 digits
|
// rond with 2 digits
|
||||||
return Math.round(result * 100.0) / 100.0;
|
return Math.round(result * 100.0) / 100.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Berechnet den gesammten OP Saldo
|
* Berechnet den gesammten OP Saldo
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double calculateInvoiceSaldo() {
|
public double calculateInvoiceSaldo() {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
for (ItemCollection invoice : invoiceList) {
|
for (ItemCollection invoice : invoiceList) {
|
||||||
result = result + invoice.getItemValueDouble("invoice.saldo");
|
result = result + invoice.getItemValueDouble("invoice.saldo");
|
||||||
}
|
}
|
||||||
// rond with 2 digits
|
// rond with 2 digits
|
||||||
return Math.round(result * 100.0) / 100.0;
|
return Math.round(result * 100.0) / 100.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the reminder date is today or in the past
|
||||||
|
*
|
||||||
|
* @param uniqueid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isInDue(String uniqueid) {
|
||||||
|
ItemCollection invoice = workflowService.getWorkItem(uniqueid);
|
||||||
|
LocalDate date = invoice.getItemValueLocalDate("invoice.reminder");
|
||||||
|
return date.compareTo(LocalDate.now()) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the reminder date is today or in the past
|
|
||||||
* @param uniqueid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isInDue(String uniqueid) {
|
|
||||||
ItemCollection invoice=workflowService.getWorkItem(uniqueid);
|
|
||||||
LocalDate date = invoice.getItemValueLocalDate("invoice.reminder");
|
|
||||||
return date.compareTo(LocalDate.now())<=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ th { font-weight: bold;}
|
||||||
<imixs:value><![CDATA[]]></imixs:value>
|
<imixs:value><![CDATA[]]></imixs:value>
|
||||||
</imixs:item>
|
</imixs:item>
|
||||||
<imixs:item name="txtactivityresult" type="xs:string">
|
<imixs:item name="txtactivityresult" type="xs:string">
|
||||||
<imixs:value><![CDATA[<item name="comment" ignore="true"/>]]></imixs:value>
|
<imixs:value><![CDATA[]]></imixs:value>
|
||||||
</imixs:item>
|
</imixs:item>
|
||||||
<imixs:item name="txtname" type="xs:string">
|
<imixs:item name="txtname" type="xs:string">
|
||||||
<imixs:value><![CDATA[Speichern]]></imixs:value>
|
<imixs:value><![CDATA[Speichern]]></imixs:value>
|
||||||
|
|
@ -291,7 +291,7 @@ th { font-weight: bold;}
|
||||||
<imixs:value><![CDATA[0]]></imixs:value>
|
<imixs:value><![CDATA[0]]></imixs:value>
|
||||||
</imixs:item>
|
</imixs:item>
|
||||||
<imixs:item name="rtfresultlog" type="xs:string">
|
<imixs:item name="rtfresultlog" type="xs:string">
|
||||||
<imixs:value><![CDATA[]]></imixs:value>
|
<imixs:value><![CDATA[Mahnlauf aktualisiert.]]></imixs:value>
|
||||||
</imixs:item>
|
</imixs:item>
|
||||||
<imixs:item name="keyupdateacl" type="xs:boolean">
|
<imixs:item name="keyupdateacl" type="xs:boolean">
|
||||||
<imixs:value>false</imixs:value>
|
<imixs:value>false</imixs:value>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue