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, [email protected] 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">
>>>
>>>
>>
> 
> 

Reply via email to