Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Adding service and UI components to link payments deposits and withdr…
Browse files Browse the repository at this point in the history
…awal with financial account. Patch from Jira#2717 with minor modifications.

Thanks Awdesh and Rishi.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@794217 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Anil Patel committed Jul 15, 2009
1 parent d60c882 commit ebf410b
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 11 deletions.
9 changes: 9 additions & 0 deletions applications/accounting/config/AccountingUiLabels.xml
Expand Up @@ -1503,6 +1503,9 @@
<value xml:lang="th">ไม่สามารถชำระเงินสำหรับแอพพลิเคชัน [${payAppl}] เนื่องจาก ${msg}</value>
<value xml:lang="zh">无法为应用[${payAppl}]获得支付,由于${msg}</value>
</property>
<property key="AccountingCannotIncludeApPaymentError">
<value xml:lang="en">Cannot include AP payment in a deposit batch</value>
</property>
<property key="AccountingCapture">
<value xml:lang="ar">خطفة</value>
<value xml:lang="de">erfassen</value>
Expand Down Expand Up @@ -5800,6 +5803,9 @@
<value xml:lang="th">การชำระเงิน [${paymentId}] นำไปใช้ได้เต็มที่</value>
<value xml:lang="zh">支付[${paymentId}]已完整应用</value>
</property>
<property key="AccountingPaymentAlreadyAssociatedToFinAccountError">
<value xml:lang="en">Payment [${paymentId}] is already associated with other financial account.</value>
</property>
<property key="AccountingPaymentAlreadyReceived">
<value xml:lang="ar">تسديد مستلم مسبقا</value>
<value xml:lang="de">Bezahlung bereits erhalten</value>
Expand Down Expand Up @@ -6425,6 +6431,9 @@
<value xml:lang="th">ส่งการชำระเงิน</value>
<value xml:lang="zh">已发送的支付</value>
</property>
<property key="AccountingPaymentStatusIsNotReceivedOrSentError">
<value xml:lang="en">Payment status must be received or sent</value>
</property>
<property key="AccountingPermissionError">
<value xml:lang="ar">لا رخصة لديكم لهذه العملية</value>
<value xml:lang="en">You do not have permission for this function.</value>
Expand Down
Expand Up @@ -374,4 +374,81 @@ under the License.
</if-empty>
</iterate>
</simple-method>

<simple-method method-name="depositWithdrawPayments" short-description="Deposit withdraw payments">
<set field="paymentIds" from-field="parameters.paymentIds"/>
<set field="finAccountId" from-field="parameters.finAccountId"/>
<entity-one entity-name="FinAccount" value-field="finAccount"/>
<set field="paymentRunningTotal" type="BigDecimal" value="0"/>
<entity-condition entity-name="Payment" list="payments">
<condition-expr field-name="paymentId" operator="in" from-field="paymentIds"/>
</entity-condition>
<iterate list="payments" entry="payment">
<set field="paymentRunningTotal" value="${paymentRunningTotal + payment.amount}" type="BigDecimal"/>
<if-not-empty field="payment.finAccountTransId">
<add-error><fail-property resource="AccountingUiLabels" property="AccountingPaymentAlreadyAssociatedToFinAccountError"/></add-error>
</if-not-empty>
<check-errors/>
<if>
<condition>
<not>
<or>
<if-compare field="payment.statusId" operator="equals" value="PMNT_SENT"/>
<if-compare field="payment.statusId" operator="equals" value="PMNT_RECEIVED"/>
</or>
</not>
</condition>
<then>
<add-error><fail-property resource="AccountingUiLabels" property="AccountingPaymentStatusIsNotReceivedOrSentError"/></add-error>
</then>
</if>
<check-errors/>
</iterate>
<if-compare field="parameters.groupInOneTransaction" operator="equals" value="Y">
<set field="createFinAccountTransMap.finAccountId" from-field="finAccountId"/>
<set field="createFinAccountTransMap.finAccountTransTypeId" value="DEPOSIT"/>
<set field="createFinAccountTransMap.partyId" from-field="finAccount.ownerPartyId"/>
<set field="createFinAccountTransMap.amount" from-field="paymentRunningTotal"/>
<set field="createFinAccountTransMap.statusId" value="FINACT_TRNS_CREATED"/>
<call-service service-name="createFinAccountTrans" in-map-name="createFinAccountTransMap">
<result-to-field result-name="finAccountTransId"/>
<result-to-result result-name="finAccountTransId"/>
</call-service>
<iterate list="payments" entry="payment">
<if-compare-field field="payment.partyIdTo" operator="not-equals" to-field="finAccount.ownerPartyId">
<add-error><fail-property resource="AccountingUiLabels" property="AccountingCannotIncludeApPaymentError"/></add-error>
</if-compare-field>
<check-errors/>
<set field="updatePaymentCtx.paymentId" from-field="payment.paymentId"/>
<set field="updatePaymentCtx.finAccountTransId" from-field="finAccountTransId"/>
<call-service service-name="updatePayment" in-map-name="updatePaymentCtx"/>
<clear-field field="updatePaymentCtx"/>
</iterate>
<else>
<iterate list="payments" entry="payment">
<if-compare-field field="payment.partyIdTo" operator="equals" to-field="finAccount.ownerPartyId">
<set field="createFinAccountTransMap.finAccountTransTypeId" value="DEPOSIT"/>
<else>
<if-compare-field field="payment.partyIdFrom" operator="equals" to-field="finAccount.ownerPartyId">
<set field="createFinAccountTransMap.finAccountTransTypeId" value="WITHDRAWAL"/>
</if-compare-field>
</else>
</if-compare-field>
<set field="createFinAccountTransMap.finAccountId" from-field="finAccountId"/>
<set field="createFinAccountTransMap.partyId" from-field="finAccount.ownerPartyId"/>
<set field="createFinAccountTransMap.paymentId" from-field="payment.paymentId"/>
<set field="createFinAccountTransMap.amount" from-field="payment.amount"/>
<set field="createFinAccountTransMap.statusId" value="FINACT_TRNS_CREATED"/>
<call-service service-name="createFinAccountTrans" in-map-name="createFinAccountTransMap">
<result-to-field result-name="finAccountTransId"/>
</call-service>
<set field="updatePaymentCtx.paymentId" from-field="payment.paymentId"/>
<set field="updatePaymentCtx.finAccountTransId" from-field="finAccountTransId"/>
<call-service service-name="updatePayment" in-map-name="updatePaymentCtx"/>
<clear-field field="updatePaymentCtx"/>
<clear-field field="createFinAccountTransMap"/>
</iterate>
</else>
</if-compare>
</simple-method>
</simple-methods>
9 changes: 9 additions & 0 deletions applications/accounting/servicedef/services_finaccount.xml
Expand Up @@ -385,4 +385,13 @@ under the License.
accounting/data/AccountingTypeData.xml
</description>
</service>

