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

How to Extend AdditionalFilters

Bulbgraph.png   This feature is available starting from 3.0RR14Q4

Overview

AdditionalFilters is the way to extend StandardFilter (filters to apply to get the discounts). With this functionality filters can be created dynamically, adding more flexibility. These filters are used to apply discounts in the WebPOS. Find more information about discounts&promotions.

The output of generateFilter must be a non-empty string starting with the word AND with also a starting space.

Example

This example shows how to create additional filters.

 
OB.Model.Discounts.additionalFilters.push({
  generateFilter: function (receipt) {
    var currentCoupons = "", i, filter = "";
    if (receipt.get('coupons')) {
      for (i = 0; i < receipt.get('coupons').length; i++) {
        if (i !== 0) {
          currentCoupons += ",";
        }
        currentCoupons += "'" + receipt.get('coupons')[i].offerid + "'";
      }
    }
    filter = "and (M_Offer.EM_OBDISCP_ISCOUPON !='true'";
    if (currentCoupons !== "") {
      filter += " or M_Offer.M_Offer_Id in (" + currentCoupons + ")) "
    } else {
      filter += ")";
    }
    return filter;
  }
});

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

This page has been accessed 2,551 times. This page was last modified on 29 September 2014, at 14:30. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.