You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2026/09/11 18:28:00 UTC
[jira] [Commented] (OFBIZ-13575) Fix Mini-lang to Groovy regressions in InvoiceServicesScript.groovy
[ https://issues.apache.org/jira/browse/OFBIZ-13575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114321#comment-18114321 ]
ASF subversion and git services commented on OFBIZ-13575:
---------------------------------------------------------
Commit b2fb29e1dcccea1b54d10b201792e86c9f163829 in ofbiz-framework's branch refs/heads/release24.09 from Mridul Pathak
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=b2fb29e1dc ]
Fixed: Mini-lang to Groovy regressions in InvoiceServicesScript (OFBIZ-13575)
- getInvoicesFilterByAssocType: invert filter condition so only invoices without the specified association are returned, restoring commission run behavior.
- addTaxOnInvoice: align parallel input lists for calcTax by only adding amounts and quantities when productId is present, preventing misalignment on non-product line items.
- updateInvoiceItem: guard calculateProductPrice to only run when productId exists, and enforce mandatory amount check on all item updates.
- autoGenerateInvoiceFromExistingInvoice: use map subscript access for switchType and ensure recurrenceInfoId is cleared on all generated invoices.
- copyInvoice: handle getInvoice failure gracefully to avoid NPE, reset invoiceDate to nowTimestamp, and clear paidDate on the new invoice.
- createInvoiceFromOrder: return error if orderHeader is not found instead of throwing NPE.
- getInvoiceRunningTotal: use safe navigation when accessing partyAccountingPreference baseCurrencyUomId.
- getNextInvoiceId & invoiceSequenceRestart: explicitly declare local variables to prevent leaking into the script binding.
> Fix Mini-lang to Groovy regressions in InvoiceServicesScript.groovy
> -------------------------------------------------------------------
>
> Key: OFBIZ-13575
> URL: https://issues.apache.org/jira/browse/OFBIZ-13575
> Project: OFBiz
> Issue Type: Bug
> Components: accounting
> Affects Versions: Upcoming Branch, 24.09.07
> Reporter: Mridul Pathak
> Assignee: Mridul Pathak
> Priority: Major
>
> During the conversion of InvoiceServices.xml from Mini-lang to Groovy (OFBIZ-13085), several logic regressions, inverted filters, desynchronized calculations, and unhandled null dereferences were introduced:
> 1. getInvoicesFilterByAssocType:
> In Mini-lang, <if-empty field="invoiceItemAssocList"> added the invoice to filteredInvoiceList so that only invoices without an association of the given type were returned. In Groovy, this condition was inverted to "parameters.invoiceList.findAll\{ invoiceIds.contains(it.invoiceId) }", returning only invoices that already have the association. This breaks the Commission Run feature by repeatedly reprocessing already-commissioned invoices and ignoring uncommissioned invoices.
> 2. addTaxOnInvoice:
> When iterating over invoice items to populate the parallel input lists for the calcTax service, itemProductList is only populated if it.productId is present, while itemAmountList, itemPriceList, itemQuantityList, and itemShippingList are populated unconditionally. When an invoice contains line items without a productId (e.g., shipping charges, fees), the lists become desynchronized, causing calcTax to misalign line amounts or crash with IndexOutOfBoundsException.
> 3. updateInvoiceItem:
> When an invoice item's productId is cleared or changed to null, it attempts to query Product with a null productId and invokes calculateProductPrice with product: null, throwing ServiceValidationException. In addition, checking for a mandatory amount was indented inside the productId-change block instead of being evaluated unconditionally.
> 4. autoGenerateInvoiceFromExistingInvoice:
> Uses callable Map syntax "switchType(it.invoiceTypeId)" instead of subscript syntax "switchType[it.invoiceTypeId]". In addition, recurrenceInfoId was originally cleared for all generated invoices, but in Groovy updateInvoice is only called if switchType contains the invoiceTypeId, leaving recurrenceInfoId attached when other template types are used.
> 5. copyInvoice:
> getInvoice returns failure() on missing invoices, which does not throw in run service:. As a result, copying a non-existent invoice causes a NullPointerException on the null result rather than propagating the service failure. Furthermore, copying all fields from the source invoice preserves the old invoiceDate and paidDate instead of resetting invoiceDate to current timestamp and clearing paidDate for the new INVOICE_IN_PROCESS invoice.
> 6. createInvoiceFromOrder:
> Dereferences order.orderId without verifying that the OrderHeader entity was found, throwing a NullPointerException when an invalid orderId is supplied.
> 7. getInvoiceRunningTotal:
> Accesses partyAccountingPreference.baseCurrencyUomId without null-safe navigation, risking a NullPointerException if preferences are not configured for the party.
> 8. Variable scoping leaks:
> In getNextInvoiceId (errorMsg) and invoiceSequenceRestart (curYearFiscalStartDate), variables are assigned without local declaration, leaking into the script binding.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)