Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBPIH-5237 Validate if merged products have pending stock movements #3875

Merged
merged 2 commits into from
Mar 6, 2023

Conversation

awalkowiak
Copy link
Collaborator

and do not allow to make a merge before finishing the pending stock movements

and do not allow to make a merge before finishing the pending stock movements
@awalkowiak awalkowiak requested a review from jmiranda March 2, 2023 16:29

flash.message = "${obsoleteProduct.productCode} Product merge to ${primaryProduct.productCode} has succeeded. " +
flash.message = "${params.obsoleteProduct} Product merge to ${params.primaryProduct} has succeeded. " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs to be localized. We should use the same pattern as with saved, created, deleted, updated, etc just in case we eventually want to merge other domain objects.

default.created.message={0} {1} created

So ...

default.merged.message = "{0} {1} was successfully merged into {0} {2}"

and then flash.message would look like this

flash.message=${g:message(code: "default.merged.label" args="[g.message(code: "product.label"), params.obsoleteProduct, params.primaryProduct]")}"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -77,6 +78,9 @@ class ProductMergeService {
*
* */

Product primary = Product.get(primaryId)
Product obsolete = Product.get(obsoleteId)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to validate the existence of these products again? What happens if someone deletes between the validation and merge process?

Also can we add a tech debt ticket to refactor the mergeProduct method to separate each operation into a separate method.

def mergeProduct(String primaryId, String obsoleteId) {
    mergeProductSuppliers(primary, obsolete)
    mergeProductComponents(...)
    ... 
    mergeTransaction() 
}

We should be able to independently test each of these merge operations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

throw new IllegalArgumentException("Cannot merge the product with itself")
}

def primaryRequisitionItems = requisitionService.getPendingRequisitionItems(primary)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with validation

validateProducts(String primaryId, String obsoleteId) { 
    validateProducts([primaryId, obsoleteId])
    validateOutboundStockMovementItems([primary, obsoleteId])
    ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

added localized message and moved validation check
@awalkowiak awalkowiak merged commit dfd9444 into feature/OBPIH-3186-Merge-products Mar 6, 2023
@awalkowiak awalkowiak deleted the OBPIH-5237 branch March 6, 2023 11:55
awalkowiak added a commit that referenced this pull request Mar 31, 2023
…3875)

* OBPIH-5237 Validate if merged products have pending stock movements
and do not allow to make a merge before finishing the pending stock movements

* OBPIH-5237 Minor improvements after review
added localized message and moved validation check
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.

None yet

2 participants