This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release24.09 by this push:
new 96ab24ebd6 Improved: GL-posting and order-completion invoicing
commit-ECAs lack run-as-user="system" (OFBIZ-13673)
96ab24ebd6 is described below
commit 96ab24ebd6743feb3c105799639a366fc66b7ddd
Author: Mridul Pathak <[email protected]>
AuthorDate: Tue Oct 13 17:06:48 2026 +0530
Improved: GL-posting and order-completion invoicing commit-ECAs lack
run-as-user="system" (OFBIZ-13673)
- Add run-as-user="system" to the createPayment/setPaymentStatus
commit-ECAs in secas_ledger.xml (PMNT_RECEIVED and PMNT_SENT), so the GL
posting no longer depends on the accounting permission of whatever caller
happened to trigger the payment status change
- Add run-as-user="system" to the createInvoiceFromOrder ECA in secas.xml
- Align createInvoiceFromOrder's "partially billed" branch with its sibling
createInvoiceForOrderAllItems, which already substitutes the system userLogin
before invoicing
---
applications/accounting/servicedef/secas_ledger.xml | 8 ++++----
.../apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy | 5 ++++-
applications/order/servicedef/secas.xml | 2 +-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/applications/accounting/servicedef/secas_ledger.xml
b/applications/accounting/servicedef/secas_ledger.xml
index 81beb50318..51237b4b23 100644
--- a/applications/accounting/servicedef/secas_ledger.xml
+++ b/applications/accounting/servicedef/secas_ledger.xml
@@ -114,25 +114,25 @@ under the License.
<!-- accounting transactions for Incoming Payment (AR) -->
<eca service="createPayment" event="commit">
<condition field-name="statusId" operator="equals"
value="PMNT_RECEIVED"/>
- <action service="createAcctgTransAndEntriesForIncomingPayment"
mode="sync"/>
+ <action service="createAcctgTransAndEntriesForIncomingPayment"
mode="sync" run-as-user="system"/>
</eca>
<eca service="setPaymentStatus" event="commit">
<condition field-name="statusId" operator="equals"
value="PMNT_RECEIVED"/>
<condition field-name="oldStatusId" operator="not-equals"
value="PMNT_RECEIVED"/>
<condition field-name="oldStatusId" operator="not-equals"
value="PMNT_CONFIRMED"/>
- <action service="createAcctgTransAndEntriesForIncomingPayment"
mode="sync"/>
+ <action service="createAcctgTransAndEntriesForIncomingPayment"
mode="sync" run-as-user="system"/>
</eca>
<!-- accounting transactions for Outgoing Payment (AP) -->
<eca service="createPayment" event="commit">
<condition field-name="statusId" operator="equals" value="PMNT_SENT"/>
- <action service="createAcctgTransAndEntriesForOutgoingPayment"
mode="sync"/>
+ <action service="createAcctgTransAndEntriesForOutgoingPayment"
mode="sync" run-as-user="system"/>
</eca>
<eca service="setPaymentStatus" event="commit">
<condition field-name="statusId" operator="equals" value="PMNT_SENT"/>
<condition field-name="oldStatusId" operator="not-equals"
value="PMNT_SENT"/>
<condition field-name="oldStatusId" operator="not-equals"
value="PMNT_CONFIRMED"/>
- <action service="createAcctgTransAndEntriesForOutgoingPayment"
mode="sync"/>
+ <action service="createAcctgTransAndEntriesForOutgoingPayment"
mode="sync" run-as-user="system"/>
</eca>
<eca service="createPaymentApplication" event="commit">
diff --git
a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy
b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy
index 254eb69320..6f6d16fd8a 100644
---
a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy
+++
b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy
@@ -646,8 +646,11 @@ Map createInvoiceFromOrder() {
}
List orderItems = from('OrderItem').where(orderId:
order.orderId).queryList()
orderItems = orderItems.findAll {
!orderItemBillingItemsSeqIds.contains(it.orderItemSeqId) }
+ // get the system userid and store in context, otherwise the invoice
add service does not work
+ GenericValue systemUserLogin = from('UserLogin').where(userLoginId:
'system').cache().queryOne()
Map serviceResult = run service: 'createInvoiceForOrder', with:
[orderId: order.orderId,
-
billItems: orderItems]
+
billItems: orderItems,
+
userLogin: systemUserLogin]
return serviceResult
}
return success()
diff --git a/applications/order/servicedef/secas.xml
b/applications/order/servicedef/secas.xml
index 06d5a22e0b..ffbe2d67d5 100644
--- a/applications/order/servicedef/secas.xml
+++ b/applications/order/servicedef/secas.xml
@@ -91,7 +91,7 @@ under the License.
<eca service="changeOrderStatus" event="global-commit-post-run"
run-on-error="false">
<condition field-name="statusId" operator="equals"
value="ORDER_COMPLETED"/>
<condition-field field-name="statusId" operator="not-equals"
to-field-name="oldStatusId"/>
- <action service="createInvoiceFromOrder" mode="sync"/>
+ <action service="createInvoiceFromOrder" mode="sync"
run-as-user="system"/>
<action service="resetGrandTotal" mode="sync"/>
<action service="sendOrderCompleteNotification" mode="async"
persist="true"/>
<action service="createReturnItemForRental" mode="sync"/>