details: https://code.openbravo.com/erp/devel/pi/rev/31716d369708
changeset: 17760:31716d369708
user: David Miguelez <david.miguelez <at> openbravo.com>
date: Fri Aug 24 13:46:23 2012 +0200
summary: Related to issue 21250: Added a process completed successfully
message
diffstat:
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentProposalPickEditLines.java
| 23 ++++++---
1 files changed, 15 insertions(+), 8 deletions(-)
diffs (90 lines):
diff -r ef3ac0e76b03 -r 31716d369708
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentProposalPickEditLines.java
---
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentProposalPickEditLines.java
Wed Aug 22 15:12:15 2012 +0200
+++
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentProposalPickEditLines.java
Fri Aug 24 13:46:23 2012 +0200
@@ -33,11 +33,10 @@
import org.openbravo.client.kernel.RequestContext;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBDal;
-import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentPropDetail;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentProposal;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail;
-import org.openbravo.service.db.DalConnectionProvider;
public class PaymentProposalPickEditLines extends BaseProcessActionHandler {
private static Logger log =
Logger.getLogger(PaymentProposalPickEditLines.class);
@@ -46,6 +45,7 @@
protected JSONObject doExecute(Map<String, Object> parameters, String
content) {
JSONObject jsonRequest = null;
OBContext.setAdminMode();
+ VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
try {
jsonRequest = new JSONObject(content);
log.debug(jsonRequest);
@@ -59,12 +59,17 @@
strPaymentProposalId);
if (cleanPaymentProposalDetails(paymentProposal)) {
- createPaymentProposalDetails(jsonRequest);
+ int cont = createPaymentProposalDetails(jsonRequest);
+ jsonRequest = new JSONObject();
+
+ JSONObject errorMessage = new JSONObject();
+ errorMessage.put("severity", "success");
+ errorMessage.put("text", OBMessageUtils.messageBD("Success"));
+ jsonRequest.put("message", errorMessage);
}
} catch (Exception e) {
OBDal.getInstance().rollbackAndClose();
- VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
log.error(e.getMessage(), e);
try {
@@ -72,8 +77,7 @@
JSONObject errorMessage = new JSONObject();
errorMessage.put("severity", "error");
- errorMessage.put("text",
- Utility.messageBD(new DalConnectionProvider(), e.getMessage(),
vars.getLanguage()));
+ errorMessage.put("text", OBMessageUtils.messageBD(e.getMessage()));
jsonRequest.put("message", errorMessage);
} catch (Exception e2) {
@@ -106,18 +110,19 @@
return true;
}
- private void createPaymentProposalDetails(JSONObject jsonRequest) throws
JSONException,
+ private int createPaymentProposalDetails(JSONObject jsonRequest) throws
JSONException,
OBException {
JSONArray selectedLines = jsonRequest.getJSONArray("_selection");
// if no lines selected don't do anything.
if (selectedLines.length() == 0) {
- return;
+ return 0;
}
final String strPaymentProposalId =
jsonRequest.getString("Fin_Payment_Proposal_ID");
FIN_PaymentProposal paymentProposal =
OBDal.getInstance().get(FIN_PaymentProposal.class,
strPaymentProposalId);
BigDecimal totalAmount = BigDecimal.ZERO, totalWriteOff = BigDecimal.ZERO;
+ int cont = 0;
for (int i = 0; i < selectedLines.length(); i++) {
JSONObject selectedLine = selectedLines.getJSONObject((int) i);
log.debug(selectedLine);
@@ -144,11 +149,13 @@
OBDal.getInstance().save(newPPD);
OBDal.getInstance().save(paymentProposal);
OBDal.getInstance().flush();
+ cont++;
}
}
paymentProposal.setAmount(totalAmount);
paymentProposal.setWriteoffAmount(totalWriteOff);
OBDal.getInstance().save(paymentProposal);
+ return cont;
}
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits