Adjust Floors for Bidadjustments#3910
Merged
Merged
Conversation
…justments-for-price-floors # Conflicts: # src/main/java/org/prebid/server/bidadjustments/BidAdjustmentFactorResolver.java # src/main/java/org/prebid/server/bidadjustments/BidAdjustmentsProcessor.java # src/test/java/org/prebid/server/bidadjustments/BidAdjustmentFactorResolverTest.java # src/test/java/org/prebid/server/bidadjustments/BidAdjustmentsProcessorTest.java
…justments-for-price-floors
CTMBNara
requested changes
May 30, 2025
Comment on lines
+64
to
+89
| private Price reversePrice(Price price, | ||
| List<BidAdjustmentsRule> bidAdjustmentRules, | ||
| BidRequest bidRequest) { | ||
|
|
||
| final List<BidAdjustmentsRule> reversedRules = bidAdjustmentRules.reversed(); | ||
| final String resolvedCurrency = price.getCurrency(); | ||
| BigDecimal resolvedPrice = price.getValue(); | ||
|
|
||
| for (BidAdjustmentsRule rule : reversedRules) { | ||
| final BidAdjustmentType adjustmentType = rule.getAdjType(); | ||
| final BigDecimal adjustmentValue = rule.getValue(); | ||
| final String adjustmentCurrency = rule.getCurrency(); | ||
|
|
||
| switch (adjustmentType) { | ||
| case MULTIPLIER -> resolvedPrice = resolvedPrice.divide(adjustmentValue, 4, RoundingMode.HALF_EVEN); | ||
| case CPM -> { | ||
| final BigDecimal convertedAdjustmentValue = currencyService.convertCurrency( | ||
| adjustmentValue, bidRequest, adjustmentCurrency, resolvedCurrency); | ||
| resolvedPrice = BidderUtil.roundFloor(resolvedPrice.add(convertedAdjustmentValue)); | ||
| } | ||
| case STATIC -> throw new PreBidException("STATIC type can't be applied to a floor price"); | ||
| } | ||
| } | ||
|
|
||
| return Price.of(resolvedCurrency, resolvedPrice); | ||
| } |
Collaborator
There was a problem hiding this comment.
I think it would be better to extract this method and BidAdjustmentsResolver.adjustPrice into a separate class so that both methods are in the same place. Also, then you can add a test that checks that
reverse(apply(price)) == price
Collaborator
Author
There was a problem hiding this comment.
@CTMBNara Not sure I like the idea. The check you suggested is more relevant to the integration/functional tests than unit tests, since this check is about the integrity. Also adjusting and reversing are not the same because of the static adjustment, so the check doesn't hit 100% success rate - it's more likely a use case for the functional test to set it up correctly and check.
CTMBNara
requested changes
Jun 3, 2025
Co-authored-by: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Co-authored-by: markiian <mmykush@magnite.com> Co-authored-by: osulzhenko <osulzhenko@magnite.com>
CTMBNara
previously approved these changes
Jun 4, 2025
…-price-floors # Conflicts: # src/main/java/org/prebid/server/auction/ExchangeService.java
CTMBNara
approved these changes
Jun 6, 2025
riteshghodrao
pushed a commit
to riteshghodrao/prebid-server-java
that referenced
this pull request
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Type of changes
✨ What's the context?
What's the context for the changes?
🧠 Rationale behind the change
Why did you choose to make these changes? Were there any trade-offs you had to consider?
🔎 New Bid Adapter Checklist
🧪 Test plan
How do you know the changes are safe to ship to production?
🏎 Quality check