svn commit: r560517 - in /ofbiz/trunk/applications: accounting/src/org/ofbiz/accounting/invoice/ accounting/webapp/accounting/invoice/ accounting/widget/ order/src/org/ofbiz/order/shoppingcart/

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

svn commit: r560517 - in /ofbiz/trunk/applications: accounting/src/org/ofbiz/accounting/invoice/ accounting/webapp/accounting/invoice/ accounting/widget/ order/src/org/ofbiz/order/shoppingcart/

jacopoc
Author: jacopoc
Date: Sat Jul 28 01:03:38 2007
New Revision: 560517

URL: http://svn.apache.org/viewvc?view=rev&rev=560517
Log:
Billing account terms are now copied as order terms when the order is created; before this change the terms were copied as invoice terms when the invoice was created: this doesn't happen now, however the invoice terms are inherited from the order terms (including billing account terms).
Also added the list of invoce terms in the invoice overview screen.
OFBIZ-1167

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
    ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml
    ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?view=diff&rev=560517&r1=560516&r2=560517
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Sat Jul 28 01:03:38 2007
@@ -276,8 +276,8 @@
                 }
             }
 
-            // order terms to invoice terms.  Implemented for purchase orders, although it may be useful
-            // for sales orders as well.  Later it might be nice to filter OrderTerms to only copy over financial terms.
+            // order terms to invoice terms.
+            // TODO: it might be nice to filter OrderTerms to only copy over financial terms.
             List orderTerms = orh.getOrderTerms();
             createInvoiceTerms(delegator, dispatcher, invoiceId, orderTerms, userLogin, locale);
 
@@ -285,12 +285,15 @@
             List billingAccountTerms = null;
             // for billing accounts we will use related information
             if (billingAccount != null) {
+                /*
+                 * jacopoc: billing account terms were already copied as order terms
+                 *          when the order was created.
                 // get the billing account terms
                 billingAccountTerms = billingAccount.getRelated("BillingAccountTerm");
 
                 // set the invoice terms as defined for the billing account
                 createInvoiceTerms(delegator, dispatcher, invoiceId, billingAccountTerms, userLogin, locale);
-
+                */
                 // set the invoice bill_to_customer from the billing account
                 List billToRoles = billingAccount.getRelated("BillingAccountRole", UtilMisc.toMap("roleTypeId", "BILL_TO_CUSTOMER"), null);
                 Iterator billToIter = billToRoles.iterator();

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=560517&r1=560516&r2=560517
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml Sat Jul 28 01:03:38 2007
@@ -338,7 +338,16 @@
         <field name="statusDate"><display description="${bsh:statusDate.toString().substring(0,10)}"/></field>
         <field name="statusId"><display-entity entity-name="StatusItem" description="${description}"/></field>
     </form>
-    
+
+    <form name="ListInvoiceTerms" list-name="invoiceTerms" target="" title="" type="list">
+        <auto-fields-entity entity-name="InvoiceTerm" default-field-type="display"/>
+        <field name="invoiceId"><hidden/></field>
+        <field name="invoiceTermId"><hidden/></field>
+        <field name="termTypeId">
+            <display-entity entity-name="TermType"/>
+        </field>
+    </form>
+
     <form name="EditInvoiceApplications" type="list"  list-name="invoiceApplications" default-entity-name="invoiceItem" use-row-submit="true" target="updateInvoiceApplication" title="Apply payments to invoices" separate-columns="false">
         <field name="statusId"><hidden/></field>
         <field name="paymentApplicationId"><hidden/></field>

Modified: ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml?view=diff&rev=560517&r1=560516&r2=560517
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml Sat Jul 28 01:03:38 2007
@@ -108,6 +108,10 @@
                     <field-map env-name="parameters.invoiceId" field-name="invoiceId"/>
                     <order-by field-name="statusDate"/>
                 </entity-and>
+                <entity-and entity-name="InvoiceTerm" list-name="invoiceTerms">
+                    <field-map env-name="parameters.invoiceId" field-name="invoiceId"/>
+                    <order-by field-name="invoiceTermId"/>
+                </entity-and>
                 <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/createApplicationList.bsh"/>
                 <entity-and entity-name="InvoiceItem" list-name="invoiceItems">
                     <field-map field-name="invoiceId" value="${parameters.invoiceId}"/>
@@ -134,6 +138,8 @@
                                 <include-form name="invoiceRoles" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
                                 <container><label style="head1" text="${uiLabelMap.AccountingInvoiceStatus}"/></container>
                                 <include-form name="ListInvoiceStatus" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
+                                <container><label style="head1" text="${uiLabelMap.PartyTerms}"/></container>
+                                <include-form name="ListInvoiceTerms" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
                                 <container><label style="head1" text="${uiLabelMap.AccountingAppliedPayments}: ${appliedAmount?currency(${invoice.currencyUomId})}, ${uiLabelMap.AccountingOpenPayments}: ${notAppliedAmount?currency(${invoice.currencyUomId})}"/></container>
                                 <container><link target="editInvoiceApplications?invoiceId=${invoiceId}" text="${uiLabelMap.CommonUpdate}" style="buttontext"/></container>
                                 <include-form name="ListInvoiceApplications" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
@@ -149,6 +155,8 @@
                                 <include-form name="invoiceRoles" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
                                 <container><label style="head1" text="${uiLabelMap.AccountingInvoiceStatus}"/></container>
                                 <include-form name="ListInvoiceStatus" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
+                                <container><label style="head1" text="${uiLabelMap.PartyTerms}"/></container>
+                                <include-form name="ListInvoiceTerms" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
                                 <container><label style="head1" text="${uiLabelMap.AccountingAppliedPayments}: ${appliedAmount?currency(${invoice.currencyUomId})}, ${uiLabelMap.AccountingOpenPayments}: ${notAppliedAmount?currency(${invoice.currencyUomId})}"/></container>
                                 <include-form name="ListInvoiceApplications" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
                                 <container><label style="head1" text="${uiLabelMap.AccountingInvoiceItems}"/></container>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?view=diff&rev=560517&r1=560516&r2=560517
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Sat Jul 28 01:03:38 2007
@@ -243,6 +243,22 @@
                 Double billingAccountAmt = (Double)selectedPaymentMethods.get("EXT_BILLACT");
                 // set cart billing account data and generate a payment method containing the amount we will be charging
                 cart.setBillingAccount(billingAccountId, (billingAccountAmt != null? billingAccountAmt.doubleValue(): 0.0));
+                // copy the billing account terms as order terms
+                try {
+                    List billingAccountTerms = delegator.findByAnd("BillingAccountTerm", UtilMisc.toMap("billingAccountId", billingAccountId));
+                    if (UtilValidate.isNotEmpty(billingAccountTerms)) {
+                        Iterator billingAccountTermsIt = billingAccountTerms.iterator();
+                        while (billingAccountTermsIt.hasNext()) {
+                            GenericValue billingAccountTerm = (GenericValue)billingAccountTermsIt.next();
+                            // the term is not copied if in the cart a term of the same type is already set
+                            if (!cart.hasOrderTerm(billingAccountTerm.getString("termTypeId"))) {
+                                cart.addOrderTerm(billingAccountTerm.getString("termTypeId"), billingAccountTerm.getDouble("termValue"), billingAccountTerm.getLong("termDays"));
+                            }
+                        }
+                    }
+                } catch(GenericEntityException gee) {
+                    Debug.logWarning("Error copying billing account terms to order terms: " + gee.getMessage(), module);
+                }
             } else {
                 // remove the billing account from the cart
                 cart.setBillingAccount(null, 0.0);

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=560517&r1=560516&r2=560517
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Sat Jul 28 01:03:38 2007
@@ -2583,6 +2583,20 @@
          this.orderTermSet = orderTermSet;
      }
 
+    public boolean hasOrderTerm(String termTypeId) {
+        if (termTypeId == null) {
+            return false;
+        }
+        Iterator orderTermsIt = orderTerms.iterator();
+        while (orderTermsIt.hasNext()) {
+            GenericValue orderTerm = (GenericValue)orderTermsIt.next();
+            if (termTypeId.equals(orderTerm.getString("termTypeId"))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public boolean isReadOnlyCart(){
        return readOnlyCart;
     }