Skip to content

Fixed: Correct receivedQuantity calculation in getReceivedQuantityForOrderItem by including quantityRejected (OFBIZ-13429)#1322

Merged
golja merged 2 commits into
apache:trunkfrom
golja:fix-quantity-received-calculation
Jun 3, 2026
Merged

Fixed: Correct receivedQuantity calculation in getReceivedQuantityForOrderItem by including quantityRejected (OFBIZ-13429)#1322
golja merged 2 commits into
apache:trunkfrom
golja:fix-quantity-received-calculation

Conversation

@golja

@golja golja commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

As described in OFBIZ-13429, when the 'Quantity Received' value exceeds the 'Quantity' specified on a purchase order, the system automatically updates the related issuance, shipment, and order items through the updateIssuanceShipmentAndPoOnReceiveInventory shipment receipt service.

However, when one or more receipts contain rejected units, order and shipment updates fail. The issue is caused by a bug in the getReceivedQuantityForOrderItem() function, which is invoked by the updateIssuanceShipmentAndPoOnReceiveInventory service to determine the received quantity.

This PR fixes the issue by including rejected units in the quantity calculation performed by getReceivedQuantityForOrderItem(), which previously considered only accepted units and ignored rejected quantities.

@golja golja self-assigned this Jun 2, 2026
@nmalin

nmalin commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Hi @golja

Thanks for this !

Little question, quantityRejected is never empty ?

This function would be simplifying like this

BigDecimal getReceivedQuantityForOrderItem (GenericValue orderItem) {
    return from('ShipmentReceipt')
            .where(orderId: orderItem.orderId,
                    orderItemSeqId: orderItem.orderItemSeqId)
            .queryList()
            .sum { it.quantityAccepted + it.quantityRejected }
}

or is quantityRejected can be empty

BigDecimal getReceivedQuantityForOrderItem (GenericValue orderItem) {
    return from('ShipmentReceipt')
            .where(orderId: orderItem.orderId,
                    orderItemSeqId: orderItem.orderItemSeqId)
            .queryList()
            .sum { it.quantityAccepted + (it.quantityRejected ?: 0) }
}

@golja

golja commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi @nmalin,
this is definitely better than the current code, thanks! I'll update my PR accordingly.

golja added 2 commits June 3, 2026 10:01
…null quantities

Thanks to Nicolas Malin for the advice and the code snippet.
@golja golja force-pushed the fix-quantity-received-calculation branch from 8121435 to e99dd05 Compare June 3, 2026 09:42
@golja

golja commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi @nmalin,
I've checked that both quantityAccepted and quantityRejected can potentially be null, using the query

Select COLUMN_NAME, IS_NULLABLE
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'SHIPMENT_RECEIPT'

Thus, I've also added a check for quantityAccepted.

Thanks again,

Anahita

@nmalin

nmalin commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

:) you're welcome

@golja golja merged commit f8f7949 into apache:trunk Jun 3, 2026
6 of 7 checks passed
@golja golja deleted the fix-quantity-received-calculation branch June 3, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants