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