Skip to content

OBPIH-6707 Indicator when quantities in split line do not sum up to o…#4916

Merged
awalkowiak merged 3 commits intodevelopfrom
OBPIH-6707
Oct 28, 2024
Merged

OBPIH-6707 Indicator when quantities in split line do not sum up to o…#4916
awalkowiak merged 3 commits intodevelopfrom
OBPIH-6707

Conversation

@kchelstowski
Copy link
Collaborator

…riginal qty

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

If this PR contains a UI change, consider adding one or more screenshots here or link to a screen recording to help reviewers visualize the change. Otherwise, you can remove this section.

@kchelstowski kchelstowski self-assigned this Oct 25, 2024
@github-actions github-actions bot added domain: frontend Changes or discussions relating to the frontend UI domain: l10n Changes or discussions relating to localization & Internationalization labels Oct 25, 2024
react.partialReceiving.error.expiryWithoutLot.label=Items with an expiry date must also have a lot number.
react.partialReceiving.error.lotAndExpiryControl.label=Both lot number and expiry date are required for this item.
react.partialReceiving.confirmReceive.notSupportingPartialReceiving.message=You have not entered a value in the receiving quantity for ${count} line/lines on this shipment. These lines will be received as zero. You will not be able to go back and receive them later. Do you want to continue?
react.partialReceiving.mismatchingQuantityShipped.label=The total edited quantity does not match the original quantity shipped.
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 we should follow one pattern when naming those labels. I saw that we are using .error. in the labels.
So maybe we can call it like: react.partialReceiving.error.mismatchingQuantityShipped.label

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 agree, I never feel comfortable adding a new label because I always wonder if any pattern is applicable there.

.reduce((acc, [key, value]) =>
({
...acc,
[key]: value.reduce((sum, curr) => (sum + _.toInteger(curr.quantityShipped)), 0),
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can just use sum or sumBy instead of using nested reduce.

* as after mapping, the result would look like
* [[<shipmentItem>, <shipmentItem>], [<shipmentItem>, <shipmentItem>]]
*/
const shipmentItems = containers.map((container) => container.shipmentItems).flat();
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about _.flatten?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see any advantage of that, since flat() does the same

Copy link
Collaborator

Choose a reason for hiding this comment

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

you're right, so I think you can use _.flatMap instead 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤔 I swear I checked whether the .flatMap exists in JS, but couldn't find it, and suddenly it exists 😆

const { shipmentItemQuantityShippedSum } = this.state;
const originalItem = values.find((item) => item.rowId);
const qtyShippedSumFromModal =
values.reduce((acc, curr) => acc + _.toInteger(curr.quantityShipped), 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

_sum or _sumBy

@awalkowiak awalkowiak merged commit 329fa25 into develop Oct 28, 2024
@awalkowiak awalkowiak deleted the OBPIH-6707 branch October 28, 2024 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: frontend Changes or discussions relating to the frontend UI domain: l10n Changes or discussions relating to localization & Internationalization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants