You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2010/05/05 03:43:45 UTC

svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Author: hansbak
Date: Wed May  5 01:43:45 2010
New Revision: 941132

URL: http://svn.apache.org/viewvc?rev=941132&view=rev
Log:
Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
    ofbiz/trunk/applications/order/servicedef/secas.xml

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
@@ -746,4 +746,72 @@ under the License.
             <clear-field field="setPaymentStatusMap"/>
         </iterate>
     </simple-method>
-</simple-methods>
+
+    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
+        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
+        <entity-and list="orderRoleToList" entity-name="OrderRole">
+            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
+            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
+        </entity-and>
+        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
+        <entity-and list="orderRoleFromList" entity-name="OrderRole">
+            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
+            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
+        </entity-and>
+        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
+        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
+            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
+                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
+                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
+                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
+            </entity-and>
+            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
+            <else>
+               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
+                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
+                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
+                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
+                </entity-and>
+                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
+            </else>
+        </if-compare>
+        <first-from-list entry="agreement" list="agreementList"/>
+        <if-not-empty field="agreement">
+            <entity-and list="orderTermList" entity-name="OrderTerm">
+                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
+                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
+            </entity-and>
+            <first-from-list entry="orderTerm" list="orderTermList"/>
+            <if-not-empty field="orderTerm.termDays">
+                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
+                <now-timestamp field="start"/>
+                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
+                    <field field="start" type="java.sql.Timestamp"/>
+                    <field field="days" type="int"/>
+                </call-class-method>
+            </if-not-empty>
+        </if-not-empty>
+        <if-empty field="parameters.effectiveDate">
+            <now-timestamp field="parameters.effectiveDate"/>
+        </if-empty>
+        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
+        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
+        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
+        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
+        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
+        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
+        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
+        <call-service service-name="createPayment" in-map-name="createPayment">
+            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
+        </call-service>
+        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
+        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
+        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
+        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
+            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
+        </call-service>
+        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
+        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
+        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
+    </simple-method>
+</simple-methods>
\ No newline at end of file

Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
@@ -233,4 +233,11 @@ under the License.
         <attribute name="statusId" type="String" mode="IN" optional="false"/>
         <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
     </service>
+
+    <service name="createPaymentFromOrder" engine="simple"
+        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
+        <description>create Payment from Order</description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
+    </service>
 </services>

Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
@@ -93,6 +93,12 @@ under the License.
         <action service="resetGrandTotal" mode="sync"/>
         <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
     </eca>
+    <eca service="changeOrderStatus" event="commit" run-on-error="false">
+        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
+        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
+        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
+        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
+    </eca>
 
     <!-- DISABLED FOR NOW
     <eca service="changeOrderStatus" event="commit" run-on-error="false">



Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Adrian Crum <ad...@yahoo.com>.
This looks wrong to me too. You don't know what to pay until the order has been received.

-Adrian

--- On Tue, 5/4/10, Scott Gray <sc...@hotwaxmedia.com> wrote:

> From: Scott Gray <sc...@hotwaxmedia.com>
> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml
> To: dev@ofbiz.apache.org
> Date: Tuesday, May 4, 2010, 6:56 PM
> Hi Hans,
> 
> Wouldn't you do this when an order is received (i.e. an
> invoice created) rather than when the order is placed?
> 
> Typically payment due dates are based on the invoice date
> not the order date.
> 
> Regards
> Scott
> 
> HotWax Media
> http://www.hotwaxmedia.com
> 
> On 5/05/2010, at 1:43 PM, hansbak@apache.org
> wrote:
> 
> > Author: hansbak
> > Date: Wed May  5 01:43:45 2010
> > New Revision: 941132
> > 
> > URL: http://svn.apache.org/viewvc?rev=941132&view=rev
> > Log:
> > Create a payment with the status 'not-paid' when a
> purchase order is approved setting the payment date
> according agreements
> > 
> > Modified:
> >   
> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> >   
> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> >   
> ofbiz/trunk/applications/order/servicedef/secas.xml
> > 
> > Modified:
> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
> >
> ==============================================================================
> > ---
> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> (original)
> > +++
> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> Wed May  5 01:43:45 2010
> > @@ -746,4 +746,72 @@ under the License.
> >         
>    <clear-field
> field="setPaymentStatusMap"/>
> >     
>    </iterate>
> >     </simple-method>
> > -</simple-methods>
> > +
> > +    <simple-method
> method-name="createPaymentFromOrder"
> short-description="Service auto create Payment from
> Order">
> > +        <entity-one
> value-field="orderHeader" entity-name="OrderHeader"/>
> > +        <entity-and
> list="orderRoleToList" entity-name="OrderRole">
> > +           
> <field-map field-name="orderId"
> from-field="orderHeader.orderId"/>
> > +           
> <field-map field-name="roleTypeId"
> value="BILL_FROM_VENDOR"/>
> > +        </entity-and>
> > +        <first-from-list
> entry="orderRoleTo" list="orderRoleToList"/>
> > +        <entity-and
> list="orderRoleFromList" entity-name="OrderRole">
> > +           
> <field-map field-name="orderId"
> from-field="orderHeader.orderId"/>
> > +           
> <field-map field-name="roleTypeId"
> value="BILL_TO_CUSTOMER"/>
> > +        </entity-and>
> > +        <first-from-list
> entry="orderRoleFrom" list="orderRoleFromList"/>
> > +        <if-compare
> operator="equals" value="PURCHASE_ORDER"
> field="orderHeader.orderTypeId">
> > +           
> <entity-and list="agreementList" entity-name="Agreement"
> filter-by-date="true">
> > +             
>   <field-map field-name="partyIdFrom"
> from-field="orderRoleFrom.partyId"/>
> > +             
>   <field-map field-name="partyIdTo"
> from-field="orderRoleTo.partyId"/>
> > +             
>   <field-map field-name="agreementTypeId"
> value="PURCHASE_AGREEMENT"/>
> > +           
> </entity-and>
> > +            <set
> field="parameters.paymentTypeId"
> value="VENDOR_PAYMENT"/>
> > +           
> <else>
> > +           
>    <entity-and list="agreementList"
> entity-name="Agreement" filter-by-date="true">
> > +             
>       <field-map field-name="partyIdFrom"
> from-field="orderRoleFrom.partyId"/>
> > +             
>       <field-map field-name="partyIdTo"
> from-field="orderRoleTo.partyId"/>
> > +             
>       <field-map
> field-name="agreementTypeId" value="SALES_AGREEMENT"/>
> > +             
>   </entity-and>
> > +             
>   <set field="parameters.paymentTypeId"
> value="CUSTOMER_PAYMENT"/>
> > +           
> </else>
> > +        </if-compare>
> > +        <first-from-list
> entry="agreement" list="agreementList"/>
> > +        <if-not-empty
> field="agreement">
> > +           
> <entity-and list="orderTermList"
> entity-name="OrderTerm">
> > +             
>   <field-map field-name="orderId"
> from-field="orderHeader.orderId"/>
> > +             
>   <field-map field-name="termTypeId"
> value="FIN_PAYMENT_TERM"/>
> > +           
> </entity-and>
> > +           
> <first-from-list entry="orderTerm"
> list="orderTermList"/>
> > +           
> <if-not-empty field="orderTerm.termDays">
> > +             
>   <set field="days" from-field="orderTerm.termDays"
> type="Integer"/>
> > +             
>   <now-timestamp field="start"/>
> > +             
>   <call-class-method
> class-name="org.ofbiz.base.util.UtilDateTime"
> method-name="addDaysToTimestamp"
> ret-field="parameters.effectiveDate">
> > +             
>       <field field="start"
> type="java.sql.Timestamp"/>
> > +             
>       <field field="days" type="int"/>
> > +             
>   </call-class-method>
> > +           
> </if-not-empty>
> > +        </if-not-empty>
> > +        <if-empty
> field="parameters.effectiveDate">
> > +           
> <now-timestamp field="parameters.effectiveDate"/>
> > +        </if-empty>
> > +        <set
> field="parameters.partyIdFrom"
> from-field="orderRoleFrom.partyId"/>
> > +        <set
> field="parameters.partyIdTo"
> from-field="orderRoleTo.partyId"/>
> > +        <set
> field="parameters.amount"
> from-field="orderHeader.grandTotal"/>
> > +        <set
> field="parameters.currencyUomId"
> from-field="orderHeader.currencyUom"/>
> > +        <set
> field="parameters.paymentMethodTypeId"
> value="COMPANY_ACCOUNT"/>
> > +        <set
> field="parameters.statusId" value="PMNT_NOT_PAID"/>
> > +        <set-service-fields
> service-name="createPayment" to-map="createPayment"
> map="parameters"/>
> > +        <call-service
> service-name="createPayment"
> in-map-name="createPayment">
> > +           
> <result-to-field result-name="paymentId"
> field="parameters.paymentId"/>
> > +        </call-service>
> > +        <set
> field="parameters.orderId"
> from-field="orderHeader.orderId"/>
> > +        <set
> field="parameters.maxAmount"
> from-field="orderHeader.grandTotal"/>
> > +        <set-service-fields
> service-name="createOrderPaymentPreference"
> to-map="newOrderPaymentPreference" map="parameters"/>
> > +        <call-service
> service-name="createOrderPaymentPreference"
> in-map-name="newOrderPaymentPreference">
> > +           
> <result-to-field result-name="orderPaymentPreferenceId"
> field="parameters.paymentPreferenceId"/>
> > +        </call-service>
> > +        <set-service-fields
> service-name="updatePayment" to-map="updatePayment"
> map="parameters"/>
> > +        <call-service
> service-name="updatePayment"
> in-map-name="updatePayment"/>
> > +        <field-to-result
> field="parameters.paymentId" result-name="paymentId"/>
> > +    </simple-method>
> > +</simple-methods>
> > \ No newline at end of file
> > 
> > Modified:
> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
> >
> ==============================================================================
> > ---
> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> (original)
> > +++
> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> Wed May  5 01:43:45 2010
> > @@ -233,4 +233,11 @@ under the License.
> >         <attribute
> name="statusId" type="String" mode="IN"
> optional="false"/>
> >         <attribute
> name="errorMessage" type="String" optional="true"
> mode="OUT"/>
> >     </service>
> > +
> > +    <service
> name="createPaymentFromOrder" engine="simple"
> > +       
> location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml"
> invoke="createPaymentFromOrder" auth="true">
> > +        <description>create
> Payment from Order</description>
> > +        <attribute
> name="orderId" type="String" mode="IN"
> optional="false"/>
> > +        <attribute
> name="paymentId" type="String" mode="OUT"
> optional="false"/>
> > +    </service>
> > </services>
> > 
> > Modified:
> ofbiz/trunk/applications/order/servicedef/secas.xml
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
> >
> ==============================================================================
> > ---
> ofbiz/trunk/applications/order/servicedef/secas.xml
> (original)
> > +++
> ofbiz/trunk/applications/order/servicedef/secas.xml Wed
> May  5 01:43:45 2010
> > @@ -93,6 +93,12 @@ under the License.
> >         <action
> service="resetGrandTotal" mode="sync"/>
> >         <action
> service="sendOrderCompleteNotification" mode="async"
> persist="true"/>
> >     </eca>
> > +    <eca service="changeOrderStatus"
> event="commit" run-on-error="false">
> > +        <condition
> field-name="orderTypeId" operator="equals"
> value="PURCHASE_ORDER"/>
> > +        <condition
> field-name="statusId" operator="equals"
> value="ORDER_APPROVED"/>
> > +        <condition-field
> field-name="statusId" operator="not-equals"
> to-field-name="oldStatusId"/>
> > +        <action
> service="createPaymentFromOrder" mode="sync"
> persist="true"/>
> > +    </eca>
> > 
> >     <!-- DISABLED FOR NOW
> >     <eca
> service="changeOrderStatus" event="commit"
> run-on-error="false">
> > 
> > 
> 
> 


      

Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Hans,

Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?

Typically payment due dates are based on the invoice date not the order date.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:

> Author: hansbak
> Date: Wed May  5 01:43:45 2010
> New Revision: 941132
> 
> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
> Log:
> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
> 
> Modified:
>    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>    ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>    ofbiz/trunk/applications/order/servicedef/secas.xml
> 
> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
> @@ -746,4 +746,72 @@ under the License.
>             <clear-field field="setPaymentStatusMap"/>
>         </iterate>
>     </simple-method>
> -</simple-methods>
> +
> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
> +        </entity-and>
> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
> +        </entity-and>
> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
> +            </entity-and>
> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
> +            <else>
> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
> +                </entity-and>
> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
> +            </else>
> +        </if-compare>
> +        <first-from-list entry="agreement" list="agreementList"/>
> +        <if-not-empty field="agreement">
> +            <entity-and list="orderTermList" entity-name="OrderTerm">
> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
> +            </entity-and>
> +            <first-from-list entry="orderTerm" list="orderTermList"/>
> +            <if-not-empty field="orderTerm.termDays">
> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
> +                <now-timestamp field="start"/>
> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
> +                    <field field="start" type="java.sql.Timestamp"/>
> +                    <field field="days" type="int"/>
> +                </call-class-method>
> +            </if-not-empty>
> +        </if-not-empty>
> +        <if-empty field="parameters.effectiveDate">
> +            <now-timestamp field="parameters.effectiveDate"/>
> +        </if-empty>
> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
> +        <call-service service-name="createPayment" in-map-name="createPayment">
> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
> +        </call-service>
> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
> +        </call-service>
> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
> +    </simple-method>
> +</simple-methods>
> \ No newline at end of file
> 
> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
> @@ -233,4 +233,11 @@ under the License.
>         <attribute name="statusId" type="String" mode="IN" optional="false"/>
>         <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>     </service>
> +
> +    <service name="createPaymentFromOrder" engine="simple"
> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
> +        <description>create Payment from Order</description>
> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
> +    </service>
> </services>
> 
> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
> @@ -93,6 +93,12 @@ under the License.
>         <action service="resetGrandTotal" mode="sync"/>
>         <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>     </eca>
> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
> +    </eca>
> 
>     <!-- DISABLED FOR NOW
>     <eca service="changeOrderStatus" event="commit" run-on-error="false">
> 
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Sam Hamilton <sa...@sh81.com>.
Spotted an error in my wording it should be:

