FANDOM


THIS MY EDITED VERSION OF ANOTHER SCRIPT POSTED HERE

It is available under the Creative Commons Share and Share Alike Licence

This code was created using MySQL in Windows.

This script will allow you to round to the nearest 5 cents when completing a sale. It rounds up and down. For rounding down only, uncomment the two lines in the center of the script.

1)Add the following event to the Ticket.Buttons resource:Edit

<event key="ticket.total" code="event.total"/>

2) Create a text resource called event.total and add the following to it:Edit

import com.openbravo.format.Formats; 
import com.openbravo.pos.ticket.TicketLineInfo; 
import com.openbravo.pos.ticket.TicketProductInfo;  
import java.util.Properties; 
 
total = ticket.getTotal();  
 
if (total > 0.0) {  
  //rounding m to nearest multiple of n  
  m=total;  
  n=5.0; //round to the nearest 5cents  
  d = Math.floor((m*100.0+n/2.0)/n)*n/100.0-m;  
  //round to 2 decimal places 
  rounding = Math.round(d * Math.pow(10, (double) 2)) / Math.pow(10,(double) 2); 
  //add line if rounding is needed 
  if (rounding <= -0.01 || rounding >= 0.01) {  
    taxes = ticket.getTaxLines();  
    for (int i = 0; i < taxes.length; i++) {  
      taxline = taxes[i];  
      // if you only want to round down, remove slashes from the next two lines
      //     if (rounding>0) {
      //       rounding = rounding - .05; }
      ticket.insertLine(ticket.getLinesCount(), 
        new TicketLineInfo( 
        "Rounding adjustment",  
        taxline.getTaxInfo().getTaxCategoryID(),  
        1.0,  
        rounding, 
        taxline.getTaxInfo()));  
    } 
  }  
  sales.setSelectedIndex(ticket.getLinesCount() - 1); 
 } else {  
  java.awt.Toolkit.getDefaultToolkit().beep(); 
} 

3. Save changes and restart the application.

That should be it. You can obviously change anything you wish to suit your setup.

Good Luck, Ronny G

available under Creative Commons Attribution-ShareAlike 2.5 Spain License.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.