Skip to content

OBPIH-6253 source pricing not visible when adding new product source on placed PO (manual and import)#4559

Merged
awalkowiak merged 2 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6253-source-pricing-not-visible-on-edit-product-page
Mar 22, 2024
Merged

OBPIH-6253 source pricing not visible when adding new product source on placed PO (manual and import)#4559
awalkowiak merged 2 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6253-source-pricing-not-visible-on-edit-product-page

Conversation

@drodzewicz
Copy link
Collaborator

The issue that was discovered during QA was that productPackage would not be updated when creating a new product source through manual edit or import on PLACED Purchase Order.

Few things I modified are:
first I added an additional condition on edit productSupplierChanged which just like other conditions checks if product Source of the orderItem is the same as the one provided by the package.

Then secondly, after investigating the whole workflow I cam to the conclusion that the chunck of code

// If not found, then we look for a product package associated with the product
if (!productPackage) {
    productPackage = orderItem.product.packages.find { ProductPackage productPackage1 ->
        return productPackage1.product == orderItem.product &&
                productPackage1.uom == orderItem.quantityUom &&
                productPackage1.quantity == orderItem.quantityPerUom
    }
}

is causing a bug which caused the product Package to be unassigned from older product source.
I noticed that ProductPackage and ProductSource have a 1:N relationship where ProductPackage can only have one Product Source and a single Product source can have many product packages.

When executing anove code

and later

orderItem.productSupplier.addToProductPackages(productPackage)

we are finding an existing productPackage that is assigned to some other product Source and we are now assigning this package to new Product source which will unassign it from the previous one. I assume this is not an expected behavior.

Lastly, I noticed that when importing orderitems we are not updating productPackage like we do on the manual create/edit so I added this chunk of code which in my opinion was missing.

 if (order.status >= OrderStatus.PLACED) {
                      updateProductPackage(orderItem)
                      updateProductUnitPrice(orderItem)
                  }

…ating a new product source on orderItem

- check if product source has changed
- removing lookup on product.packages becasue it casue a bug where it would unassing package from other product source because it is a 1:N relashinship where package can only have one product source
@awalkowiak awalkowiak merged commit 3935b71 into feature/upgrade-to-grails-3.3.10 Mar 22, 2024
@awalkowiak awalkowiak deleted the OBPIH-6253-source-pricing-not-visible-on-edit-product-page branch March 22, 2024 14:24
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.

4 participants