Skip to content

OBPIH-6278 Do not allow uom qty different than 1, when chosen uom is …#4570

Merged
awalkowiak merged 2 commits intorelease/0.9.1from
OBPIH-6278
Apr 2, 2024
Merged

OBPIH-6278 Do not allow uom qty different than 1, when chosen uom is …#4570
awalkowiak merged 2 commits intorelease/0.9.1from
OBPIH-6278

Conversation

@kchelstowski
Copy link
Collaborator

…Each for the PO items import

UnitOfMeasure uom = uomParts.length > 1 ? UnitOfMeasure.findByCodeOrName(uomParts[0], uomParts[0]) : null
orderItem.quantityUom = uom
BigDecimal qtyPerUom = uomParts.length > 1 ? CSVUtils.parseNumber(uomParts[1], "unitOfMeasure"): null
if (uom?.id == 'EA' && qtyPerUom != 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is worth moving 'EA' to Constants.groovy as UOM_EACH_ID or EACH_ID

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I always feel uncomfortable hard-coding strings, but I thought you guys would treat it as an overkill in that case 🙈 but I'm happy we are on the same page

Copy link
Member

Choose a reason for hiding this comment

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

I agree with converting string literals to constants in most cases, especially for things like PKs. The exception is when it makes it much more difficult to read the code. For example, if I need to go to the constants file in order to figure out what the code is doing then that would be worse then using the string literal.

But this rule should be in our coding conventions and perhaps should become a linter rule as well.

Copy link
Member

Choose a reason for hiding this comment

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

And in this particular case, I would prefer UOM_EA_ID over EA_ID because the latter would require me to go to the constants.groovy to figure out what's going on. So hopefully that was what we went with.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmiranda Kacper went with even more descriptive -> UOM_EACH_ID

Copy link
Member

Choose a reason for hiding this comment

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

I saw that. ⛳ 👏

@awalkowiak awalkowiak merged commit 637752f into release/0.9.1 Apr 2, 2024
@awalkowiak awalkowiak deleted the OBPIH-6278 branch April 2, 2024 17:18
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