>From my understanding of the flow of OFBiz you need to create the
Purchase Order, approve it and then once the goods have been received in
full the Purchase Invoice is generated which then kicks in the
Agreements which you set during the creation of the Purchase *Order* and
finally the Purchase Invoice is shown to the Accounts Payable team for
payment.


On 05/05/2010 11:00, Sam Hamilton wrote:
> Hi Scott,
> 
> We will ring a supplier and get a quote for a product, agree the terms
> e.g. pay first then they send the goods or 30 days credit or pay on
> delivery of goods. Then create a Purchase Order and then wire them the
> payment, the goods will then be delivered to our warehouse where we
> receive against the PO.
> 
> Sometimes the supplier can send too much or too little goods at which
> point either our purchasing department chases them for more products or
> we then send an additional wire for the extra cash or we get credit from
> the supplier to use against the next order.
> 
> From my understanding of the flow of OFBiz you need to create the
> Purchase Order, approve it and then once the goods have been received in
> full the Purchase Invoice is generated which then kicks in the
> Agreements which you set during the creation of the Purchase Invoice and
> finally the Purchase Invoice is shown to the Accounts Payable team for
> payment.
> 
> Yes I agree that this seems the wrong way round but this is how the
> business is done here and I can't change that - China can seem very
> inefficient at times.
> 
> Perhaps a On/Off switch for this code could be made - then it suits all
> companies? How best to make this work for everyone?
> 
> Cheers
> Sam
> 
> 
> 
> On 05/05/2010 10:34, Scott Gray wrote:
>> Surely they invoice you beforehand though?
>>
>> The payment should be created based on that.
>>
>> Regards
>> Scott
>>
>> On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
>>
>>> Hi Guys,
>>>
>>> Its for suppliers who need the payment of the invoice before the goods
>>> will be shipped e.g. they don't give credit.
>>>
>>> Sam
>>>
>>>
>>> On 05/05/2010 10:24, BJ Freeman wrote:
>>>> more for my understanding, I believe an invoice for a PO is internal not
>>>> sent to the supplier, if I remember a previous thread on the ml.
>>>> and that it is used to reconcile against the invoice received from the
>>>> supplier.
>>>> I did something similar.
>>>>
>>>> ========================
>>>>
>>>> BJ Freeman
>>>> http://bjfreeman.elance.com
>>>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>>>> Specialtymarket.com <http://www.specialtymarket.com/>
>>>>
>>>> Systems Integrator-- Glad to Assist
>>>>
>>>> Chat  Y! messenger: bjfr33man
>>>> Linkedin
>>>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>>>>
>>>>
>>>> Scott Gray sent the following on 5/4/2010 6:56 PM:
>>>>> Hi Hans,
>>>>>
>>>>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>>>>>
>>>>> Typically payment due dates are based on the invoice date not the order date.
>>>>>
>>>>> Regards
>>>>> Scott
>>>>>
>>>>> HotWax Media
>>>>> http://www.hotwaxmedia.com
>>>>>
>>>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>>>>>
>>>>>> Author: hansbak
>>>>>> Date: Wed May  5 01:43:45 2010
>>>>>> New Revision: 941132
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>>>>> Log:
>>>>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>>>>>
>>>>>> Modified:
>>>>>>   ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>   ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>   ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>>
>>>>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>>>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>>>>> @@ -746,4 +746,72 @@ under the License.
>>>>>>            <clear-field field="setPaymentStatusMap"/>
>>>>>>        </iterate>
>>>>>>    </simple-method>
>>>>>> -</simple-methods>
>>>>>> +
>>>>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>>>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>>>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>>>>> +        </entity-and>
>>>>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>>>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>>>>> +        </entity-and>
>>>>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>>>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>>>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>>>>> +            </entity-and>
>>>>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>>>>> +            <else>
>>>>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>>>> +                </entity-and>
>>>>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>>>>> +            </else>
>>>>>> +        </if-compare>
>>>>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>>>>> +        <if-not-empty field="agreement">
>>>>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>>>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>>>>> +            </entity-and>
>>>>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>>>>> +            <if-not-empty field="orderTerm.termDays">
>>>>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>>>>> +                <now-timestamp field="start"/>
>>>>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>>>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>>>>> +                    <field field="days" type="int"/>
>>>>>> +                </call-class-method>
>>>>>> +            </if-not-empty>
>>>>>> +        </if-not-empty>
>>>>>> +        <if-empty field="parameters.effectiveDate">
>>>>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>>>>> +        </if-empty>
>>>>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>>>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>>>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>>>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>>>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>>>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>>>>> +        </call-service>
>>>>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>>>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>>>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>>>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>>>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>>>>> +        </call-service>
>>>>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>>>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>>>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>>>>> +    </simple-method>
>>>>>> +</simple-methods>
>>>>>> \ No newline at end of file
>>>>>>
>>>>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>>>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>>>>> @@ -233,4 +233,11 @@ under the License.
>>>>>>        <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>>>>        <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>>>>    </service>
>>>>>> +
>>>>>> +    <service name="createPaymentFromOrder" engine="simple"
>>>>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>>>>> +        <description>create Payment from Order</description>
>>>>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>>>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>>>>> +    </service>
>>>>>> </services>
>>>>>>
>>>>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>>>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>>>>> @@ -93,6 +93,12 @@ under the License.
>>>>>>        <action service="resetGrandTotal" mode="sync"/>
>>>>>>        <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>>>>    </eca>
>>>>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>>>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>>>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>>>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>>>>> +    </eca>
>>>>>>
>>>>>>    <!-- DISABLED FOR NOW
>>>>>>    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Sam,

I would create a new Term Type of something like Prepayment Required and if that's present on an order then just do the payment thing like you are now.  Ideally it would be known as a prepayment and it would get posted to the ledgers appropriately and later when the good are received the invoice could be generated and the existing payment tied up to it and reconciled (expected vs. actual).

Regards
Scott

On 5/05/2010, at 4:58 PM, Sam Hamilton wrote:

> Hi Scott,
> 
> So say add a Term Type on the Order Entry Order Terms page of the
> Purchase Order workflow that would create the invoice immediately if
> required a bit like selecting Payment (net days) = 0 days, which does
> not work or we would have used that but I am sure you get my meaning.
> 
> Cheers
> Sam
> 
> 
> 
> 
> 
> On 05/05/2010 12:21, Scott Gray wrote:
>> Hi Sam,
>> 
>> It sounds like a shortcut is being taken in place of properly modeling the business process.
>> 
>> I guess at the very least an agreement of some sort should be attached to the order which results in the payment being created.  That would be your "switch", the payment is only generated if the agreements in place require it.
>> 
>> Ideally there would be some sort of RFQ process that automates the bulk of the work from the time that you approve your product requirements but that's another story.  
>> 
>> Regards
>> Scott
>> 
>> On 5/05/2010, at 3:00 PM, Sam Hamilton wrote:
>> 
>>> Hi Scott,
>>> 
>>> We will ring a supplier and get a quote for a product, agree the terms
>>> e.g. pay first then they send the goods or 30 days credit or pay on
>>> delivery of goods. Then create a Purchase Order and then wire them the
>>> payment, the goods will then be delivered to our warehouse where we
>>> receive against the PO.
>>> 
>>> Sometimes the supplier can send too much or too little goods at which
>>> point either our purchasing department chases them for more products or
>>> we then send an additional wire for the extra cash or we get credit from
>>> the supplier to use against the next order.
>>> 
>>> From my understanding of the flow of OFBiz you need to create the
>>> Purchase Order, approve it and then once the goods have been received in
>>> full the Purchase Invoice is generated which then kicks in the
>>> Agreements which you set during the creation of the Purchase Invoice and
>>> finally the Purchase Invoice is shown to the Accounts Payable team for
>>> payment.
>>> 
>>> Yes I agree that this seems the wrong way round but this is how the
>>> business is done here and I can't change that - China can seem very
>>> inefficient at times.
>>> 
>>> Perhaps a On/Off switch for this code could be made - then it suits all
>>> companies? How best to make this work for everyone?
>>> 
>>> Cheers
>>> Sam
>>> 
>>> 
>>> 
>>> On 05/05/2010 10:34, Scott Gray wrote:
>>>> Surely they invoice you beforehand though?
>>>> 
>>>> The payment should be created based on that.
>>>> 
>>>> Regards
>>>> Scott
>>>> 
>>>> On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
>>>> 
>>>>> Hi Guys,
>>>>> 
>>>>> Its for suppliers who need the payment of the invoice before the goods
>>>>> will be shipped e.g. they don't give credit.
>>>>> 
>>>>> Sam
>>>>> 
>>>>> 
>>>>> On 05/05/2010 10:24, BJ Freeman wrote:
>>>>>> more for my understanding, I believe an invoice for a PO is internal not
>>>>>> sent to the supplier, if I remember a previous thread on the ml.
>>>>>> and that it is used to reconcile against the invoice received from the
>>>>>> supplier.
>>>>>> I did something similar.
>>>>>> 
>>>>>> ========================
>>>>>> 
>>>>>> BJ Freeman
>>>>>> http://bjfreeman.elance.com
>>>>>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>>>>>> Specialtymarket.com <http://www.specialtymarket.com/>
>>>>>> 
>>>>>> Systems Integrator-- Glad to Assist
>>>>>> 
>>>>>> Chat  Y! messenger: bjfr33man
>>>>>> Linkedin
>>>>>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>>>>>> 
>>>>>> 
>>>>>> Scott Gray sent the following on 5/4/2010 6:56 PM:
>>>>>>> Hi Hans,
>>>>>>> 
>>>>>>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>>>>>>> 
>>>>>>> Typically payment due dates are based on the invoice date not the order date.
>>>>>>> 
>>>>>>> Regards
>>>>>>> Scott
>>>>>>> 
>>>>>>> HotWax Media
>>>>>>> http://www.hotwaxmedia.com
>>>>>>> 
>>>>>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>>>>>>> 
>>>>>>>> Author: hansbak
>>>>>>>> Date: Wed May  5 01:43:45 2010
>>>>>>>> New Revision: 941132
>>>>>>>> 
>>>>>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>>>>>>> Log:
>>>>>>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>>> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>>> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>>> ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>>>> 
>>>>>>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>>> ==============================================================================
>>>>>>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>>>>>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>>>>>>> @@ -746,4 +746,72 @@ under the License.
>>>>>>>>          <clear-field field="setPaymentStatusMap"/>
>>>>>>>>      </iterate>
>>>>>>>>  </simple-method>
>>>>>>>> -</simple-methods>
>>>>>>>> +
>>>>>>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>>>>>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>>>>>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>>>>>>> +        </entity-and>
>>>>>>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>>>>>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>>>>>>> +        </entity-and>
>>>>>>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>>>>>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>>>>>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>>>>>>> +            </entity-and>
>>>>>>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>>>>>>> +            <else>
>>>>>>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>>>>>> +                </entity-and>
>>>>>>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>>>>>>> +            </else>
>>>>>>>> +        </if-compare>
>>>>>>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>>>>>>> +        <if-not-empty field="agreement">
>>>>>>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>>>>>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>>>>>>> +            </entity-and>
>>>>>>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>>>>>>> +            <if-not-empty field="orderTerm.termDays">
>>>>>>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>>>>>>> +                <now-timestamp field="start"/>
>>>>>>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>>>>>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>>>>>>> +                    <field field="days" type="int"/>
>>>>>>>> +                </call-class-method>
>>>>>>>> +            </if-not-empty>
>>>>>>>> +        </if-not-empty>
>>>>>>>> +        <if-empty field="parameters.effectiveDate">
>>>>>>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>>>>>>> +        </if-empty>
>>>>>>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>>>>>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>>>>>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>>>>>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>>>>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>>>>>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>>>>>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>>>>>>> +        </call-service>
>>>>>>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>>>>>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>>>>>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>>>>>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>>>>>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>>>>>>> +        </call-service>
>>>>>>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>>>>>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>>>>>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>>>>>>> +    </simple-method>
>>>>>>>> +</simple-methods>
>>>>>>>> \ No newline at end of file
>>>>>>>> 
>>>>>>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>>> ==============================================================================
>>>>>>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>>>>>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>>>>>>> @@ -233,4 +233,11 @@ under the License.
>>>>>>>>      <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>>>>>>      <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>>>>>>  </service>
>>>>>>>> +
>>>>>>>> +    <service name="createPaymentFromOrder" engine="simple"
>>>>>>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>>>>>>> +        <description>create Payment from Order</description>
>>>>>>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>>>>>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>>>>>>> +    </service>
>>>>>>>> </services>
>>>>>>>> 
>>>>>>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>>> ==============================================================================
>>>>>>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>>>>>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>>>>>>> @@ -93,6 +93,12 @@ under the License.
>>>>>>>>      <action service="resetGrandTotal" mode="sync"/>
>>>>>>>>      <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>>>>>>  </eca>
>>>>>>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>>>>>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>>>>>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>>>>>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>>>>>>> +    </eca>
>>>>>>>> 
>>>>>>>>  <!-- DISABLED FOR NOW
>>>>>>>>  <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Hans Bakker <ma...@antwebsystems.com>.
Hi Sam, Scott,

What ever happens we always need the payment record. and this creation
saves time and, because the status is not paid it can be used when the
payment is actually done.

we can discuss about the payment date. Hoever I think that is well
covered by the agreements if available

Regards,
Hans


