View source | Discuss this page | Page history | Printable version   
Main Page
Upload file
What links here
Recent changes

PDF Books
Add page
Show collection (0 pages)
Collections help


POS - Discount price for selected products

Code snippet

Name: POS - Discount price for selected products
Version: 1.0
Author: algaja

With this module it's possible to give discount price for selected products what can apply only when customer are selected. Add new resource called Script.DiscountedPrice:

import com.openbravo.format.Formats;
import com.openbravo.pos.ticket.TicketLineInfo;
import com.openbravo.pos.ticket.TicketProductInfo;

boolean ale = false; 
customer = ticket.getCustomer(); 

if (customer != null) {
	for(int i= 0; i < ticket.getLinesCount(); i++){  
		line = ticket.getLine(i); 
		if((line.getProperty("ALLOWED").equals("YES")) && (line.getProperty("sendstatus") == null)){		
			line.setProperty("sendstatus", "No"); 

		if((line.getProperty("ALLOWED").equals("YES")) && (line.getProperty("sendstatus").equals("No"))){
			ale = true;			
			double discounted = Double.parseDouble(line.getProperty("DISCOUNTED", "0"));  
			if (discounted != null) {

	for(int i = ticket.getLinesCount()-1; i>= 0 ; i--){  
		line = ticket.getLine(i); 
		String a = line.getProperty("sendstatus"); 

		if((line.getProperty("ALLOWED").equals("YES")) && (line.getProperty("sendstatus").equals("No"))){ 
			line.setProperty("sendstatus", "OK"); 
} else {

Add into Ticket.buttons resource this line:

    <button key="button.DiscountedPrice" name="button.DiscountedPrice" code="Script.DiscountedPrice"/> 

Add into roles this line:

    <class name="button.DiscountedPrice"/> 

Add into file this line:


And now select products where you want to add discounted price and add this line into preferences tab:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "">
    <entry key="ALLOWED">YES</entry>
    <entry key="DISCOUNTED">25.00</entry>

ALLOWED show that it's allowed to apply the discounted price YES - alloed, NO - Not allowed DISCOUNTED are the discounted price with TAX

Retrieved from ""

This page has been accessed 14,068 times. This page was last modified on 15 July 2010, at 17:08. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.