This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 66803eca23 Improved: GL-posting and order-completion invoicing
commit-ECAs lack run-as-user="system" (OFBIZ-13673)
66803eca23 is described below
commit 66803eca23b595c5334e750e4356e08986962f3a
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 05c45d6389..0a2041a348 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
@@ -617,8 +617,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 29ee400cb2..e83185ee26 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"/>