<service name="depositWithdrawPayments" engine="simple"
location="component://accounting/script/org/ofbiz/accounting/finaccount/FinAccountServices.xml" invoke="depositWithdrawPayments">
<description>Deposit withdraw payments</description>
<attribute name="paymentIds" type="List" mode="IN" optional="false"/>
<attribute name="finAccountId" type="String" mode="IN" optional="false"/>
<attribute name="groupInOneTransaction" type="String" mode="IN" optional="true"/>
<attribute name="finAccountTransId" type="String" mode="OUT" optional="true"/>
</service>
</services>
10 changes: 6 additions & 4 deletions applications/accounting/webapp/accounting/WEB-INF/controller.xml
Expand Up @@ -2072,10 +2072,6 @@ under the License.
<request-map uri="FindPaymentsForDepositOrWithdraw">
<security https="true" auth="true"/>
<response name="success" type="view" value="PaymentsDepositWithdraw"/>
</request-map>
<request-map uri="ListPaymentsForDepositOrWithdraw">
<security https="true" auth="true"/>
<response name="success" type="view" value="PaymentsDepositWithdraw"/>
<response name="error" type="view" value="PaymentsDepositWithdraw"/>
</request-map>
<request-map uri="getPaymentRunningTotal">
Expand All @@ -2087,6 +2083,12 @@ under the License.
<security auth="true" https="true"/>
<response name="success" type="view" value="LookupCustomerName"/>
</request-map>
<request-map uri="depositWithdrawPayments">
<security auth="true" https="true"/>
<event type="service" invoke="depositWithdrawPayments"/>
<response name="success" type="view" value="PaymentsDepositWithdraw"/>
<response name="error" type="view" value="PaymentsDepositWithdraw"/>
</request-map>


<!-- ================ Depreciation Calculation Report requests ================ -->
Expand Down
Expand Up @@ -67,9 +67,10 @@ function getPaymentRunningTotal(e) {
</script>
<div class="screenlet">
<div class="screenlet-body">
<form id="depositWithdrawPaymentsForm" name="depositWithdrawPaymentsForm" method="post" action="<@ofbizUrl></@ofbizUrl>">
<form id="depositWithdrawPaymentsForm" name="depositWithdrawPaymentsForm" method="post" action="<@ofbizUrl>depositWithdrawPayments</@ofbizUrl>">
<#if paymentList?has_content>
<input type="hidden" name='organizationPartyId' value="${organizationPartyId?if_exists}">
<input type="hidden" name='finAccountId' value="${finAccountId?if_exists}">
<div>
<span class="label">${uiLabelMap.AccountingRunningTotal} :</span>
<span class="label" id="showPaymentRunningTotal"></span>
Expand Down Expand Up @@ -111,12 +112,14 @@ function getPaymentRunningTotal(e) {
</td>
</tr>
</#list>
<div align="right">
${uiLabelMap.AccountingGroupInOneTransaction}
<input type="checkbox" name="groupInOneTransaction" value="Y"/>
<a href="javascript:document.depositWithdrawPaymentsForm.submit();" class="buttontext">${uiLabelMap.AccountingDepositWithdraw}</a>
</div>
</table>
<div align="right">
${uiLabelMap.AccountingGroupInOneTransaction}
<input type="checkbox" name="groupInOneTransaction" value="Y"/>
<a href="javascript:document.depositWithdrawPaymentsForm.submit();" class="buttontext">${uiLabelMap.AccountingDepositWithdraw}</a>
</div>
<#else>
<span class="label">${uiLabelMap.AccountingNoRecordFound}</span>
</#if>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion applications/accounting/widget/FinAccountForms.xml
Expand Up @@ -227,7 +227,7 @@ under the License.
<field name="thruDate"><date-time/></field>
<field name="submitButton" title="${uiLabelMap.CommonAdd}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
<form name="PaymentsDepositWithdraw" type="single" target="ListPaymentsForDepositOrWithdraw" extends="FindBatchPayments" extends-resource="component://accounting/widget/ar/forms/ArPaymentForms.xml">
<form name="PaymentsDepositWithdraw" type="single" target="FindPaymentsForDepositOrWithdraw" extends="FindBatchPayments" extends-resource="component://accounting/widget/ar/forms/ArPaymentForms.xml">
<field name="finAccountId"><hidden/></field>
<field name="submitButton" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
Expand Down

0 comments on commit ebf410b

Please sign in to comment.