On Wed, 2010-05-05 at 12:58 +0800, Sam Hamilton wrote:
> Hi Scott,
> 
> So say add a Term Type on the Order Entry Order Terms page of the
> Purchase Order workflow that would create the invoice immediately if
> required a bit like selecting Payment (net days) = 0 days, which does
> not work or we would have used that but I am sure you get my meaning.
> 
> Cheers
> Sam
> 
> 
> 
> 
> 
> On 05/05/2010 12:21, Scott Gray wrote:
> > Hi Sam,
> > 
> > It sounds like a shortcut is being taken in place of properly modeling the business process.
> > 
> > I guess at the very least an agreement of some sort should be attached to the order which results in the payment being created.  That would be your "switch", the payment is only generated if the agreements in place require it.
> > 
> > Ideally there would be some sort of RFQ process that automates the bulk of the work from the time that you approve your product requirements but that's another story.  
> > 
> > Regards
> > Scott
> > 
> > On 5/05/2010, at 3:00 PM, Sam Hamilton wrote:
> > 
> >> Hi Scott,
> >>
> >> We will ring a supplier and get a quote for a product, agree the terms
> >> e.g. pay first then they send the goods or 30 days credit or pay on
> >> delivery of goods. Then create a Purchase Order and then wire them the
> >> payment, the goods will then be delivered to our warehouse where we
> >> receive against the PO.
> >>
> >> Sometimes the supplier can send too much or too little goods at which
> >> point either our purchasing department chases them for more products or
> >> we then send an additional wire for the extra cash or we get credit from
> >> the supplier to use against the next order.
> >>
> >> From my understanding of the flow of OFBiz you need to create the
> >> Purchase Order, approve it and then once the goods have been received in
> >> full the Purchase Invoice is generated which then kicks in the
> >> Agreements which you set during the creation of the Purchase Invoice and
> >> finally the Purchase Invoice is shown to the Accounts Payable team for
> >> payment.
> >>
> >> Yes I agree that this seems the wrong way round but this is how the
> >> business is done here and I can't change that - China can seem very
> >> inefficient at times.
> >>
> >> Perhaps a On/Off switch for this code could be made - then it suits all
> >> companies? How best to make this work for everyone?
> >>
> >> Cheers
> >> Sam
> >>
> >>
> >>
> >> On 05/05/2010 10:34, Scott Gray wrote:
> >>> Surely they invoice you beforehand though?
> >>>
> >>> The payment should be created based on that.
> >>>
> >>> Regards
> >>> Scott
> >>>
> >>> On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
> >>>
> >>>> Hi Guys,
> >>>>
> >>>> Its for suppliers who need the payment of the invoice before the goods
> >>>> will be shipped e.g. they don't give credit.
> >>>>
> >>>> Sam
> >>>>
> >>>>
> >>>> On 05/05/2010 10:24, BJ Freeman wrote:
> >>>>> more for my understanding, I believe an invoice for a PO is internal not
> >>>>> sent to the supplier, if I remember a previous thread on the ml.
> >>>>> and that it is used to reconcile against the invoice received from the
> >>>>> supplier.
> >>>>> I did something similar.
> >>>>>
> >>>>> ========================
> >>>>>
> >>>>> BJ Freeman
> >>>>> http://bjfreeman.elance.com
> >>>>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
> >>>>> Specialtymarket.com <http://www.specialtymarket.com/>
> >>>>>
> >>>>> Systems Integrator-- Glad to Assist
> >>>>>
> >>>>> Chat  Y! messenger: bjfr33man
> >>>>> Linkedin
> >>>>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
> >>>>>
> >>>>>
> >>>>> Scott Gray sent the following on 5/4/2010 6:56 PM:
> >>>>>> Hi Hans,
> >>>>>>
> >>>>>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
> >>>>>>
> >>>>>> Typically payment due dates are based on the invoice date not the order date.
> >>>>>>
> >>>>>> Regards
> >>>>>> Scott
> >>>>>>
> >>>>>> HotWax Media
> >>>>>> http://www.hotwaxmedia.com
> >>>>>>
> >>>>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
> >>>>>>
> >>>>>>> Author: hansbak
> >>>>>>> Date: Wed May  5 01:43:45 2010
> >>>>>>> New Revision: 941132
> >>>>>>>
> >>>>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
> >>>>>>> Log:
> >>>>>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
> >>>>>>>
> >>>>>>> Modified:
> >>>>>>>  ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> >>>>>>>  ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> >>>>>>>  ofbiz/trunk/applications/order/servicedef/secas.xml
> >>>>>>>
> >>>>>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> >>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
> >>>>>>> ==============================================================================
> >>>>>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
> >>>>>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
> >>>>>>> @@ -746,4 +746,72 @@ under the License.
> >>>>>>>           <clear-field field="setPaymentStatusMap"/>
> >>>>>>>       </iterate>
> >>>>>>>   </simple-method>
> >>>>>>> -</simple-methods>
> >>>>>>> +
> >>>>>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
> >>>>>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
> >>>>>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
> >>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
> >>>>>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
> >>>>>>> +        </entity-and>
> >>>>>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
> >>>>>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
> >>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
> >>>>>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
> >>>>>>> +        </entity-and>
> >>>>>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
> >>>>>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
> >>>>>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
> >>>>>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
> >>>>>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
> >>>>>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
> >>>>>>> +            </entity-and>
> >>>>>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
> >>>>>>> +            <else>
> >>>>>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
> >>>>>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
> >>>>>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
> >>>>>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
> >>>>>>> +                </entity-and>
> >>>>>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
> >>>>>>> +            </else>
> >>>>>>> +        </if-compare>
> >>>>>>> +        <first-from-list entry="agreement" list="agreementList"/>
> >>>>>>> +        <if-not-empty field="agreement">
> >>>>>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
> >>>>>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
> >>>>>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
> >>>>>>> +            </entity-and>
> >>>>>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
> >>>>>>> +            <if-not-empty field="orderTerm.termDays">
> >>>>>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
> >>>>>>> +                <now-timestamp field="start"/>
> >>>>>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
> >>>>>>> +                    <field field="start" type="java.sql.Timestamp"/>
> >>>>>>> +                    <field field="days" type="int"/>
> >>>>>>> +                </call-class-method>
> >>>>>>> +            </if-not-empty>
> >>>>>>> +        </if-not-empty>
> >>>>>>> +        <if-empty field="parameters.effectiveDate">
> >>>>>>> +            <now-timestamp field="parameters.effectiveDate"/>
> >>>>>>> +        </if-empty>
> >>>>>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
> >>>>>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
> >>>>>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
> >>>>>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
> >>>>>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
> >>>>>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
> >>>>>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
> >>>>>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
> >>>>>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
> >>>>>>> +        </call-service>
> >>>>>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
> >>>>>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
> >>>>>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
> >>>>>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
> >>>>>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
> >>>>>>> +        </call-service>
> >>>>>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
> >>>>>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
> >>>>>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
> >>>>>>> +    </simple-method>
> >>>>>>> +</simple-methods>
> >>>>>>> \ No newline at end of file
> >>>>>>>
> >>>>>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> >>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
> >>>>>>> ==============================================================================
> >>>>>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
> >>>>>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
> >>>>>>> @@ -233,4 +233,11 @@ under the License.
> >>>>>>>       <attribute name="statusId" type="String" mode="IN" optional="false"/>
> >>>>>>>       <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
> >>>>>>>   </service>
> >>>>>>> +
> >>>>>>> +    <service name="createPaymentFromOrder" engine="simple"
> >>>>>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
> >>>>>>> +        <description>create Payment from Order</description>
> >>>>>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
> >>>>>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
> >>>>>>> +    </service>
> >>>>>>> </services>
> >>>>>>>
> >>>>>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
> >>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
> >>>>>>> ==============================================================================
> >>>>>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
> >>>>>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
> >>>>>>> @@ -93,6 +93,12 @@ under the License.
> >>>>>>>       <action service="resetGrandTotal" mode="sync"/>
> >>>>>>>       <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
> >>>>>>>   </eca>
> >>>>>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
> >>>>>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
> >>>>>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
> >>>>>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
> >>>>>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
> >>>>>>> +    </eca>
> >>>>>>>
> >>>>>>>   <!-- DISABLED FOR NOW
> >>>>>>>   <eca service="changeOrderStatus" event="commit" run-on-error="false">
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>
> >>>
> >>
> > 
> 

-- 
Ofbiz on twitter: http://twitter.com/apache_ofbiz
Myself on twitter: http://twitter.com/hansbak
Antwebsystems.com: Quality services for competitive rates.


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Sam Hamilton <sa...@sh81.com>.
Hi Scott,

So say add a Term Type on the Order Entry Order Terms page of the
Purchase Order workflow that would create the invoice immediately if
required a bit like selecting Payment (net days) = 0 days, which does
not work or we would have used that but I am sure you get my meaning.

Cheers
Sam





On 05/05/2010 12:21, Scott Gray wrote:
> Hi Sam,
> 
> It sounds like a shortcut is being taken in place of properly modeling the business process.
> 
> I guess at the very least an agreement of some sort should be attached to the order which results in the payment being created.  That would be your "switch", the payment is only generated if the agreements in place require it.
> 
> Ideally there would be some sort of RFQ process that automates the bulk of the work from the time that you approve your product requirements but that's another story.  
> 
> Regards
> Scott
> 
> On 5/05/2010, at 3:00 PM, Sam Hamilton wrote:
> 
>> Hi Scott,
>>
>> We will ring a supplier and get a quote for a product, agree the terms
>> e.g. pay first then they send the goods or 30 days credit or pay on
>> delivery of goods. Then create a Purchase Order and then wire them the
>> payment, the goods will then be delivered to our warehouse where we
>> receive against the PO.
>>
>> Sometimes the supplier can send too much or too little goods at which
>> point either our purchasing department chases them for more products or
>> we then send an additional wire for the extra cash or we get credit from
>> the supplier to use against the next order.
>>
>> From my understanding of the flow of OFBiz you need to create the
>> Purchase Order, approve it and then once the goods have been received in
>> full the Purchase Invoice is generated which then kicks in the
>> Agreements which you set during the creation of the Purchase Invoice and
>> finally the Purchase Invoice is shown to the Accounts Payable team for
>> payment.
>>
>> Yes I agree that this seems the wrong way round but this is how the
>> business is done here and I can't change that - China can seem very
>> inefficient at times.
>>
>> Perhaps a On/Off switch for this code could be made - then it suits all
>> companies? How best to make this work for everyone?
>>
>> Cheers
>> Sam
>>
>>
>>
>> On 05/05/2010 10:34, Scott Gray wrote:
>>> Surely they invoice you beforehand though?
>>>
>>> The payment should be created based on that.
>>>
>>> Regards
>>> Scott
>>>
>>> On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
>>>
>>>> Hi Guys,
>>>>
>>>> Its for suppliers who need the payment of the invoice before the goods
>>>> will be shipped e.g. they don't give credit.
>>>>
>>>> Sam
>>>>
>>>>
>>>> On 05/05/2010 10:24, BJ Freeman wrote:
>>>>> more for my understanding, I believe an invoice for a PO is internal not
>>>>> sent to the supplier, if I remember a previous thread on the ml.
>>>>> and that it is used to reconcile against the invoice received from the
>>>>> supplier.
>>>>> I did something similar.
>>>>>
>>>>> ========================
>>>>>
>>>>> BJ Freeman
>>>>> http://bjfreeman.elance.com
>>>>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>>>>> Specialtymarket.com <http://www.specialtymarket.com/>
>>>>>
>>>>> Systems Integrator-- Glad to Assist
>>>>>
>>>>> Chat  Y! messenger: bjfr33man
>>>>> Linkedin
>>>>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>>>>>
>>>>>
>>>>> Scott Gray sent the following on 5/4/2010 6:56 PM:
>>>>>> Hi Hans,
>>>>>>
>>>>>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>>>>>>
>>>>>> Typically payment due dates are based on the invoice date not the order date.
>>>>>>
>>>>>> Regards
>>>>>> Scott
>>>>>>
>>>>>> HotWax Media
>>>>>> http://www.hotwaxmedia.com
>>>>>>
>>>>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>>>>>>
>>>>>>> Author: hansbak
>>>>>>> Date: Wed May  5 01:43:45 2010
>>>>>>> New Revision: 941132
>>>>>>>
>>>>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>>>>>> Log:
>>>>>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>>>>>>
>>>>>>> Modified:
>>>>>>>  ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>>  ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>>  ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>>>
>>>>>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>> ==============================================================================
>>>>>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>>>>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>>>>>> @@ -746,4 +746,72 @@ under the License.
>>>>>>>           <clear-field field="setPaymentStatusMap"/>
>>>>>>>       </iterate>
>>>>>>>   </simple-method>
>>>>>>> -</simple-methods>
>>>>>>> +
>>>>>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>>>>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>>>>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>>>>>> +        </entity-and>
>>>>>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>>>>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>>>>>> +        </entity-and>
>>>>>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>>>>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>>>>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>>>>>> +            </entity-and>
>>>>>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>>>>>> +            <else>
>>>>>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>>>>> +                </entity-and>
>>>>>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>>>>>> +            </else>
>>>>>>> +        </if-compare>
>>>>>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>>>>>> +        <if-not-empty field="agreement">
>>>>>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>>>>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>>>>>> +            </entity-and>
>>>>>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>>>>>> +            <if-not-empty field="orderTerm.termDays">
>>>>>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>>>>>> +                <now-timestamp field="start"/>
>>>>>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>>>>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>>>>>> +                    <field field="days" type="int"/>
>>>>>>> +                </call-class-method>
>>>>>>> +            </if-not-empty>
>>>>>>> +        </if-not-empty>
>>>>>>> +        <if-empty field="parameters.effectiveDate">
>>>>>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>>>>>> +        </if-empty>
>>>>>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>>>>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>>>>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>>>>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>>>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>>>>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>>>>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>>>>>> +        </call-service>
>>>>>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>>>>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>>>>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>>>>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>>>>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>>>>>> +        </call-service>
>>>>>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>>>>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>>>>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>>>>>> +    </simple-method>
>>>>>>> +</simple-methods>
>>>>>>> \ No newline at end of file
>>>>>>>
>>>>>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>> ==============================================================================
>>>>>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>>>>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>>>>>> @@ -233,4 +233,11 @@ under the License.
>>>>>>>       <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>>>>>       <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>>>>>   </service>
>>>>>>> +
>>>>>>> +    <service name="createPaymentFromOrder" engine="simple"
>>>>>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>>>>>> +        <description>create Payment from Order</description>
>>>>>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>>>>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>>>>>> +    </service>
>>>>>>> </services>
>>>>>>>
>>>>>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>> ==============================================================================
>>>>>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>>>>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>>>>>> @@ -93,6 +93,12 @@ under the License.
>>>>>>>       <action service="resetGrandTotal" mode="sync"/>
>>>>>>>       <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>>>>>   </eca>
>>>>>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>>>>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>>>>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>>>>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>>>>>> +    </eca>
>>>>>>>
>>>>>>>   <!-- DISABLED FOR NOW
>>>>>>>   <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Sam,

It sounds like a shortcut is being taken in place of properly modeling the business process.

I guess at the very least an agreement of some sort should be attached to the order which results in the payment being created.  That would be your "switch", the payment is only generated if the agreements in place require it.

Ideally there would be some sort of RFQ process that automates the bulk of the work from the time that you approve your product requirements but that's another story.  

Regards
Scott

On 5/05/2010, at 3:00 PM, Sam Hamilton wrote:

> Hi Scott,
> 
> We will ring a supplier and get a quote for a product, agree the terms
> e.g. pay first then they send the goods or 30 days credit or pay on
> delivery of goods. Then create a Purchase Order and then wire them the
> payment, the goods will then be delivered to our warehouse where we
> receive against the PO.
> 
> Sometimes the supplier can send too much or too little goods at which
> point either our purchasing department chases them for more products or
> we then send an additional wire for the extra cash or we get credit from
> the supplier to use against the next order.
> 
> From my understanding of the flow of OFBiz you need to create the
> Purchase Order, approve it and then once the goods have been received in
> full the Purchase Invoice is generated which then kicks in the
> Agreements which you set during the creation of the Purchase Invoice and
> finally the Purchase Invoice is shown to the Accounts Payable team for
> payment.
> 
> Yes I agree that this seems the wrong way round but this is how the
> business is done here and I can't change that - China can seem very
> inefficient at times.
> 
> Perhaps a On/Off switch for this code could be made - then it suits all
> companies? How best to make this work for everyone?
> 
> Cheers
> Sam
> 
> 
> 
> On 05/05/2010 10:34, Scott Gray wrote:
>> Surely they invoice you beforehand though?
>> 
>> The payment should be created based on that.
>> 
>> Regards
>> Scott
>> 
>> On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
>> 
>>> Hi Guys,
>>> 
>>> Its for suppliers who need the payment of the invoice before the goods
>>> will be shipped e.g. they don't give credit.
>>> 
>>> Sam
>>> 
>>> 
>>> On 05/05/2010 10:24, BJ Freeman wrote:
>>>> more for my understanding, I believe an invoice for a PO is internal not
>>>> sent to the supplier, if I remember a previous thread on the ml.
>>>> and that it is used to reconcile against the invoice received from the
>>>> supplier.
>>>> I did something similar.
>>>> 
>>>> ========================
>>>> 
>>>> BJ Freeman
>>>> http://bjfreeman.elance.com
>>>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>>>> Specialtymarket.com <http://www.specialtymarket.com/>
>>>> 
>>>> Systems Integrator-- Glad to Assist
>>>> 
>>>> Chat  Y! messenger: bjfr33man
>>>> Linkedin
>>>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>>>> 
>>>> 
>>>> Scott Gray sent the following on 5/4/2010 6:56 PM:
>>>>> Hi Hans,
>>>>> 
>>>>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>>>>> 
>>>>> Typically payment due dates are based on the invoice date not the order date.
>>>>> 
>>>>> Regards
>>>>> Scott
>>>>> 
>>>>> HotWax Media
>>>>> http://www.hotwaxmedia.com
>>>>> 
>>>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>>>>> 
>>>>>> Author: hansbak
>>>>>> Date: Wed May  5 01:43:45 2010
>>>>>> New Revision: 941132
>>>>>> 
>>>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>>>>> Log:
>>>>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>>>>> 
>>>>>> Modified:
>>>>>>  ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>  ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>  ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>> 
>>>>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>>>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>>>>> @@ -746,4 +746,72 @@ under the License.
>>>>>>           <clear-field field="setPaymentStatusMap"/>
>>>>>>       </iterate>
>>>>>>   </simple-method>
>>>>>> -</simple-methods>
>>>>>> +
>>>>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>>>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>>>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>>>>> +        </entity-and>
>>>>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>>>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>>>>> +        </entity-and>
>>>>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>>>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>>>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>>>>> +            </entity-and>
>>>>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>>>>> +            <else>
>>>>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>>>> +                </entity-and>
>>>>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>>>>> +            </else>
>>>>>> +        </if-compare>
>>>>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>>>>> +        <if-not-empty field="agreement">
>>>>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>>>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>>>>> +            </entity-and>
>>>>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>>>>> +            <if-not-empty field="orderTerm.termDays">
>>>>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>>>>> +                <now-timestamp field="start"/>
>>>>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>>>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>>>>> +                    <field field="days" type="int"/>
>>>>>> +                </call-class-method>
>>>>>> +            </if-not-empty>
>>>>>> +        </if-not-empty>
>>>>>> +        <if-empty field="parameters.effectiveDate">
>>>>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>>>>> +        </if-empty>
>>>>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>>>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>>>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>>>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>>>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>>>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>>>>> +        </call-service>
>>>>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>>>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>>>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>>>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>>>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>>>>> +        </call-service>
>>>>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>>>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>>>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>>>>> +    </simple-method>
>>>>>> +</simple-methods>
>>>>>> \ No newline at end of file
>>>>>> 
>>>>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>>>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>>>>> @@ -233,4 +233,11 @@ under the License.
>>>>>>       <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>>>>       <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>>>>   </service>
>>>>>> +
>>>>>> +    <service name="createPaymentFromOrder" engine="simple"
>>>>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>>>>> +        <description>create Payment from Order</description>
>>>>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>>>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>>>>> +    </service>
>>>>>> </services>
>>>>>> 
>>>>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>>>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>>>>> @@ -93,6 +93,12 @@ under the License.
>>>>>>       <action service="resetGrandTotal" mode="sync"/>
>>>>>>       <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>>>>   </eca>
>>>>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>>>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>>>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>>>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>>>>> +    </eca>
>>>>>> 
>>>>>>   <!-- DISABLED FOR NOW
>>>>>>   <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>> 
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Thanks Hans, much appreciated.

Regards
Scott

On 7/05/2010, at 5:58 PM, Hans Bakker wrote:

> let me see if i can accommodate your request.
> 
> On Thu, 2010-05-06 at 21:08 +1200, Scott Gray wrote:
>> I'm pretty sure it can be accommodated without making it the default behavior.
>> 
>> Hans, could you please either look at making it configurable or otherwise revert the commit?
>> 
>> Thanks
>> Scott
>> 
>> HotWax Media
>> http://www.hotwaxmedia.com
>> 
>> On 6/05/2010, at 3:28 AM, Joe Eckard wrote:
>> 
>>> I haven't looked at the actual code changes in question, but this scenario seems fairly common - I would guess at least 10% of our POs are prepaid. Some vendors don't require you to prepay, but will give a substantial discount if you do.
>>> 
>>> 
>>> On May 5, 2010, at 1:38 AM, Sam Hamilton wrote:
>>> 
>>>> Hey Adrian,
>>>> 
>>>> While its true most don't go this way, if you bought some books from
>>>> Amazon then you would need to pay before they would ship ;-)
>>>> 
>>>> This kind of interaction happens when the transaction is between 2
>>>> businesses where the supplier is used to dealing with end consumers
>>>> rather than businesses that request credit.
>>>> 
>>>> Cheers
>>>> Sam
>>>> 
>>>> 
>>>> 
>>>> On 05/05/2010 13:14, Adrian Crum wrote:
>>>>> Yeah, that scenario sounds pretty specific. That's not how most US businesses work.
>>>>> 
>>>>> -Adrian
>>>>> 
>>>>> --- On Tue, 5/4/10, Sam Hamilton <sa...@sh81.com> wrote:
>>>>> 
>>>>>> From: Sam Hamilton <sa...@sh81.com>
>>>>>> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml
>>>>>> To: dev@ofbiz.apache.org
>>>>>> Date: Tuesday, May 4, 2010, 8:00 PM
>>>>>> Hi Scott,
>>>>>> 
>>>>>> We will ring a supplier and get a quote for a product,
>>>>>> agree the terms
>>>>>> e.g. pay first then they send the goods or 30 days credit
>>>>>> or pay on
>>>>>> delivery of goods. Then create a Purchase Order and then
>>>>>> wire them the
>>>>>> payment, the goods will then be delivered to our warehouse
>>>>>> where we
>>>>>> receive against the PO.
>>>>>> 
>>>>>> Sometimes the supplier can send too much or too little
>>>>>> goods at which
>>>>>> point either our purchasing department chases them for more
>>>>>> products or
>>>>>> we then send an additional wire for the extra cash or we
>>>>>> get credit from
>>>>>> the supplier to use against the next order.
>>>>>> 
>>>>>> From my understanding of the flow of OFBiz you need to
>>>>>> create the
>>>>>> Purchase Order, approve it and then once the goods have
>>>>>> been received in
>>>>>> full the Purchase Invoice is generated which then kicks in
>>>>>> the
>>>>>> Agreements which you set during the creation of the
>>>>>> Purchase Invoice and
>>>>>> finally the Purchase Invoice is shown to the Accounts
>>>>>> Payable team for
>>>>>> payment.
>>>>>> 
>>>>>> Yes I agree that this seems the wrong way round but this is
>>>>>> how the
>>>>>> business is done here and I can't change that - China can
>>>>>> seem very
>>>>>> inefficient at times.
>>>>>> 
>>>>>> Perhaps a On/Off switch for this code could be made - then
>>>>>> it suits all
>>>>>> companies? How best to make this work for everyone?
>>>>>> 
>>>>>> Cheers
>>>>>> Sam
>>>>>> 
>> 
> 
> -- 
> Ofbiz on twitter: http://twitter.com/apache_ofbiz
> Myself on twitter: http://twitter.com/hansbak
> Antwebsystems.com: Quality services for competitive rates.
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Hans Bakker <ma...@antwebsystems.com>.
let me see if i can accommodate your request.

On Thu, 2010-05-06 at 21:08 +1200, Scott Gray wrote:
> I'm pretty sure it can be accommodated without making it the default behavior.
> 
> Hans, could you please either look at making it configurable or otherwise revert the commit?
> 
> Thanks
> Scott
> 
> HotWax Media
> http://www.hotwaxmedia.com
> 
> On 6/05/2010, at 3:28 AM, Joe Eckard wrote:
> 
> > I haven't looked at the actual code changes in question, but this scenario seems fairly common - I would guess at least 10% of our POs are prepaid. Some vendors don't require you to prepay, but will give a substantial discount if you do.
> > 
> > 
> > On May 5, 2010, at 1:38 AM, Sam Hamilton wrote:
> > 
> >> Hey Adrian,
> >> 
> >> While its true most don't go this way, if you bought some books from
> >> Amazon then you would need to pay before they would ship ;-)
> >> 
> >> This kind of interaction happens when the transaction is between 2
> >> businesses where the supplier is used to dealing with end consumers
> >> rather than businesses that request credit.
> >> 
> >> Cheers
> >> Sam
> >> 
> >> 
> >> 
> >> On 05/05/2010 13:14, Adrian Crum wrote:
> >>> Yeah, that scenario sounds pretty specific. That's not how most US businesses work.
> >>> 
> >>> -Adrian
> >>> 
> >>> --- On Tue, 5/4/10, Sam Hamilton <sa...@sh81.com> wrote:
> >>> 
> >>>> From: Sam Hamilton <sa...@sh81.com>
> >>>> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml
> >>>> To: dev@ofbiz.apache.org
> >>>> Date: Tuesday, May 4, 2010, 8:00 PM
> >>>> Hi Scott,
> >>>> 
> >>>> We will ring a supplier and get a quote for a product,
> >>>> agree the terms
> >>>> e.g. pay first then they send the goods or 30 days credit
> >>>> or pay on
> >>>> delivery of goods. Then create a Purchase Order and then
> >>>> wire them the
> >>>> payment, the goods will then be delivered to our warehouse
> >>>> where we
> >>>> receive against the PO.
> >>>> 
> >>>> Sometimes the supplier can send too much or too little
> >>>> goods at which
> >>>> point either our purchasing department chases them for more
> >>>> products or
> >>>> we then send an additional wire for the extra cash or we
> >>>> get credit from
> >>>> the supplier to use against the next order.
> >>>> 
> >>>> From my understanding of the flow of OFBiz you need to
> >>>> create the
> >>>> Purchase Order, approve it and then once the goods have
> >>>> been received in
> >>>> full the Purchase Invoice is generated which then kicks in
> >>>> the
> >>>> Agreements which you set during the creation of the
> >>>> Purchase Invoice and
> >>>> finally the Purchase Invoice is shown to the Accounts
> >>>> Payable team for
> >>>> payment.
> >>>> 
> >>>> Yes I agree that this seems the wrong way round but this is
> >>>> how the
> >>>> business is done here and I can't change that - China can
> >>>> seem very
> >>>> inefficient at times.
> >>>> 
> >>>> Perhaps a On/Off switch for this code could be made - then
> >>>> it suits all
> >>>> companies? How best to make this work for everyone?
> >>>> 
> >>>> Cheers
> >>>> Sam
> >>>> 
> 

-- 
Ofbiz on twitter: http://twitter.com/apache_ofbiz
Myself on twitter: http://twitter.com/hansbak
Antwebsystems.com: Quality services for competitive rates.


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Hans Bakker <ma...@antwebsystems.com>.
i made this function configurable in revision 943788.


Regards,
Hans


