Fixes bug 7621: Currency selector on Price list window should show full currencies name, not only ISO code
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Thu, 17 Nov 2011 17:10:43 +0100
changeset 14282 94ab187db02a
parent 14281 a86c37b5f7b0
child 14283 cf9c0c12d20a
Fixes bug 7621: Currency selector on Price list window should show full currencies name, not only ISO code
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java
src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.java
src/org/openbravo/erpCommon/ad_forms/MonedaCombo_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java	Thu Nov 17 16:33:26 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java	Thu Nov 17 17:10:43 2011 +0100
@@ -51,6 +51,7 @@
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment_Credit;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
 
 public class DocFINFinAccTransaction extends AcctServer {
@@ -456,18 +457,33 @@
       }
       // Pre-payment is consumed when Used Credit Amount not equals Zero. When consuming Credit no
       // credit is generated
-      // FIXME: WHEN RELATION BETWEEN GENERATION OF CREDIT AND CONSUMPTION IS CREATED IN DATABASE
-      // THEN I CAN CONVERT TO CALCULATE DIFFERENCES
       if (transaction.getFinPayment().getUsedCredit().compareTo(ZERO) != 0
           && transaction.getFinPayment().getGeneratedCredit().compareTo(ZERO) == 0) {
-        fact.createLine(
-            null,
-            getAccountBPartner(C_BPartner_ID, as, transaction.getFinPayment().isReceipt(), true,
-                conn), paymentCurrency.getId(),
-            (transaction.getFinPayment().isReceipt() ? transaction.getFinPayment().getUsedCredit()
-                .toString() : ""), (transaction.getFinPayment().isReceipt() ? "" : transaction
-                .getFinPayment().getUsedCredit().toString()), Fact_Acct_Group_ID, nextSeqNo(SeqNo),
-            DocumentType, conn);
+        List<FIN_Payment_Credit> creditPayments = transaction.getFinPayment()
+            .getFINPaymentCreditList();
+        for (FIN_Payment_Credit creditPayment : creditPayments) {
+          boolean isReceiptPayment = creditPayment.getCreditPaymentUsed().isReceipt();
+          String creditAmountConverted = convertAmount(creditPayment.getAmount(), isReceiptPayment,
+              DateAcct, TABLEID_Payment, creditPayment.getCreditPaymentUsed().getId(),
+              creditPayment.getCreditPaymentUsed().getCurrency().getId(), as.m_C_Currency_ID, null,
+              as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString();
+          fact.createLine(null,
+              getAccountBPartner(C_BPartner_ID, as, isReceiptPayment, true, conn), creditPayment
+                  .getCreditPaymentUsed().getCurrency().getId(),
+              (isReceiptPayment ? creditAmountConverted : ""), (isReceiptPayment ? ""
+                  : creditAmountConverted), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,
+              conn);
+        }
+        if (creditPayments.isEmpty()) {
+          fact.createLine(
+              null,
+              getAccountBPartner(C_BPartner_ID, as, transaction.getFinPayment().isReceipt(), true,
+                  conn), paymentCurrency.getId(),
+              (transaction.getFinPayment().isReceipt() ? transaction.getFinPayment()
+                  .getUsedCredit().toString() : ""), (transaction.getFinPayment().isReceipt() ? ""
+                  : transaction.getFinPayment().getUsedCredit().toString()), Fact_Acct_Group_ID,
+              nextSeqNo(SeqNo), DocumentType, conn);
+        }
       }
     } else {
       BigDecimal convertedAmount = convertAmount(transaction.getFinPayment().getAmount(),
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Thu Nov 17 16:33:26 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Thu Nov 17 17:10:43 2011 +0100
@@ -48,6 +48,7 @@
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment_Credit;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
 
 public class DocFINPayment extends AcctServer {
@@ -324,12 +325,28 @@
       // credit is generated
       if (new BigDecimal(usedAmount).compareTo(ZERO) != 0
           && new BigDecimal(generatedAmount).compareTo(ZERO) == 0) {
-        // FIXME: WHEN RELATION BETWEEN GENERATION OF CREDIT AND CONSUMPTION IS CREATED IN DATABASE
-        // THEN I CAN CONVERT TO CALCULATE DIFFERENCES
-        fact.createLine(null,
-            getAccountBPartner(C_BPartner_ID, as, payment.isReceipt(), true, conn), C_Currency_ID,
-            (payment.isReceipt() ? usedAmount : ""), (payment.isReceipt() ? "" : usedAmount),
-            Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+        List<FIN_Payment_Credit> creditPayments = payment.getFINPaymentCreditList();
+        for (FIN_Payment_Credit creditPayment : creditPayments) {
+          String creditAmountConverted = convertAmount(creditPayment.getAmount(),
+              creditPayment.getCreditPaymentUsed().isReceipt(), DateAcct, TABLEID_Payment,
+              creditPayment.getCreditPaymentUsed().getId(),
+              creditPayment.getCreditPaymentUsed().getCurrency().getId(), as.m_C_Currency_ID, null,
+              as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString();
+          fact.createLine(
+              null,
+              getAccountBPartner(C_BPartner_ID, as, creditPayment.getCreditPaymentUsed()
+                  .isReceipt(), true, conn), creditPayment.getCreditPaymentUsed().getCurrency()
+                  .getId(),
+              (creditPayment.getCreditPaymentUsed().isReceipt() ? creditAmountConverted : ""),
+              (creditPayment.getCreditPaymentUsed().isReceipt() ? "" : creditAmountConverted),
+              Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+        }
+        if (creditPayments.isEmpty()) {
+          fact.createLine(null,
+              getAccountBPartner(C_BPartner_ID, as, payment.isReceipt(), true, conn),
+              C_Currency_ID, (payment.isReceipt() ? usedAmount : ""), (payment.isReceipt() ? ""
+                  : usedAmount), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+        }
       }
     } finally {
       OBContext.restorePreviousMode();
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java	Thu Nov 17 16:33:26 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java	Thu Nov 17 17:10:43 2011 +0100
@@ -58,6 +58,7 @@
 import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment_Credit;
 import org.openbravo.model.financialmgmt.payment.FIN_Reconciliation;
 import org.openbravo.model.financialmgmt.payment.FIN_ReconciliationLine_v;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
@@ -615,17 +616,33 @@
         && !getDocumentTransactionConfirmation(transaction)) {
       // Pre-payment is consumed when Used Credit Amount not equals Zero. When consuming Credit no
       // credit is generated
-      // FIXME: WHEN RELATION BETWEEN GENERATION OF CREDIT AND CONSUMPTION IS CREATED IN DATABASE
-      // THEN I CAN CONVERT TO CALCULATE DIFFERENCES
       if (payment.getUsedCredit().compareTo(ZERO) != 0
           && payment.getGeneratedCredit().compareTo(ZERO) == 0) {
-        fact.createLine(
-            line,
-            getAccountBPartner(payment.getBusinessPartner().getId(), as, payment.isReceipt(), true,
-                conn), payment.getCurrency().getId(), (payment.isReceipt() ? payment
-                .getUsedCredit().toString() : ""), (payment.isReceipt() ? "" : payment
-                .getUsedCredit().toString()), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,
-            conn);
+        List<FIN_Payment_Credit> creditPayments = transaction.getFinPayment()
+            .getFINPaymentCreditList();
+        for (FIN_Payment_Credit creditPayment : creditPayments) {
+          boolean isReceiptPayment = creditPayment.getCreditPaymentUsed().isReceipt();
+          String creditAmountConverted = convertAmount(creditPayment.getAmount(), isReceiptPayment,
+              DateAcct, TABLEID_Payment, creditPayment.getCreditPaymentUsed().getId(),
+              creditPayment.getCreditPaymentUsed().getCurrency().getId(), as.m_C_Currency_ID, line,
+              as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString();
+          fact.createLine(
+              line,
+              getAccountBPartner(creditPayment.getCreditPaymentUsed().getBusinessPartner().getId(),
+                  as, isReceiptPayment, true, conn), creditPayment.getCreditPaymentUsed()
+                  .getCurrency().getId(), (isReceiptPayment ? creditAmountConverted : ""),
+              (isReceiptPayment ? "" : creditAmountConverted), Fact_Acct_Group_ID,
+              nextSeqNo(SeqNo), DocumentType, conn);
+        }
+        if (creditPayments.isEmpty()) {
+          fact.createLine(
+              line,
+              getAccountBPartner(payment.getBusinessPartner().getId(), as, payment.isReceipt(),
+                  true, conn), payment.getCurrency().getId(), (payment.isReceipt() ? payment
+                  .getUsedCredit().toString() : ""), (payment.isReceipt() ? "" : payment
+                  .getUsedCredit().toString()), Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType,
+              conn);
+        }
       }
     }
 
--- a/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java	Thu Nov 17 16:33:26 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java	Thu Nov 17 17:10:43 2011 +0100
@@ -103,7 +103,7 @@
     xmlDocument.setParameter("moduleTree", tree.toHtml());
     xmlDocument.setParameter("moduleTreeDescription", tree.descriptionToHtml());
 
-    xmlDocument.setData("reportCurrency", "liststructure", MonedaComboData.select(this));
+    xmlDocument.setData("reportCurrency", "liststructure", MonedaComboData.selectISO(this));
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
     out.println(xmlDocument.print());
--- a/src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.java	Thu Nov 17 16:33:26 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.java	Thu Nov 17 17:10:43 2011 +0100
@@ -134,7 +134,7 @@
 
       xmlDocument.setParameter("paramLocationId", "");
       xmlDocument.setParameter("paramLocationDescription", "");
-      xmlDocument.setData("reportCurrency", "liststructure", MonedaComboData.select(this));
+      xmlDocument.setData("reportCurrency", "liststructure", MonedaComboData.selectISO(this));
       xmlDocument.setData("reportOrgType", "liststructure",
           InitialOrgSetupData.selectOrgType(this, vars.getLanguage(), vars.getClient()));
       xmlDocument.setData("reportParentOrg", "liststructure",
--- a/src/org/openbravo/erpCommon/ad_forms/MonedaCombo_data.xsql	Thu Nov 17 16:33:26 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/MonedaCombo_data.xsql	Thu Nov 17 17:10:43 2011 +0100
@@ -31,4 +31,11 @@
       FROM C_Currency ORDER BY 2
       </Sql>
    </SqlMethod>
+   <SqlMethod name="selectISO" type="preparedStatement" return="multiple">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql>
+      SELECT C_Currency_ID as id, iso_code as name
+      FROM C_Currency ORDER BY 2
+      </Sql>
+   </SqlMethod>
 </SqlClass>