This Script adds a Deposit function for items such as Bottles and Cans that are returnable
It adds a unique line for each type of item and when you add more of the same product it updates the line.
Add a Product Attribute[]
Add this code to the properties tab to each product that you want to have a deposit taken - edit to the amount of the deposit before tax.
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <entry key="Bottle">.3</entry> </properties>
Add this to your Addline script[]
This script will not work unless you add these lines right before the first line below starting with " if
import com.openbravo.pos.ticket.TicketLineInfo;
if (line.getProperty("Bottle") != null){ bottlename = line.getProductName()+ " Deposit"; bottle = line.getProperty("Bottle"); Double newprice = new Double(bottle); NewMultiple = line.getMultiply(); boolean bottlea = false; boolean bottleb = false; index = sales.getSelectedIndex(); if (index >= 0) { for(int i= 0; i < ticket.getLinesCount(); i++){ line = ticket.getLine(i); if (line.getProductName().equals(bottlename)){ line = ticket.getLine(i); ticket.setLine(i, new TicketLineInfo( line.getProductID(), line.getProductName(), line.getProductTaxCategoryID(), line.getMultiply() + NewMultiple, line.getPrice (), line.getTaxInfo())); return; }else { bottlea = true; } } } else { bottleb = true; } if (bottlea){ ticket.insertLine(index + 1, new TicketLineInfo( bottlename, line.getProductTaxCategoryID(), line.getMultiply(), newprice, line.getTaxInfo())); } if (bottleb){ ticket.insertLine(0, new TicketLineInfo( bottlename, line.getProductTaxCategoryID(), line.getMultiply(), newprice, line.getTaxInfo())); } }