On Thu, 2010-05-06 at 21:08 +1200, Scott Gray wrote:
> I'm pretty sure it can be accommodated without making it the default behavior.
> 
> Hans, could you please either look at making it configurable or otherwise revert the commit?
> 
> Thanks
> Scott
> 
> HotWax Media
> http://www.hotwaxmedia.com
> 
> On 6/05/2010, at 3:28 AM, Joe Eckard wrote:
> 
> > I haven't looked at the actual code changes in question, but this scenario seems fairly common - I would guess at least 10% of our POs are prepaid. Some vendors don't require you to prepay, but will give a substantial discount if you do.
> > 
> > 
> > On May 5, 2010, at 1:38 AM, Sam Hamilton wrote:
> > 
> >> Hey Adrian,
> >> 
> >> While its true most don't go this way, if you bought some books from
> >> Amazon then you would need to pay before they would ship ;-)
> >> 
> >> This kind of interaction happens when the transaction is between 2
> >> businesses where the supplier is used to dealing with end consumers
> >> rather than businesses that request credit.
> >> 
> >> Cheers
> >> Sam
> >> 
> >> 
> >> 
> >> On 05/05/2010 13:14, Adrian Crum wrote:
> >>> Yeah, that scenario sounds pretty specific. That's not how most US businesses work.
> >>> 
> >>> -Adrian
> >>> 
> >>> --- On Tue, 5/4/10, Sam Hamilton <sa...@sh81.com> wrote:
> >>> 
> >>>> From: Sam Hamilton <sa...@sh81.com>
> >>>> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml
> >>>> To: dev@ofbiz.apache.org
> >>>> Date: Tuesday, May 4, 2010, 8:00 PM
> >>>> Hi Scott,
> >>>> 
> >>>> We will ring a supplier and get a quote for a product,
> >>>> agree the terms
> >>>> e.g. pay first then they send the goods or 30 days credit
> >>>> or pay on
> >>>> delivery of goods. Then create a Purchase Order and then
> >>>> wire them the
> >>>> payment, the goods will then be delivered to our warehouse
> >>>> where we
> >>>> receive against the PO.
> >>>> 
> >>>> Sometimes the supplier can send too much or too little
> >>>> goods at which
> >>>> point either our purchasing department chases them for more
> >>>> products or
> >>>> we then send an additional wire for the extra cash or we
> >>>> get credit from
> >>>> the supplier to use against the next order.
> >>>> 
> >>>> From my understanding of the flow of OFBiz you need to
> >>>> create the
> >>>> Purchase Order, approve it and then once the goods have
> >>>> been received in
> >>>> full the Purchase Invoice is generated which then kicks in
> >>>> the
> >>>> Agreements which you set during the creation of the
> >>>> Purchase Invoice and
> >>>> finally the Purchase Invoice is shown to the Accounts
> >>>> Payable team for
> >>>> payment.
> >>>> 
> >>>> Yes I agree that this seems the wrong way round but this is
> >>>> how the
> >>>> business is done here and I can't change that - China can
> >>>> seem very
> >>>> inefficient at times.
> >>>> 
> >>>> Perhaps a On/Off switch for this code could be made - then
> >>>> it suits all
> >>>> companies? How best to make this work for everyone?
> >>>> 
> >>>> Cheers
> >>>> Sam
> >>>> 
> 

-- 
Ofbiz on twitter: http://twitter.com/apache_ofbiz
Myself on twitter: http://twitter.com/hansbak
Antwebsystems.com: Quality services for competitive rates.


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Scott Gray <sc...@hotwaxmedia.com>.
I'm pretty sure it can be accommodated without making it the default behavior.

Hans, could you please either look at making it configurable or otherwise revert the commit?

Thanks
Scott

HotWax Media
http://www.hotwaxmedia.com

On 6/05/2010, at 3:28 AM, Joe Eckard wrote:

> I haven't looked at the actual code changes in question, but this scenario seems fairly common - I would guess at least 10% of our POs are prepaid. Some vendors don't require you to prepay, but will give a substantial discount if you do.
> 
> 
> On May 5, 2010, at 1:38 AM, Sam Hamilton wrote:
> 
>> Hey Adrian,
>> 
>> While its true most don't go this way, if you bought some books from
>> Amazon then you would need to pay before they would ship ;-)
>> 
>> This kind of interaction happens when the transaction is between 2
>> businesses where the supplier is used to dealing with end consumers
>> rather than businesses that request credit.
>> 
>> Cheers
>> Sam
>> 
>> 
>> 
>> On 05/05/2010 13:14, Adrian Crum wrote:
>>> Yeah, that scenario sounds pretty specific. That's not how most US businesses work.
>>> 
>>> -Adrian
>>> 
>>> --- On Tue, 5/4/10, Sam Hamilton <sa...@sh81.com> wrote:
>>> 
>>>> From: Sam Hamilton <sa...@sh81.com>
>>>> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml
>>>> To: dev@ofbiz.apache.org
>>>> Date: Tuesday, May 4, 2010, 8:00 PM
>>>> Hi Scott,
>>>> 
>>>> We will ring a supplier and get a quote for a product,
>>>> agree the terms
>>>> e.g. pay first then they send the goods or 30 days credit
>>>> or pay on
>>>> delivery of goods. Then create a Purchase Order and then
>>>> wire them the
>>>> payment, the goods will then be delivered to our warehouse
>>>> where we
>>>> receive against the PO.
>>>> 
>>>> Sometimes the supplier can send too much or too little
>>>> goods at which
>>>> point either our purchasing department chases them for more
>>>> products or
>>>> we then send an additional wire for the extra cash or we
>>>> get credit from
>>>> the supplier to use against the next order.
>>>> 
>>>> From my understanding of the flow of OFBiz you need to
>>>> create the
>>>> Purchase Order, approve it and then once the goods have
>>>> been received in
>>>> full the Purchase Invoice is generated which then kicks in
>>>> the
>>>> Agreements which you set during the creation of the
>>>> Purchase Invoice and
>>>> finally the Purchase Invoice is shown to the Accounts
>>>> Payable team for
>>>> payment.
>>>> 
>>>> Yes I agree that this seems the wrong way round but this is
>>>> how the
>>>> business is done here and I can't change that - China can
>>>> seem very
>>>> inefficient at times.
>>>> 
>>>> Perhaps a On/Off switch for this code could be made - then
>>>> it suits all
>>>> companies? How best to make this work for everyone?
>>>> 
>>>> Cheers
>>>> Sam
>>>> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Joe Eckard <jo...@redrocketcorp.com>.
I haven't looked at the actual code changes in question, but this  
scenario seems fairly common - I would guess at least 10% of our POs  
are prepaid. Some vendors don't require you to prepay, but will give a  
substantial discount if you do.


On May 5, 2010, at 1:38 AM, Sam Hamilton wrote:

> Hey Adrian,
>
> While its true most don't go this way, if you bought some books from
> Amazon then you would need to pay before they would ship ;-)
>
> This kind of interaction happens when the transaction is between 2
> businesses where the supplier is used to dealing with end consumers
> rather than businesses that request credit.
>
> Cheers
> Sam
>
>
>
> On 05/05/2010 13:14, Adrian Crum wrote:
>> Yeah, that scenario sounds pretty specific. That's not how most US  
>> businesses work.
>>
>> -Adrian
>>
>> --- On Tue, 5/4/10, Sam Hamilton <sa...@sh81.com> wrote:
>>
>>> From: Sam Hamilton <sa...@sh81.com>
>>> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications:  
>>> accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml  
>>> accounting/servicedef/services_payment.xml order/servicedef/ 
>>> secas.xml
>>> To: dev@ofbiz.apache.org
>>> Date: Tuesday, May 4, 2010, 8:00 PM
>>> Hi Scott,
>>>
>>> We will ring a supplier and get a quote for a product,
>>> agree the terms
>>> e.g. pay first then they send the goods or 30 days credit
>>> or pay on
>>> delivery of goods. Then create a Purchase Order and then
>>> wire them the
>>> payment, the goods will then be delivered to our warehouse
>>> where we
>>> receive against the PO.
>>>
>>> Sometimes the supplier can send too much or too little
>>> goods at which
>>> point either our purchasing department chases them for more
>>> products or
>>> we then send an additional wire for the extra cash or we
>>> get credit from
>>> the supplier to use against the next order.
>>>
>>> From my understanding of the flow of OFBiz you need to
>>> create the
>>> Purchase Order, approve it and then once the goods have
>>> been received in
>>> full the Purchase Invoice is generated which then kicks in
>>> the
>>> Agreements which you set during the creation of the
>>> Purchase Invoice and
>>> finally the Purchase Invoice is shown to the Accounts
>>> Payable team for
>>> payment.
>>>
>>> Yes I agree that this seems the wrong way round but this is
>>> how the
>>> business is done here and I can't change that - China can
>>> seem very
>>> inefficient at times.
>>>
>>> Perhaps a On/Off switch for this code could be made - then
>>> it suits all
>>> companies? How best to make this work for everyone?
>>>
>>> Cheers
>>> Sam
>>>

Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Sam Hamilton <sa...@sh81.com>.
Hey Adrian,

While its true most don't go this way, if you bought some books from
Amazon then you would need to pay before they would ship ;-)

This kind of interaction happens when the transaction is between 2
businesses where the supplier is used to dealing with end consumers
rather than businesses that request credit.

Cheers
Sam



