In a previous post (at Business forums) I said that I'll share step by step deploying promotion module in smartPOS.
The basic stuff I'd like to have before deployement are the following : * Discount in % during a certain period * Discount in Money during a certain period * Buy nX get nY * Buy X get Discount Y n% * Buy nX and nY cheaper (product package) * Buy nX get nY
Here is what we did. Please note that to deploy this you need to get the source code of the 2.1 smartPOS version, also the 2.1 iDempiere version and the knowledge of compiling the project with a Java IDE (Netbeans & eclipse in my case) and playing with DB (Postgresql in my case)
2.define promotion in iDempiere. you can refer from adaxa documentation (attached)
* try directly inside iDempiere, make an Order with promotion that already defined, you'll get behaviour of Sales Order it always create one new line to substract total amount of sales and it noted as charge with account that you defined in Promotion windows.
3.SQL part
First thing is to create 2 tables : the one that will contain the promotion type (called promo_type) and the one that will contain the definition of the promo itself (called promo_header).
-- Table: promo_type
CREATE TABLE promo_type
(
id bigint NOT NULL,
description character(50),
bonustype bigint,
CONSTRAINT type_id PRIMARY KEY (id )
)
WITH (
OIDS=FALSE
);
ALTER TABLE promo_type
OWNER TO postgres;
GRANT ALL ON TABLE promo_type TO postgres;
GRANT ALL ON TABLE promo_type TO public;
-- Table: promo_header
CREATE TABLE promo_header
(
id character(255) NOT NULL,
name character(255),
startdate bigint,
enddate bigint,
starthour bigint,
endhour bigint,
article character varying(255),
articlecategory character varying(255),
type bigint,
amount numeric(9,3),
qtymin bigint,
qtymax bigint,
qtystep bigint,
amountstep bigint,
bonusarticle character varying(255),
bonusarticledesc character varying(255),
bonus_point_reward integer,
customer_type integer NOT NULL DEFAULT 0,
article2 character varying(255),
qty2 bigint,
ket character varying(255),
promo_id numeric,
c_charge_id numeric,
bpgroup_id numeric,
CONSTRAINT promo_header_pkey PRIMARY KEY (id )
)
WITH (
OIDS=FALSE
);
ALTER TABLE promo_header
OWNER TO postgres;
Promo_type Rules: Type are predefined and the code is built based on that. This table is used while filling a new promotion in Promotion Code field in iDempiere promotion windows
Promo_header Rules: ID : an autogenerated identifier field Name : the name of the discount/promo, the one that you named in iDempiere at Promotion windows header (adempiere.m_promotion) startdate/ enddate : Format is YYYYMMDD. you fill it in iDempiere on preCondition tab at startdate & enddate field starthour/endhour : Format is HH. You can only manage hour, not minute. Mandatory for having a discount working properly. Article : product_id which is defined as promo product in iDempiere on Promotion Group Windows at Group Line (adempiere.m_promotiongroup_line) Type : here you define the behaviour of your promotion. Qtymin / QtypMax / QtyStep : product qty scope of your promotion depending on the type. defined in iDempiere on Promotion Windows Qty Distribution Amountstep : denomination/ percentage discount that customer will get.
* promo_id, c_charge_id, bpgroup_id : ID refer to ID that defined from iDempiere.
4. Java Part
a. create new package com.openbravo.pos.promotion (source code attached)
b. next create class I named PromotionDao for pull data from ERP (source code attached)
c. Add Method in TicketLineInfo.java
private long promoId=0;
private String promoName="";
private long chargeId;
private double diskon=0;
private double diskonPrint=0;
public void setDiskon(double diskon){
this.diskon=diskon;
}
public double getDiskon() {
return diskon;
}
public void setDiskonPrint(double diskonPrint){
this.diskonPrint=diskonPrint;
}
public double getDiskonPrint() {
return diskonPrint;
}
public String printDiskon() {
return Formats.DOUBLE.formatValue(diskon);
}
public String printDiskonPrint() {
return Formats.DOUBLE.formatValue(diskonPrint);
}
public long getPromoId() {
return promoId;
}
public void setPromoId(long promoId) {
this.promoId = promoId;
}
public String getPromoName() {
return promoName;
}
public void setPromoName(String promoName) {
this.promoName = promoName;
}
public long getChargeId() {
return chargeId;
}
public void setChargeId(long chargeId) {
this.chargeId = chargeId;
}
d. add some code/ script in JPanelTicket.java on refreshticket method
In a previous post (at Business forums) I said that I'll share step by step deploying promotion module in smartPOS.
The basic stuff I'd like to have before deployement are the following :
* Discount in % during a certain period
* Discount in Money during a certain period
* Buy nX get nY
* Buy X get Discount Y n%
* Buy nX and nY cheaper (product package)
* Buy nX get nY
Here is what we did. Please note that to deploy this you need to get the source code of the 2.1 smartPOS version, also the 2.1 iDempiere version and the knowledge of compiling the project with a Java IDE (Netbeans & eclipse in my case) and playing with DB (Postgresql in my case)
1.activate promotion module in iDempiere using promotion validator. please refer to https://idempiere.atlassian.net/browse/IDEMPIERE-2117
2.define promotion in iDempiere. you can refer from adaxa documentation (attached)
* try directly inside iDempiere, make an Order with promotion that already defined, you'll get behaviour of Sales Order it always create one new line to substract total amount of sales and it noted as charge with account that you defined in Promotion windows.
3.SQL part
First thing is to create 2 tables : the one that will contain the promotion type (called promo_type) and the one that will contain the definition of the promo itself (called promo_header).
Promo_type Rules:
Type are predefined and the code is built based on that.
This table is used while filling a new promotion in Promotion Code field in iDempiere promotion windows
Promo_header Rules:
ID : an autogenerated identifier field
Name : the name of the discount/promo, the one that you named in iDempiere at Promotion windows header (adempiere.m_promotion)
startdate/ enddate : Format is YYYYMMDD. you fill it in iDempiere on preCondition tab at startdate & enddate field
starthour/endhour : Format is HH. You can only manage hour, not minute. Mandatory for having a discount working properly.
Article : product_id which is defined as promo product in iDempiere on Promotion Group Windows at Group Line (adempiere.m_promotiongroup_line)
Type : here you define the behaviour of your promotion.
Qtymin / QtypMax / QtyStep : product qty scope of your promotion depending on the type. defined in iDempiere on Promotion Windows Qty Distribution
Amountstep : denomination/ percentage discount that customer will get.
* promo_id, c_charge_id, bpgroup_id : ID refer to ID that defined from iDempiere.
Last edit: Edwin Kurniawan 2016-07-25
continue from part above
4. Java Part
a. create new package com.openbravo.pos.promotion (source code attached)
b. next create class I named PromotionDao for pull data from ERP (source code attached)
c. Add Method in TicketLineInfo.java
d. add some code/ script in JPanelTicket.java on refreshticket method
e. Add Synch Promo Button along side with Synchonize data button in SynchPanel.java
Last edit: Edwin Kurniawan 2016-07-25
Here is video result : smartPOS-ERP Promotion
we're developing promotion module referring to http://itsurgeries.blogspot.co.id/2011/11/openbravo-pos-230-promotion-management.html that wrote by Aurélien Escartin. thanks to him :)
Last edit: Edwin Kurniawan 2016-07-25
Thanks for sharing Edwin