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

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

Search

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) {
				line.setPriceTax(discounted);	
			}			
			
		}
		
	}  

	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 {
    java.awt.Toolkit.getDefaultToolkit().beep();  
}

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 pos_messages.properties file this line:

button.DiscountedPrice=Discount

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 "http://java.sun.com/dtd/properties.dtd">
<properties>
    <entry key="ALLOWED">YES</entry>
    <entry key="DISCOUNTED">25.00</entry>
</properties>

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 "http://wiki.openbravo.com/wiki/POS_-_Discount_price_for_selected_products"

This page has been accessed 14,256 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.