On 05/05/2010 13:14, Adrian Crum wrote:
> Yeah, that scenario sounds pretty specific. That's not how most US businesses work.
> 
> -Adrian
> 
> --- On Tue, 5/4/10, Sam Hamilton <sa...@sh81.com> wrote:
> 
>> From: Sam Hamilton <sa...@sh81.com>
>> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml
>> To: dev@ofbiz.apache.org
>> Date: Tuesday, May 4, 2010, 8:00 PM
>> Hi Scott,
>>
>> We will ring a supplier and get a quote for a product,
>> agree the terms
>> e.g. pay first then they send the goods or 30 days credit
>> or pay on
>> delivery of goods. Then create a Purchase Order and then
>> wire them the
>> payment, the goods will then be delivered to our warehouse
>> where we
>> receive against the PO.
>>
>> Sometimes the supplier can send too much or too little
>> goods at which
>> point either our purchasing department chases them for more
>> products or
>> we then send an additional wire for the extra cash or we
>> get credit from
>> the supplier to use against the next order.
>>
>> From my understanding of the flow of OFBiz you need to
>> create the
>> Purchase Order, approve it and then once the goods have
>> been received in
>> full the Purchase Invoice is generated which then kicks in
>> the
>> Agreements which you set during the creation of the
>> Purchase Invoice and
>> finally the Purchase Invoice is shown to the Accounts
>> Payable team for
>> payment.
>>
>> Yes I agree that this seems the wrong way round but this is
>> how the
>> business is done here and I can't change that - China can
>> seem very
>> inefficient at times.
>>
>> Perhaps a On/Off switch for this code could be made - then
>> it suits all
>> companies? How best to make this work for everyone?
>>
>> Cheers
>> Sam
>>
>>
>>
>> On 05/05/2010 10:34, Scott Gray wrote:
>>> Surely they invoice you beforehand though?
>>>
>>> The payment should be created based on that.
>>>
>>> Regards
>>> Scott
>>>
>>> On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
>>>
>>>> Hi Guys,
>>>>
>>>> Its for suppliers who need the payment of the
>> invoice before the goods
>>>> will be shipped e.g. they don't give credit.
>>>>
>>>> Sam
>>>>
>>>>
>>>> On 05/05/2010 10:24, BJ Freeman wrote:
>>>>> more for my understanding, I believe an
>> invoice for a PO is internal not
>>>>> sent to the supplier, if I remember a previous
>> thread on the ml.
>>>>> and that it is used to reconcile against the
>> invoice received from the
>>>>> supplier.
>>>>> I did something similar.
>>>>>
>>>>> ========================
>>>>>
>>>>> BJ Freeman
>>>>> http://bjfreeman.elance.com
>>>>> Strategic Power Office with Supplier
>> Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>>>>> Specialtymarket.com <http://www.specialtymarket.com/>
>>>>>
>>>>> Systems Integrator-- Glad to Assist
>>>>>
>>>>> Chat  Y! messenger: bjfr33man
>>>>> Linkedin
>>>>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>>>>>
>>>>>
>>>>> Scott Gray sent the following on 5/4/2010 6:56
>> PM:
>>>>>> Hi Hans,
>>>>>>
>>>>>> Wouldn't you do this when an order is
>> received (i.e. an invoice created) rather than when the
>> order is placed?
>>>>>>
>>>>>> Typically payment due dates are based on
>> the invoice date not the order date.
>>>>>>
>>>>>> Regards
>>>>>> Scott
>>>>>>
>>>>>> HotWax Media
>>>>>> http://www.hotwaxmedia.com
>>>>>>
>>>>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org
>> wrote:
>>>>>>
>>>>>>> Author: hansbak
>>>>>>> Date: Wed May  5 01:43:45 2010
>>>>>>> New Revision: 941132
>>>>>>>
>>>>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>>>>>> Log:
>>>>>>> Create a payment with the status
>> 'not-paid' when a purchase order is approved setting the
>> payment date according agreements
>>>>>>>
>>>>>>> Modified:
>>>>>>>    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>>    ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>>    ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>>>
>>>>>>> Modified:
>> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>>
>> ==============================================================================
>>>>>>> ---
>> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>> (original)
>>>>>>> +++
>> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>> Wed May  5 01:43:45 2010
>>>>>>> @@ -746,4 +746,72 @@ under the
>> License.
>>>>>>>          
>>   <clear-field field="setPaymentStatusMap"/>
>>>>>>>        
>> </iterate>
>>>>>>>     </simple-method>
>>>>>>> -</simple-methods>
>>>>>>> +
>>>>>>> +    <simple-method
>> method-name="createPaymentFromOrder"
>> short-description="Service auto create Payment from
>> Order">
>>>>>>> +       
>> <entity-one value-field="orderHeader"
>> entity-name="OrderHeader"/>
>>>>>>> +       
>> <entity-and list="orderRoleToList"
>> entity-name="OrderRole">
>>>>>>> +         
>>   <field-map field-name="orderId"
>> from-field="orderHeader.orderId"/>
>>>>>>> +         
>>   <field-map field-name="roleTypeId"
>> value="BILL_FROM_VENDOR"/>
>>>>>>> +       
>> </entity-and>
>>>>>>> +       
>> <first-from-list entry="orderRoleTo"
>> list="orderRoleToList"/>
>>>>>>> +       
>> <entity-and list="orderRoleFromList"
>> entity-name="OrderRole">
>>>>>>> +         
>>   <field-map field-name="orderId"
>> from-field="orderHeader.orderId"/>
>>>>>>> +         
>>   <field-map field-name="roleTypeId"
>> value="BILL_TO_CUSTOMER"/>
>>>>>>> +       
>> </entity-and>
>>>>>>> +       
>> <first-from-list entry="orderRoleFrom"
>> list="orderRoleFromList"/>
>>>>>>> +       
>> <if-compare operator="equals" value="PURCHASE_ORDER"
>> field="orderHeader.orderTypeId">
>>>>>>> +         
>>   <entity-and list="agreementList"
>> entity-name="Agreement" filter-by-date="true">
>>>>>>> +         
>>       <field-map field-name="partyIdFrom"
>> from-field="orderRoleFrom.partyId"/>
>>>>>>> +         
>>       <field-map field-name="partyIdTo"
>> from-field="orderRoleTo.partyId"/>
>>>>>>> +         
>>       <field-map
>> field-name="agreementTypeId"
>> value="PURCHASE_AGREEMENT"/>
>>>>>>> +         
>>   </entity-and>
>>>>>>> +         
>>   <set field="parameters.paymentTypeId"
>> value="VENDOR_PAYMENT"/>
>>>>>>> +         
>>   <else>
>>>>>>> +         
>>      <entity-and list="agreementList"
>> entity-name="Agreement" filter-by-date="true">
>>>>>>> +         
>>           <field-map
>> field-name="partyIdFrom"
>> from-field="orderRoleFrom.partyId"/>
>>>>>>> +         
>>           <field-map
>> field-name="partyIdTo"
>> from-field="orderRoleTo.partyId"/>
>>>>>>> +         
>>           <field-map
>> field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>>>>> +         
>>       </entity-and>
>>>>>>> +         
>>       <set
>> field="parameters.paymentTypeId"
>> value="CUSTOMER_PAYMENT"/>
>>>>>>> +         
>>   </else>
>>>>>>> +       
>> </if-compare>
>>>>>>> +       
>> <first-from-list entry="agreement"
>> list="agreementList"/>
>>>>>>> +       
>> <if-not-empty field="agreement">
>>>>>>> +         
>>   <entity-and list="orderTermList"
>> entity-name="OrderTerm">
>>>>>>> +         
>>       <field-map field-name="orderId"
>> from-field="orderHeader.orderId"/>
>>>>>>> +         
>>       <field-map field-name="termTypeId"
>> value="FIN_PAYMENT_TERM"/>
>>>>>>> +         
>>   </entity-and>
>>>>>>> +         
>>   <first-from-list entry="orderTerm"
>> list="orderTermList"/>
>>>>>>> +         
>>   <if-not-empty field="orderTerm.termDays">
>>>>>>> +         
>>       <set field="days"
>> from-field="orderTerm.termDays" type="Integer"/>
>>>>>>> +         
>>       <now-timestamp field="start"/>
>>>>>>> +         
>>       <call-class-method
>> class-name="org.ofbiz.base.util.UtilDateTime"
>> method-name="addDaysToTimestamp"
>> ret-field="parameters.effectiveDate">
>>>>>>> +         
>>           <field field="start"
>> type="java.sql.Timestamp"/>
>>>>>>> +         
>>           <field field="days"
>> type="int"/>
>>>>>>> +         
>>       </call-class-method>
>>>>>>> +         
>>   </if-not-empty>
>>>>>>> +       
>> </if-not-empty>
>>>>>>> +       
>> <if-empty field="parameters.effectiveDate">
>>>>>>> +         
>>   <now-timestamp
>> field="parameters.effectiveDate"/>
>>>>>>> +       
>> </if-empty>
>>>>>>> +        <set
>> field="parameters.partyIdFrom"
>> from-field="orderRoleFrom.partyId"/>
>>>>>>> +        <set
>> field="parameters.partyIdTo"
>> from-field="orderRoleTo.partyId"/>
>>>>>>> +        <set
>> field="parameters.amount"
>> from-field="orderHeader.grandTotal"/>
>>>>>>> +        <set
>> field="parameters.currencyUomId"
>> from-field="orderHeader.currencyUom"/>
>>>>>>> +        <set
>> field="parameters.paymentMethodTypeId"
>> value="COMPANY_ACCOUNT"/>
>>>>>>> +        <set
>> field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>>>>> +       
>> <set-service-fields service-name="createPayment"
>> to-map="createPayment" map="parameters"/>
>>>>>>> +       
>> <call-service service-name="createPayment"
>> in-map-name="createPayment">
>>>>>>> +         
>>   <result-to-field result-name="paymentId"
>> field="parameters.paymentId"/>
>>>>>>> +       
>> </call-service>
>>>>>>> +        <set
>> field="parameters.orderId"
>> from-field="orderHeader.orderId"/>
>>>>>>> +        <set
>> field="parameters.maxAmount"
>> from-field="orderHeader.grandTotal"/>
>>>>>>> +       
>> <set-service-fields
>> service-name="createOrderPaymentPreference"
>> to-map="newOrderPaymentPreference" map="parameters"/>
>>>>>>> +       
>> <call-service service-name="createOrderPaymentPreference"
>> in-map-name="newOrderPaymentPreference">
>>>>>>> +         
>>   <result-to-field
>> result-name="orderPaymentPreferenceId"
>> field="parameters.paymentPreferenceId"/>
>>>>>>> +       
>> </call-service>
>>>>>>> +       
>> <set-service-fields service-name="updatePayment"
>> to-map="updatePayment" map="parameters"/>
>>>>>>> +       
>> <call-service service-name="updatePayment"
>> in-map-name="updatePayment"/>
>>>>>>> +       
>> <field-to-result field="parameters.paymentId"
>> result-name="paymentId"/>
>>>>>>> +    </simple-method>
>>>>>>> +</simple-methods>
>>>>>>> \ No newline at end of file
>>>>>>>
>>>>>>> Modified:
>> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>>
>> ==============================================================================
>>>>>>> ---
>> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>> (original)
>>>>>>> +++
>> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>> Wed May  5 01:43:45 2010
>>>>>>> @@ -233,4 +233,11 @@ under the
>> License.
>>>>>>>        
>> <attribute name="statusId" type="String" mode="IN"
>> optional="false"/>
>>>>>>>        
>> <attribute name="errorMessage" type="String"
>> optional="true" mode="OUT"/>
>>>>>>>     </service>
>>>>>>> +
>>>>>>> +    <service
>> name="createPaymentFromOrder" engine="simple"
>>>>>>> +       
>> location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml"
>> invoke="createPaymentFromOrder" auth="true">
>>>>>>> +       
>> <description>create Payment from
>> Order</description>
>>>>>>> +       
>> <attribute name="orderId" type="String" mode="IN"
>> optional="false"/>
>>>>>>> +       
>> <attribute name="paymentId" type="String" mode="OUT"
>> optional="false"/>
>>>>>>> +    </service>
>>>>>>> </services>
>>>>>>>
>>>>>>> Modified:
>> ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>>>>
>> ==============================================================================
>>>>>>> ---
>> ofbiz/trunk/applications/order/servicedef/secas.xml
>> (original)
>>>>>>> +++
>> ofbiz/trunk/applications/order/servicedef/secas.xml Wed
>> May  5 01:43:45 2010
>>>>>>> @@ -93,6 +93,12 @@ under the License.
>>>>>>>         <action
>> service="resetGrandTotal" mode="sync"/>
>>>>>>>         <action
>> service="sendOrderCompleteNotification" mode="async"
>> persist="true"/>
>>>>>>>     </eca>
>>>>>>> +    <eca
>> service="changeOrderStatus" event="commit"
>> run-on-error="false">
>>>>>>> +       
>> <condition field-name="orderTypeId" operator="equals"
>> value="PURCHASE_ORDER"/>
>>>>>>> +       
>> <condition field-name="statusId" operator="equals"
>> value="ORDER_APPROVED"/>
>>>>>>> +       
>> <condition-field field-name="statusId"
>> operator="not-equals" to-field-name="oldStatusId"/>
>>>>>>> +       
>> <action service="createPaymentFromOrder" mode="sync"
>> persist="true"/>
>>>>>>> +    </eca>
>>>>>>>
>>>>>>>     <!-- DISABLED FOR NOW
>>>>>>>     <eca
>> service="changeOrderStatus" event="commit"
>> run-on-error="false">
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>>
> 
> 
>       


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Adrian Crum <ad...@yahoo.com>.
Yeah, that scenario sounds pretty specific. That's not how most US businesses work.

-Adrian

--- On Tue, 5/4/10, Sam Hamilton <sa...@sh81.com> wrote:

