svn commit: r548227 - in /ofbiz/trunk/applications/accounting: config/ script/org/ofbiz/accounting/invoice/ servicedef/ webapp/accounting/WEB-INF/actions/invoice/ webapp/accounting/invoice/ widget/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r548227 - in /ofbiz/trunk/applications/accounting: config/ script/org/ofbiz/accounting/invoice/ servicedef/ webapp/accounting/WEB-INF/actions/invoice/ webapp/accounting/invoice/ widget/

hansbak-2
Author: hansbak
Date: Sun Jun 17 23:07:27 2007
New Revision: 548227

URL: http://svn.apache.org/viewvc?view=rev&rev=548227
Log:
now an invoice can be shown and send per email in the customer currency, need however the preferred currency in the party entity and appropriate values in uomConversionBydate entity

Modified:
    ofbiz/trunk/applications/accounting/config/AccountingUiLabels.properties
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/editInvoice.bsh
    ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml
    ofbiz/trunk/applications/accounting/widget/Menus.xml

Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.properties?view=diff&rev=548227&r1=548226&r2=548227
==============================================================================
--- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.properties (original)
+++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.properties Sun Jun 17 23:07:27 2007
@@ -225,6 +225,7 @@
 AccountingInvoicePayments=Payments
 AccountingInvoicePurchase=Purchase Invoice
 AccountingInvoicePDF=PDF
+AccountingInvoicePDFOtherCur=PDF other Currency
 AccountingInvoiceRoles=Roles
 AccountingInvoiceSales=Sales Invoice
 AccountingInvoiceStatus=Status

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml?view=diff&rev=548227&r1=548226&r2=548227
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml Sun Jun 17 23:07:27 2007
@@ -247,6 +247,7 @@
         <set field="emailParams.xslfoAttachScreenLocation" value="component://accounting/widget/AccountingPrintForms.xml#InvoicePDF"/>
         <set field="emailParams.bodyParameters.invoiceId" from-field="parameters.invoiceId"/>
         <set field="emailParams.bodyParameters.userLogin" from-field="parameters.userLogin"/>
+        <set field="emailParams.bodyParameters.other" from-field="parameters.other"/><!-- to to print in 'other currency' -->
         <call-service-asynch service-name="sendMailFromScreen" in-map-name="emailParams"/>
         <property-to-field resource="AccountingUiLabels" property="AccountingEmailScheduledToSend" field-name="successMessage"/>
     </simple-method>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?view=diff&rev=548227&r1=548226&r2=548227
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Sun Jun 17 23:07:27 2007
@@ -229,6 +229,7 @@
         <attribute name="sendCc" type="String" mode="IN" optional="true"/>
         <attribute name="subject" type="String" mode="IN" optional="true"/>
         <attribute name="bodyText" type="String" mode="IN" optional="true"/>
