View source | Discuss this page | Page history | Printable version   

How to show identifier instead of name for Discounts in WebPOS Order Lines

Introduction

This How To shows how can be used a discounts identifier instead o name in order lines.

In this example we want to show discounts name + discount percentage instead of only name for manual discounts. For this purpose, we will create an identifier which will contain "name + percent value".

Add Identifier to Discount

First we will create a function to get the identifier for chosen discount:

 
OB.Model.Discounts.discountRules['20E4EC27397344309A2185097392D964'] = {
  addManual: function (receipt, line, promotion) {
    addPercentage(receipt, line, promotion);
  },
  getIdentifier: function (rule, discount) {
    return (discount.name || rule.get('printName') || rule.get('name')) + ' - ' + discount.percentage + ' %';
  }
};

Set Identifier

Once we've created the function, it result will be assigned to the identifier. Before this how to, the identifier value didn't exist for discounts, so we can use it safely. The next code is implemented in "addPromotion" function to assign identifier value:

 
if (discountRule.getIdentifier) {
  disc.identifier = discountRule.getIdentifier(rule, discount);
} else {
  disc.identifier = discount.name || rule.get('printName') || rule.get('name');
}

And finally, for the "OB.UI.RenderOrderLineDiscount" component the content assign command will be changed from

 
this.$.discountName.setContent('-- ' + this.discount.name);

to

 
this.$.discountName.setContent('-- ' + this.discount.identifier);

Retrieved from "http://wiki.openbravo.com/wiki/How_to_show_identifier_instead_of_name_for_Discounts_in_WebPOS_Order_Lines"

This page has been accessed 1,839 times. This page was last modified on 13 November 2015, at 12:10. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.