> From: Sam Hamilton <sa...@sh81.com>
> Subject: Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml
> To: dev@ofbiz.apache.org
> Date: Tuesday, May 4, 2010, 8:00 PM
> Hi Scott,
> 
> We will ring a supplier and get a quote for a product,
> agree the terms
> e.g. pay first then they send the goods or 30 days credit
> or pay on
> delivery of goods. Then create a Purchase Order and then
> wire them the
> payment, the goods will then be delivered to our warehouse
> where we
> receive against the PO.
> 
> Sometimes the supplier can send too much or too little
> goods at which
> point either our purchasing department chases them for more
> products or
> we then send an additional wire for the extra cash or we
> get credit from
> the supplier to use against the next order.
> 
> From my understanding of the flow of OFBiz you need to
> create the
> Purchase Order, approve it and then once the goods have
> been received in
> full the Purchase Invoice is generated which then kicks in
> the
> Agreements which you set during the creation of the
> Purchase Invoice and
> finally the Purchase Invoice is shown to the Accounts
> Payable team for
> payment.
> 
> Yes I agree that this seems the wrong way round but this is
> how the
> business is done here and I can't change that - China can
> seem very
> inefficient at times.
> 
> Perhaps a On/Off switch for this code could be made - then
> it suits all
> companies? How best to make this work for everyone?
> 
> Cheers
> Sam
> 
> 
> 
> On 05/05/2010 10:34, Scott Gray wrote:
> > Surely they invoice you beforehand though?
> > 
> > The payment should be created based on that.
> > 
> > Regards
> > Scott
> > 
> > On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
> > 
> >> Hi Guys,
> >>
> >> Its for suppliers who need the payment of the
> invoice before the goods
> >> will be shipped e.g. they don't give credit.
> >>
> >> Sam
> >>
> >>
> >> On 05/05/2010 10:24, BJ Freeman wrote:
> >>> more for my understanding, I believe an
> invoice for a PO is internal not
> >>> sent to the supplier, if I remember a previous
> thread on the ml.
> >>> and that it is used to reconcile against the
> invoice received from the
> >>> supplier.
> >>> I did something similar.
> >>>
> >>> ========================
> >>>
> >>> BJ Freeman
> >>> http://bjfreeman.elance.com
> >>> Strategic Power Office with Supplier
> Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
> >>> Specialtymarket.com <http://www.specialtymarket.com/>
> >>>
> >>> Systems Integrator-- Glad to Assist
> >>>
> >>> Chat  Y! messenger: bjfr33man
> >>> Linkedin
> >>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
> >>>
> >>>
> >>> Scott Gray sent the following on 5/4/2010 6:56
> PM:
> >>>> Hi Hans,
> >>>>
> >>>> Wouldn't you do this when an order is
> received (i.e. an invoice created) rather than when the
> order is placed?
> >>>>
> >>>> Typically payment due dates are based on
> the invoice date not the order date.
> >>>>
> >>>> Regards
> >>>> Scott
> >>>>
> >>>> HotWax Media
> >>>> http://www.hotwaxmedia.com
> >>>>
> >>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org
> wrote:
> >>>>
> >>>>> Author: hansbak
> >>>>> Date: Wed May  5 01:43:45 2010
> >>>>> New Revision: 941132
> >>>>>
> >>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
> >>>>> Log:
> >>>>> Create a payment with the status
> 'not-paid' when a purchase order is approved setting the
> payment date according agreements
> >>>>>
> >>>>> Modified:
> >>>>>   ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> >>>>>   ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> >>>>>   ofbiz/trunk/applications/order/servicedef/secas.xml
> >>>>>
> >>>>> Modified:
> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
> >>>>>
> ==============================================================================
> >>>>> ---
> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> (original)
> >>>>> +++
> ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> Wed May  5 01:43:45 2010
> >>>>> @@ -746,4 +746,72 @@ under the
> License.
> >>>>>         
>   <clear-field field="setPaymentStatusMap"/>
> >>>>>       
> </iterate>
> >>>>>    </simple-method>
> >>>>> -</simple-methods>
> >>>>> +
> >>>>> +    <simple-method
> method-name="createPaymentFromOrder"
> short-description="Service auto create Payment from
> Order">
> >>>>> +       
> <entity-one value-field="orderHeader"
> entity-name="OrderHeader"/>
> >>>>> +       
> <entity-and list="orderRoleToList"
> entity-name="OrderRole">
> >>>>> +         
>   <field-map field-name="orderId"
> from-field="orderHeader.orderId"/>
> >>>>> +         
>   <field-map field-name="roleTypeId"
> value="BILL_FROM_VENDOR"/>
> >>>>> +       
> </entity-and>
> >>>>> +       
> <first-from-list entry="orderRoleTo"
> list="orderRoleToList"/>
> >>>>> +       
> <entity-and list="orderRoleFromList"
> entity-name="OrderRole">
> >>>>> +         
>   <field-map field-name="orderId"
> from-field="orderHeader.orderId"/>
> >>>>> +         
>   <field-map field-name="roleTypeId"
> value="BILL_TO_CUSTOMER"/>
> >>>>> +       
> </entity-and>
> >>>>> +       
> <first-from-list entry="orderRoleFrom"
> list="orderRoleFromList"/>
> >>>>> +       
> <if-compare operator="equals" value="PURCHASE_ORDER"
> field="orderHeader.orderTypeId">
> >>>>> +         
>   <entity-and list="agreementList"
> entity-name="Agreement" filter-by-date="true">
> >>>>> +         
>       <field-map field-name="partyIdFrom"
> from-field="orderRoleFrom.partyId"/>
> >>>>> +         
>       <field-map field-name="partyIdTo"
> from-field="orderRoleTo.partyId"/>
> >>>>> +         
>       <field-map
> field-name="agreementTypeId"
> value="PURCHASE_AGREEMENT"/>
> >>>>> +         
>   </entity-and>
> >>>>> +         
>   <set field="parameters.paymentTypeId"
> value="VENDOR_PAYMENT"/>
> >>>>> +         
>   <else>
> >>>>> +         
>      <entity-and list="agreementList"
> entity-name="Agreement" filter-by-date="true">
> >>>>> +         
>           <field-map
> field-name="partyIdFrom"
> from-field="orderRoleFrom.partyId"/>
> >>>>> +         
>           <field-map
> field-name="partyIdTo"
> from-field="orderRoleTo.partyId"/>
> >>>>> +         
>           <field-map
> field-name="agreementTypeId" value="SALES_AGREEMENT"/>
> >>>>> +         
>       </entity-and>
> >>>>> +         
>       <set
> field="parameters.paymentTypeId"
> value="CUSTOMER_PAYMENT"/>
> >>>>> +         
>   </else>
> >>>>> +       
> </if-compare>
> >>>>> +       
> <first-from-list entry="agreement"
> list="agreementList"/>
> >>>>> +       
> <if-not-empty field="agreement">
> >>>>> +         
>   <entity-and list="orderTermList"
> entity-name="OrderTerm">
> >>>>> +         
>       <field-map field-name="orderId"
> from-field="orderHeader.orderId"/>
> >>>>> +         
>       <field-map field-name="termTypeId"
> value="FIN_PAYMENT_TERM"/>
> >>>>> +         
>   </entity-and>
> >>>>> +         
>   <first-from-list entry="orderTerm"
> list="orderTermList"/>
> >>>>> +         
>   <if-not-empty field="orderTerm.termDays">
> >>>>> +         
>       <set field="days"
> from-field="orderTerm.termDays" type="Integer"/>
> >>>>> +         
>       <now-timestamp field="start"/>
> >>>>> +         
>       <call-class-method
> class-name="org.ofbiz.base.util.UtilDateTime"
> method-name="addDaysToTimestamp"
> ret-field="parameters.effectiveDate">
> >>>>> +         
>           <field field="start"
> type="java.sql.Timestamp"/>
> >>>>> +         
>           <field field="days"
> type="int"/>
> >>>>> +         
>       </call-class-method>
> >>>>> +         
>   </if-not-empty>
> >>>>> +       
> </if-not-empty>
> >>>>> +       
> <if-empty field="parameters.effectiveDate">
> >>>>> +         
>   <now-timestamp
> field="parameters.effectiveDate"/>
> >>>>> +       
> </if-empty>
> >>>>> +        <set
> field="parameters.partyIdFrom"
> from-field="orderRoleFrom.partyId"/>
> >>>>> +        <set
> field="parameters.partyIdTo"
> from-field="orderRoleTo.partyId"/>
> >>>>> +        <set
> field="parameters.amount"
> from-field="orderHeader.grandTotal"/>
> >>>>> +        <set
> field="parameters.currencyUomId"
> from-field="orderHeader.currencyUom"/>
> >>>>> +        <set
> field="parameters.paymentMethodTypeId"
> value="COMPANY_ACCOUNT"/>
> >>>>> +        <set
> field="parameters.statusId" value="PMNT_NOT_PAID"/>
> >>>>> +       
> <set-service-fields service-name="createPayment"
> to-map="createPayment" map="parameters"/>
> >>>>> +       
> <call-service service-name="createPayment"
> in-map-name="createPayment">
> >>>>> +         
>   <result-to-field result-name="paymentId"
> field="parameters.paymentId"/>
> >>>>> +       
> </call-service>
> >>>>> +        <set
> field="parameters.orderId"
> from-field="orderHeader.orderId"/>
> >>>>> +        <set
> field="parameters.maxAmount"
> from-field="orderHeader.grandTotal"/>
> >>>>> +       
> <set-service-fields
> service-name="createOrderPaymentPreference"
> to-map="newOrderPaymentPreference" map="parameters"/>
> >>>>> +       
> <call-service service-name="createOrderPaymentPreference"
> in-map-name="newOrderPaymentPreference">
> >>>>> +         
>   <result-to-field
> result-name="orderPaymentPreferenceId"
> field="parameters.paymentPreferenceId"/>
> >>>>> +       
> </call-service>
> >>>>> +       
> <set-service-fields service-name="updatePayment"
> to-map="updatePayment" map="parameters"/>
> >>>>> +       
> <call-service service-name="updatePayment"
> in-map-name="updatePayment"/>
> >>>>> +       
> <field-to-result field="parameters.paymentId"
> result-name="paymentId"/>
> >>>>> +    </simple-method>
> >>>>> +</simple-methods>
> >>>>> \ No newline at end of file
> >>>>>
> >>>>> Modified:
> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
> >>>>>
> ==============================================================================
> >>>>> ---
> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> (original)
> >>>>> +++
> ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> Wed May  5 01:43:45 2010
> >>>>> @@ -233,4 +233,11 @@ under the
> License.
> >>>>>       
> <attribute name="statusId" type="String" mode="IN"
> optional="false"/>
> >>>>>       
> <attribute name="errorMessage" type="String"
> optional="true" mode="OUT"/>
> >>>>>    </service>
> >>>>> +
> >>>>> +    <service
> name="createPaymentFromOrder" engine="simple"
> >>>>> +       
> location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml"
> invoke="createPaymentFromOrder" auth="true">
> >>>>> +       
> <description>create Payment from
> Order</description>
> >>>>> +       
> <attribute name="orderId" type="String" mode="IN"
> optional="false"/>
> >>>>> +       
> <attribute name="paymentId" type="String" mode="OUT"
> optional="false"/>
> >>>>> +    </service>
> >>>>> </services>
> >>>>>
> >>>>> Modified:
> ofbiz/trunk/applications/order/servicedef/secas.xml
> >>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
> >>>>>
> ==============================================================================
> >>>>> ---
> ofbiz/trunk/applications/order/servicedef/secas.xml
> (original)
> >>>>> +++
> ofbiz/trunk/applications/order/servicedef/secas.xml Wed
> May  5 01:43:45 2010
> >>>>> @@ -93,6 +93,12 @@ under the License.
> >>>>>        <action
> service="resetGrandTotal" mode="sync"/>
> >>>>>        <action
> service="sendOrderCompleteNotification" mode="async"
> persist="true"/>
> >>>>>    </eca>
> >>>>> +    <eca
> service="changeOrderStatus" event="commit"
> run-on-error="false">
> >>>>> +       
> <condition field-name="orderTypeId" operator="equals"
> value="PURCHASE_ORDER"/>
> >>>>> +       
> <condition field-name="statusId" operator="equals"
> value="ORDER_APPROVED"/>
> >>>>> +       
> <condition-field field-name="statusId"
> operator="not-equals" to-field-name="oldStatusId"/>
> >>>>> +       
> <action service="createPaymentFromOrder" mode="sync"
> persist="true"/>
> >>>>> +    </eca>
> >>>>>
> >>>>>    <!-- DISABLED FOR NOW
> >>>>>    <eca
> service="changeOrderStatus" event="commit"
> run-on-error="false">
> >>>>>
> >>>>>
> >>>>
> >>>
> >>>
> >>
> > 
> 
> 


      

Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Sam Hamilton <sa...@sh81.com>.
Hi Scott,

We will ring a supplier and get a quote for a product, agree the terms
e.g. pay first then they send the goods or 30 days credit or pay on
delivery of goods. Then create a Purchase Order and then wire them the
payment, the goods will then be delivered to our warehouse where we
receive against the PO.

Sometimes the supplier can send too much or too little goods at which
point either our purchasing department chases them for more products or
we then send an additional wire for the extra cash or we get credit from
the supplier to use against the next order.

>From my understanding of the flow of OFBiz you need to create the
Purchase Order, approve it and then once the goods have been received in
full the Purchase Invoice is generated which then kicks in the
Agreements which you set during the creation of the Purchase Invoice and
finally the Purchase Invoice is shown to the Accounts Payable team for
payment.

Yes I agree that this seems the wrong way round but this is how the
business is done here and I can't change that - China can seem very
inefficient at times.

Perhaps a On/Off switch for this code could be made - then it suits all
companies? How best to make this work for everyone?

Cheers
Sam



On 05/05/2010 10:34, Scott Gray wrote:
> Surely they invoice you beforehand though?
> 
> The payment should be created based on that.
> 
> Regards
> Scott
> 
> On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:
> 
>> Hi Guys,
>>
>> Its for suppliers who need the payment of the invoice before the goods
>> will be shipped e.g. they don't give credit.
>>
>> Sam
>>
>>
>> On 05/05/2010 10:24, BJ Freeman wrote:
>>> more for my understanding, I believe an invoice for a PO is internal not
>>> sent to the supplier, if I remember a previous thread on the ml.
>>> and that it is used to reconcile against the invoice received from the
>>> supplier.
>>> I did something similar.
>>>
>>> ========================
>>>
>>> BJ Freeman
>>> http://bjfreeman.elance.com
>>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>>> Specialtymarket.com <http://www.specialtymarket.com/>
>>>
>>> Systems Integrator-- Glad to Assist
>>>
>>> Chat  Y! messenger: bjfr33man
>>> Linkedin
>>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>>>
>>>
>>> Scott Gray sent the following on 5/4/2010 6:56 PM:
>>>> Hi Hans,
>>>>
>>>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>>>>
>>>> Typically payment due dates are based on the invoice date not the order date.
>>>>
>>>> Regards
>>>> Scott
>>>>
>>>> HotWax Media
>>>> http://www.hotwaxmedia.com
>>>>
>>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>>>>
>>>>> Author: hansbak
>>>>> Date: Wed May  5 01:43:45 2010
>>>>> New Revision: 941132
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>>>> Log:
>>>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>>>>
>>>>> Modified:
>>>>>   ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>>   ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>>   ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>>
>>>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>> ==============================================================================
>>>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>>>> @@ -746,4 +746,72 @@ under the License.
>>>>>            <clear-field field="setPaymentStatusMap"/>
>>>>>        </iterate>
>>>>>    </simple-method>
>>>>> -</simple-methods>
>>>>> +
>>>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>>>> +        </entity-and>
>>>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>>>> +        </entity-and>
>>>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>>>> +            </entity-and>
>>>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>>>> +            <else>
>>>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>>> +                </entity-and>
>>>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>>>> +            </else>
>>>>> +        </if-compare>
>>>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>>>> +        <if-not-empty field="agreement">
>>>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>>>> +            </entity-and>
>>>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>>>> +            <if-not-empty field="orderTerm.termDays">
>>>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>>>> +                <now-timestamp field="start"/>
>>>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>>>> +                    <field field="days" type="int"/>
>>>>> +                </call-class-method>
>>>>> +            </if-not-empty>
>>>>> +        </if-not-empty>
>>>>> +        <if-empty field="parameters.effectiveDate">
>>>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>>>> +        </if-empty>
>>>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>>>> +        </call-service>
>>>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>>>> +        </call-service>
>>>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>>>> +    </simple-method>
>>>>> +</simple-methods>
>>>>> \ No newline at end of file
>>>>>
>>>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>> ==============================================================================
>>>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>>>> @@ -233,4 +233,11 @@ under the License.
>>>>>        <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>>>        <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>>>    </service>
>>>>> +
>>>>> +    <service name="createPaymentFromOrder" engine="simple"
>>>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>>>> +        <description>create Payment from Order</description>
>>>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>>>> +    </service>
>>>>> </services>
>>>>>
>>>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>>> ==============================================================================
>>>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>>>> @@ -93,6 +93,12 @@ under the License.
>>>>>        <action service="resetGrandTotal" mode="sync"/>
>>>>>        <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>>>    </eca>
>>>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>>>> +    </eca>
>>>>>
>>>>>    <!-- DISABLED FOR NOW
>>>>>    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>>>
>>>>>
>>>>
>>>
>>>
>>
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Surely they invoice you beforehand though?

The payment should be created based on that.

Regards
Scott

On 5/05/2010, at 2:28 PM, Sam Hamilton wrote:

> Hi Guys,
> 
> Its for suppliers who need the payment of the invoice before the goods
> will be shipped e.g. they don't give credit.
> 
> Sam
> 
> 
> On 05/05/2010 10:24, BJ Freeman wrote:
>> more for my understanding, I believe an invoice for a PO is internal not
>> sent to the supplier, if I remember a previous thread on the ml.
>> and that it is used to reconcile against the invoice received from the
>> supplier.
>> I did something similar.
>> 
>> ========================
>> 
>> BJ Freeman
>> http://bjfreeman.elance.com
>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>> Specialtymarket.com <http://www.specialtymarket.com/>
>> 
>> Systems Integrator-- Glad to Assist
>> 
>> Chat  Y! messenger: bjfr33man
>> Linkedin
>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>> 
>> 
>> Scott Gray sent the following on 5/4/2010 6:56 PM:
>>> Hi Hans,
>>> 
>>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>>> 
>>> Typically payment due dates are based on the invoice date not the order date.
>>> 
>>> Regards
>>> Scott
>>> 
>>> HotWax Media
>>> http://www.hotwaxmedia.com
>>> 
>>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>>> 
>>>> Author: hansbak
>>>> Date: Wed May  5 01:43:45 2010
>>>> New Revision: 941132
>>>> 
>>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>>> Log:
>>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>>> 
>>>> Modified:
>>>>   ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>>   ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>>   ofbiz/trunk/applications/order/servicedef/secas.xml
>>>> 
>>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>> ==============================================================================
>>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>>> @@ -746,4 +746,72 @@ under the License.
>>>>            <clear-field field="setPaymentStatusMap"/>
>>>>        </iterate>
>>>>    </simple-method>
>>>> -</simple-methods>
>>>> +
>>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>>> +        </entity-and>
>>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>>> +        </entity-and>
>>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>>> +            </entity-and>
>>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>>> +            <else>
>>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>>> +                </entity-and>
>>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>>> +            </else>
>>>> +        </if-compare>
>>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>>> +        <if-not-empty field="agreement">
>>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>>> +            </entity-and>
>>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>>> +            <if-not-empty field="orderTerm.termDays">
>>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>>> +                <now-timestamp field="start"/>
>>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>>> +                    <field field="days" type="int"/>
>>>> +                </call-class-method>
>>>> +            </if-not-empty>
>>>> +        </if-not-empty>
>>>> +        <if-empty field="parameters.effectiveDate">
>>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>>> +        </if-empty>
>>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>>> +        </call-service>
>>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>>> +        </call-service>
>>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>>> +    </simple-method>
>>>> +</simple-methods>
>>>> \ No newline at end of file
>>>> 
>>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>> ==============================================================================
>>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>>> @@ -233,4 +233,11 @@ under the License.
>>>>        <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>>        <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>>    </service>
>>>> +
>>>> +    <service name="createPaymentFromOrder" engine="simple"
>>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>>> +        <description>create Payment from Order</description>
>>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>>> +    </service>
>>>> </services>
>>>> 
>>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>>> ==============================================================================
>>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>>> @@ -93,6 +93,12 @@ under the License.
>>>>        <action service="resetGrandTotal" mode="sync"/>
>>>>        <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>>    </eca>
>>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>>> +    </eca>
>>>> 
>>>>    <!-- DISABLED FOR NOW
>>>>    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>> 
>>>> 
>>> 
>> 
>> 
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Sam Hamilton <sa...@sh81.com>.
Hi Guys,

