{"action":"closed","issue":{"url":"https://api.github.com/repos/prebid/Prebid.js/issues/3837","repository_url":"https://api.github.com/repos/prebid/Prebid.js","labels_url":"https://api.github.com/repos/prebid/Prebid.js/issues/3837/labels{/name}","comments_url":"https://api.github.com/repos/prebid/Prebid.js/issues/3837/comments","events_url":"https://api.github.com/repos/prebid/Prebid.js/issues/3837/events","html_url":"https://github.com/prebid/Prebid.js/issues/3837","id":445651880,"node_id":"MDU6SXNzdWU0NDU2NTE4ODA=","number":3837,"title":"Bug: bid.getCpmInNewCurrency does not use latest bid.cpm value and returns value as per original bid value.","user":{"login":"pm-harshad-mane","id":8835908,"node_id":"MDQ6VXNlcjg4MzU5MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/8835908?v=4","gravatar_id":"","url":"https://api.github.com/users/pm-harshad-mane","html_url":"https://github.com/pm-harshad-mane","followers_url":"https://api.github.com/users/pm-harshad-mane/followers","following_url":"https://api.github.com/users/pm-harshad-mane/following{/other_user}","gists_url":"https://api.github.com/users/pm-harshad-mane/gists{/gist_id}","starred_url":"https://api.github.com/users/pm-harshad-mane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pm-harshad-mane/subscriptions","organizations_url":"https://api.github.com/users/pm-harshad-mane/orgs","repos_url":"https://api.github.com/users/pm-harshad-mane/repos","events_url":"https://api.github.com/users/pm-harshad-mane/events{/privacy}","received_events_url":"https://api.github.com/users/pm-harshad-mane/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"snapwich","id":551085,"node_id":"MDQ6VXNlcjU1MTA4NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/551085?v=4","gravatar_id":"","url":"https://api.github.com/users/snapwich","html_url":"https://github.com/snapwich","followers_url":"https://api.github.com/users/snapwich/followers","following_url":"https://api.github.com/users/snapwich/following{/other_user}","gists_url":"https://api.github.com/users/snapwich/gists{/gist_id}","starred_url":"https://api.github.com/users/snapwich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapwich/subscriptions","organizations_url":"https://api.github.com/users/snapwich/orgs","repos_url":"https://api.github.com/users/snapwich/repos","events_url":"https://api.github.com/users/snapwich/events{/privacy}","received_events_url":"https://api.github.com/users/snapwich/received_events","type":"User","site_admin":false},"assignees":[{"login":"snapwich","id":551085,"node_id":"MDQ6VXNlcjU1MTA4NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/551085?v=4","gravatar_id":"","url":"https://api.github.com/users/snapwich","html_url":"https://github.com/snapwich","followers_url":"https://api.github.com/users/snapwich/followers","following_url":"https://api.github.com/users/snapwich/following{/other_user}","gists_url":"https://api.github.com/users/snapwich/gists{/gist_id}","starred_url":"https://api.github.com/users/snapwich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapwich/subscriptions","organizations_url":"https://api.github.com/users/snapwich/orgs","repos_url":"https://api.github.com/users/snapwich/repos","events_url":"https://api.github.com/users/snapwich/events{/privacy}","received_events_url":"https://api.github.com/users/snapwich/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2019-05-17T23:35:02Z","updated_at":"2019-06-03T17:51:59Z","closed_at":"2019-06-03T17:51:59Z","author_association":"CONTRIBUTOR","body":"## Description\r\nBug: bid.getCpmInNewCurrency does not use the latest bid.cpm value and returns value as per original bid value.\r\nWe need an API to convert bid from one currency to another.\r\n\r\n## Scenario\r\nI have set ad-server-currency in the config to INR, let's say USD to INR rate is 1:100.\r\nI want to send bid value in INR to my ad-server but I want to send bid value in USD to my analytics.\r\n\r\nThe partner sends bid of $5.\r\nI have put a hook on \"bidResponse\" so when my handler gets a bid object\r\n- bid.cpm is now 500 (INR)\r\n- bid.getCpmInNewCurrency('USD') returns 5 ($)\r\n- now I change bid.cpm = 100\r\n- but now bid.getCpmInNewCurrency('USD') still returns 5 ($)\r\nI do not have a way to convert the 100INR to equivalent $\r\nI think the bug is introduced due to keeping the actual value of bid.cpm in a variable at https://github.com/prebid/Prebid.js/blob/master/modules/currency.js#L184 and keeping the actual currency value in https://github.com/prebid/Prebid.js/blob/master/modules/currency.js#L183 which are refered in function getCpmInNewCurrency @ https://github.com/prebid/Prebid.js/blob/master/modules/currency.js#L187\r\n\r\n### Expected results\r\nApproach 1: Quick fix: Can we extend getCpmInNewCurrency which has only one argument (toCurrency) to have multiple arguments (toCurrency, fromCurrency = fromCurrency (var on line 183), cpm = cpm (var on line 184) )\r\nThis will help publisher to change bids and also get corresponding bid value in othe currency (USD). Here still all attributes related to cpm (originalCpm etc.) are not updated and publisher will need to update those manually.\r\n\r\nApproach 2:\r\nProvide a separate API to do bid conversion in pbjs name-space.\r\n\r\nApproach 3: \r\nProvide an API to set the bid cpm value again in bid object which will recalculate values for all cpm related attributes.\r\n\r\n\r\n"}}
{"actor":{"display_login":"pm-harshad-mane"}}