You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2026/04/07 12:28:49 UTC

(ofbiz-framework) 01/02: Fixed: Ensure that the invoice item quantity is set to 1 only if the quantity is null when invoice items are created by the createInvoiceItem service (OFBIZ-13362)

This is an automated email from the ASF dual-hosted git repository.

jacopoc pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit a41476c4f857021f755980137af6a8cbf1e90042
Author: Anahita Goljahani <an...@gmail.com>
AuthorDate: Sun Apr 5 08:34:11 2026 +0200

    Fixed: Ensure that the invoice item quantity is set to 1 only if the quantity is null when invoice items are created by the createInvoiceItem service (OFBIZ-13362)
    
    When the system creates a receipt with an accepted quantity equal to
    zero, the service createInvoiceItem erroneously set the item invoice
    quantity to 1, leading to a wrong invoiced quantity.
    
    The change in this commit makes sure that only quantities equal to null are
    set to 1.
    
    (cherry picked from commit c059f1e0ba07aabeceee1f006bd82add3331393c)
---
 .../org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 13925d6dd0..cbe4794125 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
@@ -350,7 +350,7 @@ Map createInvoiceItem() {
     // if there is no amount and a productItem is supplied fill the amount(price) and description from the product record
     //     TODO: there are return adjustments now that make this code very broken. The check for price was added as a quick fix.
     if (invoiceItem.productId) {
-        invoiceItem.quantity = invoiceItem.quantity ?: 1
+        invoiceItem.quantity = (invoiceItem.quantity != null) ? invoiceItem.quantity : 1
         if (!invoiceItem.amount) {
             GenericValue product = from('Product').where(parameters).cache().queryOne()
             invoiceItem.description = product.description