Its for suppliers who need the payment of the invoice before the goods
will be shipped e.g. they don't give credit.

Sam


On 05/05/2010 10:24, BJ Freeman wrote:
> more for my understanding, I believe an invoice for a PO is internal not
> sent to the supplier, if I remember a previous thread on the ml.
> and that it is used to reconcile against the invoice received from the
> supplier.
> I did something similar.
> 
> ========================
> 
> BJ Freeman
> http://bjfreeman.elance.com
> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
> Specialtymarket.com <http://www.specialtymarket.com/>
> 
> Systems Integrator-- Glad to Assist
> 
> Chat  Y! messenger: bjfr33man
> Linkedin
> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
> 
> 
> Scott Gray sent the following on 5/4/2010 6:56 PM:
>> Hi Hans,
>>
>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>>
>> Typically payment due dates are based on the invoice date not the order date.
>>
>> Regards
>> Scott
>>
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>>
>>> Author: hansbak
>>> Date: Wed May  5 01:43:45 2010
>>> New Revision: 941132
>>>
>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>> Log:
>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>>
>>> Modified:
>>>    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>    ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>    ofbiz/trunk/applications/order/servicedef/secas.xml
>>>
>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>> @@ -746,4 +746,72 @@ under the License.
>>>             <clear-field field="setPaymentStatusMap"/>
>>>         </iterate>
>>>     </simple-method>
>>> -</simple-methods>
>>> +
>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>> +        </entity-and>
>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>> +        </entity-and>
>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>> +            </entity-and>
>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>> +            <else>
>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>> +                </entity-and>
>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>> +            </else>
>>> +        </if-compare>
>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>> +        <if-not-empty field="agreement">
>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>> +            </entity-and>
>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>> +            <if-not-empty field="orderTerm.termDays">
>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>> +                <now-timestamp field="start"/>
>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>> +                    <field field="days" type="int"/>
>>> +                </call-class-method>
>>> +            </if-not-empty>
>>> +        </if-not-empty>
>>> +        <if-empty field="parameters.effectiveDate">
>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>> +        </if-empty>
>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>> +        </call-service>
>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>> +        </call-service>
>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>> +    </simple-method>
>>> +</simple-methods>
>>> \ No newline at end of file
>>>
>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>> @@ -233,4 +233,11 @@ under the License.
>>>         <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>         <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>     </service>
>>> +
>>> +    <service name="createPaymentFromOrder" engine="simple"
>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>> +        <description>create Payment from Order</description>
>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>> +    </service>
>>> </services>
>>>
>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>> @@ -93,6 +93,12 @@ under the License.
>>>         <action service="resetGrandTotal" mode="sync"/>
>>>         <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>     </eca>
>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>> +    </eca>
>>>
>>>     <!-- DISABLED FOR NOW
>>>     <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>>
>>>
>>
> 
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Yeah the order total is an estimate and then an invoice is generated (I think?) using the quantities received and the order's estimate.  The invoice is just an internal representation of the supplier's invoice which we may not have even seen yet.

I would say that we shouldn't be attempting to automatically create a payment until the invoice moves into a 'received' state and the details are actually confirmed.

Regards
Scott

On 5/05/2010, at 2:24 PM, BJ Freeman wrote:

> more for my understanding, I believe an invoice for a PO is internal not
> sent to the supplier, if I remember a previous thread on the ml.
> and that it is used to reconcile against the invoice received from the
> supplier.
> I did something similar.
> 
> ========================
> 
> BJ Freeman
> http://bjfreeman.elance.com
> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
> Specialtymarket.com <http://www.specialtymarket.com/>
> 
> Systems Integrator-- Glad to Assist
> 
> Chat  Y! messenger: bjfr33man
> Linkedin
> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
> 
> 
> Scott Gray sent the following on 5/4/2010 6:56 PM:
>> Hi Hans,
>> 
>> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
>> 
>> Typically payment due dates are based on the invoice date not the order date.
>> 
>> Regards
>> Scott
>> 
>> HotWax Media
>> http://www.hotwaxmedia.com
>> 
>> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
>> 
>>> Author: hansbak
>>> Date: Wed May  5 01:43:45 2010
>>> New Revision: 941132
>>> 
>>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>>> Log:
>>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>> 
>>> Modified:
>>>   ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>>   ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>>   ofbiz/trunk/applications/order/servicedef/secas.xml
>>> 
>>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>>> @@ -746,4 +746,72 @@ under the License.
>>>            <clear-field field="setPaymentStatusMap"/>
>>>        </iterate>
>>>    </simple-method>
>>> -</simple-methods>
>>> +
>>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>>> +        </entity-and>
>>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>>> +        </entity-and>
>>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>>> +            </entity-and>
>>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>>> +            <else>
>>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>>> +                </entity-and>
>>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>>> +            </else>
>>> +        </if-compare>
>>> +        <first-from-list entry="agreement" list="agreementList"/>
>>> +        <if-not-empty field="agreement">
>>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>>> +            </entity-and>
>>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>>> +            <if-not-empty field="orderTerm.termDays">
>>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>>> +                <now-timestamp field="start"/>
>>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>>> +                    <field field="start" type="java.sql.Timestamp"/>
>>> +                    <field field="days" type="int"/>
>>> +                </call-class-method>
>>> +            </if-not-empty>
>>> +        </if-not-empty>
>>> +        <if-empty field="parameters.effectiveDate">
>>> +            <now-timestamp field="parameters.effectiveDate"/>
>>> +        </if-empty>
>>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>>> +        </call-service>
>>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>>> +        </call-service>
>>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>>> +    </simple-method>
>>> +</simple-methods>
>>> \ No newline at end of file
>>> 
>>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>>> @@ -233,4 +233,11 @@ under the License.
>>>        <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>>        <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>>    </service>
>>> +
>>> +    <service name="createPaymentFromOrder" engine="simple"
>>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>>> +        <description>create Payment from Order</description>
>>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>>> +    </service>
>>> </services>
>>> 
>>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>>> @@ -93,6 +93,12 @@ under the License.
>>>        <action service="resetGrandTotal" mode="sync"/>
>>>        <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>>    </eca>
>>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>>> +    </eca>
>>> 
>>>    <!-- DISABLED FOR NOW
>>>    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>> 
>>> 
>> 
> 
> 


Re: svn commit: r941132 - in /ofbiz/trunk/applications: accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml accounting/servicedef/services_payment.xml order/servicedef/secas.xml

Posted by BJ Freeman <bj...@free-man.net>.
more for my understanding, I believe an invoice for a PO is internal not
sent to the supplier, if I remember a previous thread on the ml.
and that it is used to reconcile against the invoice received from the
supplier.
I did something similar.

========================

BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
Specialtymarket.com <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


Scott Gray sent the following on 5/4/2010 6:56 PM:
> Hi Hans,
> 
> Wouldn't you do this when an order is received (i.e. an invoice created) rather than when the order is placed?
> 
> Typically payment due dates are based on the invoice date not the order date.
> 
> Regards
> Scott
> 
> HotWax Media
> http://www.hotwaxmedia.com
> 
> On 5/05/2010, at 1:43 PM, hansbak@apache.org wrote:
> 
>> Author: hansbak
>> Date: Wed May  5 01:43:45 2010
>> New Revision: 941132
>>
>> URL: http://svn.apache.org/viewvc?rev=941132&view=rev
>> Log:
>> Create a payment with the status 'not-paid' when a purchase order is approved setting the payment date according agreements
>>
>> Modified:
>>    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>>    ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>>    ofbiz/trunk/applications/order/servicedef/secas.xml
>>
>> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=941132&r1=941131&r2=941132&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
>> +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Wed May  5 01:43:45 2010
>> @@ -746,4 +746,72 @@ under the License.
>>             <clear-field field="setPaymentStatusMap"/>
>>         </iterate>
>>     </simple-method>
>> -</simple-methods>
>> +
>> +    <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order">
>> +        <entity-one value-field="orderHeader" entity-name="OrderHeader"/>
>> +        <entity-and list="orderRoleToList" entity-name="OrderRole">
>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>> +            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
>> +        </entity-and>
>> +        <first-from-list entry="orderRoleTo" list="orderRoleToList"/>
>> +        <entity-and list="orderRoleFromList" entity-name="OrderRole">
>> +            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>> +            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
>> +        </entity-and>
>> +        <first-from-list entry="orderRoleFrom" list="orderRoleFromList"/>
>> +        <if-compare operator="equals" value="PURCHASE_ORDER" field="orderHeader.orderTypeId">
>> +            <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>> +                <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>> +                <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>> +                <field-map field-name="agreementTypeId" value="PURCHASE_AGREEMENT"/>
>> +            </entity-and>
>> +            <set field="parameters.paymentTypeId" value="VENDOR_PAYMENT"/>
>> +            <else>
>> +               <entity-and list="agreementList" entity-name="Agreement" filter-by-date="true">
>> +                    <field-map field-name="partyIdFrom" from-field="orderRoleFrom.partyId"/>
>> +                    <field-map field-name="partyIdTo" from-field="orderRoleTo.partyId"/>
>> +                    <field-map field-name="agreementTypeId" value="SALES_AGREEMENT"/>
>> +                </entity-and>
>> +                <set field="parameters.paymentTypeId" value="CUSTOMER_PAYMENT"/>
>> +            </else>
>> +        </if-compare>
>> +        <first-from-list entry="agreement" list="agreementList"/>
>> +        <if-not-empty field="agreement">
>> +            <entity-and list="orderTermList" entity-name="OrderTerm">
>> +                <field-map field-name="orderId" from-field="orderHeader.orderId"/>
>> +                <field-map field-name="termTypeId" value="FIN_PAYMENT_TERM"/>
>> +            </entity-and>
>> +            <first-from-list entry="orderTerm" list="orderTermList"/>
>> +            <if-not-empty field="orderTerm.termDays">
>> +                <set field="days" from-field="orderTerm.termDays" type="Integer"/>
>> +                <now-timestamp field="start"/>
>> +                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field="parameters.effectiveDate">
>> +                    <field field="start" type="java.sql.Timestamp"/>
>> +                    <field field="days" type="int"/>
>> +                </call-class-method>
>> +            </if-not-empty>
>> +        </if-not-empty>
>> +        <if-empty field="parameters.effectiveDate">
>> +            <now-timestamp field="parameters.effectiveDate"/>
>> +        </if-empty>
>> +        <set field="parameters.partyIdFrom" from-field="orderRoleFrom.partyId"/>
>> +        <set field="parameters.partyIdTo" from-field="orderRoleTo.partyId"/>
>> +        <set field="parameters.amount" from-field="orderHeader.grandTotal"/>
>> +        <set field="parameters.currencyUomId" from-field="orderHeader.currencyUom"/>
>> +        <set field="parameters.paymentMethodTypeId" value="COMPANY_ACCOUNT"/>
>> +        <set field="parameters.statusId" value="PMNT_NOT_PAID"/>
>> +        <set-service-fields service-name="createPayment" to-map="createPayment" map="parameters"/>
>> +        <call-service service-name="createPayment" in-map-name="createPayment">
>> +            <result-to-field result-name="paymentId" field="parameters.paymentId"/>
>> +        </call-service>
>> +        <set field="parameters.orderId" from-field="orderHeader.orderId"/>
>> +        <set field="parameters.maxAmount" from-field="orderHeader.grandTotal"/>
>> +        <set-service-fields service-name="createOrderPaymentPreference" to-map="newOrderPaymentPreference" map="parameters"/>
>> +        <call-service service-name="createOrderPaymentPreference" in-map-name="newOrderPaymentPreference">
>> +            <result-to-field result-name="orderPaymentPreferenceId" field="parameters.paymentPreferenceId"/>
>> +        </call-service>
>> +        <set-service-fields service-name="updatePayment" to-map="updatePayment" map="parameters"/>
>> +        <call-service service-name="updatePayment" in-map-name="updatePayment"/>
>> +        <field-to-result field="parameters.paymentId" result-name="paymentId"/>
>> +    </simple-method>
>> +</simple-methods>
>> \ No newline at end of file
>>
>> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=941132&r1=941131&r2=941132&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
>> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May  5 01:43:45 2010
>> @@ -233,4 +233,11 @@ under the License.
>>         <attribute name="statusId" type="String" mode="IN" optional="false"/>
>>         <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
>>     </service>
>> +
>> +    <service name="createPaymentFromOrder" engine="simple"
>> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentFromOrder" auth="true">
>> +        <description>create Payment from Order</description>
>> +        <attribute name="orderId" type="String" mode="IN" optional="false"/>
>> +        <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>> +    </service>
>> </services>
>>
>> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=941132&r1=941131&r2=941132&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
>> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Wed May  5 01:43:45 2010
>> @@ -93,6 +93,12 @@ under the License.
>>         <action service="resetGrandTotal" mode="sync"/>
>>         <action service="sendOrderCompleteNotification" mode="async" persist="true"/>
>>     </eca>
>> +    <eca service="changeOrderStatus" event="commit" run-on-error="false">
>> +        <condition field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/>
>> +        <condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
>> +        <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
>> +        <action service="createPaymentFromOrder" mode="sync" persist="true"/>
>> +    </eca>
>>
>>     <!-- DISABLED FOR NOW
>>     <eca service="changeOrderStatus" event="commit" run-on-error="false">
>>
>>
>