Developer Resources
Create Quote & Create Order Gl...
Price Tags & Discount Tags
22 min
nue's pricing engine supports https //docs nue io/price and discount tags and discount tags collectively called "price dimensions" that modify line item pricing through tier based rules tags are evaluated by the pricing engine and their effects are reflected in the response as system level price adjustments tag types all tags are stored as ruby pricedimension c records the ruby recordtype c field determines whether a tag overrides the list price or applies a discount tag type recordtype effect price tag pricedimension overrides the list price based on tier rules discount tag discountdimension applies a system discount based on tier rules price type (tier behavior) the ruby pricetype c field controls how tiers are evaluated pricetype behavior example volume a single tier applies based on total quantity all units priced at the matching tier rate qty 5+ = $30/unit (all 10 units at $30) tiered multiple tiers accumulate each range of units is priced at its own tier rate first 12 months at 5%, next 12 months at 10% ramp creates separate ramp line items for each period, each with its own pricing year 1 $100/mo, year 2 $90/mo, year 3 $80/mo how tags are applied tags can reach a line item through two paths path how it works field request applied specified directly on the productinput pricetags list pricetaginput code or pricetaginput id auto attached configured in the product catalog via ruby productpricedimension c (product level) or ruby productoptionpricedimension c (bundle option level) automatic no request configuration needed both paths can be combined a product can have auto attached tags from the catalog and additional request applied tags pricetaginput tags are specified using ruby globalapitypes pricetaginput global class pricetaginput { global string code; // ruby pricedimension c ruby code c global string id; // ruby pricedimension c id } you can identify a tag by code , id , or both if both are provided, id takes precedence use cases 1\ apply discount tag by id apply a volume discount tag using its salesforce record id opportunity opp = \[select id, accountid from opportunity where id = \ oppid]; ruby globalapitypes createquoterequest request = new ruby globalapitypes createquoterequest(); request iscommit = false; request accountid = opp accountid; request quote = new quote( name = 'discount tag by id', opportunityid = opp id, ruby subscriptionstartdate c = date today(), ruby subscriptionterm c = 12, ruby subscriptiontermdimension c = 'month' ); ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // apply discount tag by id ruby globalapitypes pricetaginput tag = new ruby globalapitypes pricetaginput(); tag id = discounttagid; // ruby pricedimension c id for a 10% volume discount prod pricetags = new list\<ruby globalapitypes pricetaginput>{ tag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // expected systemdiscount applied // listtotalprice = $100 x 10 x 12 = $12,000 // systemdiscountamount = $1,200 (10%) // subtotal = $10,800 system assertequals('succeed', response status); ruby globalapitypes quotelineitemdto li = response data lineitems\[0]; system assertnotequals(null, li appliedpricetags); system assertequals(1, li appliedpricetags size()); 2\ apply discount tag by code use the tag's ruby code c value instead of its record id codes are portable across environments ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // apply discount tag by code ruby globalapitypes pricetaginput tag = new ruby globalapitypes pricetaginput(); tag code = 'regr disc term tiered'; // tiered discount 5% for first 12mo, 10% for next 12mo prod pricetags = new list\<ruby globalapitypes pricetaginput>{ tag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); system assertequals('succeed', response status); system assertnotequals(null, response data lineitems\[0] appliedpricetags); 3\ apply price tag by code a price tag overrides the product's list price based on tier rules unlike discount tags, price tags change the base price rather than applying a percentage reduction ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // price tag volume pricing — qty 5+ = $30/unit (overrides list price of $100) ruby globalapitypes pricetaginput tag = new ruby globalapitypes pricetaginput(); tag code = 'regr price qty volume'; prod pricetags = new list\<ruby globalapitypes pricetaginput>{ tag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // expected price tag overrides list price // salesprice = $30/unit (from tier), not $100/unit (list) // listtotalprice = $100 x 10 x 12 = $12,000 (original list) // systemdiscountamount may be negative if price tag increases above list system assertequals('succeed', response status); 4\ price tag + discount tag on same line both a price tag and a discount tag can be applied to the same product the price tag adjusts the base price first, then the discount tag applies its percentage reduction ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // price tag $30/unit (volume pricing) ruby globalapitypes pricetaginput pricetag = new ruby globalapitypes pricetaginput(); pricetag code = 'regr price qty volume'; // discount tag 10% volume discount ruby globalapitypes pricetaginput discounttag = new ruby globalapitypes pricetaginput(); discounttag code = 'vol discount 10'; prod pricetags = new list\<ruby globalapitypes pricetaginput>{ pricetag, discounttag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // expected price tag sets $30/unit, then 10% discount // effective price = $30 x 0 9 = $27/unit // both tags appear in appliedpricetags system assertequals('succeed', response status); system assertequals(2, response data lineitems\[0] appliedpricetags size()); 5\ auto attached + request applied tags a product may already have auto attached tags from ruby productpricedimension c records in the catalog you can add additional tags via the request both are evaluated // nue platform already has an auto attached discount tag in the product catalog ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // add an additional discount tag via the request ruby globalapitypes pricetaginput additionaltag = new ruby globalapitypes pricetaginput(); additionaltag code = 'loyalty discount 5'; prod pricetags = new list\<ruby globalapitypes pricetaginput>{ additionaltag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // expected both auto attached and request applied tags in appliedpricetags // if a duplicate tag is applied (same id), a duplicate price tag warning is returned system assertequals('succeed', response status); warning if you apply a tag that is already auto attached (same ruby pricedimension c id ), the api returns a duplicate price tag warning and the tag is applied only once 6\ different tags on different lines each product in the request can have its own set of tags tags are evaluated per line item // product 1 volume pricing tag ruby globalapitypes productinput prod1 = new ruby globalapitypes productinput(); prod1 productsku = 'nue platform'; prod1 uom = 'user/month'; prod1 quantity = 10; ruby globalapitypes pricetaginput tag1 = new ruby globalapitypes pricetaginput(); tag1 code = 'regr price qty volume'; prod1 pricetags = new list\<ruby globalapitypes pricetaginput>{ tag1 }; // product 2 tiered discount tag ruby globalapitypes productinput prod2 = new ruby globalapitypes productinput(); prod2 productsku = 'nue on salesforce'; prod2 uom = 'user/month'; prod2 quantity = 25; ruby globalapitypes pricetaginput tag2 = new ruby globalapitypes pricetaginput(); tag2 code = 'regr disc term tiered'; prod2 pricetags = new list\<ruby globalapitypes pricetaginput>{ tag2 }; request products = new list\<ruby globalapitypes productinput>{ prod1, prod2 }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // each line item has its own applied tags system assertequals('succeed', response status); system assertequals(2, response data lineitems size()); 7\ ramp discount tags ramp tags create separate line items for each period for example, a ramp discount might apply 5% for the first 12 months and 10% for the next 12 months, resulting in two child line items ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // ramp discount different rates for different periods ruby globalapitypes pricetaginput ramptag = new ruby globalapitypes pricetaginput(); ramptag code = 'ramp disc annual'; prod pricetags = new list\<ruby globalapitypes pricetaginput>{ ramptag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // expected multiple line items created for the ramp periods // the original line item is expanded into ramp segments, // each with its own start/end dates and pricing system assertequals('succeed', response status); // total line items > 1 due to ramp expansion 8\ auto attached tags in bundle context when a bundle option has ruby productoptionpricedimension c records, those tags are automatically applied to the child line item when the bundle is expanded // nue gem edition with implementation service add on // implementation service has a productoptionpricedimension "free 20 hours" discount ruby globalapitypes productinput bundle = new ruby globalapitypes productinput(); bundle productsku = 'nue gem edition'; bundle uom = 'user/month'; bundle quantity = 1; ruby globalapitypes productinput addon = new ruby globalapitypes productinput(); addon productsku = 'implementation service'; bundle addons = new list\<ruby globalapitypes productinput>{ addon }; request products = new list\<ruby globalapitypes productinput>{ bundle }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // the implementation service line item automatically has the "free 20 hours" // tag applied from ruby productoptionpricedimension c for (ruby globalapitypes quotelineitemdto li response data lineitems) { if (li quotelineitem product2 stockkeepingunit == 'implementation service') { system assertnotequals(null, li appliedpricetags); // auto attached tag from productoptionpricedimension is present } } note you can also add request applied tags on top of auto attached bundle option tags both are merged into the pricetags list before pricing 9\ volume price tag on standalone a volume price tag evaluates the total quantity against tier breakpoints and applies a single tier price to all units ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // volume price tag qty 1 4 = $100, qty 5 9 = $50, qty 10+ = $30 ruby globalapitypes pricetaginput tag = new ruby globalapitypes pricetaginput(); tag code = 'regr price qty volume'; prod pricetags = new list\<ruby globalapitypes pricetaginput>{ tag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // with qty=10, the 10+ tier applies $30/unit for all 10 units // salesprice = $30, listtotalprice = $12,000, adjusted total based on $30/unit system assertequals('succeed', response status); 10\ tiered discount tag on standalone a tiered discount accumulates across tier boundaries different portions of the quantity or term are discounted at different rates ruby globalapitypes productinput prod = new ruby globalapitypes productinput(); prod productsku = 'nue platform'; prod uom = 'user/month'; prod quantity = 10; // tiered discount first 12 months at 5%, next 12 months at 10% ruby globalapitypes pricetaginput tag = new ruby globalapitypes pricetaginput(); tag code = 'regr disc term tiered'; prod pricetags = new list\<ruby globalapitypes pricetaginput>{ tag }; request products = new list\<ruby globalapitypes productinput>{ prod }; ruby globalapitypes createquoteresponse response = ruby globalquoteserviceapi createquote(request); // the tiered discount accumulates across tiers // systemdiscount and systemdiscountamount reflect the blended tier impact system assertequals('succeed', response status); system assertnotequals(null, response data lineitems\[0] appliedpricetags); pricing impact tags affect the following fields on each line item field description ruby systemdiscount c percentage of system discount from tags ruby systemdiscountamount c currency amount of system discount ruby subtotal c listtotalprice systemdiscountamount ruby netsalesprice c effective per unit price after tag adjustments price tags may produce a negative ruby systemdiscount c when they increase the effective price above the list price (e g , a price tag that sets a higher tier rate than the product's list price) applied tags in response each line item's appliedpricetags list contains pricingdimension objects with full tag details ruby globalapitypes quotelineitemdto li = response data lineitems\[0]; for (pricingdimension pd li appliedpricetags) { system debug('tag id ' + pd id); system debug('tag name ' + pd name); system debug('record type ' + pd recordtype); // pricedimension or discountdimension system debug('price type ' + pd pricetype); // volume, tiered, or ramp } price impacts in response each line item's priceimpacts list shows the monetary effect of each applied tag for (priceimpactresult impact li priceimpacts) { system debug('price impact ' + impact priceimpact); // negative = discount, positive = surcharge // impact appliedpricedimension contains the full tag details // impact priceresult contains the resulting subtotal, salesprice, etc }
Have a question?
Get answers fast with Nue’s intelligent AI, expert support team, and a growing community of users - all here to help you succeed.
To ask a question or participate in discussions, you'll need to authenticate first.