You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Scott Gray <sc...@hotwaxmedia.com> on 2010/05/13 00:54:36 UTC

Re: svn commit: r943417 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/payment/PaymentServices.xml servicedef/secas_invoice.xml servicedef/secas_payment.xml servicedef/services_payment.xml

I don't like the idea of the system taking guesses at creating payment applications.  Why not present something in the UI when a user is entering a payment or invoice that allows them to select an outstanding invoice or payment to apply it to?

This just seems like it could get messy for companies who process a large number of repeat orders.  If the system guesses wrong then somebody has to manually go through and clean up the mess.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 12/05/2010, at 9:20 PM, hansbak@apache.org wrote:

> Author: hansbak
> Date: Wed May 12 09:20:44 2010
> New Revision: 943417
> 
> URL: http://svn.apache.org/viewvc?rev=943417&view=rev
> Log:
> if an invoice is approved or a payment is set to sent or received this service will try to find a matching payment/invoice and when found create the payment application
> 
> Modified:
>    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
>    ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml
>    ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml
>    ofbiz/trunk/applications/accounting/servicedef/services_payment.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=943417&r1=943416&r2=943417&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 12 09:20:44 2010
> @@ -814,4 +814,79 @@ under the License.
>         <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
> +    
> +    <simple-method method-name="createMatchingPaymentApplication" short-description="Create a payment application if either the invoice of payment could be found">
> +        <if-not-empty field="parameters.invoiceId">
> +            <entity-one value-field="invoice" entity-name="Invoice"/>
> +            <if-not-empty field="invoice">
> +                <call-class-method method-name="getInvoiceTotal" class-name="org.ofbiz.accounting.invoice.InvoiceWorker" ret-field="invoiceTotal">
> +                    <field field="invoice" type="GenericValue"/>
> +                </call-class-method>
> +                <entity-condition list="payments" entity-name="Payment">
> +                    <condition-list combine="and">
> +                        <condition-expr field-name="statusId" value="PMNT_CONFIRMED" operator="not-equals"/>
> +                        <condition-expr field-name="partyIdFrom" from-field="invoice.partyId" operator="equals"/>
> +                        <condition-expr field-name="partyIdTo" from-field="invoice.partyIdFrom" operator="equals"/>
> +                        <condition-expr field-name="amount" from-field="invoiceTotal" operator="equals"/>
> +                    </condition-list>
> +                    <order-by field-name="effectiveDate"/>
> +                </entity-condition>
> +                <if-not-empty field="payments">
> +                    <!-- check if already applied -->
> +                    <entity-and list="paymentAppls" entity-name="PaymentApplication">
> +                        <field-map field-name="paymentId" from-field="payments[0].paymentId"/>
> +                    </entity-and>
> +                    <if-empty field="paymentAppls">
> +                        <set field="createAppl.paymentId" from-field="payments[0].paymentId"/>
> +                        <set field="createAppl.invoiceId" from-field="parameters.invoiceId"/>
> +                        <set field="createAppl.amountApplied" from-field="invoiceTotal"/>
> +                    </if-empty>
> +                </if-not-empty>
> +            </if-not-empty>
> +        </if-not-empty>
> +    
> +        <if-not-empty field="parameters.paymentId">
> +            <entity-one value-field="payment" entity-name="Payment"/>
> +            <if-not-empty field="payment">
> +                <entity-condition list="invoices" entity-name="Invoice">
> +                    <condition-list combine="and">
> +                        <condition-expr field-name="statusId" value="INVOICE_READY" operator="not-equals"/>
> +                        <condition-expr field-name="statusId" value="INVOICE_PAID" operator="not-equals"/>
> +                        <condition-expr field-name="statusId" value="INVOICE_CANCELLED" operator="not-equals"/>
> +                        <condition-expr field-name="statusId" value="INVOICE_WRITEOFF" operator="not-equals"/>
> +                        <condition-expr field-name="partyIdFrom" from-field="payment.partyIdTo"/>
> +                        <condition-expr field-name="partyId" from-field="payment.partyIdFrom"/>
> +                    </condition-list>
> +                    <order-by field-name="invoiceDate"/>
> +                </entity-condition>
> +                <iterate entry="invoice" list="invoices">
> +                    <call-class-method method-name="getInvoiceTotal" class-name="org.ofbiz.accounting.invoice.InvoiceWorker" ret-field="invoiceTotal">
> +                        <field field="invoice" type="GenericValue"/>
> +                    </call-class-method>
> +                    <if-compare-field operator="equals" field="invoiceTotal" to-field="payment.amount">
> +                        <set field="invoiceId" from-field="invoice.invoiceId"/>
> +                    </if-compare-field>                
> +                </iterate>
> +                <if-not-empty field="invoiceId">
> +                    <entity-and list="paymentAppls" entity-name="PaymentApplication">
> +                        <field-map field-name="invoiceId" from-field="invoiceId"/>
> +                    </entity-and>
> +                    <if-empty field="paymentAppls">
> +                        <set field="createAppl.paymentId" from-field="parameters.paymentId"/>
> +                        <set field="createAppl.invoiceId" from-field="invoiceId"/>
> +                        <set field="createAppl.amountApplied" from-field="payment.amount"/>
> +                    </if-empty>
> +                </if-not-empty>
> +            </if-not-empty>
> +        </if-not-empty>
> +    
> +    
> +        <if-not-empty field="createAppl.paymentId">
> +            <if-not-empty field="createAppl.invoiceId">
> +                <call-service service-name="createPaymentApplication" in-map-name="createAppl"/>    
> +                <set field="successMessage" value="also application created"/>
> +            </if-not-empty>
> +        </if-not-empty>
> +    </simple-method>
> +    
> +</simple-methods>
> 
> Modified: ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml?rev=943417&r1=943416&r2=943417&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml (original)
> +++ ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml Wed May 12 09:20:44 2010
> @@ -31,4 +31,11 @@ under the License.
>         <condition field-name="invoiceTypeId" operator="equals" value="COMMISSION_INVOICE"/>
>         <action service="removeInvoiceItemAssocOnCancelInvoice" mode="sync"/>
>     </eca>
> +
> +    <eca service="setInvoiceStatus" event="commit">
> +        <condition operator="equals" field-name="statusId" value="INVOICE_APPROVED"/>
> +        <condition operator="not-equals" field-name="oldStatusId" value="INVOICE_APPROVED"/>
> +        <action service="createMatchingPaymentApplication" mode="sync"/>
> +    </eca>
> +
> </service-eca>
> 
> Modified: ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml?rev=943417&r1=943416&r2=943417&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml (original)
> +++ ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml Wed May 12 09:20:44 2010
> @@ -67,4 +67,17 @@ under the License.
>          <condition field-name="statusId" operator="equals" value="FINACT_TRNS_CANCELED"/>
>          <action service="setFinAccountTransStatus" mode="sync"/>
>      </eca>
> +
> +    <eca service="setPaymentStatus" event="commit">
> +        <condition operator="equals" field-name="statusId" value="PMNT_RECEIVED"/>
> +        <condition operator="not-equals" field-name="oldStatusId" value="PMNT_RECEIVED"/>
> +        <action service="createMatchingPaymentApplication" mode="sync"/>
> +    </eca>
> +
> +    <eca service="setPaymentStatus" event="commit">
> +        <condition operator="equals" field-name="statusId" value="PMNT_SENT"/>
> +        <condition operator="not-equals" field-name="oldStatusId" value="PMNT_SENT"/>
> +        <action service="createMatchingPaymentApplication" mode="sync"/>
> +    </eca>
> +
> </service-eca>
> 
> Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=943417&r1=943416&r2=943417&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
> +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May 12 09:20:44 2010
> @@ -240,4 +240,11 @@ under the License.
>         <attribute name="orderId" type="String" mode="IN" optional="false"/>
>         <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
>     </service>
> +
> +    <service name="createMatchingPaymentApplication" engine="simple"
> +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createMatchingPaymentApplication" auth="true">
> +        <description>Create a payment application if either the invoice of payment could be found</description>
> +        <attribute name="paymentId" type="String" mode="IN" optional="true"/>
> +        <attribute name="invoiceId" type="String" mode="IN" optional="true"/>
> +    </service>
> </services>
> 
> 


