Author: hansbak Date: Sun Jul 21 08:35:55 2013 New Revision: 1505303 URL: http://svn.apache.org/r1505303 Log: add the check that when a payment set to 'received' or 'sent' it should have a payment method, otherwise posting will fail
Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=1505303&r1=1505302&r2=1505303&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Sun Jul 21 08:35:55 2013 @@ -8711,6 +8711,9 @@ <value xml:lang="zh">æ¹æ³</value> <value xml:lang="zh_TW">æ¹æ³</value> </property> + <property key="AccountingMissingPaymentMethod"> + <value xml:lang="en">Cannot change the status to '${statusItem.description}' when the mandatory payment method is missing.</value> + </property> <property key="AccountingMiddleNameCard"> <value xml:lang="ar">Ø§ÙØ¥Ø³Ù اÙÙØ³Ø· عÙÙ Ø§ÙØ¨Ø·Ø§ÙØ©</value> <value xml:lang="de">Mittlerer Name auf Karte</value> 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=1505303&r1=1505302&r2=1505303&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 Sun Jul 21 08:35:55 2013 @@ -294,6 +294,9 @@ under the License. </check-permission> <entity-one entity-name="Payment" value-field="payment"/> + <entity-one entity-name="StatusItem" value-field="statusItem"> + <field-map field-name="statusId" from-field="parameters.statusId"/> + </entity-one> <field-to-result field="payment.statusId" result-name="oldStatusId"/> <if-compare-field field="payment.statusId" to-field="parameters.statusId" operator="not-equals"> @@ -308,6 +311,27 @@ under the License. <log level="error" message="Cannot change from ${payment.statusId} to ${parameters.statusId}"/> <check-errors/> <else> +<log level="info" message="===============================new status: ${parameters.statusId} payment methid: ${payment.paymentMethodId}"/> + <!-- payment method is mandatory when set to sent or received. --> + <if> + <condition> + <and> + <or> + <if-compare field="parameters.statusId" operator="equals" value="PMNT_RECEIVED"/> + <if-compare field="parameters.statusId" operator="equals" value="PMNT_SENT"/> + </or> + <if-empty field="payment.paymentMethodId"/> + </and> + </condition> + <then> + <add-error> + <fail-property resource="AccountingUiLabels" property="AccountingMissingPaymentMethod"/> + </add-error> + <log level="error" message="Cannot set status to ${parameters.statusId} on payment ${payment.paymentId}: payment method is missing"/> + <check-errors/> + </then> + </if> + <!-- check if the payment fully applied when set to confirmed--> <if-compare field="parameters.statusId" operator="equals" value="PMNT_CONFIRMED">