Skip to content

#5568 Fix kit allocation/deallocation history display direction (fixes #5568)#5628

Open
rodrigovirgilio wants to merge 3 commits into
rubyforgood:mainfrom
rodrigovirgilio:fix/kit-allocation-history-display
Open

#5568 Fix kit allocation/deallocation history display direction (fixes #5568)#5628
rodrigovirgilio wants to merge 3 commits into
rubyforgood:mainfrom
rodrigovirgilio:fix/kit-allocation-history-display

Conversation

@rodrigovirgilio

Copy link
Copy Markdown
Contributor

Resolves #5568

Description

KitAllocateEvent/KitDeallocateEvent mix directions within a single event (components move one way, the kit item moves the other), and the kit's own line item is always last in the array. The history view derived From/To and quantity sign from the first item, which picked the component's direction instead of the kit's — showing kit counts negative and under the wrong location column. Now derives direction from the kit's line item for these two event types; underlying inventory math is untouched.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Screenshots

Comment thread app/views/events/_event_row.html.erb Outdated
# kit's own line item (always last) moves opposite the component items, so the
# row's From/To direction must be derived from the kit line item, not the first one.
is_kit_event = event.is_a?(KitAllocateEvent) || event.is_a?(KitDeallocateEvent)
direction_item = is_kit_event ? event.data.items.last : event.data.items.first

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems flaky. We shouldn't be depending on ordering here. Should we not just multiply the values by -1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed: 6fe19ca

@rodrigovirgilio rodrigovirgilio force-pushed the fix/kit-allocation-history-display branch from 750e14a to 6fe19ca Compare July 13, 2026 09:19
@rodrigovirgilio rodrigovirgilio requested a review from dorner July 13, 2026 09: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.

Rework history for kit allocations to be more intuitive

2 participants