Re: svn commit: r943417 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/payment/PaymentServices.xml servicedef/secas_invoice.xml servicedef/secas_payment.xml servicedef/services_payment.xml

Posted by Hans Bakker <ma...@antwebsystems.com>.
to accommodate your request this function is now configurable in rev:
943783

On Thu, 2010-05-13 at 10:54 +1200, Scott Gray wrote:
> I don't like the idea of the system taking guesses at creating payment applications.  Why not present something in the UI when a user is entering a payment or invoice that allows them to select an outstanding invoice or payment to apply it to?
> 
> This just seems like it could get messy for companies who process a large number of repeat orders.  If the system guesses wrong then somebody has to manually go through and clean up the mess.
> 
> Regards
> Scott
> 
> HotWax Media
> http://www.hotwaxmedia.com
> 
> On 12/05/2010, at 9:20 PM, hansbak@apache.org wrote:
> 
> > Author: hansbak
> > Date: Wed May 12 09:20:44 2010
> > New Revision: 943417
> > 
> > URL: http://svn.apache.org/viewvc?rev=943417&view=rev
> > Log:
> > if an invoice is approved or a payment is set to sent or received this service will try to find a matching payment/invoice and when found create the payment application
> > 
> > Modified:
> >    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
> >    ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml
> >    ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml
> >    ofbiz/trunk/applications/accounting/servicedef/services_payment.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=943417&r1=943416&r2=943417&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 12 09:20:44 2010
> > @@ -814,4 +814,79 @@ under the License.
> >         <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
> > +    
> > +    <simple-method method-name="createMatchingPaymentApplication" short-description="Create a payment application if either the invoice of payment could be found">
> > +        <if-not-empty field="parameters.invoiceId">
> > +            <entity-one value-field="invoice" entity-name="Invoice"/>
> > +            <if-not-empty field="invoice">
> > +                <call-class-method method-name="getInvoiceTotal" class-name="org.ofbiz.accounting.invoice.InvoiceWorker" ret-field="invoiceTotal">
> > +                    <field field="invoice" type="GenericValue"/>
> > +                </call-class-method>
> > +                <entity-condition list="payments" entity-name="Payment">
> > +                    <condition-list combine="and">
> > +                        <condition-expr field-name="statusId" value="PMNT_CONFIRMED" operator="not-equals"/>
> > +                        <condition-expr field-name="partyIdFrom" from-field="invoice.partyId" operator="equals"/>
> > +                        <condition-expr field-name="partyIdTo" from-field="invoice.partyIdFrom" operator="equals"/>
> > +                        <condition-expr field-name="amount" from-field="invoiceTotal" operator="equals"/>
> > +                    </condition-list>
> > +                    <order-by field-name="effectiveDate"/>
> > +                </entity-condition>
> > +                <if-not-empty field="payments">
> > +                    <!-- check if already applied -->
> > +                    <entity-and list="paymentAppls" entity-name="PaymentApplication">
> > +                        <field-map field-name="paymentId" from-field="payments[0].paymentId"/>
> > +                    </entity-and>
> > +                    <if-empty field="paymentAppls">
> > +                        <set field="createAppl.paymentId" from-field="payments[0].paymentId"/>
> > +                        <set field="createAppl.invoiceId" from-field="parameters.invoiceId"/>
> > +                        <set field="createAppl.amountApplied" from-field="invoiceTotal"/>
> > +                    </if-empty>
> > +                </if-not-empty>
> > +            </if-not-empty>
> > +        </if-not-empty>
> > +    
> > +        <if-not-empty field="parameters.paymentId">
> > +            <entity-one value-field="payment" entity-name="Payment"/>
> > +            <if-not-empty field="payment">
> > +                <entity-condition list="invoices" entity-name="Invoice">
> > +                    <condition-list combine="and">
> > +                        <condition-expr field-name="statusId" value="INVOICE_READY" operator="not-equals"/>
> > +                        <condition-expr field-name="statusId" value="INVOICE_PAID" operator="not-equals"/>
> > +                        <condition-expr field-name="statusId" value="INVOICE_CANCELLED" operator="not-equals"/>
> > +                        <condition-expr field-name="statusId" value="INVOICE_WRITEOFF" operator="not-equals"/>
> > +                        <condition-expr field-name="partyIdFrom" from-field="payment.partyIdTo"/>
> > +                        <condition-expr field-name="partyId" from-field="payment.partyIdFrom"/>
> > +                    </condition-list>
> > +                    <order-by field-name="invoiceDate"/>
> > +                </entity-condition>
> > +                <iterate entry="invoice" list="invoices">
> > +                    <call-class-method method-name="getInvoiceTotal" class-name="org.ofbiz.accounting.invoice.InvoiceWorker" ret-field="invoiceTotal">
> > +                        <field field="invoice" type="GenericValue"/>
> > +                    </call-class-method>
> > +                    <if-compare-field operator="equals" field="invoiceTotal" to-field="payment.amount">
> > +                        <set field="invoiceId" from-field="invoice.invoiceId"/>
> > +                    </if-compare-field>                
> > +                </iterate>
> > +                <if-not-empty field="invoiceId">
> > +                    <entity-and list="paymentAppls" entity-name="PaymentApplication">
> > +                        <field-map field-name="invoiceId" from-field="invoiceId"/>
> > +                    </entity-and>
> > +                    <if-empty field="paymentAppls">
> > +                        <set field="createAppl.paymentId" from-field="parameters.paymentId"/>
> > +                        <set field="createAppl.invoiceId" from-field="invoiceId"/>
> > +                        <set field="createAppl.amountApplied" from-field="payment.amount"/>
> > +                    </if-empty>
> > +                </if-not-empty>
> > +            </if-not-empty>
> > +        </if-not-empty>
> > +    
> > +    
> > +        <if-not-empty field="createAppl.paymentId">
> > +            <if-not-empty field="createAppl.invoiceId">
> > +                <call-service service-name="createPaymentApplication" in-map-name="createAppl"/>    
> > +                <set field="successMessage" value="also application created"/>
> > +            </if-not-empty>
> > +        </if-not-empty>
> > +    </simple-method>
> > +    
> > +</simple-methods>
> > 
> > Modified: ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml?rev=943417&r1=943416&r2=943417&view=diff
> > ==============================================================================
> > --- ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml (original)
> > +++ ofbiz/trunk/applications/accounting/servicedef/secas_invoice.xml Wed May 12 09:20:44 2010
> > @@ -31,4 +31,11 @@ under the License.
> >         <condition field-name="invoiceTypeId" operator="equals" value="COMMISSION_INVOICE"/>
> >         <action service="removeInvoiceItemAssocOnCancelInvoice" mode="sync"/>
> >     </eca>
> > +
> > +    <eca service="setInvoiceStatus" event="commit">
> > +        <condition operator="equals" field-name="statusId" value="INVOICE_APPROVED"/>
> > +        <condition operator="not-equals" field-name="oldStatusId" value="INVOICE_APPROVED"/>
> > +        <action service="createMatchingPaymentApplication" mode="sync"/>
> > +    </eca>
> > +
> > </service-eca>
> > 
> > Modified: ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml?rev=943417&r1=943416&r2=943417&view=diff
> > ==============================================================================
> > --- ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml (original)
> > +++ ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml Wed May 12 09:20:44 2010
> > @@ -67,4 +67,17 @@ under the License.
> >          <condition field-name="statusId" operator="equals" value="FINACT_TRNS_CANCELED"/>
> >          <action service="setFinAccountTransStatus" mode="sync"/>
> >      </eca>
> > +
> > +    <eca service="setPaymentStatus" event="commit">
> > +        <condition operator="equals" field-name="statusId" value="PMNT_RECEIVED"/>
> > +        <condition operator="not-equals" field-name="oldStatusId" value="PMNT_RECEIVED"/>
> > +        <action service="createMatchingPaymentApplication" mode="sync"/>
> > +    </eca>
> > +
> > +    <eca service="setPaymentStatus" event="commit">
> > +        <condition operator="equals" field-name="statusId" value="PMNT_SENT"/>
> > +        <condition operator="not-equals" field-name="oldStatusId" value="PMNT_SENT"/>
> > +        <action service="createMatchingPaymentApplication" mode="sync"/>
> > +    </eca>
> > +
> > </service-eca>
> > 
> > Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=943417&r1=943416&r2=943417&view=diff
> > ==============================================================================
> > --- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
> > +++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Wed May 12 09:20:44 2010
> > @@ -240,4 +240,11 @@ under the License.
> >         <attribute name="orderId" type="String" mode="IN" optional="false"/>
> >         <attribute name="paymentId" type="String" mode="OUT" optional="false"/>
> >     </service>
> > +
> > +    <service name="createMatchingPaymentApplication" engine="simple"
> > +        location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createMatchingPaymentApplication" auth="true">
> > +        <description>Create a payment application if either the invoice of payment could be found</description>
> > +        <attribute name="paymentId" type="String" mode="IN" optional="true"/>
> > +        <attribute name="invoiceId" type="String" mode="IN" optional="true"/>
> > +    </service>
> > </services>
> > 
> > 
> 

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