{"id":905,"date":"2021-04-18T16:24:49","date_gmt":"2021-04-18T16:24:49","guid":{"rendered":"http:\/\/morecpq.com\/?p=905"},"modified":"2021-09-16T14:02:25","modified_gmt":"2021-09-16T14:02:25","slug":"cpq-amendment-discount-amount-fix","status":"publish","type":"post","link":"https:\/\/morecpq.com\/index.php\/2021\/04\/18\/cpq-amendment-discount-amount-fix\/","title":{"rendered":"CPQ &#8211; Amendment Discount Amount &#8211; Fix"},"content":{"rendered":"\n<p><strong>The Issue<br><\/strong>We recently discovered an issue with amending a Contract containing lines that had a Discount Amount on the original Quote.  The issue is that, when you amend a line that has a Discount Amount from the original Quote, the whole discount value is put on that line from before.  Which doesn&#8217;t make sense because when it is an amount, it should be a prorated amount based on the time left on the Contract.  Because of this, when a customer cancels a Contract, the refund amount (negative amount) on the Quote would be different than what was actually owed.<\/p>\n\n\n\n<p><strong>Another Detail<br><\/strong>A Quote Line that had a Discount % applied turns into a Subscription with the Discount % filled in.  All good.  When it renews, the renewal Quote Line has Discount AMOUNT $ filled in?!  Not a Discount %.  So as your discounted customers renew, this issue is propagated.<\/p>\n\n\n\n<p><strong>ProrateAmountDiscounts__c<\/strong>??<br>But but but, what about the ProrateAmountDiscounts__c special field as referenced <a rel=\"noreferrer noopener\" href=\"https:\/\/help.salesforce.com\/articleView?id=000314792&amp;type=1&amp;mode=1\" target=\"_blank\">here<\/a>?  This is a great solution but this will apply the proration to all types of Quotes.  We only want it to apply to amendments.<\/p>\n\n\n\n<p><strong>The Solution<\/strong><br>So I made a thing!  It is two formula fields and a Price Rule.  This thing will prorate the discount for any lines that had a Discount Amount on the original Quote.<\/p>\n\n\n\n<p><strong>Subscription &#8211; Original Discount $<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"850\" height=\"460\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-16.png?resize=850%2C460\" alt=\"\" class=\"wp-image-907\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-16.png?w=850&amp;ssl=1 850w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-16.png?resize=300%2C162&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-16.png?resize=768%2C416&amp;ssl=1 768w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/figure>\n\n\n\n<p><strong>Quote Line &#8211; Original Discount $<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"856\" height=\"532\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-17.png?resize=856%2C532\" alt=\"\" class=\"wp-image-908\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-17.png?w=856&amp;ssl=1 856w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-17.png?resize=300%2C186&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-17.png?resize=768%2C477&amp;ssl=1 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/figure>\n\n\n\n<p><strong>Price Rule &#8211; Quote Line &#8211; Amendment &#8211; Inject Calculated Discount $<\/strong><\/p>\n\n\n\n<p>Pertinent Price Rule Details<\/p>\n\n\n\n<p>Calculator Evaluation Event: Before Calculate<\/p>\n\n\n\n<p>Price Conditions<\/p>\n\n\n\n<p>Quote . SBQQ__Type__c equals Value Amendment<br>Quote Line . NOT(ISBLANK(Original_Discount_Amt__c)) equals Formula True<\/p>\n\n\n\n<p>Price Actions<\/p>\n\n\n\n<p>Quote Line . Discount (Amt) = Original_Discount_Amt__c \/ (IF(SBQQ__DefaultSubscriptionTerm__c == 1, SBQQ__EffectiveSubscriptionTerm__c, 1) \/ SBQQ__ProrateMultiplier__c)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"523\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/09\/image-1.png?resize=940%2C523&#038;ssl=1\" alt=\"\" class=\"wp-image-1179\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/09\/image-1.png?resize=1024%2C570&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/09\/image-1.png?resize=300%2C167&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/09\/image-1.png?resize=768%2C428&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/09\/image-1.png?resize=1536%2C855&amp;ssl=1 1536w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/09\/image-1.png?w=1597&amp;ssl=1 1597w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p>And <a href=\"https:\/\/login.salesforce.com\/packaging\/installPackage.apexp?p0=04t4x000000lwy7&amp;isdtp=p1\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a> is the production install link and <a href=\"https:\/\/test.salesforce.com\/packaging\/installPackage.apexp?p0=04t4x000000lwy7&amp;isdtp=p1\" target=\"_blank\" rel=\"noreferrer noopener\">this one<\/a> for sandbox!<\/p>\n\n\n\n<p>After you install, be sure to run the below script in the execute anonymous popup in the developer console.  Click <a href=\"https:\/\/login.salesforce.com\/_ui\/common\/apex\/debug\/ApexCSIPage\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a> to open the developer console in production and <a href=\"https:\/\/test.salesforce.com\/_ui\/common\/apex\/debug\/ApexCSIPage\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a> to open it in sandbox.<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:12px\"><code>MoreCPQPostInstall.AmendmentDiscountAmount_Fix_PostInstall();<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"314\" height=\"373\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-23.png?resize=314%2C373\" alt=\"\" class=\"wp-image-920\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-23.png?w=314&amp;ssl=1 314w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-23.png?resize=253%2C300&amp;ssl=1 253w\" sizes=\"(max-width: 314px) 100vw, 314px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"658\" height=\"407\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-22.png?resize=658%2C407\" alt=\"\" class=\"wp-image-916\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-22.png?w=658&amp;ssl=1 658w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/04\/image-22.png?resize=300%2C186&amp;ssl=1 300w\" sizes=\"(max-width: 658px) 100vw, 658px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The IssueWe recently discovered an issue with amending a Contract containing lines that had a Discount Amount on the original Quote. The issue is that, when you amend a line that has a Discount Amount from the original Quote, the whole discount value is put on that line from before. Which doesn&#8217;t make sense because &hellip;<br \/><a href=\"https:\/\/morecpq.com\/index.php\/2021\/04\/18\/cpq-amendment-discount-amount-fix\/\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">CPQ &#8211; Amendment Discount Amount &#8211; Fix<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-905","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/comments?post=905"}],"version-history":[{"count":15,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/905\/revisions"}],"predecessor-version":[{"id":1183,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/905\/revisions\/1183"}],"wp:attachment":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/media?parent=905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/categories?post=905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/tags?post=905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}