+        <attribute name="other" type="String" mode="IN" optional="true"/><!-- to send the invoice in the 'other' currency (y) -->
     </service>
     <service name="checkInvoicePaymentApplications" engine="java"
             location="org.ofbiz.accounting.invoice.InvoiceServices" invoke="checkInvoicePaymentApplications">

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/editInvoice.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/editInvoice.bsh?view=diff&rev=548227&r1=548226&r2=548227
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/editInvoice.bsh (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/editInvoice.bsh Sun Jun 17 23:07:27 2007
@@ -24,6 +24,10 @@
 import org.ofbiz.accounting.invoice.*;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import org.ofbiz.base.util.UtilNumber;
+import javolution.util.FastList;
+
 
 // delegator = parameters.get("delegator");
 invoiceId = parameters.get("invoiceId");
@@ -31,13 +35,49 @@
 invoice = delegator.findByPrimaryKey("Invoice", UtilMisc.toMap("invoiceId", invoiceId));
 context.put("invoice", invoice);
 
+other = parameters.get("other"); // allow the display of the invoice in the currency of the other party. sales: partyId, purch: partyIdFrom using the convertUom service.
+BigDecimal conversionRate = new BigDecimal("1");
+private static BigDecimal ZERO = new BigDecimal("0");
+private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
+private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+if (other != null && other.equalsIgnoreCase("y")) {
+ otherCurrency = null;
+ if ((invoice.getRelatedOne("InvoiceType")).getString("parentTypeId").equals("SALES_INVOICE"))
+ otherCurrency = invoice.getRelatedOne("Party").getString("preferredCurrencyUomId");
+ else
+ otherCurrency = invoice.getRelatedOne("FromParty").getString("preferredCurrencyUomId");
+
+ result = null;
+ if (otherCurrency != null && invoice.get("currencyUomId") != null && !otherCurrency.equals(invoice.getString("currencyUomId"))) {
+ result = dispatcher.runSync("convertUom", UtilMisc.toMap("uomId", invoice.getString("currencyUomId"), "uomIdTo", otherCurrency, "originalValue", 1.00, "asOfDate", invoice.getTimestamp("invoiceDate")));
+
+ if (result.get("convertedValue") != null) {
+ conversionRate = new BigDecimal(result.get("convertedValue").doubleValue());
+ invoice.put("invoiceMessage",
+ invoice.get("invoiceMessage") != null?
+ invoice.getString("invoiceMessage").concat(" Converted from " + invoice.getString("currencyUomId") + " Rate: " + conversionRate.setScale(6, rounding).toString()) :
+  "Converted from " + invoice.getString("currencyUomId") + " Rate: " + conversionRate.setScale(6, rounding).toString());
+ invoice.put("currencyUomId", otherCurrency);
+ }
+ }
+
+}
+
 if (invoice != null) {
     invoiceItems = invoice.getRelatedOrderBy("InvoiceItem",UtilMisc.toList("invoiceItemSeqId"));
+    invoiceItemsConv = FastList.newInstance();
+    Iterator it = invoiceItems.iterator();
+    while (it.hasNext()) {
+     invoiceItem = it.next();
+     invoiceItem.put("amount", new Double((invoiceItem.getBigDecimal("amount").multiply(conversionRate).setScale(decimals, rounding)).doubleValue()));
+     invoiceItemsConv.add(invoiceItem);
+    }
+    
 
-    context.put("invoiceItems", invoiceItems);
+    context.put("invoiceItems", invoiceItemsConv);
     
-    invoiceTotal = InvoiceWorker.getInvoiceTotal(invoice);
-    invoiceNoTaxTotal = InvoiceWorker.getInvoiceNoTaxTotal(invoice);
+    invoiceTotal = InvoiceWorker.getInvoiceTotalBd(invoice).multiply(conversionRate).setScale(decimals, rounding).doubleValue();
+    invoiceNoTaxTotal = InvoiceWorker.getInvoiceNoTaxTotalBd(invoice).multiply(conversionRate).setScale(decimals, rounding).doubleValue();
     context.put("invoiceTotal", new Double(invoiceTotal));    
     context.put("invoiceNoTaxTotal", new Double(invoiceNoTaxTotal));
     

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml?view=diff&rev=548227&r1=548226&r2=548227
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml Sun Jun 17 23:07:27 2007
@@ -426,6 +426,7 @@
         <field name="emailAddressTo" entry-name="mapFrom.emailAddress" parameter-name="sendTo" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;PURCHASE_INVOICE&quot;)"><text/></field>
         <field name="emailAddressCc" entry-name="ccEmailAddress" parameter-name="sendCc"><text/></field>
         <field name="subject"><text default-value="Please find attached invoice."/></field>
+        <field name="otherCurrency" entry-name="parameters.other" parameter-name="other"><check/></field>
         <field name="bodyText"><textarea/></field>
         <field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>

Modified: ofbiz/trunk/applications/accounting/widget/Menus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/Menus.xml?view=diff&rev=548227&r1=548226&r2=548227
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/Menus.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/Menus.xml Sun Jun 17 23:07:27 2007
@@ -121,7 +121,13 @@
             <condition>
                 <not><if-empty field-name="invoice.invoiceId"/></not>
             </condition>
-            <link target="invoice.pdf?invoiceId=${invoice.invoiceId}"/>
+            <link target="invoice.pdf?invoiceId=${invoice.invoiceId}" target-window="_BLANK"/>
+        </menu-item>
+        <menu-item name="pdfOtherCur" title="${uiLabelMap.AccountingInvoicePDFOtherCur}">
+            <condition>
+                <not><if-empty field-name="invoice.invoiceId"/></not>
+            </condition>
+            <link target="invoice.pdf?invoiceId=${invoice.invoiceId}&amp;other=Y" target-window="_BLANK"/>
         </menu-item>
         <menu-item name="statusToApproved" title="${uiLabelMap.AccountingInvoiceStatusToApproved}">
             <condition>