Sponsored Development: Promotions

From ADempiere
Revision as of 04:03, 5 July 2007 by Fredtsang (Talk) (Developers)

Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Under Construction- but please feel free to comment

Summary

ADempiere supports basic discounts. But there is a demand for many more types of promotions. This is an effort to collect and document the various promos that may be desired and establish a project to provide them.

Project Team

Coordinator

Joel Stangeland

Functional Specs

  • Joel Stangeland

Developers

  • Sendy Yagambrum (Developer)
  • Frederick Tsang (Architect)

Testers

Sponsors

Requirements

Overall

  • Promos should be configurable based on Organization, Warehouse, Business Partner, BP Group, Product, and Product Category
  • Promos should apply at the line or order level (existing discounts apply only at line level)
  • Existing functionality should be preserved
  • Need to support PromoCodes/Coupon Codes (i.e. the promo only applies if a code is submitted)

Related Threads

Give Away Articles

Sales Orders with Bonus Items

Basic Procedure

  1. When the order is prepared the Promo structure is evaluated
  2. If applicable Promo's are found insert an order line with the result
  3. Remove any promo lines (from previous prepares) that have not been delivered or invoiced


Questions

  • When/how should the promos be triggered? The current implementation is easy, it applies a discount at the line level as a reduction of the price. It is immediately visible. In order to facilitate order level promos, it seems like they need to be evaluated when the order is prepared. Does that seem right?
  • Should the promo be implemented as an inserted orderline? Would it be better to handle it similar to the tax implementation? It seems the order line would be better since some of the promos are products, the others can be charges.
  • There may be a need to check the promos before an order is processed, especially in a call center implementation. Maybe there could be a 'Check Promos' button so that you could preview the results before processing the order?
  • Is there any reason to implement these at some time other than Order?
  • The standard discount structure should probably remain for backward compatibility, but does it make sense to support discounts in the new structure as well?

What Promos to Have

  1. Existing Promos: Existing functionality is based on the discount schemas and supports the following options
    1. Flat Percentage: This existing feature allows for a percentage to be discounted from the order. The percentage can be the same for all BPs or can be defined at the individual BP level
    2. Line Level Quantity Based Break: Can define a product or product category, a minimum quantity to qualify for the break, and a discount Percent
    3. Line Level Currency Based Break: Can define a product or product category, a minimum price to qualify for the break, and a discount Percent
  2. Requested Promos
    1. "Buy x Get x": If you order x number of units of a Product or Product Category you get x units of some product free. There should also be a max quantity that the Promo applies to. This should probably also work on currency basis also (i.e. spend $50 get a free gizmo)
    2. Free Shipping: No charge incurred for shipping costs
    3. Order Level Currency Based Break: Based on the total of the order, get a discount percent
    4. Gift Card: Gift cards can be purchased in advance, and can be applied to purchases until the balance is gone. This might be a whole different animal, but note it here anyway.
    5. Promo Credit: A percent of the price of certain items is added to an account, and can later be redeemed for certain products.

AD Changes

  1. Add table M_Promo
    1. Value
    2. Name
    3. Description
    4. M_Warehouse_ID
    5. C_BPartner_ID
    6. C_BP_Group_ID
    7. C_Charge_ID  : What to charge the expense to
    8. IsCodeMandatory
    9. M_PromoType_ID
    10. M_PromoMin : The number they must purchase to get the promo.
    11. M_PromoMax  : Sometimes there is an upper limit. For example if this is 20, then if they buy more than 20, they only get the free items based on the first 20.
    12. M_PROMO_PRODUCT_ID : This is the item that they get free
    13. M_PROMO_QTY : This is the number of the item that they can get free
    14. VALIDFROM  :Date the promo starts
    15. VALIDTO  : date the promo ends
    16. IsExclusive  : No other Promos can be used
  2. Add to C_Orderline
    1. IsPromoGenerated flag to C_Orderline (for cleanup in case the order is changed and re-prepared)
    2. M_PROMO_ID
  3. Add table M_Promocode
    1. Value
    2. Name
    3. Description
    4. M_Promo_ID
  4. M_PromoType - for adding the different promo methods listed above
    1. Value
    2. Class


Code Specifications

buy x get x

When the order is prepared or completed:

0. Check to see if there are any orderlines where ISPROMOGENERATED=Y AND QtyDelivered=0. Delete these lines- previously generated but not shipped out yet.

1. Check to see if the order BPartner or BPartnerGroup matches to an M_Promo record or if there is an M_Promo that applies to all BPs; and C_Order.DateOrdered is in between M_Promo.ValidFrom and M_Promo.ValidTo if so, then #2.

2. Check to see if C_Orderline.M_Product_ID is in M_Promo where IsActive='Y' AND C_Order.DateOrdered is in between M_Promo.ValidFrom and M_Promo.ValidTo AND C_Orderline.QtyOrdered > M_Promo.MinQty if so then #4

3. Get the Qty to use as MultiplierQty. Take the lesser of QtyOrdered or X_MaxQty

4. Insert a line to the order with M_product_ID=M_Promo_Product_ID AND QtyOrdered= MultiplierQty*M_Promo_Qty AND Price=0 AND M_PROMO_ID= the promo that created the line, AND ISPROMOGENERATED='Y'